Create the main wrapper module.
67 {
69 std::ofstream fs;
70 if(!openFileStream(fs, fileName)){return false;}
72 fs << "\n";
73
74
75
76
77 fs << "\n";
78 fs << "#include <Python.h>\n";
79 fs << "#include \"structmember.h\"\n";
80
81 fs << "\n";
82 fs << "#include <string>\n";
83 fs << "#include <iostream>\n";
84
86 fs <<
"#include \"" << config.
getFileName().getFileName().eraseExtension() <<
"_wrapper.h\"\n";
87 }
88 fs << "\n";
89
90
91 fs << "static PyMethodDef _"+moduleName+"_methods[] = {\n";
92 fs << "\t{NULL, NULL}\n";
93 fs << "};\n\n";
94
95 fs << "static PyModuleDef _"+moduleName+"_module = {\n";
96 fs << "\tPyModuleDef_HEAD_INIT,\n";
97 fs << "\t\""+moduleName+"\",\n";
98 fs << "\t\"\",\n";
99 fs << "\t-1,\n";
100 fs << "\t_"+moduleName+"_methods,\n";
101 fs << "\tNULL,\n";
102 fs << "\tNULL,\n";
103 fs << "\tNULL,\n";
104 fs << "\tNULL\n";
105 fs << "};\n\n";
106
107 fs << "///Create the python module "+moduleName+"\n";
108 fs << "/**\t@return python module "+moduleName+"\n";
109 fs << "*/\n";
110 fs << "PyMODINIT_FUNC PyInit_"+moduleName+"(void){\n";
111
112 fs << "\n";
115 }
116 fs << "\t\n";
117 fs << "\tPyObject * m = PyModule_Create(&_"+moduleName+"_module);\n";
118 fs << "\tif(m == NULL){\n";
119 fs << "\t\treturn NULL;\n";
120 fs << "\t}\n";
121 fs << "\t\n";
124 }
125 fs << "\t\n";
128 }
129 fs << "\t\n";
130 fs << "\treturn m;\n";
131 fs << "}\n\n";
132 fs.close();
133 return true;
134}
Class to describe a basic class.
const PVecClassConfig & getVecClassConfig() const
Get the vector of all config class of the current pdata file.
const PPath & getFileName() const
Get the file name of the current PDataConfig.
PString moduleName
Name of the wrapper python module.
GeneratorMode mode
Mode to be used to generate the project.
PVecDataConfig vecDataConfig
Configuration of classes to be generated.
void project_wrapper_modulePyTypeReady(std::ofstream &fs, const PVecClassConfig &vecClassConfig)
Create the PyType_Ready for all classes of the module.
void project_wrapper_moduleAddObject(std::ofstream &fs, const PVecClassConfig &vecClassConfig)
Create the Py_INCREF for all classes of the module.
void project_wrapper_modulePyIncref(std::ofstream &fs, const PVecClassConfig &vecClassConfig)
Create the Py_INCREF for all classes of the module.