1. 25 Oct, 2016 1 commit
    • Jason Rhinelander's avatar
      Prevent overwriting previous declarations · 6873c202
      Jason Rhinelander authored
      Currently pybind11 doesn't check when you define a new object (e.g. a
      class, function, or exception) that overwrites an existing one.  If the
      thing being overwritten is a class, this leads to a segfault (because
      pybind still thinks the type is defined, even though Python no longer
      has the type).  In other cases this is harmless (e.g. replacing a
      function with an exception), but even in that case it's most likely a
      bug.
      
      This code doesn't prevent you from actively doing something harmful,
      like deliberately overwriting a previous definition, but detects
      overwriting with a run-time error if it occurs in the standard
      class/function/exception/def registration interfaces.
      
      All of the additions are in non-template code; the result is actually a
      tiny decrease in .so size compared to master without the new test code
      (977304 to 977272 bytes), and about 4K higher with the new tests.
      6873c202
  2. 23 Oct, 2016 1 commit
  3. 21 Oct, 2016 1 commit
  4. 20 Oct, 2016 5 commits
  5. 14 Oct, 2016 1 commit
  6. 13 Oct, 2016 1 commit
  7. 12 Oct, 2016 3 commits
  8. 11 Oct, 2016 1 commit
  9. 09 Oct, 2016 2 commits
  10. 29 Sep, 2016 1 commit
  11. 27 Sep, 2016 1 commit
  12. 23 Sep, 2016 3 commits
  13. 22 Sep, 2016 1 commit
  14. 20 Sep, 2016 1 commit
  15. 19 Sep, 2016 2 commits
  16. 17 Sep, 2016 1 commit
  17. 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
  18. 13 Sep, 2016 3 commits
  19. 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
  20. 10 Sep, 2016 5 commits
  21. 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
  22. 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