Commit Graph

11 Commits

Author SHA1 Message Date
Daniel Grunwald 0222176836 #40: split ExtractPyObject into two traits:
* FromPyObject for all conversions that don't need to borrow temporaries
* RefFromPyObject for extracting references out of temporaries
  (currently only used for extracting `&str`)
2016-05-08 21:25:09 +02:00
Daniel Grunwald 0bd9e3ebd2 Adjust extension test cases. 2016-03-12 18:14:21 +01:00
Daniel Grunwald d705620502 Add support for Rust stable.
All functions that depend on PyObject having the same memory layout
as *mut ffi::PyObject should now be hidden behind #[cfg(feature="nightly")].
2016-03-06 01:08:40 +01:00
Daniel Grunwald 53353d374b Remove dependency on interpolate_idents.
We now use the generic <DUMMY> hack to avoid duplicate extern "C" symbols.
See rust-lang/rust#26201.

py_module_initializer!() calls now need to manually concatenate the module
name with the prefixes "init" and "PyInit_".
2016-03-05 23:20:53 +01:00
Daniel Grunwald 0a270a0583 Put Python argument at beginning of argument list.
Closes #33.
2015-10-26 23:52:18 +01:00
Daniel Grunwald 44611991c3 Remove 'p lifetime from PyObject (#15)
Since the `Python` token no longer is a part of `PyObject`,
lots of methods now require the token as additional argument.

This [breaking-change] breaks everything!
2015-10-25 17:55:29 +01:00
Daniel Grunwald a23b5b5910 Add parameter extraction support to `py_fn!` and `py_method!`.
These macros now support specifying an argument list:
`py_fn!(myfn(myarg: i32))`
will expect `myfn` to be a function with the signature:
`fn myfn<'p>(py: Python<'p>, myarg: i32) -> PyResult<'p, _>`

It can called from python as `myfn(1)`
or using keyword arguments: `myfn(myarg=1)`.

If no parameter list is specified (`py_fn!(myfn)`), the expected signature
now includes the keyword arguments:
`fn run<'p>(py: Python<'p>, args: &PyTuple<'p>, kwargs: Option<&PyDict<'p>>)`

Due to the additional `kwargs` argument, this is a [breaking-change].
2015-08-03 00:06:15 +02:00
Daniel Grunwald 5c74f55862 Change `py_func!(py, f)` to `py_fn(f)`. 2015-06-25 00:02:56 +02:00
Daniel Grunwald 8c8779e3fb py_module_initializer! for python 3 2015-05-24 20:06:08 +02:00
Daniel Grunwald 5a303789b9 Don't export cstr! macro 2015-04-18 22:20:19 +02:00
Daniel Grunwald f8e24a870c Add support for exposing rust functions to python 2015-04-18 20:17:25 +02:00