Commit f642f513 authored by David Gobbi's avatar David Gobbi

Wrap enum constant members for non-vtkObject types.

Change-Id: Id9b7b1659b07103ebb8dd80df02cccd56e5ab6a0
parent a73ab651
......@@ -8,8 +8,14 @@ set(Module_SRCS
set_source_files_properties(
vtkErrorCode.cxx
vtkPolygonBuilder
vtkPolygonBuilder.cxx
WRAP_EXCLUDE
)
set_source_files_properties(
vtkErrorCode.cxx
vtkPolygonBuilder.cxx
PROPERTIES WRAP_SPECIAL 1
)
vtk_module_library(vtkCommonMisc ${Module_SRCS})
......@@ -15,6 +15,7 @@
#include "vtkWrapPythonType.h"
#include "vtkWrapPythonClass.h"
#include "vtkWrapPythonConstant.h"
#include "vtkWrapPythonMethod.h"
#include "vtkWrapPythonMethodDef.h"
#include "vtkWrapPythonTemplate.h"
......@@ -638,6 +639,8 @@ void vtkWrapPython_GenerateSpecialType(
SpecialTypeInfo info;
const char *constructor;
size_t n, m;
int i;
int has_constants = 0;
int has_superclass = 0;
int is_external = 0;
......@@ -861,15 +864,48 @@ void vtkWrapPython_GenerateSpecialType(
fprintf(fp,
"static PyObject *Py%s_TypeNew(const char *)\n"
"{\n"
" return PyVTKSpecialType_New(\n"
" PyObject *cls = PyVTKSpecialType_New(\n"
" &Py%s_Type,\n"
" Py%s_Methods,\n"
" Py%s_%*.*s_Methods,\n"
" &Py%s_NewMethod,\n"
" Py%s_Doc(), &Py%s_CCopy);\n"
"}\n"
"\n",
classname, classname, classname,
classname, (int)n, (int)n, constructor, classname,
classname, classname);
/* check whether the class has any constants as members */
for (i = 0; i < data->NumberOfConstants; i++)
{
if (data->Constants[i]->Access == VTK_ACCESS_PUBLIC)
{
has_constants = 1;
}
}
if (has_constants)
{
fprintf(fp,
" PyObject *d = Py%s_Type.tp_dict;\n"
" PyObject *o;\n"
"\n",
classname);
/* add any constants defined in the class to its dict */
for (i = 0; i < data->NumberOfConstants; i++)
{
if (data->Constants[i]->Access == VTK_ACCESS_PUBLIC)
{
vtkWrapPython_AddConstant(
fp, " ", "d", "o", data->Constants[i]);
fprintf(fp, "\n");
}
}
}
fprintf(fp,
" return cls;\n"
"}\n"
"\n");
}
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