From 16b82845eee4198b2d56aa5a5c373008f5070f7f Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 17 Mar 2013 18:30:31 +0000 Subject: code cleanup: add 'const' to headers to quiet msvc warnings, also remove (char *) casts that aren't needed now we're on Python3.3 --- source/blender/blenlib/BLI_path_util.h | 12 ++++---- .../blender/python/generic/bpy_internal_import.c | 2 +- source/blender/python/intern/bpy.c | 2 +- source/blender/python/intern/bpy_driver.c | 4 +-- .../blender/python/intern/bpy_interface_atexit.c | 2 +- source/blender/python/intern/bpy_rna.c | 2 +- source/blender/python/mathutils/mathutils_noise.c | 34 +++++++++++----------- .../gameengine/GameLogic/SCA_PythonController.cpp | 2 +- source/gameengine/Ketsji/KX_PolygonMaterial.cpp | 2 +- source/gameengine/Ketsji/KX_PythonInit.cpp | 6 ++-- source/gameengine/Ketsji/KX_PythonInitTypes.cpp | 6 ++-- source/gameengine/VideoTexture/PyTypeList.cpp | 2 +- source/gameengine/VideoTexture/blendVideoTex.cpp | 12 ++++---- 13 files changed, 44 insertions(+), 44 deletions(-) diff --git a/source/blender/blenlib/BLI_path_util.h b/source/blender/blenlib/BLI_path_util.h index 20fc489cbc3..136a51cf55e 100644 --- a/source/blender/blenlib/BLI_path_util.h +++ b/source/blender/blenlib/BLI_path_util.h @@ -86,10 +86,10 @@ void BLI_setenv_if_new(const char *env, const char *val); void BLI_make_file_string(const char *relabase, char *string, const char *dir, const char *file); void BLI_make_exist(char *dir); void BLI_make_existing_file(const char *name); -void BLI_split_dirfile(const char *string, char *dir, char *file, size_t dirlen, size_t filelen); -void BLI_split_dir_part(const char *string, char *dir, size_t dirlen); -void BLI_split_file_part(const char *string, char *file, size_t filelen); -void BLI_join_dirfile(char *string, size_t maxlen, const char *dir, const char *file); +void BLI_split_dirfile(const char *string, char *dir, char *file, const size_t dirlen, const size_t filelen); +void BLI_split_dir_part(const char *string, char *dir, const size_t dirlen); +void BLI_split_file_part(const char *string, char *file, const size_t filelen); +void BLI_join_dirfile(char *string, const size_t maxlen, const char *dir, const char *file); const char *BLI_path_basename(const char *path); typedef enum bli_rebase_state { @@ -105,7 +105,7 @@ int BLI_add_slash(char *string); void BLI_del_slash(char *string); const char *BLI_first_slash(const char *string); -void BLI_getlastdir(const char *dir, char *last, size_t maxlen); +void BLI_getlastdir(const char *dir, char *last, const size_t maxlen); bool BLI_testextensie(const char *str, const char *ext); bool BLI_testextensie_array(const char *str, const char **ext_array); bool BLI_testextensie_glob(const char *str, const char *ext_fnmatch); @@ -117,7 +117,7 @@ bool BLI_uniquename_cb(bool (*unique_check)(void * arg, const char * name), void BLI_newname(char *name, int add); int BLI_stringdec(const char *string, char *head, char *start, unsigned short *numlen); void BLI_stringenc(char *string, const char *head, const char *tail, unsigned short numlen, int pic); -int BLI_split_name_num(char *left, int *nr, const char *name, char delim); +int BLI_split_name_num(char *left, int *nr, const char *name, const char delim); /* make sure path separators conform to system one */ void BLI_clean(char *path) diff --git a/source/blender/python/generic/bpy_internal_import.c b/source/blender/python/generic/bpy_internal_import.c index 0c0ad50ebe4..734d4b6b83f 100644 --- a/source/blender/python/generic/bpy_internal_import.c +++ b/source/blender/python/generic/bpy_internal_import.c @@ -81,7 +81,7 @@ void bpy_import_init(PyObject *builtins) /* move reload here * XXX, use import hooks */ - mod = PyImport_ImportModuleLevel((char *)"imp", NULL, NULL, NULL, 0); + mod = PyImport_ImportModuleLevel("imp", NULL, NULL, NULL, 0); if (mod) { PyObject *mod_dict = PyModule_GetDict(mod); diff --git a/source/blender/python/intern/bpy.c b/source/blender/python/intern/bpy.c index a0e7c4332e1..36fd78db1b7 100644 --- a/source/blender/python/intern/bpy.c +++ b/source/blender/python/intern/bpy.c @@ -222,7 +222,7 @@ static PyMethodDef meth_bpy_resource_path = static PyObject *bpy_import_test(const char *modname) { - PyObject *mod = PyImport_ImportModuleLevel((char *)modname, NULL, NULL, NULL, 0); + PyObject *mod = PyImport_ImportModuleLevel(modname, NULL, NULL, NULL, 0); if (mod) { Py_DECREF(mod); } diff --git a/source/blender/python/intern/bpy_driver.c b/source/blender/python/intern/bpy_driver.c index c49794ad37a..72bfda89b64 100644 --- a/source/blender/python/intern/bpy_driver.c +++ b/source/blender/python/intern/bpy_driver.c @@ -75,14 +75,14 @@ int bpy_pydriver_create_dict(void) } /* add bpy to global namespace */ - mod = PyImport_ImportModuleLevel((char *)"bpy", NULL, NULL, NULL, 0); + mod = PyImport_ImportModuleLevel("bpy", NULL, NULL, NULL, 0); if (mod) { PyDict_SetItemString(bpy_pydriver_Dict, "bpy", mod); Py_DECREF(mod); } /* add noise to global namespace */ - mod = PyImport_ImportModuleLevel((char *)"mathutils", NULL, NULL, NULL, 0); + mod = PyImport_ImportModuleLevel("mathutils", NULL, NULL, NULL, 0); if (mod) { PyObject *modsub = PyDict_GetItemString(PyModule_GetDict(mod), "noise"); PyDict_SetItemString(bpy_pydriver_Dict, "noise", modsub); diff --git a/source/blender/python/intern/bpy_interface_atexit.c b/source/blender/python/intern/bpy_interface_atexit.c index d1d33a01e55..5c4f6ba327c 100644 --- a/source/blender/python/intern/bpy_interface_atexit.c +++ b/source/blender/python/intern/bpy_interface_atexit.c @@ -57,7 +57,7 @@ static void atexit_func_call(const char *func_name, PyObject *atexit_func_arg) * this is intended, but if its problematic it could be changed * - campbell */ - PyObject *atexit_mod = PyImport_ImportModuleLevel((char *)"atexit", NULL, NULL, NULL, 0); + PyObject *atexit_mod = PyImport_ImportModuleLevel("atexit", NULL, NULL, NULL, 0); PyObject *atexit_func = PyObject_GetAttrString(atexit_mod, func_name); PyObject *args = PyTuple_New(1); PyObject *ret; diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c index 0adb5e2e90e..8fe75032a46 100644 --- a/source/blender/python/intern/bpy_rna.c +++ b/source/blender/python/intern/bpy_rna.c @@ -6118,7 +6118,7 @@ static PyObject *pyrna_srna_ExternalType(StructRNA *srna) PyObject *newclass; if (bpy_types_dict == NULL) { - PyObject *bpy_types = PyImport_ImportModuleLevel((char *)"bpy_types", NULL, NULL, NULL, 0); + PyObject *bpy_types = PyImport_ImportModuleLevel("bpy_types", NULL, NULL, NULL, 0); if (bpy_types == NULL) { PyErr_Print(); diff --git a/source/blender/python/mathutils/mathutils_noise.c b/source/blender/python/mathutils/mathutils_noise.c index 4977663038d..31663bd369d 100644 --- a/source/blender/python/mathutils/mathutils_noise.c +++ b/source/blender/python/mathutils/mathutils_noise.c @@ -870,16 +870,16 @@ PyMODINIT_FUNC PyInit_mathutils_noise_types(void) { PyObject *submodule = PyModule_Create(&M_NoiseTypes_module_def); - PyModule_AddIntConstant(submodule, (char *)"BLENDER", TEX_BLENDER); - PyModule_AddIntConstant(submodule, (char *)"STDPERLIN", TEX_STDPERLIN); - PyModule_AddIntConstant(submodule, (char *)"NEWPERLIN", TEX_NEWPERLIN); - PyModule_AddIntConstant(submodule, (char *)"VORONOI_F1", TEX_VORONOI_F1); - PyModule_AddIntConstant(submodule, (char *)"VORONOI_F2", TEX_VORONOI_F2); - PyModule_AddIntConstant(submodule, (char *)"VORONOI_F3", TEX_VORONOI_F3); - PyModule_AddIntConstant(submodule, (char *)"VORONOI_F4", TEX_VORONOI_F4); - PyModule_AddIntConstant(submodule, (char *)"VORONOI_F2F1", TEX_VORONOI_F2F1); - PyModule_AddIntConstant(submodule, (char *)"VORONOI_CRACKLE", TEX_VORONOI_CRACKLE); - PyModule_AddIntConstant(submodule, (char *)"CELLNOISE", TEX_CELLNOISE); + PyModule_AddIntConstant(submodule, "BLENDER", TEX_BLENDER); + PyModule_AddIntConstant(submodule, "STDPERLIN", TEX_STDPERLIN); + PyModule_AddIntConstant(submodule, "NEWPERLIN", TEX_NEWPERLIN); + PyModule_AddIntConstant(submodule, "VORONOI_F1", TEX_VORONOI_F1); + PyModule_AddIntConstant(submodule, "VORONOI_F2", TEX_VORONOI_F2); + PyModule_AddIntConstant(submodule, "VORONOI_F3", TEX_VORONOI_F3); + PyModule_AddIntConstant(submodule, "VORONOI_F4", TEX_VORONOI_F4); + PyModule_AddIntConstant(submodule, "VORONOI_F2F1", TEX_VORONOI_F2F1); + PyModule_AddIntConstant(submodule, "VORONOI_CRACKLE", TEX_VORONOI_CRACKLE); + PyModule_AddIntConstant(submodule, "CELLNOISE", TEX_CELLNOISE); return submodule; } @@ -900,13 +900,13 @@ PyMODINIT_FUNC PyInit_mathutils_noise_metrics(void) { PyObject *submodule = PyModule_Create(&M_NoiseMetrics_module_def); - PyModule_AddIntConstant(submodule, (char *)"DISTANCE", TEX_DISTANCE); - PyModule_AddIntConstant(submodule, (char *)"DISTANCE_SQUARED", TEX_DISTANCE_SQUARED); - PyModule_AddIntConstant(submodule, (char *)"MANHATTAN", TEX_MANHATTAN); - PyModule_AddIntConstant(submodule, (char *)"CHEBYCHEV", TEX_CHEBYCHEV); - PyModule_AddIntConstant(submodule, (char *)"MINKOVSKY_HALF", TEX_MINKOVSKY_HALF); - PyModule_AddIntConstant(submodule, (char *)"MINKOVSKY_FOUR", TEX_MINKOVSKY_FOUR); - PyModule_AddIntConstant(submodule, (char *)"MINKOVSKY", TEX_MINKOVSKY); + PyModule_AddIntConstant(submodule, "DISTANCE", TEX_DISTANCE); + PyModule_AddIntConstant(submodule, "DISTANCE_SQUARED", TEX_DISTANCE_SQUARED); + PyModule_AddIntConstant(submodule, "MANHATTAN", TEX_MANHATTAN); + PyModule_AddIntConstant(submodule, "CHEBYCHEV", TEX_CHEBYCHEV); + PyModule_AddIntConstant(submodule, "MINKOVSKY_HALF", TEX_MINKOVSKY_HALF); + PyModule_AddIntConstant(submodule, "MINKOVSKY_FOUR", TEX_MINKOVSKY_FOUR); + PyModule_AddIntConstant(submodule, "MINKOVSKY", TEX_MINKOVSKY); return submodule; } diff --git a/source/gameengine/GameLogic/SCA_PythonController.cpp b/source/gameengine/GameLogic/SCA_PythonController.cpp index c2b1470ae7a..3a9e8ff0bbc 100644 --- a/source/gameengine/GameLogic/SCA_PythonController.cpp +++ b/source/gameengine/GameLogic/SCA_PythonController.cpp @@ -270,7 +270,7 @@ void SCA_PythonController::ErrorPrint(const char *error_msg) * their user count. Not to mention holding references to wrapped data. * This is especially bad when the PyObject for the wrapped data is freed, after blender * has already dealocated the pointer */ - PySys_SetObject( (char *)"last_traceback", NULL); + PySys_SetObject("last_traceback", NULL); PyErr_Clear(); /* just to be sure */ } diff --git a/source/gameengine/Ketsji/KX_PolygonMaterial.cpp b/source/gameengine/Ketsji/KX_PolygonMaterial.cpp index 5ce370ccdfe..0f53c510cf7 100644 --- a/source/gameengine/Ketsji/KX_PolygonMaterial.cpp +++ b/source/gameengine/Ketsji/KX_PolygonMaterial.cpp @@ -154,7 +154,7 @@ bool KX_PolygonMaterial::Activate(RAS_IRasterizer* rasty, TCachingInfo& cachingI { PyErr_Print(); PyErr_Clear(); - PySys_SetObject( (char *)"last_traceback", NULL); + PySys_SetObject("last_traceback", NULL); } } else diff --git a/source/gameengine/Ketsji/KX_PythonInit.cpp b/source/gameengine/Ketsji/KX_PythonInit.cpp index 22715214324..66333a061c5 100644 --- a/source/gameengine/Ketsji/KX_PythonInit.cpp +++ b/source/gameengine/Ketsji/KX_PythonInit.cpp @@ -1929,14 +1929,14 @@ PyObject *initGamePlayerPythonScripting(const STR_String& progname, TPythonSecur /* mathutils types are used by the BGE even if we don't import them */ { - PyObject *mod= PyImport_ImportModuleLevel((char *)"mathutils", NULL, NULL, NULL, 0); + PyObject *mod = PyImport_ImportModuleLevel("mathutils", NULL, NULL, NULL, 0); Py_DECREF(mod); } #ifdef WITH_AUDASPACE /* accessing a SoundActuator's sound results in a crash if aud is not initialized... */ { - PyObject *mod= PyImport_ImportModuleLevel((char *)"aud", NULL, NULL, NULL, 0); + PyObject *mod = PyImport_ImportModuleLevel("aud", NULL, NULL, NULL, 0); Py_DECREF(mod); } #endif @@ -1993,7 +1993,7 @@ PyObject *initGamePythonScripting(const STR_String& progname, TPythonSecurityLev #ifdef WITH_AUDASPACE /* accessing a SoundActuator's sound results in a crash if aud is not initialized... */ { - PyObject *mod= PyImport_ImportModuleLevel((char *)"aud", NULL, NULL, NULL, 0); + PyObject *mod= PyImport_ImportModuleLevel("aud", NULL, NULL, NULL, 0); Py_DECREF(mod); } #endif diff --git a/source/gameengine/Ketsji/KX_PythonInitTypes.cpp b/source/gameengine/Ketsji/KX_PythonInitTypes.cpp index c6aa436537a..05bdb3463a6 100644 --- a/source/gameengine/Ketsji/KX_PythonInitTypes.cpp +++ b/source/gameengine/Ketsji/KX_PythonInitTypes.cpp @@ -172,9 +172,9 @@ void initPyTypes(void) */ /* For now just do PyType_Ready */ - PyObject *mod= PyModule_New("GameTypes"); - PyObject *dict= PyModule_GetDict(mod); - PyDict_SetItemString(PySys_GetObject((char *)"modules"), (char *)"GameTypes", mod); + PyObject *mod = PyModule_New("GameTypes"); + PyObject *dict = PyModule_GetDict(mod); + PyDict_SetItemString(PySys_GetObject("modules"), "GameTypes", mod); Py_DECREF(mod); diff --git a/source/gameengine/VideoTexture/PyTypeList.cpp b/source/gameengine/VideoTexture/PyTypeList.cpp index 96ac1cc5b6b..99e9ae13e64 100644 --- a/source/gameengine/VideoTexture/PyTypeList.cpp +++ b/source/gameengine/VideoTexture/PyTypeList.cpp @@ -92,6 +92,6 @@ void PyTypeList::reg(PyObject *module) // increase ref count Py_INCREF((*it)->getType()); // add type to module - PyModule_AddObject(module, (char*)(*it)->getName(), (PyObject *)(*it)->getType()); + PyModule_AddObject(module, (*it)->getName(), (PyObject *)(*it)->getType()); } } diff --git a/source/gameengine/VideoTexture/blendVideoTex.cpp b/source/gameengine/VideoTexture/blendVideoTex.cpp index 72415026bb9..e23bd1a3231 100644 --- a/source/gameengine/VideoTexture/blendVideoTex.cpp +++ b/source/gameengine/VideoTexture/blendVideoTex.cpp @@ -214,12 +214,12 @@ PyObject *initVideoTexture(void) pyFilterTypes.reg(m); Py_INCREF(&TextureType); - PyModule_AddObject(m, (char*)"Texture", (PyObject *)&TextureType); - PyModule_AddIntConstant(m, (char*)"SOURCE_ERROR", SourceError); - PyModule_AddIntConstant(m, (char*)"SOURCE_EMPTY", SourceEmpty); - PyModule_AddIntConstant(m, (char*)"SOURCE_READY", SourceReady); - PyModule_AddIntConstant(m, (char*)"SOURCE_PLAYING", SourcePlaying); - PyModule_AddIntConstant(m, (char*)"SOURCE_STOPPED", SourceStopped); + PyModule_AddObject(m, "Texture", (PyObject *)&TextureType); + PyModule_AddIntConstant(m, "SOURCE_ERROR", SourceError); + PyModule_AddIntConstant(m, "SOURCE_EMPTY", SourceEmpty); + PyModule_AddIntConstant(m, "SOURCE_READY", SourceReady); + PyModule_AddIntConstant(m, "SOURCE_PLAYING", SourcePlaying); + PyModule_AddIntConstant(m, "SOURCE_STOPPED", SourceStopped); // init last error description Exception::m_lastError = ""; -- cgit v1.2.3