Skip to content

Map wrapped classes by both ClassName() and Python type name

David Gobbi requested to merge dgobbi/vtk:add-pythonname into master

This change is needed by the wrappers to handle an edge case for templated classes.

For templated VTK classes, the GetClassName() method returns the result of typeid(type).name(). Since the wrappers rely on GetClassName() for VTK RTTI, the Python ClassMap also uses typeid(type).name() as the key for templated classes.

The issue that this MR aims to fix is that the ClassMap is used for more than just GetClassName() lookups. It is also used in some places where the Python class name is known, but not the VTK ClassName. As an example, consider vtkSOADataArrayTemplate<float> which has a VTK ClassName of "23vtkSOADataArrayTemplateIfE" (on linux-gcc) but has a Python class name of "vtkSOADataArrayTemplate_IfE" (since the VTK ClassName isn't a legal Python identifier).

One specific edge case is vtkPythonOverload.cxx, which performs overload resolution to figure out which C++ method to call as the result of a Python method call. To resolve overloads, the wrappers have a list parameter types for each overloaded method signature. The Python class name is used in this list, and the ClassMap is used to retrieve the actual PyType object which is then used for parameter type checking. So that ClassMap must be able to take the Python class name as a key, or else overload resolution based on templated VTK classes will not work.

Merge request reports

Loading