Replace mashup with paste

This commit is contained in:
kngwyu 2019-08-04 23:50:10 +09:00
parent 83b92a6a55
commit 41f31e85fd
5 changed files with 11 additions and 22 deletions

View File

@ -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

View File

@ -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"

26
src/lib.rs Normal file → Executable file
View File

@ -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, [<PyInit_ $module_name>]()) }
}
}};
}

View File

@ -3,3 +3,5 @@ error: #[pyclass] cannot have generic parameters
|
4 | struct ClassWithGenerics<A> {
| ^^^
error: Could not compile `pyo3-tests`.

View File

@ -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`.