Commit 67eb4fc5 authored by David Gobbi's avatar David Gobbi

15995: Implement C++ templates as Python modules.

The help() function was not working on wrapped class templates, so the
PyVTKTemplate type has been re-imagined as a module that contains the
instantiations of the template, since the help() function works with
module docstrings. PyVTKTemplate still supports the mapping protocol
as before, which allows lookup of the instantiated templates via the
template arguments.
parent 331df4a5
Pipeline #7480 passed with stage
This diff is collapsed.
......@@ -27,16 +27,6 @@
#include "vtkPython.h"
#include "vtkSystemIncludes.h"
// The PyVTKTemplate is a wrapper around a dict.
struct PyVTKTemplate {
PyObject *dict;
PyObject *doc;
PyObject *name;
PyObject *module;
PyObject *bases; // this is just a hint for help()
#define PyVTKTemplate_Check(obj) \
......@@ -45,7 +35,7 @@ extern VTKWRAPPINGPYTHONCORE_EXPORT PyTypeObject PyVTKTemplate_Type;
extern "C"
PyObject *PyVTKTemplate_New(const char *name, const char *modulename,
PyObject *PyVTKTemplate_New(const char *name,
const char *docstring[]);
......@@ -390,10 +390,10 @@ int vtkWrapPython_WrapTemplatedClass(
" PyObject *o;\n"
" PyObject *temp = PyVTKTemplate_New(\"%s\", \"%s\",\n"
" PyObject *temp = PyVTKTemplate_New(\"%sPython.%s\",\n"
" Py%s_Doc);\n"
data->Name, data->Name, modulename, data->Name);
data->Name, modulename, data->Name, data->Name);
for (k = 0; k < ninstantiations; k++)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment