Commit Graph

1166 Commits

Author SHA1 Message Date
Jason Rhinelander
20ef62656f Fix minor documentation spelling mistakes 2016-09-21 13:39:02 -04:00
Wenzel Jakob
d4285a6dda ..one more typo 2016-09-21 19:30:23 +02:00
Wenzel Jakob
514371ebec typo fixes (spotted by @TheGhostHuCodes) 2016-09-21 19:29:19 +02:00
Wenzel Jakob
bc622dc936 Merge pull request #418 from dean0x7d/fix-missing-test
Fix missing smart_ptr test
2016-09-20 12:31:46 +02:00
Dean Moldovan
568ec6b35a Fix missing smart_ptr test 2016-09-20 11:52:25 +02:00
Wenzel Jakob
d922dffec4 Merge pull request #410 from wjakob/mi
WIP: Multiple inheritance support
2016-09-19 18:55:05 +02:00
Wenzel Jakob
e72a676b72 More verbose error messages when PyType_Ready fails 2016-09-19 13:45:34 +02:00
Wenzel Jakob
c1fc27e2b5 use detail::enable_if_t everywhere 2016-09-19 13:45:34 +02:00
Wenzel Jakob
8e5dceb6a6 Multiple inheritance support 2016-09-19 13:45:31 +02:00
Wenzel Jakob
bad589a477 deprecated py::base<>, added a macro for improved readability 2016-09-19 13:43:47 +02:00
Wenzel Jakob
e99ebaedcf nicer error message for invalid function arguments 2016-09-19 13:43:43 +02:00
Wenzel Jakob
7962f30d70 set possible build types in cmake build system 2016-09-17 12:58:18 +02:00
Jason Rhinelander
b3794f1087 Added py::register_exception for simple case (#296)
The custom exception handling added in PR #273 is robust, but is overly
complex for declaring the most common simple C++ -> Python exception
mapping that needs only to copy `what()`.  This add a simpler
`py::register_exception<CppExp>(module, "PyExp");` function that greatly
simplifies the common basic case of translation of a simple CppException
into a simple PythonException, while not removing the more advanced
capabilities of defining custom exception handlers.
2016-09-16 08:04:15 +02:00
Trent Houliston
ad3bb9bbab Include the cmath header for std::lround.
Fix spaces before parens for style guide.
2016-09-14 19:27:53 +10:00
Trent Houliston
2f597687e7 Changed non system clocks to be time deltas
Allowed durations and non system clocks to be set from floats.
2016-09-13 20:40:28 +10:00
Trent Houliston
207d0da31c Move the python datetime header into the chrono header 2016-09-13 19:58:05 +10:00
Trent Houliston
0ee97dd6d0 Only import PyDateTime if we have to 2016-09-13 19:58:05 +10:00
Trent Houliston
8fe2fa7eba Increase the amount of time to execute the functions to 50ms 2016-09-13 19:58:05 +10:00
Trent Houliston
352149e892 Refactor the chrono cast functions into chrono.h.
Add unit tests and documentation for the chrono cast.
2016-09-13 19:58:05 +10:00
Trent Houliston
6ddfd1e090 Add in casts for c++11s chrono classes to pythons datetime 2016-09-13 19:41:48 +10:00
Wenzel Jakob
29b5064e9c Merge pull request #411 from jagerman/debug-build-and-fix
Debug build and fix
2016-09-13 09:27:09 +09:00
Jason Rhinelander
4a4fb396e7 Fix build under debug mode
Take load_type by nested type_caster template arguments instead of by
full type_caster type.
2016-09-12 16:21:40 -04:00
Jason Rhinelander
5b4968df3a Make the gcc6/python 3.5 build use debug mode 2016-09-12 16:04:31 -04:00
Wenzel Jakob
591a9999c2 Merge pull request #409 from jagerman/dynamic-cast-test
Added a test to detect invalid RTTI caching
2016-09-12 08:17:52 +09:00
Jason Rhinelander
0e489777ff Added a test to detect invalid RTTI caching
The current inheritance testing isn't sufficient to detect a cache
failure; the test added here breaks PR #390, which caches the
run-time-determined return type the first time a function is called,
then reuses that cached type even though the run-time type could be
different for a future call.
2016-09-11 18:41:28 -04:00
Wenzel Jakob
f22683806e Merge pull request #400 from jagerman/add-ref-virtual-macros
Add a way to deal with copied value references
2016-09-12 06:32:39 +09:00
Jason Rhinelander
3e4fe6c0a8 Store a static type_caster rather than the basic type 2016-09-11 12:17:41 -04:00
Jason Rhinelander
f3f53e2b03 Removed unused/unwanted public ref_cast 2016-09-11 11:36:33 -04:00
Wenzel Jakob
b2eda9ac7c Merge pull request #408 from dean0x7d/exc-destructors
Fix Python C API calls in desctuctors triggered by error_already_set
2016-09-11 21:33:33 +09:00
Wenzel Jakob
e3c297f03e Merge pull request #407 from wjakob/fix_iterator
parameterize iterators by return value policy (fixes #388)
2016-09-11 20:02:32 +09:00
Jason Rhinelander
7dfb932e70 Update OVERLOAD macros to support ref/ptr return type overloads
This adds a static local variable (in dead code unless actually needed)
in the overload code that is used for storage if the overload is for
some convert-by-value type (such as numeric values or std::string).

This has limitations (as written up in the advanced doc), but is better
than simply not being able to overload reference or pointer methods.
2016-09-11 01:21:53 -04:00
Jason Rhinelander
116d37c9ba Use 'override' rather than 'virtual' for overrides
Minor change that makes this example more compliant with the C++ Core
Guidelines.
2016-09-11 01:16:19 -04:00
Jason Rhinelander
6eca083e4c Fix doc typo
"trampoline" is doubled in the first sentence.
2016-09-11 01:16:19 -04:00
Wenzel Jakob
f217c04195 Merge pull request #402 from aldanor/feature/numpy-c-api
Add array methods via C API
2016-09-11 08:34:04 +09:00
Ivan Smirnov
aca6bcaea5 Add tests for array data access /index methods 2016-09-10 16:42:17 +01:00
Ivan Smirnov
f2a0ad5855 array: add direct data access and indexing methods 2016-09-10 16:24:00 +01:00
Ivan Smirnov
91b3d681ad Expose some dtype/array attributes via NumPy C API 2016-09-10 16:24:00 +01:00
Dean Moldovan
f69071ca4b Make it easier to add new binding of builtin Python exceptions 2016-09-10 16:14:36 +02:00
Dean Moldovan
135ba8deaf Make error_already_set fetch and hold the Python error
This clears the Python error at the error_already_set throw site, thus
allowing Python calls to be made in destructors which are triggered by
the exception. This is preferable to the alternative, which would be
guarding every Python API call with an error_scope.

This effectively flips the behavior of error_already_set. Previously,
it was assumed that the error stays in Python, so handling the exception
in C++ would require explicitly calling PyErr_Clear(), but nothing was
needed to propagate the error to Python. With this change, handling the
error in C++ does not require a PyErr_Clear() call, but propagating the
error to Python requires an explicit error_already_set::restore().

The change does not break old code which explicitly calls PyErr_Clear()
for cleanup, which should be the majority of user code. The need for an
explicit restore() call does break old code, but this should be mostly
confined to the library and not user code.
2016-09-10 12:08:32 +02:00
Wenzel Jakob
b212f6c416 parameterize iterators by return value policy (fixes #388) 2016-09-10 17:16:16 +09:00
Wenzel Jakob
720136bfa7 RAII wrapper for error state 2016-09-10 16:32:17 +09:00
Wenzel Jakob
1f2e417d8c Merge pull request #403 from jagerman/alias-initialization
Implement py::init_alias<>() constructors
2016-09-10 16:12:19 +09:00
Wenzel Jakob
3d1bb29ee5 Merge pull request #406 from wjakob/master
operators should return NotImplemented given unsupported input (fixes #393)
2016-09-10 16:02:53 +09:00
Wenzel Jakob
382484ae56 operators should return NotImplemented given unsupported input (fixes #393) 2016-09-10 15:34:26 +09:00
Wenzel Jakob
8d38ebed91 Merge pull request #405 from jagerman/retry-apt-get
apt-get tweaks for the docker/debian builds
2016-09-10 13:46:57 +09:00
Jason Rhinelander
bf14cea7c7 apt-get tweaks for the debian builds
- Try to update and upgrade twice (with a brief pause between attempts)
  to deal with occassional spurious server failures or repository race
  conditions.  Do the same for the main package install.
- Use dist-upgrade instead of upgrade for updating the image
- Add -q to the upgrade and install commands to make apt less verbose.
2016-09-10 00:04:09 -04:00
Jason Rhinelander
ec62d977c4 Implement py::init_alias<>() constructors
This commit adds support for forcing alias type initialization by
defining constructors with `py::init_alias<arg1, arg2>()` instead of
`py::init<arg1, arg2>()`.  Currently py::init<> only results in Alias
initialization if the type is extended in python, or the given
arguments can't be used to construct the base type, but can be used to
construct the alias.  py::init_alias<>, in contrast, always invokes the
constructor of the alias type.

It looks like this was already the intention of
`py::detail::init_alias`, which was forward-declared in
86d825f330, but was apparently never
finished: despite the existance of a .def method accepting it, the
`detail::init_alias` class isn't actually defined anywhere.

This commit completes the feature (or possibly repurposes it), allowing
declaration of classes that will always initialize the trampoline which
is (as I argued in #397) sometimes useful.
2016-09-09 03:04:09 -04:00
Wenzel Jakob
356bf94a85 Merge pull request #401 from jagerman/templates-simplification
Small template simplifications
2016-09-09 08:44:33 +09:00
Jason Rhinelander
5aa2cd5eb9 Template simplifications
Switch count_t to use constexpr_sum (under non-MSVC), and then make
all_of_t/any_of_t use it instead of doing the sum itself.

For MSVC, count_t is still done using template recursion, but
all_of_t/any_of_t can also make use of it.
2016-09-08 17:59:50 -04:00
Wenzel Jakob
260b26b3d6 Merge pull request #399 from jagerman/fix-alias-initialization
Fix type alias initialization
2016-09-09 00:39:43 +09:00