Merge pull request #139 from konstin/codegen_crate
Move codegen into its own crate
This commit is contained in:
commit
8783d61c02
|
@ -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"
|
||||
|
|
18
pyo3-derive-backend/Cargo.toml
Normal file
18
pyo3-derive-backend/Cargo.toml
Normal 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"]
|
21
pyo3-derive-backend/src/lib.rs
Normal file
21
pyo3-derive-backend/src/lib.rs
Normal 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;
|
|
@ -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
|
|
@ -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
|
||||
};
|
|
@ -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
|
||||
};
|
|
@ -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
|
||||
|
|
@ -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"
|
|
@ -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]
|
||||
|
|
Loading…
Reference in a new issue