Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/lsst/cpputils/python.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ Add `__eq__` and `__ne__` methods based on two std::shared_ptr<T> pointing to th

lsst::afw::table records are considered equal if two `std::shared_ptr<record>` point to the same record.
This is wrapped as follows for `lsst::afw::table::BaseRecord`, where `cls` is an instance of
`pybind11::class_<BaseRecord, std::shared_ptr<BaseRecord>>)`:
`pybind11::classh<BaseRecord>)`:

utils::addSharedPtrEquality<BaseRecord>(cls);

Expand Down
94 changes: 0 additions & 94 deletions include/lsst/cpputils/python/PySharedPtr.h

This file was deleted.

11 changes: 5 additions & 6 deletions tests/inheritance.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
#include <memory>
#include <string>

#include "lsst/cpputils/python/PySharedPtr.h"

namespace py = pybind11;
using namespace pybind11::literals;

Expand All @@ -41,6 +39,7 @@ class CppBase {
std::string nonOverridable() const noexcept { return "42"; }
virtual std::string overridable() const { return ""; }
virtual std::string abstract() const = 0;
virtual ~CppBase() = default;
};

class CppDerived : public CppBase {
Expand All @@ -50,7 +49,7 @@ class CppDerived : public CppBase {
};

template <class Base = CppBase>
class Trampoline : public Base {
class Trampoline : public Base, pybind11::trampoline_self_life_support {
public:
using Base::Base;

Expand All @@ -72,11 +71,11 @@ std::string printFromCpp(CppBase const& obj) {
}

PYBIND11_MODULE(_inheritance, mod) {
py::class_<CppBase, Trampoline<>, PySharedPtr<CppBase>>(mod, "CppBase").def(py::init<>());
py::class_<CppDerived, Trampoline<CppDerived>, CppBase, PySharedPtr<CppDerived>>(mod, "CppDerived")
py::classh<CppBase, Trampoline<>>(mod, "CppBase").def(py::init<>());
py::classh<CppDerived, Trampoline<CppDerived>, CppBase>(mod, "CppDerived")
.def(py::init<>());

py::class_<CppStorage, std::shared_ptr<CppStorage>>(mod, "CppStorage")
py::classh<CppStorage>(mod, "CppStorage")
.def(py::init<std::shared_ptr<CppBase>>());

mod.def("getFromStorage", &getFromStorage, "holder"_a);
Expand Down
7 changes: 4 additions & 3 deletions tests/test_pySharedPtr.py → tests/test_smart_holder.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
import _inheritance


class PySharedPtrTestSuite(unittest.TestCase):
"""Test the ability of PySharedPtr to safely pass hybrid objects
class SmartHolderTestSuite(unittest.TestCase):
"""Test the ability of pybind11 to safely pass hybrid objects
between C++ and Python."""

class PyDerived(_inheritance.CppBase):
Expand All @@ -52,7 +52,8 @@ def abstract(self):
return "py-abstract"

def checkGarbageCollection(self, concreteClass, returns):
"""Generic test for whether a C++/Python class survives garbage collection.
"""Generic test for whether a C++/Python class survives garbage
collection.

Parameters
----------
Expand Down