Commit c48b3cca authored by David Gobbi's avatar David Gobbi Committed by Marcus D. Hanwell
Browse files

ENH: Remove methods that will be replaced by customized methods

When the wrappers add custom methods like AddObserver() they should
ensure that the orginal method of the same name is not wrapped or
the override will not be successful (or worse, there will be duplicate
symbols and the wrappers won't even compile).

As a side-entry to this commit, I've also made "unsigned long" return
values as python ints unless they are too large, in which case they
are returned as python longs.
parent de1a579e
...@@ -569,6 +569,7 @@ void outputFunction(FILE *fp, FileInfo *data) ...@@ -569,6 +569,7 @@ void outputFunction(FILE *fp, FileInfo *data)
if (((aType & VTK_PARSE_INDIRECT) != VTK_PARSE_POINTER) && if (((aType & VTK_PARSE_INDIRECT) != VTK_PARSE_POINTER) &&
((aType & VTK_PARSE_INDIRECT) != 0) && ((aType & VTK_PARSE_INDIRECT) != 0) &&
(aType != VTK_PARSE_STRING_REF)) args_ok = 0; (aType != VTK_PARSE_STRING_REF)) args_ok = 0;
if (aType == VTK_PARSE_STRING_PTR) args_ok = 0;
if (aType == VTK_PARSE_UNSIGNED_CHAR_PTR) args_ok = 0; if (aType == VTK_PARSE_UNSIGNED_CHAR_PTR) args_ok = 0;
if (aType == VTK_PARSE_UNSIGNED_INT_PTR) args_ok = 0; if (aType == VTK_PARSE_UNSIGNED_INT_PTR) args_ok = 0;
if (aType == VTK_PARSE_UNSIGNED_SHORT_PTR) args_ok = 0; if (aType == VTK_PARSE_UNSIGNED_SHORT_PTR) args_ok = 0;
...@@ -593,6 +594,7 @@ void outputFunction(FILE *fp, FileInfo *data) ...@@ -593,6 +594,7 @@ void outputFunction(FILE *fp, FileInfo *data)
if (((rType & VTK_PARSE_INDIRECT) != VTK_PARSE_POINTER) && if (((rType & VTK_PARSE_INDIRECT) != VTK_PARSE_POINTER) &&
((rType & VTK_PARSE_INDIRECT) != 0) && ((rType & VTK_PARSE_INDIRECT) != 0) &&
(rType != VTK_PARSE_STRING_REF)) args_ok = 0; (rType != VTK_PARSE_STRING_REF)) args_ok = 0;
if (rType == VTK_PARSE_STRING_PTR) args_ok = 0;
/* eliminate unsigned char * and unsigned short * */ /* eliminate unsigned char * and unsigned short * */
if (rType == VTK_PARSE_UNSIGNED_INT_PTR) args_ok = 0; if (rType == VTK_PARSE_UNSIGNED_INT_PTR) args_ok = 0;
...@@ -636,6 +638,36 @@ void outputFunction(FILE *fp, FileInfo *data) ...@@ -636,6 +638,36 @@ void outputFunction(FILE *fp, FileInfo *data)
break; break;
} }
/* make sure there isn't a Java-specific override */
if (!strcmp("vtkObject",data->ClassName))
{
/* remove the original vtkCommand observer methods */
if (!strcmp(currentFunction->Name,"AddObserver") ||
!strcmp(currentFunction->Name,"GetCommand") ||
(!strcmp(currentFunction->Name,"RemoveObserver") &&
(currentFunction->ArgTypes[0] != VTK_PARSE_UNSIGNED_LONG)) ||
((!strcmp(currentFunction->Name,"RemoveObservers") ||
!strcmp(currentFunction->Name,"HasObserver")) &&
(((currentFunction->ArgTypes[0] != VTK_PARSE_UNSIGNED_LONG) &&
(currentFunction->ArgTypes[0] !=
(VTK_PARSE_CHAR_PTR|VTK_PARSE_CONST))) ||
(currentFunction->NumberOfArguments > 1))) ||
(!strcmp(currentFunction->Name,"RemoveAllObservers") &&
(currentFunction->NumberOfArguments > 0)))
{
args_ok = 0;
}
}
else if (!strcmp("vtkObjectBase",data->ClassName))
{
/* remove the special vtkObjectBase methods */
if (!strcmp(currentFunction->Name,"PrintRevisions") ||
!strcmp(currentFunction->Name,"Print"))
{
args_ok = 0;
}
}
/* make sure it isn't a Delete or New function */ /* make sure it isn't a Delete or New function */
if (!strcmp("Delete",currentFunction->Name) || if (!strcmp("Delete",currentFunction->Name) ||
!strcmp("New",currentFunction->Name)) !strcmp("New",currentFunction->Name))
......
...@@ -400,6 +400,7 @@ void outputFunction(FILE *fp, FileInfo *data) ...@@ -400,6 +400,7 @@ void outputFunction(FILE *fp, FileInfo *data)
if (((aType & VTK_PARSE_INDIRECT) != VTK_PARSE_POINTER) && if (((aType & VTK_PARSE_INDIRECT) != VTK_PARSE_POINTER) &&
((aType & VTK_PARSE_INDIRECT) != 0) && ((aType & VTK_PARSE_INDIRECT) != 0) &&
(aType != VTK_PARSE_STRING_REF)) args_ok = 0; (aType != VTK_PARSE_STRING_REF)) args_ok = 0;
if (aType == VTK_PARSE_STRING_PTR) args_ok = 0;
if (aType == VTK_PARSE_UNSIGNED_CHAR_PTR) args_ok = 0; if (aType == VTK_PARSE_UNSIGNED_CHAR_PTR) args_ok = 0;
if (aType == VTK_PARSE_UNSIGNED_INT_PTR) args_ok = 0; if (aType == VTK_PARSE_UNSIGNED_INT_PTR) args_ok = 0;
if (aType == VTK_PARSE_UNSIGNED_SHORT_PTR) args_ok = 0; if (aType == VTK_PARSE_UNSIGNED_SHORT_PTR) args_ok = 0;
...@@ -424,6 +425,7 @@ void outputFunction(FILE *fp, FileInfo *data) ...@@ -424,6 +425,7 @@ void outputFunction(FILE *fp, FileInfo *data)
if (((rType & VTK_PARSE_INDIRECT) != VTK_PARSE_POINTER) && if (((rType & VTK_PARSE_INDIRECT) != VTK_PARSE_POINTER) &&
((rType & VTK_PARSE_INDIRECT) != 0) && ((rType & VTK_PARSE_INDIRECT) != 0) &&
(rType != VTK_PARSE_STRING_REF)) args_ok = 0; (rType != VTK_PARSE_STRING_REF)) args_ok = 0;
if (rType == VTK_PARSE_STRING_PTR) args_ok = 0;
/* eliminate unsigned char * and unsigned short * */ /* eliminate unsigned char * and unsigned short * */
if (rType == VTK_PARSE_UNSIGNED_CHAR_PTR) args_ok = 0; if (rType == VTK_PARSE_UNSIGNED_CHAR_PTR) args_ok = 0;
...@@ -465,6 +467,36 @@ void outputFunction(FILE *fp, FileInfo *data) ...@@ -465,6 +467,36 @@ void outputFunction(FILE *fp, FileInfo *data)
break; break;
} }
/* make sure there isn't a Java-specific override */
if (!strcmp("vtkObject",data->ClassName))
{
/* remove the original vtkCommand observer methods */
if (!strcmp(currentFunction->Name,"AddObserver") ||
!strcmp(currentFunction->Name,"GetCommand") ||
(!strcmp(currentFunction->Name,"RemoveObserver") &&
(currentFunction->ArgTypes[0] != VTK_PARSE_UNSIGNED_LONG)) ||
((!strcmp(currentFunction->Name,"RemoveObservers") ||
!strcmp(currentFunction->Name,"HasObserver")) &&
(((currentFunction->ArgTypes[0] != VTK_PARSE_UNSIGNED_LONG) &&
(currentFunction->ArgTypes[0] !=
(VTK_PARSE_CHAR_PTR|VTK_PARSE_CONST))) ||
(currentFunction->NumberOfArguments > 1))) ||
(!strcmp(currentFunction->Name,"RemoveAllObservers") &&
(currentFunction->NumberOfArguments > 0)))
{
args_ok = 0;
}
}
else if (!strcmp("vtkObjectBase",data->ClassName))
{
/* remove the special vtkObjectBase methods */
if (!strcmp(currentFunction->Name,"PrintRevisions") ||
!strcmp(currentFunction->Name,"Print"))
{
args_ok = 0;
}
}
/* make sure it isn't a Delete or New function */ /* make sure it isn't a Delete or New function */
if (!strcmp("Delete",currentFunction->Name) || if (!strcmp("Delete",currentFunction->Name) ||
!strcmp("New",currentFunction->Name)) !strcmp("New",currentFunction->Name))
......
...@@ -895,6 +895,7 @@ void outputFunction(FILE *fp, FileInfo *data) ...@@ -895,6 +895,7 @@ void outputFunction(FILE *fp, FileInfo *data)
if (((aType & VTK_PARSE_INDIRECT) != VTK_PARSE_POINTER) && if (((aType & VTK_PARSE_INDIRECT) != VTK_PARSE_POINTER) &&
((aType & VTK_PARSE_INDIRECT) != 0) && ((aType & VTK_PARSE_INDIRECT) != 0) &&
(aType != VTK_PARSE_STRING_REF)) args_ok = 0; (aType != VTK_PARSE_STRING_REF)) args_ok = 0;
if (aType == VTK_PARSE_STRING_PTR) args_ok = 0;
if (aType == VTK_PARSE_UNSIGNED_CHAR_PTR) args_ok = 0; if (aType == VTK_PARSE_UNSIGNED_CHAR_PTR) args_ok = 0;
if (aType == VTK_PARSE_UNSIGNED_INT_PTR) args_ok = 0; if (aType == VTK_PARSE_UNSIGNED_INT_PTR) args_ok = 0;
if (aType == VTK_PARSE_UNSIGNED_SHORT_PTR) args_ok = 0; if (aType == VTK_PARSE_UNSIGNED_SHORT_PTR) args_ok = 0;
...@@ -919,6 +920,7 @@ void outputFunction(FILE *fp, FileInfo *data) ...@@ -919,6 +920,7 @@ void outputFunction(FILE *fp, FileInfo *data)
if (((rType & VTK_PARSE_INDIRECT) != VTK_PARSE_POINTER) && if (((rType & VTK_PARSE_INDIRECT) != VTK_PARSE_POINTER) &&
((rType & VTK_PARSE_INDIRECT) != 0) && ((rType & VTK_PARSE_INDIRECT) != 0) &&
(rType != VTK_PARSE_STRING_REF)) args_ok = 0; (rType != VTK_PARSE_STRING_REF)) args_ok = 0;
if (rType == VTK_PARSE_STRING_PTR) args_ok = 0;
/* eliminate unsigned short * usigned int * etc */ /* eliminate unsigned short * usigned int * etc */
if (rType == VTK_PARSE_UNSIGNED_INT_PTR) args_ok = 0; if (rType == VTK_PARSE_UNSIGNED_INT_PTR) args_ok = 0;
...@@ -962,6 +964,36 @@ void outputFunction(FILE *fp, FileInfo *data) ...@@ -962,6 +964,36 @@ void outputFunction(FILE *fp, FileInfo *data)
break; break;
} }
/* make sure there isn't a Java-specific override */
if (!strcmp("vtkObject",data->ClassName))
{
/* remove the original vtkCommand observer methods */
if (!strcmp(currentFunction->Name,"AddObserver") ||
!strcmp(currentFunction->Name,"GetCommand") ||
(!strcmp(currentFunction->Name,"RemoveObserver") &&
(currentFunction->ArgTypes[0] != VTK_PARSE_UNSIGNED_LONG)) ||
((!strcmp(currentFunction->Name,"RemoveObservers") ||
!strcmp(currentFunction->Name,"HasObserver")) &&
(((currentFunction->ArgTypes[0] != VTK_PARSE_UNSIGNED_LONG) &&
(currentFunction->ArgTypes[0] !=
(VTK_PARSE_CHAR_PTR|VTK_PARSE_CONST))) ||
(currentFunction->NumberOfArguments > 1))) ||
(!strcmp(currentFunction->Name,"RemoveAllObservers") &&
(currentFunction->NumberOfArguments > 0)))
{
args_ok = 0;
}
}
else if (!strcmp("vtkObjectBase",data->ClassName))
{
/* remove the special vtkObjectBase methods */
if (!strcmp(currentFunction->Name,"PrintRevisions") ||
!strcmp(currentFunction->Name,"Print"))
{
args_ok = 0;
}
}
/* make sure it isn't a Delete or New function */ /* make sure it isn't a Delete or New function */
if (!strcmp("Delete",currentFunction->Name) || if (!strcmp("Delete",currentFunction->Name) ||
!strcmp("New",currentFunction->Name)) !strcmp("New",currentFunction->Name))
......
...@@ -37,9 +37,14 @@ static void vtkWrapPython_ClassDoc( ...@@ -37,9 +37,14 @@ static void vtkWrapPython_ClassDoc(
static void vtkWrapPython_GenerateSpecialHeaders( static void vtkWrapPython_GenerateSpecialHeaders(
FILE *fp, FileInfo *data); FILE *fp, FileInfo *data);
/* print out any custom methods */
static void vtkWrapPython_CustomMethods(
FILE *fp, FileInfo *data, int do_constructors);
/* print out all methods and the method table */ /* print out all methods and the method table */
static void vtkWrapPython_GenerateMethods( static void vtkWrapPython_GenerateMethods(
FILE *fp, FileInfo *data, int class_has_new, int do_constructors); FILE *fp, FileInfo *data, int class_has_new,
int is_vtkobject, int do_constructors);
/* make a temporary variable for an arg value or a return value */ /* make a temporary variable for an arg value or a return value */
static void vtkWrapPython_MakeTempVariable( static void vtkWrapPython_MakeTempVariable(
...@@ -495,10 +500,12 @@ static void vtkWrapPython_ReturnValue( ...@@ -495,10 +500,12 @@ static void vtkWrapPython_ReturnValue(
deref, MAX_ARGS); deref, MAX_ARGS);
break; break;
} }
case VTK_PARSE_UNSIGNED_CHAR: #if (VTK_SIZEOF_INT < VTK_SIZEOF_LONG)
case VTK_PARSE_UNSIGNED_CHAR_REF:
case VTK_PARSE_UNSIGNED_INT: case VTK_PARSE_UNSIGNED_INT:
case VTK_PARSE_UNSIGNED_INT_REF: case VTK_PARSE_UNSIGNED_INT_REF:
#endif
case VTK_PARSE_UNSIGNED_CHAR:
case VTK_PARSE_UNSIGNED_CHAR_REF:
case VTK_PARSE_UNSIGNED_SHORT: case VTK_PARSE_UNSIGNED_SHORT:
case VTK_PARSE_UNSIGNED_SHORT_REF: case VTK_PARSE_UNSIGNED_SHORT_REF:
case VTK_PARSE_INT: case VTK_PARSE_INT:
...@@ -532,21 +539,33 @@ static void vtkWrapPython_ReturnValue( ...@@ -532,21 +539,33 @@ static void vtkWrapPython_ReturnValue(
} }
/* PyLong_FromUnsignedLong() is new to Python 2.2 */ /* PyLong_FromUnsignedLong() is new to Python 2.2 */
#if (VTK_SIZEOF_INT == VTK_SIZEOF_LONG)
case VTK_PARSE_UNSIGNED_INT:
case VTK_PARSE_UNSIGNED_INT_REF:
#endif
case VTK_PARSE_UNSIGNED_LONG: case VTK_PARSE_UNSIGNED_LONG:
case VTK_PARSE_UNSIGNED_LONG_REF: case VTK_PARSE_UNSIGNED_LONG_REF:
{ {
fprintf(fp, fprintf(fp,
"#if (PY_VERSION_HEX >= 0x02020000)\n" "#if (PY_VERSION_HEX >= 0x02020000)\n"
" result = PyLong_FromUnsignedLong(%stemp%i);\n" " if ((long)(%stemp%i) >= 0)\n"
" {\n"
" result = PyInt_FromLong((long)(%stemp%i));\n"
" }\n"
" else\n"
" {\n"
" result = PyLong_FromUnsignedLong(%stemp%i);\n"
" }\n"
"#else\n" "#else\n"
" result = PyInt_FromLong((long)%stemp%i);\n" " result = PyInt_FromLong((long)(%stemp%i));\n"
"#endif\n", "#endif\n",
deref, MAX_ARGS, deref, MAX_ARGS); deref, MAX_ARGS, deref, MAX_ARGS, deref, MAX_ARGS,
deref, MAX_ARGS);
break; break;
} }
/* Support for vtkIdType depends on config and capabilities */ /* Support for vtkIdType depends on config and capabilities */
#if defined(VTK_USE_64BIT_IDS) && defined(PY_LONG_LONG) && (VTK_SIZEOF_LONG != VTK_SIZEOF_ID_TYPE) #if defined(VTK_USE_64BIT_IDS) && defined(PY_LONG_LONG) && (VTK_SIZEOF_LONG != 8)
case VTK_PARSE_ID_TYPE: case VTK_PARSE_ID_TYPE:
case VTK_PARSE_ID_TYPE_REF: case VTK_PARSE_ID_TYPE_REF:
{ {
...@@ -577,57 +596,28 @@ static void vtkWrapPython_ReturnValue( ...@@ -577,57 +596,28 @@ static void vtkWrapPython_ReturnValue(
{ {
fprintf(fp, fprintf(fp,
"#if (PY_VERSION_HEX >= 0x02020000)\n" "#if (PY_VERSION_HEX >= 0x02020000)\n"
" result = PyLong_FromUnsignedLong((unsigned long)%stemp%i);\n" " if ((long)(%stemp%i) >= 0)\n"
" {\n"
" result = PyInt_FromLong((long)(%stemp%i));\n"
" }\n"
" else\n"
" {\n"
" result = PyLong_FromUnsignedLong(%stemp%i);\n"
" }\n"
"#else\n" "#else\n"
" result = PyInt_FromLong((long)%stemp%i);\n" " result = PyInt_FromLong((long)(%stemp%i));\n"
"#endif\n", "#endif\n",
deref, MAX_ARGS, deref, MAX_ARGS); deref, MAX_ARGS, deref, MAX_ARGS, deref, MAX_ARGS,
deref, MAX_ARGS);
break; break;
} }
#endif #endif
/* support for "long long" depends on config and capabilities */ /* support for "long long" depends on config and capabilities */
#if defined(VTK_TYPE_USE_LONG_LONG) #if defined(VTK_TYPE_USE_LONG_LONG) || defined(VTK_TYPE_USE___INT64)
# if defined(PY_LONG_LONG) && (VTK_SIZEOF_LONG != VTK_SIZEOF_LONG_LONG) # if defined(PY_LONG_LONG) && (VTK_SIZEOF_LONG != 8)
case VTK_PARSE_LONG_LONG:
case VTK_PARSE_LONG_LONG_REF:
{
fprintf(fp,
" result = PyLong_FromLongLong(%stemp%i);\n",
deref, MAX_ARGS);
break;
}
case VTK_PARSE_UNSIGNED_LONG_LONG:
case VTK_PARSE_UNSIGNED_LONG_LONG_REF:
{
fprintf(fp,
" result = PyLong_FromUnsignedLongLong(%stemp%i);\n",
deref, MAX_ARGS);
break;
}
# else
case VTK_PARSE_LONG_LONG: case VTK_PARSE_LONG_LONG:
case VTK_PARSE_LONG_LONG_REF: case VTK_PARSE_LONG_LONG_REF:
{
fprintf(fp,
" result = PyLong_FromLong(%stemp%i);\n",
deref, MAX_ARGS);
break;
}
case VTK_PARSE_UNSIGNED_LONG_LONG:
case VTK_PARSE_UNSIGNED_LONG_LONG_REF:
{
fprintf(fp,
" result = PyLong_FromUnsignedLong(%stemp%i);\n",
deref, MAX_ARGS);
break;
}
# endif
#endif
/* support for "__int64" depends on config and capabilities */
#if defined(VTK_TYPE_USE___INT64)
# if defined(PY_LONG_LONG) && (VTK_SIZEOF_LONG != VTK_SIZEOF___INT64)
case VTK_PARSE___INT64: case VTK_PARSE___INT64:
case VTK_PARSE___INT64_REF: case VTK_PARSE___INT64_REF:
{ {
...@@ -636,6 +626,8 @@ static void vtkWrapPython_ReturnValue( ...@@ -636,6 +626,8 @@ static void vtkWrapPython_ReturnValue(
deref, MAX_ARGS); deref, MAX_ARGS);
break; break;
} }
case VTK_PARSE_UNSIGNED_LONG_LONG:
case VTK_PARSE_UNSIGNED_LONG_LONG_REF:
case VTK_PARSE_UNSIGNED___INT64: case VTK_PARSE_UNSIGNED___INT64:
case VTK_PARSE_UNSIGNED___INT64_REF: case VTK_PARSE_UNSIGNED___INT64_REF:
{ {
...@@ -645,6 +637,8 @@ static void vtkWrapPython_ReturnValue( ...@@ -645,6 +637,8 @@ static void vtkWrapPython_ReturnValue(
break; break;
} }
# else # else
case VTK_PARSE_LONG_LONG:
case VTK_PARSE_LONG_LONG_REF:
case VTK_PARSE___INT64: case VTK_PARSE___INT64:
case VTK_PARSE___INT64_REF: case VTK_PARSE___INT64_REF:
{ {
...@@ -653,16 +647,26 @@ static void vtkWrapPython_ReturnValue( ...@@ -653,16 +647,26 @@ static void vtkWrapPython_ReturnValue(
deref, MAX_ARGS); deref, MAX_ARGS);
break; break;
} }
case VTK_PARSE_UNSIGNED_LONG_LONG:
case VTK_PARSE_UNSIGNED_LONG_LONG_REF:
case VTK_PARSE_UNSIGNED___INT64: case VTK_PARSE_UNSIGNED___INT64:
case VTK_PARSE_UNSIGNED___INT64_REF: case VTK_PARSE_UNSIGNED___INT64_REF:
{ {
fprintf(fp, fprintf(fp,
"#if (PY_VERSION_HEX >= 0x02020000)\n" "#if (PY_VERSION_HEX >= 0x02020000)\n"
" result = PyLong_FromUnsignedLong((unsigned long)%stemp%i);\n" " if ((long)(%stemp%i) >= 0)\n"
" {\n"
" result = PyInt_FromLong((long)(%stemp%i));\n"
" }\n"
" else\n"
" {\n"
" result = PyLong_FromUnsignedLong(%stemp%i);\n"
" }\n"
"#else\n" "#else\n"
" result = PyInt_FromLong((long)%stemp%i);\n" " result = PyInt_FromLong((long)(%stemp%i));\n"
"#endif\n", "#endif\n",
deref, MAX_ARGS, deref, MAX_ARGS); deref, MAX_ARGS, deref, MAX_ARGS, deref, MAX_ARGS,
deref, MAX_ARGS);
break; break;
} }
# endif # endif
...@@ -852,7 +856,7 @@ static char *vtkWrapPython_FormatString(FunctionInfo *currentFunction) ...@@ -852,7 +856,7 @@ static char *vtkWrapPython_FormatString(FunctionInfo *currentFunction)
} }
} }
result[currPos] = '\0'; result[currPos++] = '\0';
return result; return result;
} }
...@@ -1446,9 +1450,10 @@ void vtkWrapPython_RemovePreceededMethods( ...@@ -1446,9 +1450,10 @@ void vtkWrapPython_RemovePreceededMethods(
* words, this poorly named function is "the big one". */ * words, this poorly named function is "the big one". */
static void vtkWrapPython_GenerateMethods( static void vtkWrapPython_GenerateMethods(
FILE *fp, FileInfo *data, int class_has_new, int do_constructors) FILE *fp, FileInfo *data, int class_has_new,
int is_vtkobject, int do_constructors)
{ {
int i, j, k, is_static, is_pure_virtual, is_vtkobject, fnum, occ; int i, j, k, is_static, is_pure_virtual, fnum, occ;
int numberOfSignatures, signatureCount; int numberOfSignatures, signatureCount;
char signatureSuffix[8]; char signatureSuffix[8];
int all_legacy, all_static; int all_legacy, all_static;
...@@ -1462,8 +1467,10 @@ static void vtkWrapPython_GenerateMethods( ...@@ -1462,8 +1467,10 @@ static void vtkWrapPython_GenerateMethods(
int needs_cleanup = 0; int needs_cleanup = 0;
char on_error[32]; char on_error[32];
/* go through all functions and see which are wrappable, /* output any custom methods */
* note that "theSignature" is a global variable */ vtkWrapPython_CustomMethods(fp, data, do_constructors);
/* go through all functions and see which are wrappable */
for (i = 0; i < data->NumberOfFunctions; i++) for (i = 0; i < data->NumberOfFunctions; i++)
{ {
theFunc = &data->Functions[i]; theFunc = &data->Functions[i];
...@@ -1477,10 +1484,6 @@ static void vtkWrapPython_GenerateMethods( ...@@ -1477,10 +1484,6 @@ static void vtkWrapPython_GenerateMethods(
} }
} }
/* check for derivation from vtkObjectBase */
is_vtkobject = ((strcmp(data->ClassName,"vtkObjectBase") == 0) ||
(data->NumberOfSuperClasses != 0));
/* create a python-type signature for each method (for use in docstring) */ /* create a python-type signature for each method (for use in docstring) */
for (fnum = 0; fnum < numberOfWrappedFunctions; fnum++) for (fnum = 0; fnum < numberOfWrappedFunctions; fnum++)
{ {
...@@ -1646,15 +1649,18 @@ static void vtkWrapPython_GenerateMethods( ...@@ -1646,15 +1649,18 @@ static void vtkWrapPython_GenerateMethods(
if (is_static || !is_vtkobject) if (is_static || !is_vtkobject)
{ {
fprintf(fp, fprintf(fp,
" if ((PyArg_ParseTuple(args, (char*)\"%s\"", " if ((PyArg_ParseTuple(args, (char*)\"%s:%s\"",
vtkWrapPython_FormatString(theSignature)); vtkWrapPython_FormatString(theSignature),
theSignature->Name);
} }
else else
{ {
fprintf(fp, fprintf(fp,
" op = static_cast<%s *>(vtkPythonUtil::VTKParseTuple(self, args, \"%s\"", " op = static_cast<%s *>(vtkPythonUtil::VTKParseTuple(\n"
" self, args, \"%s:%s\"",
data->ClassName, data->ClassName,
vtkWrapPython_FormatString(theSignature)); vtkWrapPython_FormatString(theSignature),
theSignature->Name);
} }
for (i = 0; i < theSignature->NumberOfArguments; i++) for (i = 0; i < theSignature->NumberOfArguments; i++)
...@@ -1708,6 +1714,7 @@ static void vtkWrapPython_GenerateMethods( ...@@ -1708,6 +1714,7 @@ static void vtkWrapPython_GenerateMethods(
else else
{ {
fprintf(fp,"));\n" fprintf(fp,"));\n"
"\n"
" if (op)\n" " if (op)\n"
" {\n"); " {\n");
} }
...@@ -2199,7 +2206,7 @@ static void vtkWrapPython_GenerateMethods( ...@@ -2199,7 +2206,7 @@ static void vtkWrapPython_GenerateMethods(
} }
/* vtkObject needs a special entry for AddObserver */ /* vtkObject needs a special entry for AddObserver */
if (!strcmp("vtkObject",data->ClassName)) if (strcmp("vtkObject", data->ClassName) == 0)
{ {
fprintf(fp, fprintf(fp,
" {(char*)\"AddObserver\", (PyCFunction)Py%s_AddObserver, 1,\n" " {(char*)\"AddObserver\", (PyCFunction)Py%s_AddObserver, 1,\n"
...@@ -2208,7 +2215,7 @@ static void vtkWrapPython_GenerateMethods( ...@@ -2208,7 +2215,7 @@ static void vtkWrapPython_GenerateMethods(
} }
/* vtkObjectBase needs entries for GetAddressAsString and PrintRevisions */ /* vtkObjectBase needs entries for GetAddressAsString and PrintRevisions */
else if (!strcmp("vtkObjectBase",data->ClassName)) else if (strcmp("vtkObjectBase", data->ClassName) == 0)
{ {
fprintf(fp, fprintf(fp,
" {(char*)\"GetAddressAsString\", (PyCFunction)Py%s_GetAddressAsString, 1,\n" " {(char*)\"GetAddressAsString\", (PyCFunction)Py%s_GetAddressAsString, 1,\n"
...@@ -2599,56 +2606,78 @@ static void vtkWrapPython_GenerateSpecialHeaders( ...@@ -2599,56 +2606,78 @@ static void vtkWrapPython_GenerateSpecialHeaders(
/* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */
/* generate code for custom methods for some classes */ /* generate code for custom methods for some classes */
static void vtkWrapPython_CustomMethods(FILE *fp, FileInfo *data) static void vtkWrapPython_CustomMethods(
FILE *fp, FileInfo *data, int do_constructors)
{ {
int i;
FunctionInfo *theFunc;
/* the python vtkObject needs special hooks for observers */ /* the python vtkObject needs special hooks for observers */
if (strcmp("vtkObject",data->ClassName) == 0) if (strcmp("vtkObject", data->ClassName) == 0 &&
do_constructors == 0)
{ {
/* remove the original vtkCommand observer methods */
for (i = 0; i < data->NumberOfFunctions; i++)
{
theFunc = &data->Functions[i];
if ((strcmp(theFunc->Name, "AddObserver") == 0) ||
(strcmp(theFunc->Name, "GetCommand") == 0) ||
((strcmp(theFunc->Name, "RemoveObserver") == 0) &&
(theFunc->ArgTypes[0] != VTK_PARSE_UNSIGNED_LONG)) ||
(((strcmp(theFunc->Name, "RemoveObservers") == 0) ||
(strcmp(theFunc->Name, "HasObserver") == 0)) &&
(((theFunc->ArgTypes[0] != VTK_PARSE_UNSIGNED_LONG) &&
(theFunc->ArgTypes[0] != (VTK_PARSE_CHAR_PTR|VTK_PARSE_CONST))) ||
(theFunc->NumberOfArguments > 1))) ||
((strcmp(theFunc->Name, "RemoveAllObservers") == 0) &&
(theFunc->NumberOfArguments > 0)))
{
data->Functions[i].Name = NULL;
}
}