Commit Graph

80 Commits

Author SHA1 Message Date
Ivan Smirnov
42ad328481 Change format_descriptor::value to a static func 2016-08-13 12:43:16 +01:00
Jason Rhinelander
5aa85be26e Added pybind11::make_key_iterator for map iteration
This allows exposing a dict-like interface to python code, allowing
iteration over keys via:

    for k in custommapping:
        ...

while still allowing iteration over pairs, so that you can also
implement 'dict.items()' functionality which returns a pair iterator,
allowing:

    for k, v in custommapping.items():
        ...

example-sequences-and-iterators is updated with a custom class providing
both types of iteration.
2016-08-11 21:22:05 -04:00
Jason Rhinelander
f2ecd8927e Implement reference_internal with a keep_alive
reference_internal requires an `instance` field to track the returned
reference's parent, but that's just a duplication of what
keep_alive<0,1> does, so use a keep alive to do this to eliminate the
duplication.
2016-08-10 12:08:04 -04:00
Jason Rhinelander
efc2aa7ee7 Removed obsolete documentation about duplicate address problems
It no longer applies since instances are now identified by both address
and type.
2016-08-10 11:38:33 -04:00
Jason Rhinelander
d6c365bcfa virtual + inheritance example: remove multiple inheritance approach
It was already pretty badly intrusive, but it also appears to make MSVC
segfault.  Rather than investigating and fixing it, it's easier to just
remove it.
2016-08-05 18:03:06 -04:00
Jason Rhinelander
0ca96e2915 Added advanced doc section on virtual methods + inheritance
As discussed in #320.

The adds a documentation block that mentions that the trampoline classes
must provide overrides for both the classes' own virtual methods *and*
any inherited virtual methods.  It also provides a templated solution to
avoiding method duplication.

The example includes a third method (only mentioned in the "see also"
section of the documentation addition), using multiple inheritance.
While this approach works, and avoids code generation in deep
hierarchies, it is intrusive by requiring that the wrapped classes use
virtual inheritance, which itself is more instrusive if any of the
virtual base classes need anything other than default constructors.  As
per the discussion in #320, it is kept as an example, but not suggested
in the documentation.
2016-08-05 18:02:37 -04:00
Jason Rhinelander
b68d8fc2c5 *Really* fix enumeration indices 2016-08-04 16:39:30 -04:00
Jason Rhinelander
38d5b4565c Fixed enumeration indices 2016-08-04 16:36:16 -04:00
Jason Rhinelander
9ffb3dda5f Eigen support for special matrix objects
Functions returning specialized Eigen matrices like Eigen::DiagonalMatrix and
Eigen::SelfAdjointView--which inherit from EigenBase but not
DenseBase--isn't currently allowed; such classes are explicitly copyable
into a Matrix (by definition), and so we can support functions that
return them by copying the value into a Matrix then casting that
resulting dense Matrix into a numpy.ndarray.  This commit does exactly
that.
2016-08-04 15:24:41 -04:00
Wenzel Jakob
3764e28475 added note about args/kwargs limitation 2016-08-01 23:34:48 +02:00
Wenzel Jakob
f38f359f96 documentation fix (fixes #290) 2016-07-19 17:48:42 +02:00
Jason Rhinelander
3e2e44f53f Updated advanced.rst example references 2016-07-18 17:03:37 -04:00
Wenzel Jakob
fb6aed2157 return value policy clarifications 2016-07-18 20:29:53 +02:00
Wenzel Jakob
3c6ada3a48 Merge pull request #273 from lsst-dm/master
Add support for user defined exception translators
2016-07-11 23:38:21 +02:00
Pim Schellart
5a7d17ff16 Add support for user defined exception translators 2016-07-11 17:33:04 -04:00
Wenzel Jakob
954b7932fe avoid C++ -> Python -> C++ overheads when passing around function objects 2016-07-10 10:44:44 +02:00
Wenzel Jakob
0d3fc3566a complete rewrite of eval/exec patch 2016-07-08 10:52:10 +02:00
Klemens Morgenstern
c6ad2c4993 added exec functions 2016-07-08 10:05:24 +02:00
Wenzel Jakob
3eeea6fa61 docs: point out limitations of implicit conversions 2016-06-30 18:10:28 +02:00
Wenzel Jakob
f53e300fbd doc updates 2016-06-30 14:59:23 +02:00
nafur
717df75237 Added warning about same-address-optimization
See https://github.com/pybind/pybind11/issues/254
2016-06-28 18:07:11 +02:00
Wenzel Jakob
37e1f61f54 allow passing a 'return value policy' to handle::operator() 2016-06-22 14:29:13 +02:00
Wenzel Jakob
f88af0c127 clarification on static properties (fixes #248) 2016-06-22 13:52:31 +02:00
Brad Harmon
835fc06ca4 Add callback examples with named parameters 2016-06-16 13:19:15 -05:00
Wenzel Jakob
ca8dc08a66 updated pbtest link 2016-06-03 14:24:17 +02:00
Wenzel Jakob
9bb97c1b96 docs: added a general note about macro usage 2016-06-03 11:19:50 +02:00
Wenzel Jakob
99279f7107 docs: switched lexer for python console snippets to 'pycon' 2016-06-03 11:19:50 +02:00
Wenzel Jakob
86d825f330 Redesigned virtual call mechanism and user-facing syntax (breaking change!)
Sergey Lyskov pointed out that the trampoline mechanism used to override
virtual methods from within Python caused unnecessary overheads when
instantiating the original (i.e. non-extended) class.

This commit removes this inefficiency, but some syntax changes were
needed to achieve this. Projects using this features will need to make a
few changes:

In particular, the example below shows the old syntax to instantiate a
class with a trampoline:

class_<TrampolineClass>("MyClass")
    .alias<MyClass>()
    ....

This is what should be used now:

class_<MyClass, std::unique_ptr<MyClass, TrampolineClass>("MyClass")
    ....

Importantly, the trampoline class is now specified as the *third*
argument to the class_ template, and the alias<..>() call is gone. The
second argument with the unique pointer is simply the default holder
type used by pybind11.
2016-05-26 13:36:24 +02:00
Wenzel Jakob
1e3be73a52 PYBIND11_OVERLOAD_NAME and PYBIND11_OVERLOAD_PURE_NAME (fixes #205) 2016-05-24 23:42:14 +02:00
Wenzel Jakob
bd986fe57e add comment about macro issues (fixes #203) 2016-05-21 10:48:30 +02:00
Wenzel Jakob
b47a9de035 ability to prevent force casts in numpy arguments 2016-05-19 16:02:09 +02:00
Nils Werner
f7048f25b1 Fixed typo in NumPy example which prevented compilation 2016-05-19 11:17:17 +02:00
Sergey Lyskov
a95bde1ea5 Adding documentation for value_error. Fixing various formatting issues. Removing redundant binding for C++ style methods. Adding bindings for iterator and slicing protocol. Extending examples. 2016-05-15 20:46:07 +02:00
Wenzel Jakob
178c8a899d nicer type_caster::load() calling conventions 2016-05-15 20:23:27 +02:00
Wenzel Jakob
9e0a0568fe transparent conversion of dense and sparse Eigen types 2016-05-05 21:44:29 +02:00
Wenzel Jakob
e762853bba nicer example on instantiating Eigen matrices 2016-05-05 11:07:54 +02:00
Wenzel Jakob
f1032df891 only do numpy contiguous C/Fortran array conversion when explicitly requested 2016-05-05 10:00:00 +02:00
Wenzel Jakob
876eeab4ca redesigned format_descriptor<> and npy_format_descriptor<>
This somewhat heavyweight solution will avoid size_t/long long/long/int
mismatches on various platforms once and for all. The previous template
overloads could e.g. not handle size_t on Darwin.

One gotcha: the 'format_descriptor<T>::value()' syntax changed to just
'format_descriptor<T>::value'
2016-05-04 22:36:57 +02:00
Wenzel Jakob
8e93df825e minor clarification regarding keep_alive; fixed some typos 2016-05-01 02:36:58 +02:00
Wenzel Jakob
81e0975b82 clarified pickle version requirements (fixes #186) 2016-04-30 23:16:31 +02:00
Wenzel Jakob
06f56ee1e9 opaque type redesign 2016-04-28 17:49:46 +02:00
Wenzel Jakob
f64feaf3e4 documentation improvements 2016-04-28 15:32:07 +02:00
Wenzel Jakob
e84f557edf documentation improvements 2016-04-26 23:48:55 +02:00
Wenzel Jakob
f7b5874ca3 new move value policy 2016-04-25 23:04:27 +02:00
Wenzel Jakob
0871228f42 opaque<> clarifications 2016-04-22 16:52:15 +02:00
Wenzel Jakob
8bd31c71e4 New automatic return value policy for cat() and make_tuple(), fixed an ambiguity issue 2016-04-14 15:00:30 +02:00
Wenzel Jakob
b282595bba convenience wrapper for constructing iterators (fixes #142) 2016-04-14 00:23:37 +02:00
Wenzel Jakob
ef7a9b9a3f added info about autogenerated Sphinx docs (fixes #112) 2016-04-13 18:41:59 +02:00
Wenzel Jakob
d40885a1e6 clarified pickling docs 2016-04-13 13:30:05 +02:00
Wenzel Jakob
3d0e6fff25 typos 2016-04-13 11:48:10 +02:00