- 06 Sep, 2016 16 commits
-
-
Keyword arguments and generalized unpacking for C++ API
Wenzel Jakob committed -
With this change arg_t is no longer a template, but it must remain so for backward compatibility. Thus, a non-template arg_v is introduced, while a dummy template alias arg_t is there to keep old code from breaking. This can be remove in the next major release. The implementation of arg_v also needed to be placed a little earlier in the headers because it's not a template any more and unpacking_collector needs more than a forward declaration.
Dean Moldovan committed -
Dean Moldovan committed
-
MSVC fails to compile if the constructor is defined out-of-line. The error states that it cannot deduce the type of the default template parameter which is used for SFINAE.
Dean Moldovan committed -
The variadic handle::operator() offers the same functionality as well as mixed positional, keyword, * and ** arguments. The tests are also superseded by the ones in `test_callbacks`.
Dean Moldovan committed -
Dean Moldovan committed
-
Dean Moldovan committed
-
Dean Moldovan committed
-
Replicates Python API including keyword arguments.
Dean Moldovan committed -
A Python function can be called with the syntax: ```python foo(a1, a2, *args, ka=1, kb=2, **kwargs) ``` This commit adds support for the equivalent syntax in C++: ```c++ foo(a1, a2, *args, "ka"_a=1, "kb"_a=2, **kwargs) ``` In addition, generalized unpacking is implemented, as per PEP 448, which allows calls with multiple * and ** unpacking: ```python bar(*args1, 99, *args2, 101, **kwargs1, kz=200, **kwargs2) ``` and ```c++ bar(*args1, 99, *args2, 101, **kwargs1, "kz"_a=200, **kwargs2) ```
Dean Moldovan committed -
Dean Moldovan committed
-
Wenzel Jakob committed
-
Wenzel Jakob committed
-
Wenzel Jakob committed
-
Wenzel Jakob committed
-
Adding bind_map. Adding key_error exception.
Wenzel Jakob committed
-
- 05 Sep, 2016 4 commits
-
-
Sergey Lyskov committed
-
enum serialization support (fixes #380)
Wenzel Jakob committed -
Wenzel Jakob committed
-
Wenzel Jakob committed
-
- 04 Sep, 2016 7 commits
-
-
Make unique_ptr's with non-default deleters work
Wenzel Jakob committed -
Wenzel Jakob committed
-
Currently pybind11 only supports std::unique_ptr<T> holders by default (other holders can, of course, be declared using the macro). PR #368 added a `py::nodelete` that is intended to be used as: py::class_<Type, std::unique_ptr<Type, py::nodelete>> c("Type"); but this doesn't work out of the box. (You could add an explicit holder type declaration, but this doesn't appear to have been the intention of the commit). This commit fixes it by generalizing the unique_ptr type_caster to take both the type and deleter as template arguments, so that *any* unique_ptr instances are now automatically handled by pybind. It also adds a test to test_smart_ptr, testing both that py::nodelete (now) works, and that the object is indeed not deleted as intended.Jason Rhinelander committed -
Wenzel Jakob committed
-
Buffer info improvements
Wenzel Jakob committed -
Wenzel Jakob committed
-
Make test initialization self-registering
Wenzel Jakob committed
-
- 03 Sep, 2016 1 commit
-
-
Adding or removing tests is a little bit cumbersome currently: the test needs to be added to CMakeLists.txt, the init function needs to be predeclared in pybind11_tests.cpp, then called in the plugin initialization. While this isn't a big deal for tests that are being committed, it's more of a hassle when working on some new feature or test code for which I temporarily only care about building and linking the test being worked on rather than the entire test suite. This commit changes tests to self-register their initialization by having each test initialize a local object (which stores the initialization function in a static variable). This makes changing the set of tests being build easy: one only needs to add or comment out test names in tests/CMakeLists.txt. A couple other minor changes that go along with this: - test_eigen.cpp is now included in the test list, then removed if eigen isn't available. This lets you disable the eigen tests by commenting it out, just like all the other tests, but keeps the build working without eigen eigen isn't available. (Also, if it's commented out, we don't even bother looking for and reporting the building with/without eigen status message). - pytest is now invoked with all the built test names (with .cpp changed to .py) so that it doesn't try to run tests that weren't built.
Jason Rhinelander committed
-
- 02 Sep, 2016 4 commits
-
-
Jason Newton committed
-
Jason Newton committed
-
Jason Newton committed
-
Jason Newton committed
-
- 30 Aug, 2016 3 commits
-
-
Fix check-style exit status and improve failure messages
Wenzel Jakob committed -
Fix template trampoline overload lookup failure
Wenzel Jakob committed -
This makes the output considerably easier to use: it now highlights (in red) matched tabs (instead of just listing the filenames), and adds line numbers to both the tabs check and the space-less if check outputs.
Jason Rhinelander committed
-
- 29 Aug, 2016 5 commits
-
-
Problem ======= The template trampoline pattern documented in PR #322 has a problem with virtual method overloads in intermediate classes in the inheritance chain between the trampoline class and the base class. For example, consider the following inheritance structure, where `B` is the actual class, `PyB<B>` is the trampoline class, and `PyA<B>` is an intermediate class adding A's methods into the trampoline: PyB<B> -> PyA<B> -> B -> A Suppose PyA<B> has a method `some_method()` with a PYBIND11_OVERLOAD in it to overload the virtual `A::some_method()`. If a Python class `C` is defined that inherits from the pybind11-registered `B` and tries to provide an overriding `some_method()`, the PYBIND11_OVERLOADs declared in PyA<B> fails to find this overloaded method, and thus never invoke it (or, if pure virtual and not overridden in PyB<B>, raises an exception). This happens because the base (internal) `PYBIND11_OVERLOAD_INT` macro simply calls `get_overload(this, name)`; `get_overload()` then uses the inferred type of `this` to do a type lookup in `registered_types_cpp`. This is where it fails: `this` will be a `PyA<B> *`, but `PyA<B>` is neither the base type (`B`) nor the trampoline type (`PyB<B>`). As a result, the overload fails and we get a failed overload lookup. The fix ======= The fix is relatively simple: we can cast `this` passed to `get_overload()` to a `const B *`, which lets get_overload look up the correct class. Since trampoline classes should be derived from `B` classes anyway, this cast should be perfectly safe. This does require adding the class name as an argument to the PYBIND11_OVERLOAD_INT macro, but leaves the public macro signatures unchanged.Jason Rhinelander committed -
The check-style exit status wasn't being propagated properly because the loops were running in a subshell (and so the change the the `errors` variable wasn't in the active command shell). This fixes it by running the greps in subshells and the loops in the main shell. This also avoids the if(/for(/while( style check on tests/CMakeLists.txt, since it *does* have if() statements with no space that are producing error messages, but that is (acceptable) CMake style.
Jason Rhinelander committed -
Doc fix for OVERLOAD*_NAME macros
Wenzel Jakob committed -
The documentation says the string-valued python function name goes after the C++ function, but it actually goes before it.
Jason Rhinelander committed -
Check for style issues during docs build
Wenzel Jakob committed
-