"vscode:/vscode.git/clone" did not exist on "5812d64ba28b62e6509ea1e8b115464e7b45256b"
  1. 13 Oct, 2016 1 commit
  2. 12 Oct, 2016 2 commits
    • Wenzel Jakob's avatar
      Permit creation of NumPy arrays with a "base" object that owns the data · 369e9b39
      Wenzel Jakob authored
      This patch adds an extra base handle parameter to most ``py::array`` and
      ``py::array_t<>`` constructors. If specified along with a pointer to
      data, the base object will be registered within NumPy, which increases
      the base's reference count. This feature is useful to create shallow
      copies of C++ or Python arrays while ensuring that the owners of the
      underlying can't be garbage collected while referenced by NumPy.
      
      The commit also adds a simple test function involving a ``wrap()``
      function that creates shallow copies of various N-D arrays.
      369e9b39
    • Wenzel Jakob's avatar
      added numpy test (minor): check that 'strides' is respected even when creating new arrays · 43f6aa68
      Wenzel Jakob authored
      - This actually works with no changes, I just wasn't 100% convinced and
        decided to write a test to see if it's true.
      43f6aa68
  3. 11 Oct, 2016 1 commit
  4. 09 Oct, 2016 2 commits
  5. 29 Sep, 2016 1 commit
  6. 27 Sep, 2016 1 commit
  7. 23 Sep, 2016 3 commits
  8. 22 Sep, 2016 1 commit
  9. 20 Sep, 2016 1 commit
  10. 19 Sep, 2016 2 commits
  11. 17 Sep, 2016 1 commit
  12. 16 Sep, 2016 1 commit
    • Jason Rhinelander's avatar
      Added py::register_exception for simple case (#296) · b3794f10
      Jason Rhinelander authored
      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.
      b3794f10
  13. 13 Sep, 2016 3 commits
  14. 11 Sep, 2016 3 commits
    • Jason Rhinelander's avatar
      Added a test to detect invalid RTTI caching · 0e489777
      Jason Rhinelander authored
      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.
      0e489777
    • Jason Rhinelander's avatar
      Update OVERLOAD macros to support ref/ptr return type overloads · 7dfb932e
      Jason Rhinelander authored
      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.
      7dfb932e
    • Jason Rhinelander's avatar
      Use 'override' rather than 'virtual' for overrides · 116d37c9
      Jason Rhinelander authored
      Minor change that makes this example more compliant with the C++ Core
      Guidelines.
      116d37c9
  15. 10 Sep, 2016 5 commits
  16. 09 Sep, 2016 1 commit
    • Jason Rhinelander's avatar
      Implement py::init_alias<>() constructors · ec62d977
      Jason Rhinelander authored
      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
      86d825f3, 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.
      ec62d977
  17. 08 Sep, 2016 1 commit
    • Jason Rhinelander's avatar
      Fix type alias initialization · 9c6859ee
      Jason Rhinelander authored
      Type alias for alias classes with members didn't work properly: space
      was only allocated for sizeof(type), but if we want to be able to put a
      type_alias instance there, we need sizeof(type_alias), but
      sizeof(type_alias) > sizeof(type) whenever type_alias has members.
      9c6859ee
  18. 07 Sep, 2016 4 commits
    • Ivan Smirnov's avatar
      67b54894
    • Jason Rhinelander's avatar
      Fail static_assert when trying to reference non-referencable types · c03db9ba
      Jason Rhinelander authored
      The previous commit to address #392 triggers a compiler warning about
      returning a reference to a local variable, which is *not* a false alarm:
      the following:
      
          py::cast<int &>(o)
      
      (which happens internally in an overload declaration) really is
      returning a reference to a local, because the cast operators for the
      type_caster for numeric types returns a reference to its own member.
      
      This commit adds a static_assert to make that a compilation failure
      rather than returning a reference into about-to-be-freed memory.
      
      Incidentally, this is also a fix for #219, which is exactly the same
      issue: we can't reference numeric primitives that are cast from
      wrappers around python numeric types.
      c03db9ba
    • Jason Rhinelander's avatar
      Fix type caster for heap reference types · 56f71775
      Jason Rhinelander authored
      Need to use the intrinsic type, not the raw type.
      
      Fixes #392.
      56f71775
    • Jason Rhinelander's avatar
      Allow passing base types as a template parameter · 6b52c838
      Jason Rhinelander authored
      This allows a slightly cleaner base type specification of:
      
          py::class_<Type, Base>("Type")
      
      as an alternative to
      
          py::class_<Type>("Type", py::base<Base>())
      
      As with the other template parameters, the order relative to the holder
      or trampoline types doesn't matter.
      
      This also includes a compile-time assertion failure if attempting to
      specify more than one base class (but is easily extendible to support
      multiple inheritance, someday, by updating the class_selector::set_bases
      function to set multiple bases).
      6b52c838
  19. 06 Sep, 2016 6 commits
    • Dean Moldovan's avatar
      Replace std::cout with py::print in tests · 81511be3
      Dean Moldovan authored
      With this change both C++ and Python write to sys.stdout which resolves
      the capture issues noted in #351. Therefore, the related workarounds are
      removed.
      81511be3
    • Jason Rhinelander's avatar
      Allow arbitrary class_ template option ordering · 5fffe200
      Jason Rhinelander authored
      The current pybind11::class_<Type, Holder, Trampoline> fixed template
      ordering results in a requirement to repeat the Holder with its default
      value (std::unique_ptr<Type>) argument, which is a little bit annoying:
      it needs to be specified not because we want to override the default,
      but rather because we need to specify the third argument.
      
      This commit removes this limitation by making the class_ template take
      the type name plus a parameter pack of options.  It then extracts the
      first valid holder type and the first subclass type for holder_type and
      trampoline type_alias, respectively.  (If unfound, both fall back to
      their current defaults, `std::unique_ptr<type>` and `type`,
      respectively).  If any unmatched template arguments are provided, a
      static assertion fails.
      
      What this means is that you can specify or omit the arguments in any
      order:
      
          py::class_<A, PyA> c1(m, "A");
          py::class_<B, PyB, std::shared_ptr<B>> c2(m, "B");
          py::class_<C, std::shared_ptr<C>, PyB> c3(m, "C");
      
      It also allows future class attributes (such as base types in the next
      commit) to be passed as class template types rather than needing to use
      a py::base<> wrapper.
      5fffe200
    • Wenzel Jakob's avatar
      c84b37b5
    • Dean Moldovan's avatar
      Remove superseded handle::operator() overloads · 16db1bfb
      Dean Moldovan authored
      The variadic handle::operator() offers the same functionality as well
      as mixed positional, keyword, * and ** arguments. The tests are also
      superseded by the ones in `test_callbacks`.
      16db1bfb
    • Dean Moldovan's avatar
      Add py::dict() keyword constructor · 15a112f8
      Dean Moldovan authored
      15a112f8
    • Dean Moldovan's avatar
      Add py::str::format() method · 66aa2728
      Dean Moldovan authored
      66aa2728