- 27 Apr, 2017 1 commit
-
-
Jason Rhinelander authored
When we are returned a base class pointer (either directly or via shared_from_this()) we detect its runtime type (using `typeid`), then end up essentially reinterpret_casting the pointer to the derived type. This is invalid when the base class pointer was a non-first base, and we end up with an invalid pointer. We could dynamic_cast to the most-derived type, but if *that* type isn't pybind11-registered, the resulting pointer given to the base `cast` implementation isn't necessarily valid to be reinterpret_cast'ed back to the backup type. This commit removes the "backup" type argument from the many-argument `cast(...)` and instead does the derived-or-pointer type decision and type lookup in type_caster_base, where the dynamic_cast has to be to correctly get the derived pointer, but also has to do the type lookup to ensure that we don't pass the wrong (derived) pointer when the backup type (i.e. the type caster intrinsic type) pointer is needed. Since the lookup is needed before calling the base cast(), this also changes the input type to a detail::type_info rather than doing a (second) lookup in cast().
-
- 01 Feb, 2017 1 commit
-
-
Jason Rhinelander authored
Issue #633 suggests people might be tempted to copy the test scripts self-binding code, but that's a bad idea for pretty much anything other than a test suite with self-contained test code. This commit adds a comment as such with a reference to the documentation that tells people how to do it instead.
-
- 31 Jan, 2017 1 commit
-
-
Jason Rhinelander authored
* Minor doc syntax fix The numpy documentation had a bad :file: reference (was using double backticks instead of single backticks). * Changed long-outdated "example" -> "tests" wording The ConstructorStats internal docs still had "from example import", and the main testing cpp file still used "example" in the module description.
-
- 12 Dec, 2016 1 commit
-
-
Jason Rhinelander authored
This adds automatic casting when assigning to python types like dict, list, and attributes. Instead of: dict["key"] = py::cast(val); m.attr("foo") = py::cast(true); list.append(py::cast(42)); you can now simply write: dict["key"] = val; m.attr("foo") = true; list.append(42); Casts needing extra parameters (e.g. for a non-default rvp) still require the py::cast() call. set::add() is also supported. All usage is channeled through a SFINAE implementation which either just returns or casts. Combined non-converting handle and autocasting template methods via a helper method that either just returns (handle) or casts (C++ type).
-
- 22 Sep, 2016 1 commit
-
-
Dean Moldovan authored
This also adds the `hasattr` and `getattr` functions which are needed with the new attribute behavior. The new functions behave exactly like their Python counterparts. Similarly `object` gets a `contains` method which calls `__contains__`, i.e. it's the same as the `in` keyword in Python.
-
- 03 Sep, 2016 1 commit
-
-
Jason Rhinelander authored
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.
-
- 24 Aug, 2016 1 commit
-
-
Wenzel Jakob authored
- ICPC can't handle the NCVirt trampoline which returns a non-copyable type, which is likely due to a constexpr/SFINAE issue. This disables the test on that compiler so that at least the rest can be tested.
-
- 19 Aug, 2016 2 commits
-
-
Dean Moldovan authored
There are more enum tests than 'constants and functions'.
-
Dean Moldovan authored
Use simple asserts and pytest's powerful introspection to make testing simpler. This merges the old .py/.ref file pairs into simple .py files where the expected values are right next to the code being tested. This commit does not touch the C++ part of the code and replicates the Python tests exactly like the old .ref-file-based approach.
-
- 13 Aug, 2016 2 commits
-
-
Ivan Smirnov authored
-
Ivan Smirnov authored
-
- 11 Aug, 2016 1 commit
-
-
Jason Rhinelander authored
This commit rewrites the examples that look for constructor/destructor calls to do so via static variable tracking rather than output parsing. The added ConstructorStats class provides methods to keep track of constructors and destructors, number of default/copy/move constructors, and number of copy/move assignments. It also provides a mechanism for storing values (e.g. for value construction), and then allows all of this to be checked at the end of a test by getting the statistics for a C++ (or python mapping) class. By not relying on the precise pattern of constructions/destructions, but rather simply ensuring that every construction is matched with a destruction on the same object, we ensure that everything that gets created also gets destroyed as expected. This replaces all of the various "std::cout << whatever" code in constructors/destructors with `print_created(this)`/`print_destroyed(this)`/etc. functions which provide similar output, but now has a unified format across the different examples, including a new ### prefix that makes mixed example output and lifecycle events easier to distinguish. With this change, relaxed mode is no longer needed, which enables testing for proper destruction under MSVC, and under any other compiler that generates code calling extra constructors, or optimizes away any constructors. GCC/clang are used as the baseline for move constructors; the tests are adapted to allow more move constructors to be evoked (but other types are constructors much have matching counts). This commit also disables output buffering of tests, as the buffering sometimes results in C++ output ending up in the middle of python output (or vice versa), depending on the OS/python version.
-
- 18 Jul, 2016 1 commit
-
-
Jason Rhinelander authored
This renames example files from `exampleN` to `example-description`. Specifically, the following renaming is applied: example1 -> example-methods-and-attributes example2 -> example-python-types example3 -> example-operator-overloading example4 -> example-constants-and-functions example5 -> example-callbacks (*) example6 -> example-sequence-and-iterators example7 -> example-buffers example8 -> example-custom-ref-counting example9 -> example-modules example10 -> example-numpy-vectorize example11 -> example-arg-keywords-and-defaults example12 -> example-virtual-functions example13 -> example-keep-alive example14 -> example-opaque-types example15 -> example-pickling example16 -> example-inheritance example17 -> example-stl-binders example18 -> example-eval example19 -> example-custom-exceptions * the inheritance parts of example5 are moved into example-inheritance (previously example16), and the remainder is left as example-callbacks. This commit also renames the internal variables ("Example1", "Example2", "Example4", etc.) into non-numeric names ("ExampleMandA", "ExamplePythonTypes", "ExampleWithEnum", etc.) to correspond to the file renaming. The order of tests is preserved, but this can easily be changed if there is some more natural ordering by updating the list in examples/CMakeLists.txt.
-
- 11 Jul, 2016 1 commit
-
-
Pim Schellart authored
-
- 08 Jul, 2016 1 commit
-
-
Klemens Morgenstern authored
-
- 15 May, 2016 1 commit
-
-
Sergey Lyskov authored
-
- 05 May, 2016 1 commit
-
-
Wenzel Jakob authored
-
- 18 Apr, 2016 1 commit
-
-
Wenzel Jakob authored
-
- 13 Apr, 2016 2 commits
-
-
Wenzel Jakob authored
-
Wenzel Jakob authored
-
- 15 Mar, 2016 1 commit
-
-
Wenzel Jakob authored
-
- 10 Mar, 2016 1 commit
-
-
Wenzel Jakob authored
-
- 17 Jan, 2016 1 commit
-
-
Wenzel Jakob authored
-
- 18 Oct, 2015 1 commit
-
-
Wenzel Jakob authored
-
- 13 Oct, 2015 1 commit
-
-
Wenzel Jakob authored
1. Renamed PYTHON_* to PYBIND_* everywhere 2. Renamed pybind::array_dtype<> to pybind::array_t<>
-
- 01 Oct, 2015 1 commit
-
-
Wenzel Jakob authored
-
- 29 Jul, 2015 1 commit
-
-
Wenzel Jakob authored
-
- 28 Jul, 2015 1 commit
-
-
Wenzel Jakob authored
-
- 09 Jul, 2015 1 commit
-
-
Wenzel Jakob authored
-