Commit Graph

282 Commits

Author SHA1 Message Date
Pim Schellart
5a7d17ff16 Add support for user defined exception translators 2016-07-11 17:33:04 -04:00
Wenzel Jakob
678d59d21f Python 2.7 fixes for eval() 2016-07-08 15:14:48 +02:00
Wenzel Jakob
464c43513e further eval() improvements 2016-07-08 15:08:30 +02:00
Wenzel Jakob
dc13cf0e54 quench warning on windows 2016-07-08 11:07:02 +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
Jason Rhinelander
0b12f91fa3 Only disable placement-new warning under gcc >= 6
Otherwise this would create unknown option warnings under g++ < 6.
2016-07-07 16:26:04 -04:00
Jason Rhinelander
cae0e00947 Disable -Wplacement-new warning false alarm
GCC-6 adds a -Wplacement-new warning that warns for placement-new into a
space that is too small, which is sometimes being triggered here (e.g.
example5 always generates the warning under g++-6).  It's a false
warning, however: the line immediately before just checked the size, and
so this line is never going to actually be reached in the cases where
the GCC warning is being triggered.

This localizes the warning disabling just to this one spot as there are
other placement-new uses in pybind11 where this warning could warn about
legitimate future problems.
2016-07-07 16:11:42 -04:00
Jason Rhinelander
4609beb46e Merge remote-tracking branch 'upstream/master' into ternary-description 2016-07-06 00:49:49 -04:00
Jason Rhinelander
8469f751cb Add _<bool>("s1", "s2") ternary & use TYPE_CASTER
This commit adds an additional _ template function for compile-time
selection between two description strings.  This in turn allows the
elimination of needing two name() methods in type_caster<arithmetic
types> and type_caster<eigen types>, which allows them to start using
PYBIND11_TYPE_CASTER instead, simplifying their code by eliminating all
the code that they are duplicating from the macro.
2016-07-06 00:40:54 -04:00
Ben North
93594a3857 Fix handling of one-dimensional input arrays
In eigen.h, type_caster<Type>::load():  For the 'ndim == 1' case, use
the 'InnerStride' type because there is only an inner stride for a
vector.  Choose between (n_elts x 1) or (1 x n_elts) according to
whether we're constructing a Vector or a RowVector.
2016-07-05 21:13:24 +01:00
Merlin Nimier-David
68ca3b6343 more informative error message when py::make_tuple fails 2016-07-01 20:35:35 +02:00
Wenzel Jakob
0006259508 switched internal usage of cast_error exception to reference_cast_error 2016-07-01 16:07:35 +02:00
Wenzel Jakob
472ffbba96 more informative error message when py::cast fails 2016-07-01 16:07:24 +02:00
hbruintjes
70d2e57b09 Cast to derived holder using container type when using std::enable_shared_from_this.
Allows const types to be used by shared_ptr
2016-07-01 12:39:55 +02:00
Wenzel Jakob
2353b9b8fa quench C4459 warning on MSVC2015 2016-06-27 16:05:46 +02:00
Wenzel Jakob
37e1f61f54 allow passing a 'return value policy' to handle::operator() 2016-06-22 14:29:13 +02:00
Wenzel Jakob
4a53d38bd4 only deprecate call() function if C++14 is available 2016-06-22 14:02:27 +02:00
Ivan Smirnov
daed1abc9c Switch to using prefix increment in make_iterator 2016-06-17 22:50:34 +01:00
Ivan Smirnov
3ae5bd787f Remove extraneous semicolon (-pedantic warning) 2016-06-17 22:29:10 +01:00
Jerry Gamache
b8f2d1886c Remove unnecessary braces. 2016-06-15 12:55:34 -04:00
Jerry Gamache
c6e0cdfa54 Allow pybind11::arg to have 0, false, or "" as default values. 2016-06-15 12:48:15 -04:00
Wenzel Jakob
f85c52901e starting to work on release v1.9 2016-06-14 15:24:47 +02:00
Dean Moldovan
9e62558d52 Check the number of named arguments at compile time 2016-06-04 00:27:32 +02:00
Dean Moldovan
96017dd7cd Add _a literal for named arguments 2016-06-03 23:15:22 +02:00
Wenzel Jakob
7c99ff2a00 fix segfault when passing a docstring to def_property* (fixes #222) 2016-06-02 20:34:01 +02:00
Dean Moldovan
f2b36c2ed2 Fix a couple of warnings
- Conversion warning on clang: 'long' to 'size_t'
- Unused variable warning on MSVC
2016-06-01 23:48:23 +02:00
Wenzel Jakob
38d8b8cfe2 don't allow registering a class twice (fixes #218) 2016-05-31 09:53:28 +02:00
Wenzel Jakob
5eda97d7e4 gcc fix 2016-05-30 11:45:02 +02:00
Wenzel Jakob
b569272127 quench some Eigen-related warnings 2016-05-30 11:37:07 +02:00
Wenzel Jakob
5dd33d880d fix issues with std::vector<bool> overload in STL (fixes #216) 2016-05-30 11:28:21 +02:00
Wenzel Jakob
0a07805ab6 fixed many conversion warnings on clang 2016-05-29 13:40:40 +02:00
Wenzel Jakob
c48da92561 Merge branch 'cygwin' of https://github.com/BorisSchaeling/pybind11 into BorisSchaeling-cygwin 2016-05-29 12:46:21 +02:00
Boris Schäling
20ee935203 Use decltype to deduce return type of PyThread_create_key 2016-05-28 12:26:18 +02:00
Boris Schäling
8965644536 Make examples build and run on Cygwin 2016-05-26 22:42:07 +02:00
Wenzel Jakob
69e1a5c91b quenched warnings on windows, comments in gil_scoped_release 2016-05-26 14:29:31 +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
60abf299c6 minor cleanups in pytypes.h 2016-05-26 10:47:11 +02:00
Yung-Yu Chen
114bfeb762 pybind11::args should have been derived from tuple
args was derived from list, but cpp_function::dispatcher sends a tuple to it->impl (line #346 and #392 in pybind11.h).  As a result args::size() and args::operator[] don't work at all.  On my mac args::size() returns -1.  Making args a subclass of tuple fixes it.
2016-05-25 21:09:35 +08:00
Wenzel Jakob
1e3be73a52 PYBIND11_OVERLOAD_NAME and PYBIND11_OVERLOAD_PURE_NAME (fixes #205) 2016-05-24 23:42:14 +02:00
Wenzel Jakob
b437867338 eigen.h: relax access to members 2016-05-24 21:40:03 +02:00
Andreas Bergmeier
16d4394845 Increase available information on invocation error. 2016-05-24 09:19:44 +02:00
Wenzel Jakob
a970a579b2 eigen.h: return compile time vectors as 1D NumPy arrays 2016-05-20 12:01:03 +02:00
Wenzel Jakob
b47a9de035 ability to prevent force casts in numpy arguments 2016-05-19 16:02:09 +02:00
Sergey Lyskov
065526a369 Refactoring bind_vector to take std::string to avoid capture of potentially temporary char const * when calling vector_if_insertion_operator 2016-05-17 23:30:58 -04:00
Wenzel Jakob
3f200fab22 don't implicitly convert doubles to ints 2016-05-17 15:35:29 +02:00
Wenzel Jakob
d1bfc4e0f8 support __bool__ on Python 2.x and 3.x 2016-05-16 18:52:50 +02:00
Wenzel Jakob
00c7d6ccc7 Merge branch 'stl_bind' 2016-05-16 12:33:20 +02:00
Wenzel Jakob
25c03cecfa stl_bind redesign & cleanup pass 2016-05-16 12:12:58 +02:00
Wenzel Jakob
affb9f40c5 quench conversion warnings on windows 2016-05-16 00:04:20 +02:00