- 24 Jun, 2017 3 commits
-
-
Bruce Merry authored
This fixes #856. Instead of the weakref trick, the internals structure holds an unordered_map from PyObject* to a vector of references. To avoid the cost of the unordered_map lookup for objects that don't have any keep_alive patients, a flag is added to each instance to indicate whether there is anything to do.
-
Jason Rhinelander authored
Using `std::type_info::operator==` fails under libc++ because the .so is loaded with RTLD_LOCAL. libc++ considers types under such .sos distinct, and so comparing typeid() values directly isn't going to work. This adds a custom hasher and equality class for the type lookup maps when not under stdlibc++, and adds a `detail::same_type` function to perform the equality test. It also converts a few pointer arguments to const lvalue references, particularly since doing the pointer comparison wasn't technically valid to being with (though in practice, appeared to work everywhere). This fixes #912.
-
Dean Moldovan authored
Fixes a race condition when multiple threads try to acquire the GIL before `detail::internals` have been initialized. `gil_scoped_release` is now tasked with initializing `internals` (guaranteed single-threaded) to ensure the safety of subsequent `acquire` calls from multiple threads.
-
- 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.
-
- 10 Jun, 2017 1 commit
-
-
Dean Moldovan authored
Fixes #896. From Python docs: "Once an iterator’s `__next__()` method raises `StopIteration`, it must continue to do so on subsequent calls. Implementations that do not obey this property are deemed broken."
-
- 07 Jun, 2017 1 commit
-
-
Dean Moldovan authored
Fixes #887.
-
- 28 May, 2017 1 commit
-
-
Dean Moldovan authored
-
- 25 May, 2017 2 commits
-
-
Jason Rhinelander authored
Adds `remove_reference_t` and converts various `typename std::remove_reference<...>::type` to using it.
-
Jason Rhinelander authored
This allows calling of functions (typically void) over a parameter pack, replacing usage such as: bool unused[] = { (voidfunc(param_pack_arg), false)..., false }; (void) unused; with a much cleaner: PYBIND11_EXPAND_SIDE_EFFECTS(voidfunc(param_pack_arg));
-
- 24 May, 2017 2 commits
-
-
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.
-
Jason Rhinelander authored
This commit allows type_casters to allow their local values to be moved away, rather than copied, when the type caster instance itself is an rvalue. This only applies (automatically) to type casters using PYBIND11_TYPE_CASTER; the generic type type casters don't own their own pointer, and various value casters (e.g. std::string, std::pair, arithmetic types) already cast to an rvalue (i.e. they return by value). This updates various calling code to attempt to get a movable value whenever the value is itself coming from a type caster about to be destroyed: for example, when constructing an std::pair or various stl.h containers. For types that don't support value moving, the cast_op falls back to an lvalue cast. There wasn't an obvious place to add the tests, so I added them to test_copy_move_policies, but also renamed it to drop the _policies as it now tests more than just policies.
-
- 22 May, 2017 3 commits
-
-
Bruce Merry authored
Closes #857, by adding overloads to def_buffer that match pointers to member functions and wrap them in lambdas.
-
Jason Rhinelander authored
This changes javadoc-style documenting comments from: /** Text starts here * and continues here */ to: /** * Test starts here * and continues here */ which looks a little better, and also matches the javadoc-recommended way of writing documenting comments. -
Jason Rhinelander authored
Using a dynamic_cast instead of a static_cast is needed to safely cast from a base to a derived type. The previous static_pointer_cast isn't safe, however, when downcasting (and fails to compile when downcasting with virtual inheritance). Switching this to always use a dynamic_pointer_cast shouldn't incur any additional overhead when a static_pointer_cast is safe (i.e. when upcasting, or self-casting): compilers don't need RTTI checks in those cases.
-
- 09 May, 2017 3 commits
-
-
Jason Rhinelander authored
The PYBIND11_CPP14 macro started out as a guard for the compile-time path code in `descr.h`, but has since come to mean other things. This means that while the `descr.h` check has just checked the `PYBIND11_CPP14` macro, various other places now check `PYBIND11_CPP14 || _MSC_VER`. This reverses that by now setting the CPP14 macro when MSVC is trying to support C++14, but disabling the `descr.h` C++14 code (which still fails under MSVC 2017). The CPP17 macro also gets enabled when MSVC 2017 is compiling with /std:c++latest (the default is /std:c++14), which enables `std::optional` and `std::variant` support under MSVC.
-
Jason Rhinelander authored
-
Jason Rhinelander authored
GCC 7 generates (when compiling in C++11/14 mode) warnings such as: mangled name for ‘pybind11::class_<type_, options>& pybind11::class_<type_, options>::def(const char*, Func&&, const Extra& ...) [with Func = int (test_exc_sp::C::*)(int) noexcept; Extra = {}; type_ = test_exc_sp::C; options = {}]’ will change in C++17 because the exception specification is part of a function type [-Wnoexcept-type] There's nothing we can actually do in the code to avoid this, so just disable the warning.
-
- 07 May, 2017 1 commit
-
-
Dean Moldovan authored
-
- 29 Apr, 2017 1 commit
-
-
Wenzel Jakob authored
Enumerations on Python 2.7 were not always implicitly converted to integers (depending on the target size). This patch adds a __long__ conversion function (only enabled on 2.7) which fixes this issue. The attached test case fails without this patch.
-
- 28 Apr, 2017 1 commit
-
-
Jason Rhinelander authored
Python 3's `PyInstanceMethod_Type` hides itself via its `tp_descr_get`, which prevents aliasing methods via `cls.attr("m2") = cls.attr("m1")`: instead the `tp_descr_get` returns a plain function, when called on a class, or a `PyMethod`, when called on an instance. Override that behaviour for pybind11 types with a special bypass for `PyInstanceMethod_Types`.
-
- 27 Apr, 2017 1 commit
-
-
Jason Rhinelander authored
This commits adds base class pointers of offset base classes (i.e. due to multiple inheritance) to `registered_instances` so that if such a pointer is returned we properly recognize it as an existing instance. Without this, returning a base class pointer will cast to the existing instance if the pointer happens to coincide with the instance pointer, but constructs a new instance (quite possibly with a segfault, if ownership is applied) for unequal base class pointers due to multiple inheritance.
-
- 18 Apr, 2017 1 commit
-
-
Jason Rhinelander authored
We currently fail at runtime when trying to call a method that is overloaded with both static and non-static methods. This is something python won't allow: the object is either a function or an instance, and can't be both.
-
- 02 Apr, 2017 2 commits
-
-
Dean Moldovan authored
-
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 }); ```
-
- 30 Mar, 2017 1 commit
-
-
Wenzel Jakob authored
-
- 22 Mar, 2017 2 commits
-
-
Wenzel Jakob authored
* nicer py::capsule destructor mechanism * added destructor-only version of capsule & tests * added documentation for module destructors (fixes #733)
-
Dean Moldovan authored
Fixes #754.
-
- 19 Mar, 2017 1 commit
-
-
Jason Rhinelander authored
py::arg() doesn't only specify named arguments anymore, so the error message was misleading (e.g. when using `py::arg().noconvert()` and forgetting `py::arg()` for a second positional argument).
-
- 18 Mar, 2017 1 commit
-
-
Jason Rhinelander authored
This adds brief API documentation for make_iterator/make_key_iterator, specifically mentioning that it requires InputIterators. Closes #734. [skip ci] (no code change here)
-
- 17 Mar, 2017 1 commit
-
-
Jason Rhinelander authored
We can't support this for classes from imported modules (which is the primary purpose of a ctor argument base class) because we *have* to have both parent and derived to properly extract a multiple-inheritance base class pointer from a derived class pointer. We could support this for actual `class_<Base, ...> instances, but since in that case the `Base` is already present in the code, it seems more consistent to simply always require MI to go via template options.
-
- 13 Mar, 2017 1 commit
-
-
Jason Rhinelander authored
Fixes #697
-
- 12 Mar, 2017 1 commit
-
-
Jason Rhinelander authored
The `decltype(...)` in the template parameter that gives us SFINAE matching for a lambda makes MSVC 2017 ICE; this works around if by changing the test to an explicit not-a-function-or-pointer test, which seems to work everywhere.
-
- 08 Mar, 2017 1 commit
-
-
Jason Rhinelander authored
When using pybind::options to disable function signatures, user-defined docstrings only get appended if they exist, but newlines were getting appended unconditionally, so the docstring could end up with blank lines (depending on which overloads, in particular, provided docstrings). This commit suppresses the empty lines by only adding newlines for overloads when needed.
-
- 04 Mar, 2017 1 commit
-
-
Jason Rhinelander authored
Added in 6fb48490 The second constructor can't be doing anything--the signatures are exactly the same, and so the first is always going to be the one invoked by the dispatcher.
-
- 03 Mar, 2017 1 commit
-
-
Matthieu Bec authored
-
- 26 Feb, 2017 1 commit
-
-
Dean Moldovan authored
* The definition of `PySequence_Fast` is more restrictive on PyPy, so use the slow path instead. * `PyDict_Next` has been fixed in PyPy -> remove workaround.
-
- 24 Feb, 2017 3 commits
-
-
Jason Rhinelander authored
Eigen::Ref objects, when returned, are almost always returned as rvalues; what's important is the data they reference, not the outer shell, and so we want to be able to use `::copy`, `::reference_internal`, etc. to refer to the data the Eigen::Ref references (in the following commits), rather than the Eigen::Ref instance itself. This moves the policy override into a struct so that code that wants to avoid it (or wants to provide some other Return-type-conditional override) can create a specialization of return_value_policy_override<Return> in order to override the override. This lets an Eigen::Ref-returning function be bound with `rvp::copy`, for example, to specify that the data should be copied into a new numpy array rather than referenced, or `rvp::reference_internal` to indicate that it should be referenced, but a keep-alive used (actually, we used the array's `base` rather than a py::keep_alive in such a case, but it accomplishes the same thing).
-
Jason Rhinelander authored
With the previous commit, output can be very confusing because you only see positional arguments in the "invoked with" line, but you can have a failure from kwargs as well (in particular, when a value is invalidly specified via both via positional and kwargs). This commits adds kwargs to the output, and updates the associated tests to match.
-
Jason Rhinelander authored
Fixes #688. My (commented) assumption that such an error is "highly likely to be a caller mistake" was proven false by #688.
-
- 23 Feb, 2017 1 commit
-
-
Dean Moldovan authored
Now that only one shared metaclass is ever allocated, it's extremely cheap to enable it for all pybind11 types. * Deprecate the default py::metaclass() since it's not needed anymore. * Allow users to specify a custom metaclass via py::metaclass(handle).
-