[Smtk-developers] Pybind and attribute::ItemDefinition subclasses

T.J. Corona tj.corona at kitware.com
Wed Apr 4 22:09:45 EDT 2018


Hi David,

All classes that require the use of shared pointers must also do so in pybind11 (as you discovered). The auto gen script should have done that for you (and It may be documented there). Did you use the script or wrap the class by hand? If the former, then that is indeed a problem with the script (it looks to see if a class inherits from shared_from_this, if memory serves). If the latter, then the pybind11 documentation would have probably gotten you to the answer...

Sincerely,
T.J.

Sent from my iPhone

> On Apr 4, 2018, at 7:25 PM, David Thompson <david.thompson at kitware.com> wrote:
> 
> Hi TJ,
> 
> While working on the great ModelEntityItem purge of 2018, I ran into an issue wrapping its replacement's definition class (ReferenceItemDefinition). It builds but running a python test like unitAttributeBasicsPy causes this failure:
> 
>  ImportError: generic_type: type "ReferenceItemDefinition" does not have a non-default holder type while its base "smtk::attribute::ItemDefinition" does
> 
> I can get it to run properly if I copy the pattern from ItemDefinition (which creates a PySharedPtrClass<T> instead of a py::class_<T, T::Superclass>)... but is this something I should know to do or is there a problem with the ReferenceItemDefinition header that causes the utilities/python/cpp_to_pybind11.py script to barf out brokenness? If the former can we document it somewhere?
> 
>    Thanks,
>    David


More information about the Smtk-developers mailing list