Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorInes Almeida <britalmeida@gmail.com>2015-01-12 22:10:07 +0300
committerInes Almeida <britalmeida@gmail.com>2015-02-03 18:32:55 +0300
commit0e0af4f77222002ddf029095ca36fea71c9ab049 (patch)
tree76fa7a0f267e0c7379d3cd2d1635db5627553d58 /source/gameengine/Ketsji/KX_PythonInitTypes.cpp
parente67bd30bdf9282f01f5bc3c44503aa496127c582 (diff)
BGE: python API cleanup - adding proper initialization to GameTypes
Diffstat (limited to 'source/gameengine/Ketsji/KX_PythonInitTypes.cpp')
-rw-r--r--source/gameengine/Ketsji/KX_PythonInitTypes.cpp42
1 files changed, 41 insertions, 1 deletions
diff --git a/source/gameengine/Ketsji/KX_PythonInitTypes.cpp b/source/gameengine/Ketsji/KX_PythonInitTypes.cpp
index 7d38ce58eee..5c1ad56147e 100644
--- a/source/gameengine/Ketsji/KX_PythonInitTypes.cpp
+++ b/source/gameengine/Ketsji/KX_PythonInitTypes.cpp
@@ -171,8 +171,10 @@ void initPyTypes(void)
* .....
*/
+ /* Use existing module where possible */
+ PyObject *mod = initGameTypesPythonBinding();
+
/* For now just do PyType_Ready */
- PyObject *mod = PyModule_New("GameTypes");
PyObject *dict = PyModule_GetDict(mod);
PyDict_SetItemString(PySys_GetObject("modules"), "GameTypes", mod);
Py_DECREF(mod);
@@ -269,4 +271,42 @@ void initPyTypes(void)
#endif
}
+
+PyDoc_STRVAR(GameTypes_module_documentation,
+"This module provides access to the game engine data types."
+);
+static struct PyModuleDef GameTypes_module_def = {
+ PyModuleDef_HEAD_INIT,
+ "GameTypes", /* m_name */
+ GameTypes_module_documentation, /* m_doc */
+ 0, /* m_size */
+ NULL, /* m_methods */
+ NULL, /* m_reload */
+ NULL, /* m_traverse */
+ NULL, /* m_clear */
+ NULL, /* m_free */
+};
+
+
+PyMODINIT_FUNC initGameTypesPythonBinding(void)
+{
+ PyObject *m;
+
+ /* Use existing module where possible */
+ m = PyImport_ImportModule( "GameTypes" );
+ if (m) {
+ Py_DECREF(m);
+ return m;
+ }
+ else {
+ PyErr_Clear();
+
+ // Create the module and add the functions
+ m = PyModule_Create(&GameTypes_module_def);
+ PyDict_SetItemString(PySys_GetObject("modules"), GameTypes_module_def.m_name, m);
+ }
+
+ return m;
+}
+
#endif // WITH_PYTHON