- 28 Aug, 2017 3 commits
-
-
Dean Moldovan committed
-
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.
Dean Moldovan committed -
[skip ci]
Dean Moldovan committed
-
- 25 Aug, 2017 4 commits
-
-
Wenzel Jakob committed
-
Dean Moldovan committed
-
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.
Wenzel Jakob committed -
Henry Schreiner committed
-
- 24 Aug, 2017 2 commits
-
-
For the case of `pip install --user`, the header include dirs must also include `pybind11.get_include(True)`. [skip appveyor]
Dean Moldovan committed -
The default `install_headers` from `distutils` flattens all the headers into a single directory -- `detail` subdirectory was lost. This commit fixes this by overriding the setup with a custom header installer. Tests are added to Travis to make sure `setup.py sdist` and `pip install` do not miss any headers and that the directory structure is preserved. [skip appveyor]
Dean Moldovan committed
-
- 23 Aug, 2017 9 commits
-
-
Matthias Hochsteger committed
-
Jason Rhinelander committed
-
Newer clang produces additional warnings. [skip appveyor]
Jason Rhinelander committed -
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.
Dean Moldovan committed -
Wenzel Jakob committed
-
Dean Moldovan committed
-
Dean Moldovan committed
-
The current PYBIND11_INTERNALS_ID depends on the version of the library in order to isolate binary incompatible internals capsules. However, this does not preclude conflicts between modules built from different (binary incompatible) commits with the same version number. For example, if one module was built with an early v2.2.dev and submitted to PyPI, it could not be loaded alongside a v2.2.x release module -- it would segfault because of incompatible internals with the same ID. This PR changes the ID to depend on PYBIND11_INTERNALS_VERSION which is independent of the main library version. It's an integer which should be incremented whenever a binary incompatible change is made to internals. PYBIND11_INTERNALS_KIND is also introduced for a similar reason. The same versioning scheme is also applied to `type_info` and the `module_local` type attribute.
Dean Moldovan committed -
Dean Moldovan committed
-
- 22 Aug, 2017 4 commits
-
-
Baljak committed
-
Wenzel Jakob committed
-
Wenzel Jakob committed
-
Dean Moldovan committed
-
- 21 Aug, 2017 1 commit
-
-
The "see above" comment being referenced in the code comments isn't "above" anymore; copy the later factory init comment into the first constructor block to fix it.
Jason Rhinelander committed
-
- 20 Aug, 2017 2 commits
-
-
[skip ci]
Dean Moldovan committed -
[skip ci]
Dean Moldovan committed
-
- 19 Aug, 2017 2 commits
-
-
Fixes one small variable name typo, and two instances where `py::arg().nocopy()` is used, where I think it should be `py::arg().noconvert()` instead. Probably `nocopy()` was the old/original name for it and then it was changed.
Patrik Huber committed -
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.
Jason Rhinelander committed
-
- 17 Aug, 2017 10 commits
-
-
The macro isn't doing anything useful now that hidden visibility is applied to all pybind11 code.
Jason Rhinelander committed -
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 committed -
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 committed -
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.
Jason Rhinelander committed -
`function_signature_t` extracts the function type from a function, function pointer, or lambda. `is_lambda` (which is really `is_not_a_function_or_pointer_or_member_pointer`, but that name is a bit too long) checks whether the type is (in the approprate context) a lambda. `is_function_pointer` checks whether the type is a pointer to a function.
Jason Rhinelander committed -
We currently allocate instance values when creating the instance itself (except when constructing the instance for a `cast()`), but there is no particular reason to do so: the instance itself and the internals (for a non-simple layout) are allocated via Python, with no reason to expect better locality from the invoked `operator new`. Moreover, it makes implementation of factory function constructors trickier and slightly less efficient: they don't use the pre-eallocate the memory, which means there is a pointless allocation and free. This commit makes the allocation lazy: instead of preallocating when creating the instance, the allocation happens when the instance is first loaded (if null at that time). In addition to making it more efficient to deal with cases that don't need preallocation, this also allows for a very slight performance increase by not needing to look up the instances types during allocation. (There is a lookup during the eventual load, of course, but that is happening already).
Jason Rhinelander committed -
* Doxygen needs `RECURSIVE = YES` in order to parse the `detail` subdir. * The `-W` warnings-as-errors option for sphinx doesn't work with the makefile build. Switched to calling sphinx directly. * Fix "citation [cppimport] is not referenced" warning.
Dean Moldovan committed -
Embedding may well be used in places where hidden visibility isn't desired. It should be relatively safe to allow it there; any potential conflict would come in if modules are loaded into that embedded interpreter, but as long as the modules are compiled with hidden visibility they shouldn't conflict. There could still be warnings if the embedded code attempts to export classes with internal (hidden) pybind members, but that seems a legitimate warning (and already has a FAQ entry).
Jason Rhinelander committed -
Dean Moldovan committed
-
CMAKE_CXX_STANDARD is only available on CMake >= 3.1. If the flag is set, we avoid initializing PYBIND11_CPP_STANDARD.
Dean Moldovan committed
-
- 14 Aug, 2017 2 commits
-
-
This updates the compilation to always apply hidden visibility to resolve the issues with default visibility causing problems under debug compilations. Moreover using the cmake property makes it easier for a caller to override if absolutely needed for some reason. For `pybind11_add_module` we use cmake to set the property; for the targets, we append to compilation option to non-MSVC compilers.
Jason Rhinelander committed -
This adds a PYBIND11_NAMESPACE macro that expands to the `pybind11` namespace with hidden visibility under gcc-type compilers, and otherwise to the plain `pybind11`. This then forces hidden visibility on everything in pybind, solving the visibility issues discussed at end end of #949.
Jason Rhinelander committed
-
- 13 Aug, 2017 1 commit
-
-
One module uses a generic vector caster from `<pybind11/stl.h>` while the other exports `std::vector<int>` with a local `py:bind_vector`.
Dean Moldovan committed
-