- 08 Sep, 2016 8 commits
-
-
Small template simplifications
Wenzel Jakob committed -
Switch count_t to use constexpr_sum (under non-MSVC), and then make all_of_t/any_of_t use it instead of doing the sum itself. For MSVC, count_t is still done using template recursion, but all_of_t/any_of_t can also make use of it.
Jason Rhinelander committed -
Fix type alias initialization
Wenzel Jakob committed -
Type alias for alias classes with members didn't work properly: space was only allocated for sizeof(type), but if we want to be able to put a type_alias instance there, we need sizeof(type_alias), but sizeof(type_alias) > sizeof(type) whenever type_alias has members.
Jason Rhinelander committed -
Wenzel Jakob committed
-
Fix ref heap casts
Wenzel Jakob committed -
error_already_set improvements
Wenzel Jakob committed -
Add handle::is_none()
Wenzel Jakob committed
-
- 07 Sep, 2016 10 commits
-
-
Ivan Smirnov committed
-
Ivan Smirnov committed
-
Ivan Smirnov committed
-
The previous commit to address #392 triggers a compiler warning about returning a reference to a local variable, which is *not* a false alarm: the following: py::cast<int &>(o) (which happens internally in an overload declaration) really is returning a reference to a local, because the cast operators for the type_caster for numeric types returns a reference to its own member. This commit adds a static_assert to make that a compilation failure rather than returning a reference into about-to-be-freed memory. Incidentally, this is also a fix for #219, which is exactly the same issue: we can't reference numeric primitives that are cast from wrappers around python numeric types.Jason Rhinelander committed -
Ivan Smirnov committed
-
Need to use the intrinsic type, not the raw type. Fixes #392.
Jason Rhinelander committed -
Wenzel Jakob committed
-
Allow arbitrary class_ template option ordering
Wenzel Jakob committed -
Replace std::cout with py::print in tests
Wenzel Jakob committed -
This allows a slightly cleaner base type specification of: py::class_<Type, Base>("Type") as an alternative to py::class_<Type>("Type", py::base<Base>()) As with the other template parameters, the order relative to the holder or trampoline types doesn't matter. This also includes a compile-time assertion failure if attempting to specify more than one base class (but is easily extendible to support multiple inheritance, someday, by updating the class_selector::set_bases function to set multiple bases).Jason Rhinelander committed
-
- 06 Sep, 2016 19 commits
-
-
With this change both C++ and Python write to sys.stdout which resolves the capture issues noted in #351. Therefore, the related workarounds are removed.
Dean Moldovan committed -
The current pybind11::class_<Type, Holder, Trampoline> fixed template ordering results in a requirement to repeat the Holder with its default value (std::unique_ptr<Type>) argument, which is a little bit annoying: it needs to be specified not because we want to override the default, but rather because we need to specify the third argument. This commit removes this limitation by making the class_ template take the type name plus a parameter pack of options. It then extracts the first valid holder type and the first subclass type for holder_type and trampoline type_alias, respectively. (If unfound, both fall back to their current defaults, `std::unique_ptr<type>` and `type`, respectively). If any unmatched template arguments are provided, a static assertion fails. What this means is that you can specify or omit the arguments in any order: py::class_<A, PyA> c1(m, "A"); py::class_<B, PyB, std::shared_ptr<B>> c2(m, "B"); py::class_<C, std::shared_ptr<C>, PyB> c3(m, "C"); It also allows future class attributes (such as base types in the next commit) to be passed as class template types rather than needing to use a py::base<> wrapper.Jason Rhinelander committed -
Wenzel Jakob committed
-
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 3 commits
-
-
Sergey Lyskov committed
-
enum serialization support (fixes #380)
Wenzel Jakob committed -
Wenzel Jakob committed
-