8 /* warning this code is also in getclasses.cxx under pcmaker */
13 for (i = 0; i < anindex; i++)
15 fprintf(stdout,"extern \"C\" { PyObject *PyVTKClass_%sNew(char *); }\n",
19 fprintf(stdout,"\nstatic PyMethodDef Py%s_ClassMethods[] = {\n",
21 fprintf(stdout,"{NULL, NULL}};\n\n");
23 fprintf(stdout,"extern \"C\" { void init%s();}\n\n",kitName);
25 /* module init function */
26 fprintf(stdout,"void init%s()\n{\n",kitName);
27 fprintf(stdout," PyObject *m, *d, *c;\n\n");
28 fprintf(stdout," static char modulename[] = \"%s\";\n",kitName);
29 fprintf(stdout," m = Py_InitModule(modulename, Py%s_ClassMethods);\n",
32 fprintf(stdout," d = PyModule_GetDict(m);\n");
33 fprintf(stdout," if (!d) Py_FatalError(\"can't get dictionary for module %s!\");\n\n",
36 for (i = 0; i < anindex; i++)
38 fprintf(stdout," if ((c = PyVTKClass_%sNew(modulename)))\n",names[i]);
39 fprintf(stdout," if (-1 == PyDict_SetItemString(d, \"%s\", c))\n",
41 fprintf(stdout," Py_FatalError(\"can't add class %s to dictionary!\");\n\n",
44 fprintf(stdout,"}\n\n");
47 int main(int argc,char *argv[])
55 fprintf(stderr,"Usage: %s kit_name file1 file2 file3 ...\n",argv[0]);
59 kitName = strdup(argv[1]);
61 /* fill in the correct arrays */
62 for (i = 2, j = 0; i < argc; i++)
65 strcpy(tmp+strlen(tmp)-2,"Python.cxx");
66 file = fopen(tmp,"r");
72 if (strcmp(tmp,"// python wrapper for") != 0)
76 /* remove the .h and store */
77 names[j] = strdup(argv[i]);
78 names[j++][strlen(argv[i])-2] = '\0';
82 fprintf(stdout,"#include <string.h>\n");
83 fprintf(stdout,"#include \"Python.h\"\n\n");