PhoenixGenerator  2.0.4
Set of tools to generate code
Loading...
Searching...
No Matches
wrapper_generator_module.h File Reference
#include "ProjectParam.h"
+ Include dependency graph for wrapper_generator_module.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

bool project_wrapper_moduleGeneratorMain (const PPath &fileName, const ProjectParam &projectParam)
 Create the main wrapper module.
 

Function Documentation

◆ project_wrapper_moduleGeneratorMain()

bool project_wrapper_moduleGeneratorMain ( const PPath & fileName,
const ProjectParam & projectParam )

Create the main wrapper module.

Parameters
fileName: path of the module
projectParam: config of the project
Returns
true on success, false otherwise

Definition at line 67 of file wrapper_generator_module.cpp.

67 {
68 PString moduleName(projectParam.mode.moduleName);
69 std::ofstream fs;
70 if(!openFileStream(fs, fileName)){return false;}
71 licenceSave(fs);
72 fs << "\n";
73// fs << "#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION\n";
74// fs << "#ifndef DISABLE_COOL_ARRAY\n";
75// fs << "#\tdefine PY_ARRAY_UNIQUE_SYMBOL "+moduleName+"_ARRAY_API\n";
76// fs << "#endif\n";
77 fs << "\n";
78 fs << "#include <Python.h>\n";
79 fs << "#include \"structmember.h\"\n";
80// fs << "#include <numpy/arrayobject.h>\n";
81 fs << "\n";
82 fs << "#include <string>\n";
83 fs << "#include <iostream>\n";
84 //TODO : put the includes of all class definitions
85 for(const PDataConfig & config : projectParam.vecDataConfig){
86 fs << "#include \"" << config.getFileName().getFileName().eraseExtension() <<"_wrapper.h\"\n";
87 }
88 fs << "\n";
89// fs << "#include \""+ baseImplInclude + "_wrapper.h\"\n\n";
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// fs << "\timport_array();\n"; //For numpy stuff
112 fs << "\n";
113 for(const PDataConfig & config : projectParam.vecDataConfig){
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";
122 for(const PDataConfig & config : projectParam.vecDataConfig){
124 }
125 fs << "\t\n";
126 for(const PDataConfig & config : projectParam.vecDataConfig){
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.
Definition PDataConfig.h:17
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.
void licenceSave(std::ofstream &fs)
Saves the policy.
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.

References PDataConfig::getFileName(), PDataConfig::getVecClassConfig(), licenceSave(), ProjectParam::mode, GeneratorMode::moduleName, project_wrapper_moduleAddObject(), project_wrapper_modulePyIncref(), project_wrapper_modulePyTypeReady(), and ProjectParam::vecDataConfig.

Referenced by wrapper_generator_class_full().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: