int checkFunctionSignature(ClassInfo *data) { static unsigned int supported_types[] = { VTK_PARSE_VOID, VTK_PARSE_BOOL, VTK_PARSE_FLOAT, VTK_PARSE_DOUBLE, VTK_PARSE_CHAR, VTK_PARSE_UNSIGNED_CHAR, VTK_PARSE_SIGNED_CHAR, VTK_PARSE_INT, VTK_PARSE_UNSIGNED_INT, VTK_PARSE_SHORT, VTK_PARSE_UNSIGNED_SHORT, VTK_PARSE_LONG, VTK_PARSE_UNSIGNED_LONG, VTK_PARSE_ID_TYPE, VTK_PARSE_UNSIGNED_ID_TYPE, VTK_PARSE_LONG_LONG, VTK_PARSE_UNSIGNED_LONG_LONG, VTK_PARSE___INT64, VTK_PARSE_UNSIGNED___INT64, VTK_PARSE_VTK_OBJECT, VTK_PARSE_STRING, 0 }; int i, j; int args_ok = 1; unsigned int rType = (currentFunction->ReturnType & VTK_PARSE_UNQUALIFIED_TYPE); unsigned int aType = 0; unsigned int baseType = 0; /* some functions will not get wrapped no matter what else */ if (currentFunction->IsOperator || currentFunction->ArrayFailure || !currentFunction->IsPublic || !currentFunction->Name) { return 0; } /* NewInstance and SafeDownCast can not be wrapped because it is a (non-virtual) method which returns a pointer of the same type as the current pointer. Since all methods are virtual in Java, this looks like polymorphic return type. */ if (!strcmp("NewInstance",currentFunction->Name)) { return 0; } if (!strcmp("SafeDownCast",currentFunction->Name)) { return 0; } /* The GetInput() in vtkMapper cannot be overriden with a * different return type, Java doesn't allow this */ if (strcmp(data->Name, "vtkMapper") == 0 && strcmp(currentFunction->Name, "GetInput") == 0) { return 0; } /* function pointer arguments for callbacks */ if (currentFunction->NumberOfArguments == 2 && currentFunction->ArgTypes[0] == VTK_PARSE_FUNCTION && currentFunction->ArgTypes[1] == VTK_PARSE_VOID_PTR && rType == VTK_PARSE_VOID) { return 1; } /* check to see if we can handle the args */ for (i = 0; i < currentFunction->NumberOfArguments; i++) { aType = (currentFunction->ArgTypes[i] & VTK_PARSE_UNQUALIFIED_TYPE); baseType = (aType & VTK_PARSE_BASE_TYPE); for (j = 0; supported_types[j] != 0; j++) { if (baseType == supported_types[j]) { break; } } if (supported_types[j] == 0) { args_ok = 0; } if (baseType == VTK_PARSE_OBJECT) { if ((aType & VTK_PARSE_INDIRECT) != VTK_PARSE_POINTER) { args_ok = 0; } else if (!isClassWrapped(currentFunction->ArgClasses[i])) { args_ok = 0; } } if (aType == VTK_PARSE_VTK_OBJECT) args_ok = 0; if (((aType & VTK_PARSE_INDIRECT) != VTK_PARSE_POINTER) && ((aType & VTK_PARSE_INDIRECT) != 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_INT_PTR) args_ok = 0; if (aType == VTK_PARSE_UNSIGNED_SHORT_PTR) args_ok = 0; if (aType == VTK_PARSE_UNSIGNED_LONG_PTR) args_ok = 0; if (aType == VTK_PARSE_UNSIGNED_ID_TYPE_PTR) args_ok = 0; if (aType == VTK_PARSE_UNSIGNED_LONG_LONG_PTR) args_ok = 0; if (aType == VTK_PARSE_UNSIGNED___INT64_PTR) args_ok = 0; } baseType = (rType & VTK_PARSE_BASE_TYPE); for (j = 0; supported_types[j] != 0; j++) { if (baseType == supported_types[j]) { break; } } if (supported_types[j] == 0) { args_ok = 0; } if (baseType == VTK_PARSE_OBJECT) { if ((rType & VTK_PARSE_INDIRECT) != VTK_PARSE_POINTER) { args_ok = 0; } else if (!isClassWrapped(currentFunction->ReturnClass)) { args_ok = 0; } } if (((rType & VTK_PARSE_INDIRECT) != VTK_PARSE_POINTER) && ((rType & VTK_PARSE_INDIRECT) != 0) && (rType != VTK_PARSE_STRING_REF)) args_ok = 0; if (rType == VTK_PARSE_STRING_PTR) args_ok = 0; /* eliminate unsigned char * and unsigned short * */ if (rType == VTK_PARSE_UNSIGNED_INT_PTR) args_ok = 0; if (rType == VTK_PARSE_UNSIGNED_SHORT_PTR) args_ok = 0; if (rType == VTK_PARSE_UNSIGNED_LONG_PTR) args_ok = 0; if (rType == VTK_PARSE_UNSIGNED_ID_TYPE_PTR) args_ok = 0; if (rType == VTK_PARSE_UNSIGNED_LONG_LONG_PTR) args_ok = 0; if (rType == VTK_PARSE_UNSIGNED___INT64_PTR) args_ok = 0; /* make sure we have all the info we need for array arguments in */ for (i = 0; i < currentFunction->NumberOfArguments; i++) { aType = (currentFunction->ArgTypes[i] & VTK_PARSE_UNQUALIFIED_TYPE); if (((aType & VTK_PARSE_INDIRECT) == VTK_PARSE_POINTER)&& (currentFunction->ArgCounts[i] <= 0)&& (aType != VTK_PARSE_VTK_OBJECT_PTR)&& (aType != VTK_PARSE_CHAR_PTR)) args_ok = 0; } /* if we need a return type hint make sure we have one */ switch (rType) { case VTK_PARSE_FLOAT_PTR: case VTK_PARSE_VOID_PTR: case VTK_PARSE_DOUBLE_PTR: case VTK_PARSE_INT_PTR: case VTK_PARSE_SHORT_PTR: case VTK_PARSE_LONG_PTR: case VTK_PARSE_ID_TYPE_PTR: case VTK_PARSE_LONG_LONG_PTR: case VTK_PARSE___INT64_PTR: case VTK_PARSE_SIGNED_CHAR_PTR: case VTK_PARSE_BOOL_PTR: case VTK_PARSE_UNSIGNED_CHAR_PTR: args_ok = currentFunction->HaveHint; break; } /* make sure there isn't a Java-specific override */ if (!strcmp("vtkObject",data->Name)) { /* 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->Name)) { /* remove the special vtkObjectBase methods */ if (!strcmp(currentFunction->Name,"Print") #ifndef VTK_LEGACY_REMOVE || !strcmp(currentFunction->Name,"PrintRevisions") #endif ) { args_ok = 0; } } /* make sure it isn't a Delete or New function */ if (!strcmp("Delete",currentFunction->Name) || !strcmp("New",currentFunction->Name)) { args_ok = 0; } return args_ok; }
/* check whether a function is wrappable */ int checkFunctionSignature(ClassInfo *data) { static unsigned int supported_types[] = { VTK_PARSE_VOID, VTK_PARSE_BOOL, VTK_PARSE_FLOAT, VTK_PARSE_DOUBLE, VTK_PARSE_CHAR, VTK_PARSE_UNSIGNED_CHAR, VTK_PARSE_SIGNED_CHAR, VTK_PARSE_INT, VTK_PARSE_UNSIGNED_INT, VTK_PARSE_SHORT, VTK_PARSE_UNSIGNED_SHORT, VTK_PARSE_LONG, VTK_PARSE_UNSIGNED_LONG, VTK_PARSE_ID_TYPE, VTK_PARSE_UNSIGNED_ID_TYPE, #ifdef VTK_TYPE_USE_LONG_LONG VTK_PARSE_LONG_LONG, VTK_PARSE_UNSIGNED_LONG_LONG, #endif #ifdef VTK_TYPE_USE___INT64 VTK_PARSE___INT64, VTK_PARSE_UNSIGNED___INT64, #endif VTK_PARSE_OBJECT, VTK_PARSE_STRING, 0 }; int i, j; int args_ok = 1; unsigned int returnType = 0; unsigned int argType = 0; unsigned int baseType = 0; /* some functions will not get wrapped no matter what else */ if (currentFunction->IsOperator || currentFunction->ArrayFailure || !currentFunction->IsPublic || !currentFunction->Name) { return 0; } /* The unwrappable methods in Filtering/vtkInformation.c */ if (strcmp(data->Name, "vtkInformation") == 0 && currentFunction->IsLegacy) { return 0; } /* function pointer arguments for callbacks */ if (currentFunction->NumberOfArguments == 2 && currentFunction->ArgTypes[0] == VTK_PARSE_FUNCTION && currentFunction->ArgTypes[1] == VTK_PARSE_VOID_PTR && (currentFunction->ReturnType & VTK_PARSE_UNQUALIFIED_TYPE) == VTK_PARSE_VOID) { return 1; } /* check to see if we can handle the args */ for (i = 0; i < currentFunction->NumberOfArguments; i++) { argType = (currentFunction->ArgTypes[i] & VTK_PARSE_UNQUALIFIED_TYPE); baseType = (argType & VTK_PARSE_BASE_TYPE); for (j = 0; supported_types[j] != 0; j++) { if (baseType == supported_types[j]) { break; } } if (supported_types[j] == 0) { args_ok = 0; } if (baseType == VTK_PARSE_STRING && (argType & VTK_PARSE_INDIRECT) != 0 && (argType & VTK_PARSE_INDIRECT) != VTK_PARSE_REF) { args_ok = 0; } if (baseType == VTK_PARSE_OBJECT) { if ((argType & VTK_PARSE_INDIRECT) != VTK_PARSE_POINTER) { args_ok = 0; } else if (!isClassWrapped(currentFunction->ArgClasses[i])) { args_ok = 0; } } if (((argType & VTK_PARSE_INDIRECT) != VTK_PARSE_POINTER) && ((argType & VTK_PARSE_INDIRECT) != VTK_PARSE_REF) && ((argType & VTK_PARSE_INDIRECT) != 0)) args_ok = 0; /* if its a pointer arg make sure we have the ArgCount */ if (((argType & VTK_PARSE_INDIRECT) != 0) && (argType != VTK_PARSE_CHAR_PTR) && (baseType != VTK_PARSE_OBJECT)) { if (currentFunction->NumberOfArguments > 1 || !currentFunction->ArgCounts[i]) { args_ok = 0; } } if (((argType & VTK_PARSE_UNSIGNED) != 0) && (argType != VTK_PARSE_UNSIGNED_CHAR) && (argType != VTK_PARSE_UNSIGNED_INT) && (argType != VTK_PARSE_UNSIGNED_SHORT) && (argType != VTK_PARSE_UNSIGNED_LONG) && (argType != VTK_PARSE_UNSIGNED_LONG_LONG) && (argType != VTK_PARSE_UNSIGNED_ID_TYPE)) { args_ok = 0; } /* don't allow "char []", only allow "char *" */ if (argType == VTK_PARSE_CHAR_PTR && currentFunction->ArgCounts[i] != 0) { args_ok = 0; } } /* check the return type */ returnType = (currentFunction->ReturnType & VTK_PARSE_UNQUALIFIED_TYPE); baseType = (returnType & VTK_PARSE_BASE_TYPE); for (j = 0; supported_types[j] != 0; j++) { if (baseType == supported_types[j]) { break; } } if (supported_types[j] == 0) { args_ok = 0; } if (baseType == VTK_PARSE_STRING && (returnType & VTK_PARSE_INDIRECT) != 0 && (returnType & VTK_PARSE_INDIRECT) != VTK_PARSE_REF) { args_ok = 0; } if (baseType == VTK_PARSE_OBJECT) { if ((returnType & VTK_PARSE_INDIRECT) != VTK_PARSE_POINTER) { args_ok = 0; } else if (!isClassWrapped(currentFunction->ReturnClass)) { args_ok = 0; } } if (((returnType & VTK_PARSE_INDIRECT) != VTK_PARSE_POINTER) && ((returnType & VTK_PARSE_INDIRECT) != VTK_PARSE_REF) && ((returnType & VTK_PARSE_INDIRECT) != 0)) { args_ok = 0; } /* we can't handle void * return types */ if (returnType == VTK_PARSE_VOID_PTR) { args_ok = 0; } /* watch out for functions that dont have enough info */ switch (returnType) { case VTK_PARSE_FLOAT_PTR: case VTK_PARSE_DOUBLE_PTR: case VTK_PARSE_INT_PTR: case VTK_PARSE_SHORT_PTR: case VTK_PARSE_LONG_PTR: case VTK_PARSE_ID_TYPE_PTR: case VTK_PARSE_LONG_LONG_PTR: case VTK_PARSE___INT64_PTR: case VTK_PARSE_SIGNED_CHAR_PTR: case VTK_PARSE_BOOL_PTR: case VTK_PARSE_UNSIGNED_CHAR_PTR: case VTK_PARSE_UNSIGNED_INT_PTR: case VTK_PARSE_UNSIGNED_SHORT_PTR: case VTK_PARSE_UNSIGNED_LONG_PTR: case VTK_PARSE_UNSIGNED_ID_TYPE_PTR: case VTK_PARSE_UNSIGNED_LONG_LONG_PTR: case VTK_PARSE_UNSIGNED___INT64_PTR: args_ok = currentFunction->HaveHint; break; } /* don't allow "char []", only allow "char *" */ if (returnType == VTK_PARSE_CHAR_PTR && currentFunction->HaveHint) { args_ok = 0; } /* check for methods that will be overriden especially for Tcl */ if (!strcmp("vtkObject",data->Name)) { if (!strcmp(currentFunction->Name,"AddObserver")) { args_ok = 0; } } else if (!strcmp("vtkObjectBase",data->Name)) { /* remove the special vtkObjectBase methods */ if (!strcmp(currentFunction->Name,"PrintRevisions") || !strcmp(currentFunction->Name,"Print")) { args_ok = 0; } } return args_ok; }