- 17 Aug, 2017 1 commit
-
-
Dean Moldovan authored
* Doxygen needs `RECURSIVE = YES` in order to parse the `detail` subdir. * The `-W` warnings-as-errors option for sphinx doesn't work with the makefile build. Switched to calling sphinx directly. * Fix "citation [cppimport] is not referenced" warning.
-
- 14 Aug, 2017 1 commit
-
-
Jason Rhinelander authored
This updates the compilation to always apply hidden visibility to resolve the issues with default visibility causing problems under debug compilations. Moreover using the cmake property makes it easier for a caller to override if absolutely needed for some reason. For `pybind11_add_module` we use cmake to set the property; for the targets, we append to compilation option to non-MSVC compilers.
-
- 12 Aug, 2017 1 commit
-
-
Dean Moldovan authored
In C++11 mode, `boost::apply_visitor` requires an explicit `result_type`. This also adds optional tests for `boost::variant` in C++11/14, if boost is available. In C++17 mode, `std::variant` is tested instead.
-
- 07 Aug, 2017 2 commits
-
-
EricCousineau-TRI authored
* Ensure :ref: for virtual_and_inheritance is parsed. * Add quick blurb about __init__ with inherited types. [skip ci]
-
Jason Rhinelander authored
boost::apply_visitor accepts its arguments by non-const lvalue reference, which fails to bind to an rvalue reference. Change the example to remove the argument forwarding.
-
- 05 Aug, 2017 1 commit
-
-
Jason Rhinelander authored
Attempting to mix py::module_local and non-module_local classes results in some unexpected/undesirable behaviour: - if a class is registered non-local by some other module, a later attempt to register it locally fails. It doesn't need to: it is perfectly acceptable for the local registration to simply override the external global registration. - going the other way (i.e. module `A` registers a type `T` locally, then `B` registers the same type `T` globally) causes a more serious issue: `A.T`'s constructors no longer work because the `self` argument gets converted to a `B.T`, which then fails to resolve. Changing the cast precedence to prefer local over global fixes this and makes it work more consistently, regardless of module load order.
-
- 04 Aug, 2017 1 commit
-
-
Jason Rhinelander authored
This commit adds a `py::module_local` attribute that lets you confine a registered type to the module (more technically, the shared object) in which it is defined, by registering it with: py::class_<C>(m, "C", py::module_local()) This will allow the same C++ class `C` to be registered in different modules with independent sets of class definitions. On the Python side, two such types will be completely distinct; on the C++ side, the C++ type resolves to a different Python type in each module. This applies `py::module_local` automatically to `stl_bind.h` bindings when the container value type looks like something global: i.e. when it is a converting type (for example, when binding a `std::vector<int>`), or when it is a registered type itself bound with `py::module_local`. This should help resolve potential future conflicts (e.g. if two completely unrelated modules both try to bind a `std::vector<int>`. Users can override the automatic selection by adding a `py::module_local()` or `py::module_local(false)`. Note that this does mildly break backwards compatibility: bound stl containers of basic types like `std::vector<int>` cannot be bound in one module and returned in a different module. (This can be re-enabled with `py::module_local(false)` as described above, but with the potential for eventual load conflicts).
-
- 23 Jul, 2017 1 commit
-
-
Dustin Spicuzza authored
Resolves #645.
-
- 27 Jun, 2017 2 commits
-
-
Dean Moldovan authored
-
Dean Moldovan authored
-
- 25 Jun, 2017 1 commit
-
-
Dean Moldovan authored
[skip ci]
-
- 24 Jun, 2017 3 commits
-
-
Jason Rhinelander authored
-
Jason Rhinelander authored
-
Jason Rhinelander authored
Wrapped long lines and removed a few trailing spaces.
-
- 15 Jun, 2017 1 commit
-
-
Ian Bell authored
-
- 12 Jun, 2017 1 commit
-
-
Jason Rhinelander authored
This commit allows multiple inheritance of pybind11 classes from Python, e.g. class MyType(Base1, Base2): def __init__(self): Base1.__init__(self) Base2.__init__(self) where Base1 and Base2 are pybind11-exported classes. This requires collapsing the various builtin base objects (pybind11_object_56, ...) introduced in 2.1 into a single pybind11_object of a fixed size; this fixed size object allocates enough space to contain either a simple object (one base class & small* holder instance), or a pointer to a new allocation that can contain an arbitrary number of base classes and holders, with holder size unrestricted. * "small" here means having a sizeof() of at most 2 pointers, which is enough to fit unique_ptr (sizeof is 1 ptr) and shared_ptr (sizeof is 2 ptrs). To minimize the performance impact, this repurposes `internals::registered_types_py` to store a vector of pybind-registered base types. For direct-use pybind types (e.g. the `PyA` for a C++ `A`) this is simply storing the same thing as before, but now in a vector; for Python-side inherited types, the map lets us avoid having to do a base class traversal as long as we've seen the class before. The change to vector is needed for multiple inheritance: Python types inheriting from multiple registered bases have one entry per base.
-
- 08 Jun, 2017 1 commit
-
-
Matthew Chan authored
Fix spelling
-
- 31 May, 2017 1 commit
-
-
Dean Moldovan authored
[skip ci]
-
- 29 May, 2017 1 commit
-
-
Dean Moldovan authored
This commit also adds `doc()` to `object_api` as a shortcut for the `attr("__doc__")` accessor. The module macro changes from: ```c++ PYBIND11_PLUGIN(example) { pybind11::module m("example", "pybind11 example plugin"); m.def("add", [](int a, int b) { return a + b; }); return m.ptr(); } ``` to: ```c++ PYBIND11_MODULE(example, m) { m.doc() = "pybind11 example plugin"; m.def("add", [](int a, int b) { return a + b; }); } ``` Using the old macro results in a deprecation warning. The warning actually points to the `pybind11_init` function (since attributes don't bind to macros), but the message should be quite clear: "PYBIND11_PLUGIN is deprecated, use PYBIND11_MODULE".
-
- 28 May, 2017 2 commits
-
-
Dean Moldovan authored
-
Dean Moldovan authored
-
- 27 May, 2017 2 commits
-
-
Jason Rhinelander authored
:exc: isn't valid.
-
chenzy authored
-
- 25 May, 2017 1 commit
-
-
Jason Rhinelander authored
This extends py::vectorize to automatically pass through non-vectorizable arguments. This removes the need for the documented "explicitly exclude an argument" workaround. Vectorization now applies to arithmetic, std::complex, and POD types, passed as plain value or by const lvalue reference (previously only pass-by-value types were supported). Non-const lvalue references and any other types are passed through as-is. Functions with rvalue reference arguments (whether vectorizable or not) are explicitly prohibited: an rvalue reference is inherently not something that can be passed multiple times and is thus unsuitable to being in a vectorized function. The vectorize returned value is also now more sensitive to inputs: previously it would return by value when all inputs are of size 1; this is now amended to having all inputs of size 1 *and* 0 dimensions. Thus if you pass in, for example, [[1]], you get back a 1x1, 2D array, while previously you got back just the resulting single value. Vectorization of member function specializations is now also supported via `py::vectorize(&Class::method)`; this required passthrough support for the initial object pointer on the wrapping function pointer.
-
- 24 May, 2017 1 commit
-
-
Jason Rhinelander authored
This attribute lets you disable (or explicitly enable) passing None to an argument that otherwise would allow it by accepting a value by raw pointer or shared_ptr.
-
- 10 May, 2017 2 commits
-
-
Bruce Merry authored
This exposed a few underlying issues: 1. is_pod_struct was too strict to allow this. I've relaxed it to require only trivially copyable and standard layout, rather than POD (which additionally requires a trivial constructor, which std::complex violates). 2. format_descriptor<std::complex<T>>::format() returned numpy format strings instead of PEP3118 format strings, but register_dtype feeds format codes of its fields to _dtype_from_pep3118. I've changed it to return PEP3118 format codes. format_descriptor is a public type, so this may be considered an incompatible change. 3. register_structured_dtype tried to be smart about whether to mark fields as unaligned (with ^). However, it's examining the C++ alignment, rather than what numpy (or possibly PEP3118) thinks the alignment should be. For complex values those are different. I've made it mark all fields as ^ unconditionally, which should always be safe even if they are aligned, because we explicitly mark the padding.
-
Bruce Merry authored
Resolves #800. Both C++ arrays and std::array are supported, including mixtures like std::array<int, 2>[4]. In a multi-dimensional array of char, the last dimension is used to construct a numpy string type.
-
- 09 May, 2017 1 commit
-
-
Jason Rhinelander authored
Under MSVC we were ignoring PYBIND11_CPP_STANDARD and simply not passing any standard (which makes MSVC default to its C++14 mode). MSVC 2015u3 added the `/std:c++14` and `/std:c++latest` flags; the latter, under MSVC 2017, enables some C++17 features (such as `std::optional` and `std::variant`), so it is something we need to start supporting under MSVC. This makes the PYBIND11_CPP_STANDARD cmake variable work under MSVC, defaulting it to /std:c++14 (matching the default -std=c++14 for non-MSVC). It also adds a new appveyor test running under MSVC 2017 with /std:c++latest, which runs (and passes) the `std::optional`/`std::variant` tests. Also updated the documentation to clarify the c++ flags and add show MSVC flag examples.
-
- 08 May, 2017 1 commit
-
-
Dean Moldovan authored
-
- 07 May, 2017 3 commits
-
-
Cris Luengo authored
-
Jason Rhinelander authored
We're current copy by creating an Eigen::Map into the input numpy array, then assigning that to the basic eigen type, effectively having Eigen do the copy. That doesn't work for negative strides, though: Eigen doesn't allow them. This commit makes numpy do the copying instead by allocating the eigen type, then having numpy copy from the input array into a numpy reference into the eigen object's data. This also saves a copy when type conversion is required: numpy can do the conversion on-the-fly as part of the copy. Finally this commit also makes non-reference parameters respect the convert flag, declining the load when called in a noconvert pass with a convertible, but non-array input or an array with the wrong dtype.
-
Cris Luengo authored
-
- 29 Apr, 2017 1 commit
-
-
Dean Moldovan authored
-
- 07 Apr, 2017 1 commit
-
-
Wenzel Jakob authored
-
- 02 Apr, 2017 1 commit
-
-
Dean Moldovan authored
```c++ m.def("foo", foo, py::call_guard<T>()); ``` is equivalent to: ```c++ m.def("foo", [](args...) { T scope_guard; return foo(args...); // forwarded arguments }); ```
-
- 28 Mar, 2017 1 commit
-
-
Dean Moldovan authored
* Support raw string literals as input for py::eval * Dedent only when needed
-
- 22 Mar, 2017 4 commits
-
-
Wenzel Jakob authored
-
Wenzel Jakob authored
-
Wenzel Jakob authored
-
Wenzel Jakob authored
* nicer py::capsule destructor mechanism * added destructor-only version of capsule & tests * added documentation for module destructors (fixes #733)
-