1. 02 Nov, 2017 1 commit
    • Unknown's avatar
      Trivial typos · 0b3f44eb
      Unknown authored
      Non-user facing. 
      Found using `codespell -q 3`
      0b3f44eb
  2. 25 Oct, 2017 1 commit
  3. 22 Oct, 2017 1 commit
    • Jason Rhinelander's avatar
      Miscellaneous travis-ci updates/fixes · 835fa9bc
      Jason Rhinelander authored
      - For the debian/buster docker build (GCC 7/C++17) install and use the
        system `catch` package; this also renames "COMPILER_PACKAGES" to
        "EXTRA_PACKAGES" since it now contains a non-compiler package.
      
      - Add a status message indicating the catch version being used for
        compiling the embedded tests
      
      - Simplify some bash code by using VAR+=" foo" to append (rather than
        VAR="${VAR} foo"
      
      - Fix CMAKE_INCLUDE_PATH appending: it was prepending the ':' but not
        the existing $CMAKE_INCLUDE_PATH value and so would end up with
        ":/eigen-path" if CMAKE_INCLUDE_PATH was already set.  (This wasn't
        bug that was actually noticed since currently nothing else sets it).
      835fa9bc
  4. 12 Oct, 2017 2 commits
    • Jason Rhinelander's avatar
      Fix 2D Nx1/1xN inputs to eigen dense vector args · 6a81dbbb
      Jason Rhinelander authored
      This fixes a bug introduced in b68959e8
      when passing in a two-dimensional, but conformable, array as the value
      for a compile-time Eigen vector (such as VectorXd or RowVectorXd).  The
      commit switched to using numpy to copy into the eigen data, but this
      broke the described case because numpy refuses to broadcast a (N,1)
      into a (N).
      
      This commit fixes it by squeezing the input array whenever the output
      array is 1-dimensional, which will let the problematic case through.
      (This shouldn't squeeze inappropriately as dimension compatibility is
      already checked for conformability before getting to the copy code).
      6a81dbbb
    • Jason Rhinelander's avatar
      Fix `char &` arguments being non-bindable · 1b08df58
      Jason Rhinelander authored
      This changes the caster to return a reference to a (new) local `CharT`
      type caster member so that binding lvalue-reference char arguments
      works (currently it results in a compilation failure).
      
      Fixes #1116
      1b08df58
  5. 28 Sep, 2017 1 commit
  6. 21 Sep, 2017 1 commit
    • Ansgar Burchardt's avatar
      correct stride in matrix example and test · a22dd2d1
      Ansgar Burchardt authored
      This also matches the Eigen example for the row-major case.
      
      This also enhances one of the tests to trigger a failure (and fixes it in the PR).  (This isn't really a flaw in pybind itself, but rather fixes wrong code in the test code and docs).
      a22dd2d1
  7. 20 Sep, 2017 2 commits
  8. 16 Sep, 2017 1 commit
  9. 12 Sep, 2017 2 commits
    • Dean Moldovan's avatar
      Make TypeErrors more informative when an optional header is missing · 2b4477eb
      Dean Moldovan authored
      E.g. trying to convert a `list` to a `std::vector<int>` without
      including <pybind11/stl.h> will now raise an error with a note that
      suggests checking the headers.
      
      The note is only appended if `std::` is found in the function
      signature. This should only be the case when a header is missing.
      E.g. when stl.h is included, the signature would contain `List[int]`
      instead of `std::vector<int>` while using stl_bind.h would produce
      something like `MyVector`. Similarly for `std::map`/`Dict`, `complex`,
      `std::function`/`Callable`, etc.
      
      There's a possibility for false positives, but it's pretty low.
      2b4477eb
    • Gunnar Läthén's avatar
      c64e6b16
  10. 11 Sep, 2017 1 commit
  11. 10 Sep, 2017 2 commits
  12. 06 Sep, 2017 2 commits
  13. 30 Aug, 2017 4 commits
  14. 28 Aug, 2017 2 commits
    • Wenzel Jakob's avatar
    • Dean Moldovan's avatar
      Reduce binary size overhead of new-style constructors · 39fd6a94
      Dean Moldovan authored
      The lookup of the `self` type and value pointer are moved out of
      template code and into `dispatcher`. This brings down the binary
      size of constructors back to the level of the old placement-new
      approach. (It also avoids a second lookup for `init_instance`.)
      
      With this implementation, mixing old- and new-style constructors
      in the same overload set may result in some runtime overhead for
      temporary allocations/deallocations, but this should be fine as
      old style constructors are phased out.
      39fd6a94
  15. 25 Aug, 2017 3 commits
  16. 23 Aug, 2017 2 commits
    • Jason Rhinelander's avatar
      Fix clang5 warnings · e9bb843e
      Jason Rhinelander authored
      e9bb843e
    • Dean Moldovan's avatar
      Speed up AppVeyor build (#1021) · b33475d0
      Dean Moldovan authored
      The `latest` build remains as is, but all others are modified to:
      
      * Use regular Python instead of conda. `pip install` is much faster
        than conda, but scipy isn't available. Numpy is still tested.
      
      * Compile in debug mode instead of release.
      
      * Skip CMake build tests. For some reason, CMake configuration is very
        slow on AppVeyor and these tests are almost entirely CMake.
      
      The changes reduce build time to about 1/3 of the original. The `latest` 
      config still covers scipy, release mode and the CMake build tests, so 
      the others don't need to.
      b33475d0
  17. 22 Aug, 2017 2 commits
  18. 19 Aug, 2017 1 commit
    • Jason Rhinelander's avatar
      Allow module-local classes to be loaded externally · 5e14aa6a
      Jason Rhinelander authored
      The main point of `py::module_local` is to make the C++ -> Python cast
      unique so that returning/casting a C++ instance is well-defined.
      Unfortunately it also makes loading unique, but this isn't particularly
      desirable: when an instance contains `Type` instance there's no reason
      it shouldn't be possible to pass that instance to a bound function
      taking a `Type` parameter, even if that function is in another module.
      
      This commit solves the issue by allowing foreign module (and global)
      type loaders have a chance to load the value if the local module loader
      fails.  The implementation here does this by storing a module-local
      loading function in a capsule in the python type, which we can then call
      if the local (and possibly global, if the local type is masking a global
      type) version doesn't work.
      5e14aa6a
  19. 17 Aug, 2017 3 commits
    • Jason Rhinelander's avatar
      Reimplement py::init<...> to use common factory code · c4e18008
      Jason Rhinelander authored
      This reimplements the py::init<...> implementations using the various
      functions added to support `py::init(...)`, and moves the implementing
      structs into `detail/init.h` from `pybind11.h`.  It doesn't simply use a
      factory directly, as this is a very common case and implementation
      without an extra lambda call is a small but useful optimization.
      
      This, combined with the previous lazy initialization, also avoids
      needing placement new for `py::init<...>()` construction: such
      construction now occurs via an ordinary `new Type(...)`.
      
      A consequence of this is that it also fixes a potential bug when using
      multiple inheritance from Python: it was very easy to write classes
      that double-initialize an existing instance which had the potential to
      leak for non-pod classes.  With the new implementation, an attempt to
      call `__init__` on an already-initialized object is now ignored.  (This
      was already done in the previous commit for factory constructors).
      
      This change exposed a few warnings (fixed here) from deleting a pointer
      to a base class with virtual functions but without a virtual destructor.
      These look like legitimate warnings that we shouldn't suppress; this
      adds virtual destructors to the appropriate classes.
      c4e18008
    • Jason Rhinelander's avatar
      Allow binding factory functions as constructors · 464d9896
      Jason Rhinelander authored
      This allows you to use:
      
          cls.def(py::init(&factory_function));
      
      where `factory_function` returns a pointer, holder, or value of the
      class type (or a derived type).  Various compile-time checks
      (static_asserts) are performed to ensure the function is valid, and
      various run-time type checks where necessary.
      
      Some other details of this feature:
      - The `py::init` name doesn't conflict with the templated no-argument
        `py::init<...>()`, but keeps the naming consistent: the existing
        templated, no-argument one wraps constructors, the no-template,
        function-argument one wraps factory functions.
      - If returning a CppClass (whether by value or pointer) when an CppAlias
        is required (i.e. python-side inheritance and a declared alias), a
        dynamic_cast to the alias is attempted (for the pointer version); if
        it fails, or if returned by value, an Alias(Class &&) constructor
        is invoked.  If this constructor doesn't exist, a runtime error occurs.
      - for holder returns when an alias is required, we try a dynamic_cast of
        the wrapped pointer to the alias to see if it is already an alias
        instance; if it isn't, we raise an error.
      - `py::init(class_factory, alias_factory)` is also available that takes
        two factories: the first is called when an alias is not needed, the
        second when it is.
      - Reimplement factory instance clearing.  The previous implementation
        failed under python-side multiple inheritance: *each* inherited
        type's factory init would clear the instance instead of only setting
        its own type value.  The new implementation here clears just the
        relevant value pointer.
      - dealloc is updated to explicitly set the leftover value pointer to
        nullptr and the `holder_constructed` flag to false so that it can be
        used to clear preallocated value without needing to rebuild the
        instance internals data.
      - Added various tests to test out new allocation/deallocation code.
      - With preallocation now done lazily, init factory holders can
        completely avoid the extra overhead of needing an extra
        allocation/deallocation.
      - Updated documentation to make factory constructors the default
        advanced constructor style.
      - If an `__init__` is called a second time, we have two choices: we can
        throw away the first instance, replacing it with the second; or we can
        ignore the second call.  The latter is slightly easier, so do that.
      464d9896
    • Jason Rhinelander's avatar
      Add a polymorphic static assert when using an alias · 42e5ddc5
      Jason Rhinelander authored
      An alias can be used for two main purposes: to override virtual methods,
      and to add some extra data to a class needed for the pybind-wrapper.
      Both of these absolutely require that the wrapped class be polymorphic
      so that virtual dispatch and destruction, respectively, works.
      42e5ddc5
  20. 13 Aug, 2017 1 commit
  21. 12 Aug, 2017 1 commit
    • Dean Moldovan's avatar
      Add support for boost::variant in C++11 mode · 7918bcc9
      Dean Moldovan authored
      In C++11 mode, `boost::apply_visitor` requires an explicit `result_type`.
      This also adds optional tests for `boost::variant` in C++11/14, if boost
      is available. In C++17 mode, `std::variant` is tested instead.
      7918bcc9
  22. 07 Aug, 2017 1 commit
  23. 05 Aug, 2017 3 commits
    • Jason Rhinelander's avatar
      Update all remaining tests to new test styles · 391c7544
      Jason Rhinelander authored
      This udpates all the remaining tests to the new test suite code and
      comment styles started in #898.  For the most part, the test coverage
      here is unchanged, with a few minor exceptions as noted below.
      
      - test_constants_and_functions: this adds more overload tests with
        overloads with different number of arguments for more comprehensive
        overload_cast testing.  The test style conversion broke the overload
        tests under MSVC 2015, prompting the additional tests while looking
        for a workaround.
      
      - test_eigen: this dropped the unused functions `get_cm_corners` and
        `get_cm_corners_const`--these same tests were duplicates of the same
        things provided (and used) via ReturnTester methods.
      
      - test_opaque_types: this test had a hidden dependence on ExampleMandA
        which is now fixed by using the global UserType which suffices for the
        relevant test.
      
      - test_methods_and_attributes: this required some additions to UserType
        to make it usable as a replacement for the test's previous SimpleType:
        UserType gained a value mutator, and the `value` property is not
        mutable (it was previously readonly).  Some overload tests were also
        added to better test overload_cast (as described above).
      
      - test_numpy_array: removed the untemplated mutate_data/mutate_data_t:
        the templated versions with an empty parameter pack expand to the same
        thing.
      
      - test_stl: this was already mostly in the new style; this just tweaks
        things a bit, localizing a class, and adding some missing
        `// test_whatever` comments.
      
      - test_virtual_functions: like `test_stl`, this was mostly in the new
        test style already, but needed some `// test_whatever` comments.
        This commit also moves the inherited virtual example code to the end
        of the file, after the main set of tests (since it is less important
        than the other tests, and rather length); it also got renamed to
        `test_inherited_virtuals` (from `test_inheriting_repeat`) because it
        tests both inherited virtual approaches, not just the repeat approach.
      391c7544
    • Jason Rhinelander's avatar
    • Jason Rhinelander's avatar
      b468a3ce