Commit Graph

2420 Commits

Author SHA1 Message Date
Wenzel Jakob
9180519d8c added an example on using fancier kinds of default arguments 2016-01-17 22:31:15 +01:00
Wenzel Jakob
1ae77fe4d3 added a changelog file and version defines 2016-01-17 22:31:15 +01:00
Wenzel Jakob
53b26549d0 python 3.2 compatiblity (closes #56) 2016-01-17 22:31:15 +01:00
Wenzel Jakob
ba0732e7dc fixed a terrible bug in def_property_static and switched to the faster PyObject_CallFunctionObjArgs API call 2016-01-17 22:31:15 +01:00
Wenzel Jakob
678d787ca4 do more work with classes from pytypes.h (especially for STL container casting) 2016-01-17 22:31:15 +01:00
Wenzel Jakob
d561cb010c fully moved __pybind11__ Python attributes to the C++ side, cleanup & documentation pass over the main header file 2016-01-17 22:31:15 +01:00
Wenzel Jakob
e45b29047a numpy.h: fixed a leak, added some comments to buffer_info 2016-01-17 22:31:15 +01:00
Wenzel Jakob
d33361a6d7 moved lifetime management of Py_buffer to pybind11::buffer_info, renamed count->size to match NumPy naming (fixes #34) 2016-01-17 22:31:15 +01:00
Wenzel Jakob
95d18691c9 minor fixes & removed a leak when freeing functions 2016-01-17 22:31:15 +01:00
Wenzel Jakob
b2c2c79240 improved handling of shared/smart pointers
Previously, pybind11 required classes using std::shared_ptr<> to derive
from std::enable_shared_from_this<> (or compilation failures would ensue).

Everything now also works for classes that don't do this, assuming that
some basic rules are followed (e.g. never passing "raw" pointers of
instances manged by shared pointers). The safer
std::enable_shared_from_this<> approach continues to be supported.
2016-01-17 22:31:15 +01:00
Wenzel Jakob
2ca07de83c minor fix for PYBIND11_OBJECT_CVT 2016-01-17 22:31:15 +01:00
Wenzel Jakob
5f218b3f2c keep_alive call policy (analogous to Boost.Python's with_custodian_and_ward, fixes #62) 2016-01-17 22:31:15 +01:00
Wenzel Jakob
87187afe91 switch NumPy array to object API, avoid unnecessary copy operation in vectorize 2016-01-17 22:31:15 +01:00
Wenzel Jakob
87dfad6544 avoid naming clashes with numpy (fixes #36) 2016-01-17 22:31:15 +01:00
Wenzel Jakob
4177ed4336 renamed decay -> intrinsic_type (fixes #59) 2016-01-17 22:31:15 +01:00
Wenzel Jakob
82ffd40870 type of void fixed (None -> NoneType) 2016-01-17 22:31:15 +01:00
Wenzel Jakob
56e9f4942b improved signature names for subclasses of pybind11::handle 2016-01-17 22:31:15 +01:00
Wenzel Jakob
d0325bbd97 switched a few admissible cases from PyTuple_Set/GetItem -> PyTuple_SET/GET_ITEM 2016-01-17 22:31:15 +01:00
Wenzel Jakob
27e8e1066b added new type pybind11::bytes, cleanup of various macros (fixes #49) 2016-01-17 22:31:15 +01:00
Wenzel Jakob
2dfbadee5d documentation on using multiple extension modules 2016-01-17 22:31:15 +01:00
Wenzel Jakob
4c1a6be4bd minor cleanups in numpy.h, updated gitignore file for ninja 2016-01-17 22:31:15 +01:00
Wenzel Jakob
6eb11da94a Very minor documentation fixes, updated logo 2016-01-17 22:31:15 +01:00
Wenzel Jakob
f4671f6a04 use RAII in dispatcher to avoid refcount leaks in certain circumstances when handling exceptions 2016-01-17 22:31:15 +01:00
Wenzel Jakob
66c9a40213 Much more efficient generation of function signatures, updated docs
This modification taps into some newer C++14 features (if present) to
generate function signatures considerably more efficiently at compile
time rather than at run time.

With this change, pybind11 binaries are now *2.1 times* smaller compared
to the Boost.Python baseline in the benchmark. Compilation times get a
nice improvement as well.

Visual Studio 2015 unfortunately doesn't implement 'constexpr' well
enough yet to support this change and uses a runtime fallback.
2016-01-17 22:31:15 +01:00
Wenzel Jakob
2ac5044a05 moved processing of cpp_function arguments out of dispatch code
The cpp_function class accepts a variadic argument, which was formerly
processed twice -- once at registration time, and once in the dispatch
lambda function. This is not only unnecessarily slow but also leads to
code bloat since it adds to the object code generated for every bound
function. This change removes the second pass at dispatch time.

One noteworthy change of this commit is that default arguments are now
constructed (and converted to Python objects) right at declaration time.
Consider the following example:

py::class_<MyClass>("MyClass")
    .def("myFunction", py::arg("arg") = SomeType(123));

In this case, the change means that pybind11 must already be set up to
deal with values of the type 'SomeType', or an exception will be thrown.
Another change is that the "preview" of the default argument in the
function signature is generated using the __repr__ special method. If
it is not available in this type, the signature may not be very helpful,
i.e.:

|  myFunction(...)
|      Signature : (MyClass, arg : SomeType = <SomeType object at 0x101b7b080>) -> None

One workaround (other than defining SomeType.__repr__) is to specify the
human-readable preview of the default argument manually using the more
cumbersome arg_t notation:

py::class_<MyClass>("MyClass")
    .def("myFunction", py::arg_t<SomeType>("arg", SomeType(123), "SomeType(123)"));
2016-01-17 22:31:15 +01:00
Wenzel Jakob
caa9d44cc7 cmake: robustified search for python 2016-01-17 22:31:15 +01:00
Wenzel Jakob
3faa3879c6 Merge pull request #66 from aldanor/patch-1
Add an include in cmake.rst
2016-01-17 17:43:23 +01:00
Ivan Smirnov
4f88edde14 Add an include in cmake.rst 2016-01-17 16:42:11 +00:00
Wenzel Jakob
f08a3f0622 Merge pull request #52 from tmiasko/const-correctness
Make handle and related classes const correct.
2016-01-10 21:34:55 +01:00
Wenzel Jakob
deadbbb671 Merge pull request #57 from tmiasko/conversion
Use object class to hold partially converted python objects.
2016-01-07 00:08:38 +01:00
Tomasz Miąsko
ca77130be8 Use object class to hold partially converted python objects.
Using object class to hold converted object automatically deallocates
object if an exception is thrown or scope is left before constructing
complete Python object.

Additionally added method object::release() that allows to release
ownership of python object without decreasing its reference count.
2016-01-02 21:07:18 +01:00
Wenzel Jakob
3367cecc6b detect unreferenced keyword arguments in function calls 2015-12-30 18:48:20 +01:00
Wenzel Jakob
e9dc824866 Merge pull request #53 from tmiasko/clean-type
Clean the type name alone, not the whole message.
2015-12-28 11:18:11 +01:00
Tomasz Miąsko
5d53ac4cbf Clean the type name alone, not the whole message. 2015-12-28 08:49:17 +01:00
Tomasz Miąsko
875df5528d Make handle and related classes const correct.
This gives handle classes a typical pointer semantics with respects to
constness.
2015-12-28 08:11:16 +01:00
Wenzel Jakob
45f7c65594 Merge pull request #50 from tmiasko/handle_cast_const
Add const modifier to handle::cast.
2015-12-27 17:29:24 +01:00
Wenzel Jakob
386ac5cbab Merge pull request #51 from tmiasko/def_tuple
Create an empty python tuple in pybind::tuple default constructor.
2015-12-27 17:28:30 +01:00
Tomasz Miąsko
c83e062263 Create an empty python tuple in pybind::tuple default constructor.
Follow the same semantics as constructors of dict, list, and set by
creating valid Python object in default constructor of a tuple class.
2015-12-27 09:05:25 +01:00
Tomasz Miąsko
cc39b2f37f Add const modifier to handle::cast. 2015-12-26 19:01:28 +01:00
Wenzel Jakob
dd57a34e2d improved error handling at module import time 2015-12-26 14:04:52 +01:00
Wenzel Jakob
9d573f44b9 stl.h fix for std::map (see PR #43) 2015-12-26 13:37:59 +01:00
Wenzel Jakob
1546b85797 Merge pull request #44 from onionhammer/patch-1
functional.h not included in "make install"
2015-12-22 12:05:44 +01:00
Erik O'Leary
a1718a66d3 functional.h not included in "make install" 2015-12-21 20:26:02 -06:00
Wenzel Jakob
4b279327a3 stl.h bugfix for std::set, misc. cleanups 2015-12-18 18:41:36 +01:00
Wenzel Jakob
dbfaf370a5 Merge pull request #41 from jaredcasper/master
Fix typo in STL docs.
2015-12-16 12:22:20 +01:00
Wenzel Jakob
d1a24823bc considerable simplifications to the Python type casters 2015-12-16 12:17:46 +01:00
Wenzel Jakob
9b0b40e0b0 add converter for nullptr_t 2015-12-16 11:41:53 +01:00
Jared Casper
6be9e2fff5 Fix typo in STL docs. 2015-12-15 15:56:14 -08:00
Wenzel Jakob
5ef1219030 smart pointer clarifications 2015-12-15 17:07:35 +01:00
Wenzel Jakob
8b5bf00f26 added enhancements clause to license 2015-12-15 16:35:20 +01:00