diff options
author | Ines Almeida <britalmeida@gmail.com> | 2014-06-04 12:17:52 +0400 |
---|---|---|
committer | Ines Almeida <britalmeida@gmail.com> | 2015-02-03 18:32:54 +0300 |
commit | 95425bc97a9d07bbb5e2396d12ffdbf3d9400d04 (patch) | |
tree | d85ef185f2b4cf59fa87e8a6c582547d1d5a4be8 /source/gameengine/Ketsji | |
parent | c48c20b498d97cd4b9d31d040872fac82f0f70aa (diff) |
BGE: python API initialization cleanup
-Removing unused parameters
-Updating some parts to match bpy_interface.c initialization
Cherry-picking 14fceb6 onto 117edbb
Conflicts:
source/gameengine/Ketsji/KX_PythonInit.cpp
Diffstat (limited to 'source/gameengine/Ketsji')
-rw-r--r-- | source/gameengine/Ketsji/KX_PythonInit.cpp | 32 | ||||
-rw-r--r-- | source/gameengine/Ketsji/KX_PythonInit.h | 7 |
2 files changed, 21 insertions, 18 deletions
diff --git a/source/gameengine/Ketsji/KX_PythonInit.cpp b/source/gameengine/Ketsji/KX_PythonInit.cpp index 348b84e8cf3..7819eb7c518 100644 --- a/source/gameengine/Ketsji/KX_PythonInit.cpp +++ b/source/gameengine/Ketsji/KX_PythonInit.cpp @@ -2082,7 +2082,7 @@ static struct _inittab bge_internal_modules[] = { * Python is not initialized. * see bpy_interface.c's BPY_python_start() which shares the same functionality in blender. */ -PyObject *initGamePlayerPythonScripting(const STR_String& progname, TPythonSecurityLevel level, Main *maggie, int argc, char** argv) +PyObject *initGamePlayerPythonScripting(Main *maggie, int argc, char** argv) { /* Yet another gotcha in the py api * Cant run PySys_SetArgv more than once because this adds the @@ -2093,14 +2093,20 @@ PyObject *initGamePlayerPythonScripting(const STR_String& progname, TPythonSecur static bool first_time = true; const char * const py_path_bundle = BKE_appdir_folder_id(BLENDER_SYSTEM_PYTHON, NULL); -#if 0 // TODO - py3 - STR_String pname = progname; - Py_SetProgramName(pname.Ptr()); -#endif + /* not essential but nice to set our name */ + static wchar_t program_path_wchar[FILE_MAX]; /* python holds a reference */ + BLI_strncpy_wchar_from_utf8(program_path_wchar, BLI_program_path(), sizeof(program_path_wchar) / sizeof(wchar_t)); + Py_SetProgramName(program_path_wchar); + /* Update, Py3.3 resolves attempting to parse non-existing header */ + #if 0 + /* Python 3.2 now looks for '2.xx/python/include/python3.2d/pyconfig.h' to + * parse from the 'sysconfig' module which is used by 'site', + * so for now disable site. alternatively we could copy the file. */ if (py_path_bundle != NULL) { Py_NoSiteFlag = 1; } + #endif Py_FrozenFlag = 1; @@ -2186,12 +2192,12 @@ void exitGamePlayerPythonScripting() /** * Python is already initialized. */ -PyObject *initGamePythonScripting(const STR_String& progname, TPythonSecurityLevel level, Main *maggie) +PyObject *initGamePythonScripting(Main *maggie) { -#if 0 // XXX TODO Py3 - STR_String pname = progname; - Py_SetProgramName(pname.Ptr()); -#endif + /* not essential but nice to set our name */ + static wchar_t program_path_wchar[FILE_MAX]; /* python holds a reference */ + BLI_strncpy_wchar_from_utf8(program_path_wchar, BLI_program_path(), sizeof(program_path_wchar) / sizeof(wchar_t)); + Py_SetProgramName(program_path_wchar); #ifdef WITH_AUDASPACE /* accessing a SoundActuator's sound results in a crash if aud is not initialized... */ @@ -2241,9 +2247,9 @@ void setupGamePython(KX_KetsjiEngine* ketsjiengine, KX_Scene *startscene, Main * PyObject *dictionaryobject; if (argv) /* player only */ - dictionaryobject= initGamePlayerPythonScripting("Ketsji", psl_Lowest, blenderdata, argc, argv); + dictionaryobject= initGamePlayerPythonScripting(blenderdata, argc, argv); else - dictionaryobject= initGamePythonScripting("Ketsji", psl_Lowest, blenderdata); + dictionaryobject= initGamePythonScripting(blenderdata); ketsjiengine->SetPyNamespace(dictionaryobject); initRasterizer(ketsjiengine->GetRasterizer(), ketsjiengine->GetCanvas()); @@ -2297,8 +2303,6 @@ PyObject *initRasterizer(RAS_IRasterizer* rasty,RAS_ICanvas* canvas) { gp_Canvas = canvas; gp_Rasterizer = rasty; - - PyObject *m; PyObject *d; diff --git a/source/gameengine/Ketsji/KX_PythonInit.h b/source/gameengine/Ketsji/KX_PythonInit.h index 719a74ee219..e9c94a05b3d 100644 --- a/source/gameengine/Ketsji/KX_PythonInit.h +++ b/source/gameengine/Ketsji/KX_PythonInit.h @@ -47,10 +47,9 @@ extern bool gUseVisibilityTemp; PyObject *initGameLogic(class KX_KetsjiEngine *engine, class KX_Scene *ketsjiscene); PyObject *initGameKeys(); PyObject *initRasterizer(class RAS_IRasterizer *rasty,class RAS_ICanvas *canvas); -PyObject *initGamePlayerPythonScripting(const STR_String &progname, TPythonSecurityLevel level, - struct Main *maggie, int argc, char **argv); -PyObject *initVideoTexture(void); -PyObject *initGamePythonScripting(const STR_String &progname, TPythonSecurityLevel level, struct Main *maggie); +PyObject *initVideoTexture(void); +PyObject *initGamePlayerPythonScripting(struct Main *maggie, int argc, char **argv); +PyObject *initGamePythonScripting(struct Main *maggie); void exitGamePlayerPythonScripting(); void exitGamePythonScripting(); |