File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed
Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change 1919#include " llvm/Support/raw_ostream.h"
2020
2121#include < string>
22+ #include < typeinfo>
2223#include < variant>
2324
2425template <>
@@ -344,7 +345,17 @@ class Sliceable {
344345
345346 // / Binds the indexing and length methods in the Python class.
346347 static void bind (nanobind::module_ &m) {
347- auto clazz = nanobind::class_<Derived>(m, Derived::pyClassName)
348+ const std::type_info &elemTy = typeid (ElementTy);
349+ PyObject *elemTyInfo = nanobind::detail::nb_type_lookup (&elemTy);
350+ assert (elemTyInfo && " expected nb_type_lookup to succeed" );
351+ nanobind::handle elemTyName = nanobind::detail::nb_type_name (elemTyInfo);
352+ std::string sig = " class " ;
353+ sig += Derived::pyClassName;
354+ sig += " (collections.abc.Sequence[" ;
355+ sig += nanobind::cast<std::string>(elemTyName);
356+ sig += " ])" ;
357+ auto clazz = nanobind::class_<Derived>(m, Derived::pyClassName,
358+ nanobind::sig (sig.c_str ()))
348359 .def (" __add__" , &Sliceable::dunderAdd);
349360 Derived::bindDerived (clazz);
350361
You can’t perform that action at this time.
0 commit comments