Commit Graph

1137 Commits

Author SHA1 Message Date
Wenzel Jakob
6f017cf658 basics.rst: minor table update for Eigen types 2016-09-06 14:13:35 +09:00
Wenzel Jakob
48ce0727e4 added docs for custom type casters (fixes #298) 2016-09-06 14:13:22 +09:00
Wenzel Jakob
146397ecf4 allow iterators with different RV policies (fixes #388) 2016-09-06 13:06:31 +09:00
Wenzel Jakob
fe34241e50 minor doc & style fixes 2016-09-06 13:02:29 +09:00
Wenzel Jakob
07082eecc3 Merge pull request #235 from RosettaCommons/stl
Adding bind_map. Adding key_error exception.
2016-09-06 12:11:41 +09:00
Sergey Lyskov
7520418e26 Adding bind_map 2016-09-05 17:11:16 -04:00
Wenzel Jakob
ba21f1dbd6 Merge pull request #386 from wjakob/enum-fix
enum serialization support (fixes #380)
2016-09-05 23:29:31 +09:00
Wenzel Jakob
8ac9715f84 enum serialization support (fixes #380) 2016-09-05 17:20:50 +09:00
Wenzel Jakob
70f5a4dc8b minor: added error message to faq 2016-09-05 17:19:18 +09:00
Wenzel Jakob
614988c875 Merge pull request #384 from jagerman/unique-ptr-non-default-deleters
Make unique_ptr's with non-default deleters work
2016-09-05 08:26:34 +09:00
Wenzel Jakob
cc4e4065b3 .. and another one 2016-09-05 08:25:10 +09:00
Jason Rhinelander
a6495af87a Make unique_ptr's with non-default deleters work
Currently pybind11 only supports std::unique_ptr<T> holders by default
(other holders can, of course, be declared using the macro).  PR #368
added a `py::nodelete` that is intended to be used as:

    py::class_<Type, std::unique_ptr<Type, py::nodelete>> c("Type");

but this doesn't work out of the box.  (You could add an explicit
holder type declaration, but this doesn't appear to have been the
intention of the commit).

This commit fixes it by generalizing the unique_ptr type_caster to take
both the type and deleter as template arguments, so that *any*
unique_ptr instances are now automatically handled by pybind.  It also
adds a test to test_smart_ptr, testing both that py::nodelete (now)
works, and that the object is indeed not deleted as intended.
2016-09-04 18:23:55 -04:00
Wenzel Jakob
f3be07c661 minor code style fixes 2016-09-04 23:03:48 +09:00
Wenzel Jakob
987be18fee Merge pull request #379 from nevion/buffer_info
Buffer info improvements
2016-09-04 23:02:20 +09:00
Wenzel Jakob
85f07e18cc minor code style checker update 2016-09-04 23:00:49 +09:00
Wenzel Jakob
2ea4b8e8bb Merge pull request #381 from jagerman/tests-self-registering
Make test initialization self-registering
2016-09-04 22:49:53 +09:00
Jason Rhinelander
52f4be8946 Make test initialization self-registering
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.
2016-09-03 17:34:41 -04:00
Jason Newton
10d46e7f73 explicitly delete copy-ctor and assignment operator 2016-09-02 18:39:47 -04:00
Jason Newton
4764698069 add move ctor and move-assignment operator 2016-09-02 18:37:13 -04:00
Jason Newton
514c6dad70 add field for ownership 2016-09-02 17:10:50 -04:00
Jason Newton
3718c38e68 default all fields in all ctors 2016-09-02 17:10:02 -04:00
Wenzel Jakob
06d8de113a Merge pull request #373 from jagerman/style-check-fix
Fix check-style exit status and improve failure messages
2016-08-30 21:17:40 +09:00
Wenzel Jakob
c50bd5cb3d Merge pull request #374 from jagerman/tpl-tramp-resolution-fix
Fix template trampoline overload lookup failure
2016-08-30 21:17:27 +09:00
Jason Rhinelander
d472f0f058 Add line numbers; show and highlight found tabs
This makes the output considerably easier to use: it now highlights (in
red) matched tabs (instead of just listing the filenames), and adds
line numbers to both the tabs check and the space-less if check outputs.
2016-08-29 21:25:11 -04:00
Jason Rhinelander
2097826346 Fix template trampoline overload lookup failure
Problem
=======

The template trampoline pattern documented in PR #322 has a problem with
virtual method overloads in intermediate classes in the inheritance
chain between the trampoline class and the base class.

For example, consider the following inheritance structure, where `B` is
the actual class, `PyB<B>` is the trampoline class, and `PyA<B>` is an
intermediate class adding A's methods into the trampoline:

    PyB<B> -> PyA<B> -> B -> A

Suppose PyA<B> has a method `some_method()` with a PYBIND11_OVERLOAD in
it to overload the virtual `A::some_method()`.  If a Python class `C` is
defined that inherits from the pybind11-registered `B` and tries to
provide an overriding `some_method()`, the PYBIND11_OVERLOADs declared
in PyA<B> fails to find this overloaded method, and thus never invoke it
(or, if pure virtual and not overridden in PyB<B>, raises an exception).

This happens because the base (internal) `PYBIND11_OVERLOAD_INT` macro
simply calls `get_overload(this, name)`; `get_overload()` then uses the
inferred type of `this` to do a type lookup in `registered_types_cpp`.
This is where it fails: `this` will be a `PyA<B> *`, but `PyA<B>` is
neither the base type (`B`) nor the trampoline type (`PyB<B>`).  As a
result, the overload fails and we get a failed overload lookup.

The fix
=======

The fix is relatively simple: we can cast `this` passed to
`get_overload()` to a `const B *`, which lets get_overload look up the
correct class.  Since trampoline classes should be derived from `B`
classes anyway, this cast should be perfectly safe.

This does require adding the class name as an argument to the
PYBIND11_OVERLOAD_INT macro, but leaves the public macro signatures
unchanged.
2016-08-29 19:41:44 -04:00
Jason Rhinelander
5a3570c47c Fix check-style exit status
The check-style exit status wasn't being propagated properly because
the loops were running in a subshell (and so the change the the
`errors` variable wasn't in the active command shell).  This fixes it
by running the greps in subshells and the loops in the main shell.

This also avoids the if(/for(/while( style check on
tests/CMakeLists.txt, since it *does* have if() statements with no space
that are producing error messages, but that is (acceptable) CMake style.
2016-08-29 19:04:12 -04:00
Wenzel Jakob
d9b3db3e64 Merge pull request #371 from jagerman/overload-name-doc-fix
Doc fix for OVERLOAD*_NAME macros
2016-08-29 23:03:46 +02:00
Jason Rhinelander
64830e3333 Doc fix for OVERLOAD*_NAME macros
The documentation says the string-valued python function name goes
after the C++ function, but it actually goes before it.
2016-08-29 16:58:59 -04:00
Wenzel Jakob
7946715d02 Merge pull request #369 from jagerman/check-for-tabs
Check for style issues during docs build
2016-08-29 22:31:42 +02:00
Wenzel Jakob
5d1d380e0c Merge pull request #370 from jagerman/contributing-test-target
Minor doc fix: ``make test`` -> ``make pytest``
2016-08-29 22:29:37 +02:00
Jason Rhinelander
dbc4bf68ed check-style: also report no space in if(/for(/while( 2016-08-28 14:53:04 -04:00
Jason Rhinelander
79583b5643 Minor doc fix: `make test -> make pytest`
The test target changed with the new testing framework.
2016-08-28 14:26:50 -04:00
Jason Rhinelander
540ae61d3c Replace tabs with spaces (to pass style check) 2016-08-28 14:11:38 -04:00
Jason Rhinelander
ac4278970c Check for tabs instead of spaces in the doc build
This adds a tool that checks style (currently just for tabs instead of
spaces in files under include/tests/docs) and produces a travis-ci build
failure if any problems are found.
2016-08-28 14:11:23 -04:00
Wenzel Jakob
8c41974630 Merge pull request #367 from dean0x7d/debug_ext_name
Fix module file name when working with debug builds of Python
2016-08-28 02:05:11 +02:00
Wenzel Jakob
5e4e477b8b minor fixes to PR #368 2016-08-28 02:03:15 +02:00
Wenzel Jakob
a3906778eb minor: renamed argument in array constructor 2016-08-28 01:55:07 +02:00
Wenzel Jakob
35540ea35d Merge pull request #368 from nbelakovski/master
Added support for exposing classes with private destructors and corresponding documentation
2016-08-28 01:54:38 +02:00
Nickolai Belakovski
6333825350 Added support for exposing classes with private destructors and corresponding documentation 2016-08-27 15:09:15 -07:00
Dean Moldovan
7b4f8dc048 Fix module file name when working with debug builds of Python
Fixes #365. `sysconfig.get_config_var('SO')` already returns the correct
PYTHON_MODULE_EXTENSION, even for debug builds, so there is no need to
add anything else manually.
2016-08-27 20:34:33 +02:00
Wenzel Jakob
36919ea695 Merge pull request #364 from jagerman/cmake-remove-pip
Don't install pytest from cmake, just fail instead
2016-08-27 11:34:01 +02:00
Jason Rhinelander
dd3d56a885 Don't install pytest from cmake, just fail instead
Installing something outside the project directory from a cmake
invocation is overly intrusive; this changes tests/CMakeLists.txt to
just fail with an informative message instead, and changes the
travis-ci builds to install pytest via pip or apt-get.
2016-08-26 17:22:48 -04:00
Wenzel Jakob
324c9c521b minor Intel compiler fix 2016-08-26 16:52:45 +02:00
Wenzel Jakob
c7c7705f86 Merge pull request #361 from dean0x7d/barebones
Test absence of optional dependencies and CMake automatic discovery functions
2016-08-26 12:34:38 +02:00
Dean Moldovan
14bd10d6d6 Fix Travis cache config: remove ccache, add OS X pip cache
ccache on Travis was never configured properly so the setting never
actually did anything. Enabling ccache for real brings other issues:
due to the way the preprocessor is handled, some of the Python header
macros produce bogus compiler warnings (which in turn produce errors
with -Werror). ccache also requires additional configuration on OS X
and docker. It would reduce compile time by ~30 seconds at best, so
it's not worth the trouble.

[skip appveyor]
2016-08-26 11:53:25 +02:00
Dean Moldovan
b62a896f31 Add barebones build to Travis CI
This build makes sure everything still works without optional
dependencies (numpy/scipy/eigen) and also tests the automatic
discovery functions in CMake (Python version, C++ standard).

[skip appveyor]
2016-08-26 11:41:27 +02:00
Wenzel Jakob
7b748cef3b Merge pull request #359 from dean0x7d/fix_skip_numpy
Fix test suite failure without numpy and improve module init diagnostics
2016-08-26 09:53:44 +02:00
Wenzel Jakob
3c49bca67a Merge pull request #358 from aldanor/bugfix/icpc-numpy
Fix dtype::strip_padding() on Intel compiler
2016-08-25 22:56:38 +02:00
Ivan Smirnov
d8b11b8708 Fix dtype::strip_padding() on Intel compiler 2016-08-25 21:52:52 +01:00
Dean Moldovan
23919174a7 Fix test suite failure without numpy and improve module init diagnostics
Fixes #357.
2016-08-25 17:08:09 +02:00