Merge pull request #139 from konstin/codegen_crate

Move codegen into its own crate
This commit is contained in:
konstin 2018-05-05 14:21:42 +02:00 committed by GitHub
commit 8783d61c02
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 52 additions and 22 deletions

View file

@ -23,7 +23,7 @@ log = "0.4"
libc = "0.2"
spin = "0.4.6"
num-traits = "0.2"
pyo3cls = { path = "pyo3cls", version = "^0.2.1" }
pyo3cls = { path = "pyo3cls", version = "0.2.5" }
[dev-dependencies]
docmatic = "^0.1.2"

View file

@ -0,0 +1,18 @@
[package]
name = "pyo3-derive-backend"
version = "0.2.5"
description = "Code generation for PyO3 package"
authors = ["PyO3 Project and Contributors <https://github.com/PyO3"]
homepage = "https://github.com/pyo3/pyo3"
repository = "https://github.com/pyo3/pyo3.git"
documentation = "http://pyo3.github.io/PyO3/pyo3/"
categories = ["api-bindings", "development-tools::ffi"]
license = "Apache-2.0"
[dependencies]
quote="0.3"
log="0.4"
[dependencies.syn]
version="0.11"
features=["full"]

View file

@ -0,0 +1,21 @@
// Copyright (c) 2017-present PyO3 Project and Contributors
#![recursion_limit = "1024"]
#[macro_use]
extern crate log;
#[macro_use]
extern crate quote;
extern crate syn;
extern crate proc_macro;
pub mod py_class;
pub mod py_impl;
pub mod py_proto;
pub mod py_method;
pub mod args;
pub mod defs;
pub mod func;
pub mod method;
pub mod module;
pub mod utils;

View file

@ -44,7 +44,6 @@ pub fn py3_init(fnname: &syn::Ident, name: &String, doc: syn::Lit) -> Tokens {
#[no_mangle]
#[allow(non_snake_case, unused_imports)]
pub unsafe extern "C" fn #cb_name() -> *mut ::pyo3::ffi::PyObject {
extern crate pyo3;
use std;
use pyo3::{IntoPyPointer, ObjectProtocol};
@ -121,7 +120,6 @@ pub fn py2_init(fnname: &syn::Ident, name: &String, doc: syn::Lit) -> Tokens {
#[no_mangle]
#[allow(non_snake_case, unused_imports)]
pub unsafe extern "C" fn #cb_name() {
extern crate pyo3;
use std;
// initialize python

View file

@ -41,7 +41,7 @@ pub fn build_py_class(ast: &mut syn::DeriveInput, attr: String) -> Tokens {
unused_qualifications, unused_variables, non_camel_case_types)]
const #dummy_const: () = {
use std;
extern crate pyo3 as _pyo3;
use pyo3 as _pyo3;
#tokens
};
@ -372,7 +372,7 @@ fn impl_descriptors(cls: &syn::Ty, descriptors: Vec<(syn::Field, Vec<FnType>)>)
#[allow(non_upper_case_globals, unused_attributes,
unused_qualifications, unused_variables, unused_imports)]
const #dummy_const: () = {
extern crate pyo3 as _pyo3;
use pyo3 as _pyo3;
#tokens
};

View file

@ -57,7 +57,7 @@ fn impl_methods(ty: &Box<syn::Ty>, impls: &mut Vec<syn::ImplItem>) -> Tokens {
#[allow(non_upper_case_globals, unused_attributes,
unused_qualifications, unused_variables, unused_imports)]
const #dummy_const: () = {
extern crate pyo3 as _pyo3;
use pyo3 as _pyo3;
#tokens
};

View file

@ -128,7 +128,7 @@ fn impl_proto_impl(ty: &Box<syn::Ty>,
#[allow(non_upper_case_globals, unused_attributes,
unused_qualifications, unused_variables)]
const #dummy_const: () = {
extern crate pyo3 as _pyo3;
use pyo3 as _pyo3;
#tokens

View file

@ -1,6 +1,6 @@
[package]
name = "pyo3cls"
version = "0.2.1"
version = "0.2.5"
description = "Proc macros for PyO3 package"
authors = ["PyO3 Project and Contributors <https://github.com/PyO3"]
homepage = "https://github.com/pyo3/pyo3"
@ -14,8 +14,11 @@ proc-macro = true
[dependencies]
quote="0.3"
log="0.4"
[dependencies.syn]
version="0.11"
features=["full"]
[dependencies.pyo3-derive-backend]
path = "../pyo3-derive-backend"
version = "0.2.5"

View file

@ -5,24 +5,14 @@
extern crate proc_macro;
extern crate syn;
#[macro_use] extern crate quote;
#[macro_use] extern crate log;
extern crate quote;
extern crate pyo3_derive_backend;
use std::str::FromStr;
use proc_macro::TokenStream;
use quote::{Tokens, ToTokens};
mod py_class;
mod py_impl;
mod py_proto;
mod py_method;
mod args;
mod defs;
mod func;
mod method;
mod module;
mod utils;
use pyo3_derive_backend::*;
#[proc_macro_attribute]