- 02 Nov, 2017 1 commit
-
-
Unknown authored
Non-user facing. Found using `codespell -q 3`
-
- 25 Oct, 2017 1 commit
-
-
Jason Rhinelander authored
The just-updated flake8 package hits a bunch of: E741 ambiguous variable name 'l' warnings. This commit renames them all from `l` to `lst` (they are all list values) to avoid the error.
-
- 22 Oct, 2017 1 commit
-
-
Jason Rhinelander authored
- For the debian/buster docker build (GCC 7/C++17) install and use the system `catch` package; this also renames "COMPILER_PACKAGES" to "EXTRA_PACKAGES" since it now contains a non-compiler package. - Add a status message indicating the catch version being used for compiling the embedded tests - Simplify some bash code by using VAR+=" foo" to append (rather than VAR="${VAR} foo" - Fix CMAKE_INCLUDE_PATH appending: it was prepending the ':' but not the existing $CMAKE_INCLUDE_PATH value and so would end up with ":/eigen-path" if CMAKE_INCLUDE_PATH was already set. (This wasn't bug that was actually noticed since currently nothing else sets it).
-
- 12 Oct, 2017 2 commits
-
-
Jason Rhinelander authored
This fixes a bug introduced in b68959e8 when passing in a two-dimensional, but conformable, array as the value for a compile-time Eigen vector (such as VectorXd or RowVectorXd). The commit switched to using numpy to copy into the eigen data, but this broke the described case because numpy refuses to broadcast a (N,1) into a (N). This commit fixes it by squeezing the input array whenever the output array is 1-dimensional, which will let the problematic case through. (This shouldn't squeeze inappropriately as dimension compatibility is already checked for conformability before getting to the copy code).
-
Jason Rhinelander authored
This changes the caster to return a reference to a (new) local `CharT` type caster member so that binding lvalue-reference char arguments works (currently it results in a compilation failure). Fixes #1116
-
- 28 Sep, 2017 1 commit
-
-
Jason Rhinelander authored
Fixes #1117
-
- 21 Sep, 2017 1 commit
-
-
Ansgar Burchardt authored
This also matches the Eigen example for the row-major case. This also enhances one of the tests to trigger a failure (and fixes it in the PR). (This isn't really a flaw in pybind itself, but rather fixes wrong code in the test code and docs).
-
- 20 Sep, 2017 2 commits
-
-
Jason Rhinelander authored
The entire test file is already marked as requiring numpy; it isn't needed on the individual test.
-
Jason Rhinelander authored
`PyArray_DescrConverter_` doesn't steal a reference to the argument, and so the passed arguments shouldn't be `.release()`d.
-
- 16 Sep, 2017 1 commit
-
-
Dean Moldovan authored
The current C++14 constexpr signatures don't require relaxed constexpr, but only `auto` return type deduction. To get around this in C++11, the type caster's `name()` static member functions are turned into `static constexpr auto` variables.
-
- 12 Sep, 2017 2 commits
-
-
Dean Moldovan authored
E.g. trying to convert a `list` to a `std::vector<int>` without including <pybind11/stl.h> will now raise an error with a note that suggests checking the headers. The note is only appended if `std::` is found in the function signature. This should only be the case when a header is missing. E.g. when stl.h is included, the signature would contain `List[int]` instead of `std::vector<int>` while using stl_bind.h would produce something like `MyVector`. Similarly for `std::map`/`Dict`, `complex`, `std::function`/`Callable`, etc. There's a possibility for false positives, but it's pretty low.
-
Gunnar Läthén authored
-
- 11 Sep, 2017 1 commit
-
-
Dean Moldovan authored
Fixes #1069.
-
- 10 Sep, 2017 2 commits
-
-
Dean Moldovan authored
-
Dean Moldovan authored
To avoid an ODR violation in the test suite while testing both `stl.h` and `std_bind.h` with `std::vector<bool>`, the `py::bind_vector<std::vector<bool>>` test is moved to the secondary module (which does not include `stl.h`).
-
- 06 Sep, 2017 2 commits
-
-
Dean Moldovan authored
Fixes #1061. `T` and `const T &` are compatible types.
-
Dean Moldovan authored
-
- 30 Aug, 2017 4 commits
-
-
Dean Moldovan authored
Fixes #1046.
-
Bruce Merry authored
There are two separate additions: 1. `py::hash(obj)` is equivalent to the Python `hash(obj)`. 2. `.def(hash(py::self))` registers the hash function defined by `std::hash<T>` as the Python hash function.
-
Florian Apolloner authored
-
Dean Moldovan authored
This is analogous to `py::init()` vs `__init__` + placement-new. `py::pickle()` reuses most of the implementation details of `py::init()`.
-
- 28 Aug, 2017 2 commits
-
-
Wenzel Jakob authored
-
Dean Moldovan authored
The lookup of the `self` type and value pointer are moved out of template code and into `dispatcher`. This brings down the binary size of constructors back to the level of the old placement-new approach. (It also avoids a second lookup for `init_instance`.) With this implementation, mixing old- and new-style constructors in the same overload set may result in some runtime overhead for temporary allocations/deallocations, but this should be fine as old style constructors are phased out.
-
- 25 Aug, 2017 3 commits
-
-
Dean Moldovan authored
-
Wenzel Jakob authored
Creating an instance of of a pybind11-bound type caused a reference leak in the associated Python type object, which could prevent these from being collected upon interpreter shutdown. This commit fixes that issue for all types that are defined in a scope (e.g. a module). Unscoped anonymous types (e.g. custom iterator types) always retain a positive reference count to prevent their collection.
-
Henry Schreiner authored
-
- 23 Aug, 2017 2 commits
-
-
Jason Rhinelander authored
-
Dean Moldovan authored
The `latest` build remains as is, but all others are modified to: * Use regular Python instead of conda. `pip install` is much faster than conda, but scipy isn't available. Numpy is still tested. * Compile in debug mode instead of release. * Skip CMake build tests. For some reason, CMake configuration is very slow on AppVeyor and these tests are almost entirely CMake. The changes reduce build time to about 1/3 of the original. The `latest` config still covers scipy, release mode and the CMake build tests, so the others don't need to.
-
- 22 Aug, 2017 2 commits
-
-
Wenzel Jakob authored
-
Dean Moldovan authored
-
- 19 Aug, 2017 1 commit
-
-
Jason Rhinelander authored
The main point of `py::module_local` is to make the C++ -> Python cast unique so that returning/casting a C++ instance is well-defined. Unfortunately it also makes loading unique, but this isn't particularly desirable: when an instance contains `Type` instance there's no reason it shouldn't be possible to pass that instance to a bound function taking a `Type` parameter, even if that function is in another module. This commit solves the issue by allowing foreign module (and global) type loaders have a chance to load the value if the local module loader fails. The implementation here does this by storing a module-local loading function in a capsule in the python type, which we can then call if the local (and possibly global, if the local type is masking a global type) version doesn't work.
-
- 17 Aug, 2017 3 commits
-
-
Jason Rhinelander authored
This reimplements the py::init<...> implementations using the various functions added to support `py::init(...)`, and moves the implementing structs into `detail/init.h` from `pybind11.h`. It doesn't simply use a factory directly, as this is a very common case and implementation without an extra lambda call is a small but useful optimization. This, combined with the previous lazy initialization, also avoids needing placement new for `py::init<...>()` construction: such construction now occurs via an ordinary `new Type(...)`. A consequence of this is that it also fixes a potential bug when using multiple inheritance from Python: it was very easy to write classes that double-initialize an existing instance which had the potential to leak for non-pod classes. With the new implementation, an attempt to call `__init__` on an already-initialized object is now ignored. (This was already done in the previous commit for factory constructors). This change exposed a few warnings (fixed here) from deleting a pointer to a base class with virtual functions but without a virtual destructor. These look like legitimate warnings that we shouldn't suppress; this adds virtual destructors to the appropriate classes.
-
Jason Rhinelander authored
This allows you to use: cls.def(py::init(&factory_function)); where `factory_function` returns a pointer, holder, or value of the class type (or a derived type). Various compile-time checks (static_asserts) are performed to ensure the function is valid, and various run-time type checks where necessary. Some other details of this feature: - The `py::init` name doesn't conflict with the templated no-argument `py::init<...>()`, but keeps the naming consistent: the existing templated, no-argument one wraps constructors, the no-template, function-argument one wraps factory functions. - If returning a CppClass (whether by value or pointer) when an CppAlias is required (i.e. python-side inheritance and a declared alias), a dynamic_cast to the alias is attempted (for the pointer version); if it fails, or if returned by value, an Alias(Class &&) constructor is invoked. If this constructor doesn't exist, a runtime error occurs. - for holder returns when an alias is required, we try a dynamic_cast of the wrapped pointer to the alias to see if it is already an alias instance; if it isn't, we raise an error. - `py::init(class_factory, alias_factory)` is also available that takes two factories: the first is called when an alias is not needed, the second when it is. - Reimplement factory instance clearing. The previous implementation failed under python-side multiple inheritance: *each* inherited type's factory init would clear the instance instead of only setting its own type value. The new implementation here clears just the relevant value pointer. - dealloc is updated to explicitly set the leftover value pointer to nullptr and the `holder_constructed` flag to false so that it can be used to clear preallocated value without needing to rebuild the instance internals data. - Added various tests to test out new allocation/deallocation code. - With preallocation now done lazily, init factory holders can completely avoid the extra overhead of needing an extra allocation/deallocation. - Updated documentation to make factory constructors the default advanced constructor style. - If an `__init__` is called a second time, we have two choices: we can throw away the first instance, replacing it with the second; or we can ignore the second call. The latter is slightly easier, so do that. -
Jason Rhinelander authored
An alias can be used for two main purposes: to override virtual methods, and to add some extra data to a class needed for the pybind-wrapper. Both of these absolutely require that the wrapped class be polymorphic so that virtual dispatch and destruction, respectively, works.
-
- 13 Aug, 2017 1 commit
-
-
Dean Moldovan authored
One module uses a generic vector caster from `<pybind11/stl.h>` while the other exports `std::vector<int>` with a local `py:bind_vector`.
-
- 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 1 commit
-
-
Dean Moldovan authored
-
- 05 Aug, 2017 3 commits
-
-
Jason Rhinelander authored
This udpates all the remaining tests to the new test suite code and comment styles started in #898. For the most part, the test coverage here is unchanged, with a few minor exceptions as noted below. - test_constants_and_functions: this adds more overload tests with overloads with different number of arguments for more comprehensive overload_cast testing. The test style conversion broke the overload tests under MSVC 2015, prompting the additional tests while looking for a workaround. - test_eigen: this dropped the unused functions `get_cm_corners` and `get_cm_corners_const`--these same tests were duplicates of the same things provided (and used) via ReturnTester methods. - test_opaque_types: this test had a hidden dependence on ExampleMandA which is now fixed by using the global UserType which suffices for the relevant test. - test_methods_and_attributes: this required some additions to UserType to make it usable as a replacement for the test's previous SimpleType: UserType gained a value mutator, and the `value` property is not mutable (it was previously readonly). Some overload tests were also added to better test overload_cast (as described above). - test_numpy_array: removed the untemplated mutate_data/mutate_data_t: the templated versions with an empty parameter pack expand to the same thing. - test_stl: this was already mostly in the new style; this just tweaks things a bit, localizing a class, and adding some missing `// test_whatever` comments. - test_virtual_functions: like `test_stl`, this was mostly in the new test style already, but needed some `// test_whatever` comments. This commit also moves the inherited virtual example code to the end of the file, after the main set of tests (since it is less important than the other tests, and rather length); it also got renamed to `test_inherited_virtuals` (from `test_inheriting_repeat`) because it tests both inherited virtual approaches, not just the repeat approach.
-
Jason Rhinelander authored
-
Jason Rhinelander authored
-