From 41f31e85fd45fdfc06c9f8cf368bc3963ca7be10 Mon Sep 17 00:00:00 2001 From: kngwyu Date: Sun, 4 Aug 2019 23:50:10 +0900 Subject: [PATCH] Replace mashup with paste --- CHANGELOG.md | 1 + Cargo.toml | 2 +- src/lib.rs | 26 +++++-------------------- tests/ui/reject_generics.stderr | 2 ++ tests/ui/too_many_args_to_getter.stderr | 2 ++ 5 files changed, 11 insertions(+), 22 deletions(-) mode change 100644 => 100755 src/lib.rs diff --git a/CHANGELOG.md b/CHANGELOG.md index 814e07d1..80d26a53 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. * Implementing the Using the `gc` parameter for `pyclass` (e.g. `#[pyclass(gc)]`) without implementing the `class::PyGCProtocol` trait is now a compile-time error. Failing to implement this trait could lead to segfaults. [#532](https://github.com/PyO3/pyo3/pull/532) * `PyByteArray::data` has been replaced with `PyDataArray::to_vec` because returning a `&[u8]` is unsound. (See [this comment](https://github.com/PyO3/pyo3/issues/373#issuecomment-512332696) for a great write-up for why that was unsound) + * Replace `mashup` with `paste`. ## [0.7.0] - 2018-05-26 diff --git a/Cargo.toml b/Cargo.toml index 7ded547b..65be6a19 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,11 +23,11 @@ libc = "0.2.54" spin = "0.5.0" num-traits = "0.2.6" pyo3cls = { path = "pyo3cls", version = "=0.7.0" } -mashup = "0.1.9" num-complex = { version = "0.2.1", optional = true } inventory = "0.1.3" indoc = "0.3.3" unindent = "0.1.3" +paste = "0.1.5" [dev-dependencies] assert_approx_eq = "1.1.0" diff --git a/src/lib.rs b/src/lib.rs old mode 100644 new mode 100755 index 7e7148c9..1a9981d6 --- a/src/lib.rs +++ b/src/lib.rs @@ -132,7 +132,7 @@ pub use crate::type_object::{PyObjectAlloc, PyRawObject, PyTypeInfo}; // Re-exported for wrap_function #[doc(hidden)] -pub use mashup; +pub use paste; // Re-exported for py_run #[doc(hidden)] pub use indoc; @@ -183,18 +183,8 @@ pub mod proc_macro { /// Use this together with `#[pyfunction]` and [types::PyModule::add_wrapped]. #[macro_export] macro_rules! wrap_pyfunction { - ($function_name:ident) => {{ - // Get the mashup macro and its helpers into scope - use pyo3::mashup::*; - - mashup! { - // Make sure this ident matches the one in function_wrapper_ident - m["method"] = __pyo3_get_function_ $function_name; - } - - m! { - &"method" - } + ($function_name: ident) => {{ + &pyo3::paste::expr! { [<__pyo3_get_function_ $function_name>] } }}; } @@ -204,14 +194,8 @@ macro_rules! wrap_pyfunction { #[macro_export] macro_rules! wrap_pymodule { ($module_name:ident) => {{ - use pyo3::mashup::*; - - mashup! { - m["method"] = PyInit_ $module_name; - } - - m! { - &|py| unsafe { pyo3::PyObject::from_owned_ptr(py, "method"()) } + pyo3::paste::expr! { + &|py| unsafe { pyo3::PyObject::from_owned_ptr(py, []()) } } }}; } diff --git a/tests/ui/reject_generics.stderr b/tests/ui/reject_generics.stderr index c06f9dfb..7084138e 100644 --- a/tests/ui/reject_generics.stderr +++ b/tests/ui/reject_generics.stderr @@ -3,3 +3,5 @@ error: #[pyclass] cannot have generic parameters | 4 | struct ClassWithGenerics { | ^^^ + +error: Could not compile `pyo3-tests`. diff --git a/tests/ui/too_many_args_to_getter.stderr b/tests/ui/too_many_args_to_getter.stderr index a81bb1be..341b278e 100644 --- a/tests/ui/too_many_args_to_getter.stderr +++ b/tests/ui/too_many_args_to_getter.stderr @@ -3,3 +3,5 @@ error: Getter function can only have one argument of type pyo3::Python! | 11 | fn get_num(&self, index: u32) {} | ^^^ + +error: Could not compile `pyo3-tests`.