Changeset View
Changeset View
Standalone View
Standalone View
source/gameengine/Ketsji/KX_PythonInit.cpp
| Context not available. | |||||
| #include "BKE_global.h" | #include "BKE_global.h" | ||||
| #include "BKE_library.h" | #include "BKE_library.h" | ||||
| #include "BKE_appdir.h" | #include "BKE_appdir.h" | ||||
| #include "BKE_blender.h" | |||||
| #include "BLI_blenlib.h" | #include "BLI_blenlib.h" | ||||
| #include "GPU_material.h" | #include "GPU_material.h" | ||||
| #include "MEM_guardedalloc.h" | #include "MEM_guardedalloc.h" | ||||
| Context not available. | |||||
| PyObject *sys_modules = PyThreadState_GET()->interp->modules; | PyObject *sys_modules = PyThreadState_GET()->interp->modules; | ||||
| mod = PyModule_Create(&BGE_module_def); | mod = PyModule_Create(&BGE_module_def); | ||||
| PyModule_AddObject(mod, "app", (submodule = initApplicationPythonBinding())); | |||||
campbellbarton: these lines changed in master. (trivial to update) | |||||
campbellbartonUnsubmitted Not Done Inline ActionsThis still needs updating to match master. campbellbarton: This still needs updating to match master. | |||||
MatpiAuthorUnsubmitted Not Done Inline ActionsWill be done, sorry. Matpi: Will be done, sorry. | |||||
| PyDict_SetItemString(sys_modules, PyModule_GetName(submodule), submodule); | |||||
| Py_INCREF(submodule); | |||||
| PyModule_AddObject(mod, "constraints", (submodule = initConstraintPythonBinding())); | PyModule_AddObject(mod, "constraints", (submodule = initConstraintPythonBinding())); | ||||
| PyDict_SetItemString(sys_modules, PyModule_GetName(submodule), submodule); | PyDict_SetItemString(sys_modules, PyModule_GetName(submodule), submodule); | ||||
| Py_INCREF(submodule); | Py_INCREF(submodule); | ||||
| Context not available. | |||||
| return m; | return m; | ||||
| } | } | ||||
| /* ------------------------------------------------------------------------- */ | |||||
| /* Application: application values that remain unchanged during runtime */ | |||||
| /* ------------------------------------------------------------------------- */ | |||||
| PyDoc_STRVAR(Application_module_documentation, | |||||
| "This module contains application values that remain unchanged during runtime." | |||||
| ); | |||||
| static struct PyModuleDef Application_module_def = { | |||||
| PyModuleDef_HEAD_INIT, | |||||
| "Application", /* m_name */ | |||||
campbellbartonUnsubmitted Not Done Inline Actionsshould be "bpy.app" campbellbarton: should be "bpy.app" | |||||
MatpiAuthorUnsubmitted Not Done Inline ActionsNo, "bge.app". ;-) Matpi: No, "bge.app". ;-) | |||||
| Application_module_documentation, /* m_doc */ | |||||
| 0, /* m_size */ | |||||
| NULL, /* m_methods */ | |||||
| 0, /* m_reload */ | |||||
| 0, /* m_traverse */ | |||||
| 0, /* m_clear */ | |||||
| 0, /* m_free */ | |||||
| }; | |||||
| PyMODINIT_FUNC initApplicationPythonBinding() | |||||
| { | |||||
| PyObject *m; | |||||
| PyObject *d; | |||||
| m = PyModule_Create(&Application_module_def); | |||||
| PyDict_SetItemString(PySys_GetObject("modules"), Application_module_def.m_name, m); | |||||
campbellbartonUnsubmitted Not Done Inline ActionsThis is left over from old days where we could do import GameLogic This line allows for import Application But I think we should only have access via bpy.app campbellbarton: This is left over from old days where we could do `import GameLogic`
This line allows for… | |||||
MatpiAuthorUnsubmitted Not Done Inline ActionsDidn't know this was not meant to be kept as a feature. Will update. Matpi: Didn't know this was not meant to be kept as a feature. Will update. | |||||
| // Add some symbolic constants to the module | |||||
| d = PyModule_GetDict(m); | |||||
| PyDict_SetItemString(d, "version", Py_BuildValue("(iii)", | |||||
| BLENDER_VERSION / 100, BLENDER_VERSION % 100, BLENDER_SUBVERSION)); | |||||
| PyDict_SetItemString(d, "version_string", PyUnicode_FromFormat("%d.%02d (sub %d)", | |||||
| BLENDER_VERSION / 100, BLENDER_VERSION % 100, BLENDER_SUBVERSION)); | |||||
| PyDict_SetItemString(d, "version_char", PyUnicode_FromString( | |||||
| STRINGIFY(BLENDER_VERSION_CHAR))); | |||||
| PyDict_SetItemString(d, "has_texture_ffmpeg", | |||||
| #ifdef WITH_FFMPEG | |||||
| Py_True | |||||
| #else | |||||
| Py_False | |||||
| #endif | |||||
| ); | |||||
| PyDict_SetItemString(d, "has_joystick", | |||||
| #ifdef WITH_SDL | |||||
| Py_True | |||||
| #else | |||||
| Py_False | |||||
| #endif | |||||
| ); | |||||
| PyDict_SetItemString(d, "has_physics", | |||||
| #ifdef WITH_BULLET | |||||
| Py_True | |||||
| #else | |||||
| Py_False | |||||
| #endif | |||||
| ); | |||||
| // Check for errors | |||||
Not Done Inline Actionssuggest has_ prefix for compile time options. campbellbarton: suggest `has_` prefix for compile time options. | |||||
| if (PyErr_Occurred()) | |||||
campbellbartonUnsubmitted Not Done Inline Actionsstyle. campbellbarton: style. | |||||
MatpiAuthorUnsubmitted Not Done Inline ActionsSorry, don't get what's wrong with it? Matpi: Sorry, don't get what's wrong with it? | |||||
| { | |||||
| Py_FatalError("can't initialize module Application"); | |||||
| } | |||||
| return m; | |||||
| } | |||||
| // utility function for loading and saving the globalDict | // utility function for loading and saving the globalDict | ||||
| int saveGamePythonConfig( char **marshal_buffer) | int saveGamePythonConfig( char **marshal_buffer) | ||||
| { | { | ||||
| Context not available. | |||||
these lines changed in master. (trivial to update)