@@ -51,12 +51,15 @@ class Object : public drjit::TraversableBase {
51
51
52
52
template <typename Value>
53
53
class CustomBase : public Object {
54
+ Value m_base_value;
55
+
54
56
public:
55
- CustomBase () : Object() {}
57
+ CustomBase (const Value &base_value ) : Object(), m_base_value(base_value ) {}
56
58
59
+ Value &base_value () { return m_base_value; }
57
60
virtual Value &value () = 0;
58
61
59
- DR_TRAVERSE_CB (Object);
62
+ DR_TRAVERSE_CB (Object, m_base_value );
60
63
};
61
64
62
65
template <typename Value>
@@ -65,7 +68,7 @@ class PyCustomBase : public CustomBase<Value>{
65
68
using Base = CustomBase<Value>;
66
69
NB_TRAMPOLINE (Base, 1 );
67
70
68
- PyCustomBase () : Base() {}
71
+ PyCustomBase (const Value &base_value ) : Base(base_value ) {}
69
72
70
73
Value &value () override { NB_OVERRIDE_PURE (value); }
71
74
@@ -77,8 +80,7 @@ class CustomA: public CustomBase<Value>{
77
80
public:
78
81
using Base = CustomBase<Value>;
79
82
80
- CustomA () {}
81
- CustomA (const Value &v) : m_value(v) {}
83
+ CustomA (const Value &value, const Value &base_value) : Base(base_value), m_value(value) {}
82
84
83
85
Value &value () override { return m_value; }
84
86
@@ -119,13 +121,15 @@ template <JitBackend Backend> void bind(nb::module_ &m) {
119
121
nb::intrusive_ptr<Object>(
120
122
[](Object *o, PyObject *po) noexcept { o->set_self_py (po); }));
121
123
122
- auto base = nb::class_<CustomBase, Object, PyCustomBase>(m, " CustomBase" )
123
- .def (nb::init ())
124
- .def (" value" , nb::overload_cast<>(&CustomBase::value));
124
+ auto base =
125
+ nb::class_<CustomBase, Object, PyCustomBase>(m, " CustomBase" )
126
+ .def (nb::init<Float>())
127
+ .def (" value" , nb::overload_cast<>(&CustomBase::value))
128
+ .def (" base_value" , nb::overload_cast<>(&CustomBase::base_value));
125
129
126
130
drjit::bind_traverse (base);
127
131
128
- auto a = nb::class_<CustomA>(m, " CustomA" ).def (nb::init<Float>());
132
+ auto a = nb::class_<CustomA>(m, " CustomA" ).def (nb::init<Float, Float >());
129
133
130
134
drjit::bind_traverse (a);
131
135
0 commit comments