/* convert C++ identifier to a valid python identifier by mangling */ void vtkWrapText_PythonName(const char *name, char *pname) { size_t j = 0; size_t i; size_t l; char *cp; int scoped = 0; /* look for first char that is not alphanumeric or underscore */ l = vtkParse_IdentifierLength(name); if (name[l] != '\0') { /* get the mangled name */ vtkParse_MangledTypeName(name, pname); /* put dots after namespaces */ i = 0; cp = pname; if (cp[0] == 'S' && cp[1] >= 'a' && cp[1] <= 'z') { /* keep std:: namespace abbreviations */ pname[j++] = *cp++; pname[j++] = *cp++; } while (*cp == 'N') { scoped++; cp++; while (*cp >= '0' && *cp <= '9') { i = i*10 + (*cp++ - '0'); } i += j; while (j < i) { pname[j++] = *cp++; } pname[j++] = '.'; } /* remove mangling from first identifier and add an underscore */ i = 0; while (*cp >= '0' && *cp <= '9') { i = i*10 + (*cp++ - '0'); } i += j; while (j < i) { pname[j++] = *cp++; } pname[j++] = '_'; while (*cp != '\0') { pname[j++] = *cp++; } pname[j] = '\0'; } else { strcpy(pname, name); } /* remove the "_E" that is added to mangled scoped names */ if (scoped) { j = strlen(pname); if (j > 2 && pname[j-2] == '_' && pname[j-1] == 'E') { pname[j-2] = '\0'; } } }
/* Get the header file for the specified class */ static const char *vtkWrapPython_ClassHeader( HierarchyInfo *hinfo, const char *classname) { /* to allow special types to be used when "hinfo" is not available * (this is necessary until VTK exports the hierarchy files) */ static const char *headers[][2] = { { "vtkArrayCoordinates", "vtkArrayCoordinates.h" }, { "vtkArrayExtents", "vtkArrayExtents.h" }, { "vtkArrayExtentsList", "vtkArrayExtentsList.h" }, { "vtkArrayRange", "vtkArrayRange.h" }, { "vtkArraySort", "vtkArraySort.h" }, { "vtkArrayWeights", "vtkArrayWeights.h" }, { "vtkAtom", "vtkAtom.h" }, { "vtkBond", "vtkBond.h" }, { "vtkTimeStamp", "vtkTimeStamp.h" }, { "vtkVariant", "vtkVariant.h" }, { "vtkStdString", "vtkStdString.h" }, { "vtkUnicodeString", "vtkUnicodeString.h" }, { "vtkTuple", "vtkVector.h" }, { "vtkVector", "vtkVector.h" }, { "vtkVector2", "vtkVector.h" }, { "vtkVector2i", "vtkVector.h" }, { "vtkVector2f", "vtkVector.h" }, { "vtkVector2d", "vtkVector.h" }, { "vtkVector3", "vtkVector.h" }, { "vtkVector3i", "vtkVector.h" }, { "vtkVector3f", "vtkVector.h" }, { "vtkVector3d", "vtkVector.h" }, { "vtkRect", "vtkRect.h" }, { "vtkRecti", "vtkRect.h" }, { "vtkRectf", "vtkRect.h" }, { "vtkRectd", "vtkRect.h" }, { "vtkColor", "vtkColor.h" }, { "vtkColor3", "vtkColor.h" }, { "vtkColor3ub", "vtkColor.h" }, { "vtkColor3f", "vtkColor.h" }, { "vtkColor3d", "vtkColor.h" }, { "vtkColor4", "vtkColor.h" }, { "vtkColor4ub", "vtkColor.h" }, { "vtkColor4f", "vtkColor.h" }, { "vtkColor4d", "vtkColor.h" }, { "vtkAMRBox", "vtkAMRBox.h" }, { "vtkEdgeBase", "vtkGraph.h" }, { "vtkEdgeType", "vtkGraph.h" }, { "vtkInEdgeType", "vtkGraph.h" }, { "vtkOutEdgeType", "vtkGraph.h" }, { NULL, NULL } }; HierarchyEntry *entry; int i; size_t n; /* if "hinfo" is present, use it to find the file */ if (hinfo) { entry = vtkParseHierarchy_FindEntry(hinfo, classname); if (entry) { return entry->HeaderFile; } } /* otherwise, use the hard-coded entries */ n = vtkParse_IdentifierLength(classname); for (i = 0; headers[i][0]; i++) { if (strlen(headers[i][0]) == n && strncmp(classname, headers[i][0], n) == 0) { return headers[i][1]; } } return 0; }