From 699030ceb698f827fe582bf03a78a44ffc283629 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 27 Oct 2011 14:41:26 +0000 Subject: [PATCH] use const for readonly strings and set some functions to static --- intern/ghost/intern/GHOST_WindowX11.cpp | 27 ------------------- source/blender/blenkernel/BKE_image.h | 2 +- source/blender/blenkernel/intern/image.c | 2 +- source/blender/collada/ArmatureImporter.cpp | 2 +- source/blender/collada/ArmatureImporter.h | 2 +- source/blender/makesdna/intern/makesdna.c | 20 +++++++------- source/blender/makesrna/intern/makesrna.c | 4 +-- .../python/generic/bpy_internal_import.c | 2 +- .../python/generic/bpy_internal_import.h | 2 +- .../blender/render/intern/source/pipeline.c | 2 +- .../Converter/KX_ConvertActuators.cpp | 2 +- .../Converter/KX_ConvertActuators.h | 2 +- .../gameengine/GamePlayer/common/GPC_Engine.h | 4 +-- .../gameengine/Ketsji/KX_CameraActuator.cpp | 2 +- source/gameengine/Ketsji/KX_CameraActuator.h | 2 +- source/gameengine/Ketsji/KX_IpoActuator.cpp | 3 ++- source/gameengine/Ketsji/KX_IpoActuator.h | 2 +- source/gameengine/Ketsji/KX_PythonInit.cpp | 8 +++--- source/gameengine/Ketsji/KX_PythonInit.h | 2 +- source/gameengine/Ketsji/KX_SceneActuator.cpp | 4 +-- source/gameengine/Ketsji/KX_SceneActuator.h | 4 +-- source/gameengine/VideoTexture/Texture.cpp | 2 +- source/gameengine/VideoTexture/Texture.h | 2 +- 23 files changed, 39 insertions(+), 65 deletions(-) diff --git a/intern/ghost/intern/GHOST_WindowX11.cpp b/intern/ghost/intern/GHOST_WindowX11.cpp index 1c729fc0772..c379e4c7e48 100644 --- a/intern/ghost/intern/GHOST_WindowX11.cpp +++ b/intern/ghost/intern/GHOST_WindowX11.cpp @@ -1585,30 +1585,3 @@ setWindowCustomCursorShape( return GHOST_kSuccess; } - -/* - -void glutCustomCursor(char *data1, char *data2, int size) -{ - Pixmap source, mask; - Cursor cursor; - XColor fg, bg; - - if(XAllocNamedColor(__glutDisplay, DefaultColormap(__glutDisplay, __glutScreen), - "White", &fg, &fg) == 0) return; - if(XAllocNamedColor(__glutDisplay, DefaultColormap(__glutDisplay, __glutScreen), - "Red", &bg, &bg) == 0) return; - - - source= XCreateBitmapFromData(__glutDisplay, xdraw, data2, size, size); - mask= XCreateBitmapFromData(__glutDisplay, xdraw, data1, size, size); - - cursor= XCreatePixmapCursor(__glutDisplay, source, mask, &fg, &bg, 7, 7); - - XFreePixmap(__glutDisplay, source); - XFreePixmap(__glutDisplay, mask); - - XDefineCursor(__glutDisplay, xdraw, cursor); -} - -*/ diff --git a/source/blender/blenkernel/BKE_image.h b/source/blender/blenkernel/BKE_image.h index c7e269a3b75..adb34f4c501 100644 --- a/source/blender/blenkernel/BKE_image.h +++ b/source/blender/blenkernel/BKE_image.h @@ -58,7 +58,7 @@ int BKE_ftype_to_imtype(int ftype); int BKE_imtype_to_ftype(int imtype); int BKE_imtype_is_movie(int imtype); -struct anim *openanim(char * name, int flags, int streamindex); +struct anim *openanim(const char *name, int flags, int streamindex); void image_de_interlace(struct Image *ima, int odd); diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index d88cbc33926..8bce7515695 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -1500,7 +1500,7 @@ void BKE_makepicstring(char *string, const char *base, int frame, int imtype, co } /* used by sequencer too */ -struct anim *openanim(char *name, int flags, int streamindex) +struct anim *openanim(const char *name, int flags, int streamindex) { struct anim *anim; struct ImBuf *ibuf; diff --git a/source/blender/collada/ArmatureImporter.cpp b/source/blender/collada/ArmatureImporter.cpp index 219cf47d857..7e9634da21d 100644 --- a/source/blender/collada/ArmatureImporter.cpp +++ b/source/blender/collada/ArmatureImporter.cpp @@ -567,7 +567,7 @@ void ArmatureImporter::create_armature_bones(SkinInfo& skin) // is a child of a node (not joint), root should be true since // this is where we build armature bones from -void ArmatureImporter::set_pose ( Object * ob_arm , COLLADAFW::Node * root_node , char *parentname, float parent_mat[][4]) +void ArmatureImporter::set_pose ( Object * ob_arm , COLLADAFW::Node * root_node , const char *parentname, float parent_mat[][4]) { char * bone_name = (char *) bc_get_joint_name ( root_node); float mat[4][4]; diff --git a/source/blender/collada/ArmatureImporter.h b/source/blender/collada/ArmatureImporter.h index cc8c3de57f0..d2e3b8be4f5 100644 --- a/source/blender/collada/ArmatureImporter.h +++ b/source/blender/collada/ArmatureImporter.h @@ -113,7 +113,7 @@ private: void fix_leaf_bones(); - void set_pose ( Object * ob_arm , COLLADAFW::Node * root_node ,char * parentname, float parent_mat[][4]); + void set_pose ( Object * ob_arm , COLLADAFW::Node * root_node , const char *parentname, float parent_mat[][4]); #if 0 diff --git a/source/blender/makesdna/intern/makesdna.c b/source/blender/makesdna/intern/makesdna.c index 39cb1743c25..a966523d990 100644 --- a/source/blender/makesdna/intern/makesdna.c +++ b/source/blender/makesdna/intern/makesdna.c @@ -168,35 +168,35 @@ static int additional_slen_offset; * \param str char * \param len int */ -int add_type(const char *str, int len); +static int add_type(const char *str, int len); /** * Add variable \c str to * \param str */ -int add_name(char *str); +static int add_name(const char *str); /** * Search whether this structure type was already found, and if not, * add it. */ -short *add_struct(int namecode); +static short *add_struct(int namecode); /** * Remove comments from this buffer. Assumes that the buffer refers to * ascii-code text. */ -int preprocess_include(char *maindata, int len); +static int preprocess_include(char *maindata, int len); /** * Scan this file for serializable types. */ -int convert_include(char *filename); +static int convert_include(char *filename); /** * Determine how many bytes are needed for an array. */ -int arraysize(char *astr, int len); +static int arraysize(char *astr, int len); /** * Determine how many bytes are needed for each struct. @@ -267,12 +267,12 @@ int add_type(const char *str, int len) * cases, unfortunately. These are explicitly checked. * * */ -int add_name(char *str) +static int add_name(const char *str) { int nr, i, j, k; char *cp; char buf[255]; /* stupid limit, change it :) */ - char *name; + const char *name; additional_slen_offset = 0; @@ -422,7 +422,7 @@ short *add_struct(int namecode) return sp; } -int preprocess_include(char *maindata, int len) +static int preprocess_include(char *maindata, int len) { int a, newlen, comment = 0; char *cp, *temp, *md; @@ -1087,7 +1087,7 @@ static int make_structDNA(char *baseDirectory, FILE *file) /* ************************* END MAKE DNA ********************** */ -static void make_bad_file(char *file, int line) +static void make_bad_file(const char *file, int line) { FILE *fp= fopen(file, "w"); fprintf(fp, "#error \"Error! can't make correct DNA.c file from %s:%d, STUPID!\"\n", __FILE__, line); diff --git a/source/blender/makesrna/intern/makesrna.c b/source/blender/makesrna/intern/makesrna.c index d7fb9536587..adedcbb18b3 100644 --- a/source/blender/makesrna/intern/makesrna.c +++ b/source/blender/makesrna/intern/makesrna.c @@ -2768,14 +2768,14 @@ static void rna_generate_header_cpp(BlenderRNA *brna, FILE *f) fprintf(f, "}\n\n#endif /* __RNA_BLENDER_CPP_H__ */\n\n"); } -static void make_bad_file(char *file, int line) +static void make_bad_file(const char *file, int line) { FILE *fp= fopen(file, "w"); fprintf(fp, "#error \"Error! can't make correct RNA file from %s:%d, STUPID!\"\n", __FILE__, line); fclose(fp); } -static int rna_preprocess(char *outfile) +static int rna_preprocess(const char *outfile) { BlenderRNA *brna; StructDefRNA *ds; diff --git a/source/blender/python/generic/bpy_internal_import.c b/source/blender/python/generic/bpy_internal_import.c index ac54cef7d4d..293ade35584 100644 --- a/source/blender/python/generic/bpy_internal_import.c +++ b/source/blender/python/generic/bpy_internal_import.c @@ -124,7 +124,7 @@ PyObject *bpy_text_import(Text *text) return PyImport_ExecCodeModule(modulename, text->compiled); } -PyObject *bpy_text_import_name(char *name, int *found) +PyObject *bpy_text_import_name(const char *name, int *found) { Text *text; char txtname[MAX_ID_NAME-2]; diff --git a/source/blender/python/generic/bpy_internal_import.h b/source/blender/python/generic/bpy_internal_import.h index 8bc10234a9b..2ce644715e9 100644 --- a/source/blender/python/generic/bpy_internal_import.h +++ b/source/blender/python/generic/bpy_internal_import.h @@ -49,7 +49,7 @@ struct Text; void bpy_import_init(PyObject *builtins); PyObject* bpy_text_import(struct Text *text); -PyObject* bpy_text_import_name(char *name, int *found); +PyObject* bpy_text_import_name(const char *name, int *found); PyObject* bpy_text_reimport(PyObject *module, int *found); /* void bpy_text_clear_modules(int clear_all);*/ /* Clear user modules */ diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c index bbe32765443..64b36c1fd12 100644 --- a/source/blender/render/intern/source/pipeline.c +++ b/source/blender/render/intern/source/pipeline.c @@ -405,7 +405,7 @@ static const char *get_pass_name(int passtype, int channel) return "Unknown"; } -static int passtype_from_name(char *str) +static int passtype_from_name(const char *str) { if(strcmp(str, "Combined")==0) diff --git a/source/gameengine/Converter/KX_ConvertActuators.cpp b/source/gameengine/Converter/KX_ConvertActuators.cpp index 6e9c51eaa83..f4b173763d3 100644 --- a/source/gameengine/Converter/KX_ConvertActuators.cpp +++ b/source/gameengine/Converter/KX_ConvertActuators.cpp @@ -111,7 +111,7 @@ KX_BLENDERTRUNC needed to round 'almost' zero values to zero, else velocities et #define KX_BLENDERTRUNC(x) (( x < 0.0001 && x > -0.0001 ) ? 0.0 : x) -void BL_ConvertActuators(char* maggiename, +void BL_ConvertActuators(const char* maggiename, struct Object* blenderobject, KX_GameObject* gameobj, SCA_LogicManager* logicmgr, diff --git a/source/gameengine/Converter/KX_ConvertActuators.h b/source/gameengine/Converter/KX_ConvertActuators.h index e1c1d22337c..836bcd860fa 100644 --- a/source/gameengine/Converter/KX_ConvertActuators.h +++ b/source/gameengine/Converter/KX_ConvertActuators.h @@ -32,7 +32,7 @@ #ifndef __KX_CONVERTACTUATORS_H #define __KX_CONVERTACTUATORS_H -void BL_ConvertActuators(char* maggiename, +void BL_ConvertActuators(const char* maggiename, struct Object* blenderobject, class KX_GameObject* gameobj, class SCA_LogicManager* logicmgr, diff --git a/source/gameengine/GamePlayer/common/GPC_Engine.h b/source/gameengine/GamePlayer/common/GPC_Engine.h index 5df8834dbae..70e5a3ee631 100644 --- a/source/gameengine/GamePlayer/common/GPC_Engine.h +++ b/source/gameengine/GamePlayer/common/GPC_Engine.h @@ -102,9 +102,9 @@ public: // Initialize() functions are not put here since they have // different prototypes for Unix and Windows void StartLoadingAnimation(); - bool Start(char *filename); // file-on-disk starter + bool Start(const char *filename); // file-on-disk starter bool Start(unsigned char *blenderDataBuffer, - unsigned int blenderDataBufferSize); // file-in-memory starter + unsigned int blenderDataBufferSize); // file-in-memory starter void Stop(); virtual void Exit(); diff --git a/source/gameengine/Ketsji/KX_CameraActuator.cpp b/source/gameengine/Ketsji/KX_CameraActuator.cpp index 47c10439f02..d4aae68dafb 100644 --- a/source/gameengine/Ketsji/KX_CameraActuator.cpp +++ b/source/gameengine/Ketsji/KX_CameraActuator.cpp @@ -346,7 +346,7 @@ bool KX_CameraActuator::Update(double curtime, bool frame) return true; } -CValue *KX_CameraActuator::findObject(char *obName) +CValue *KX_CameraActuator::findObject(const char *obName) { /* hook to object system */ return NULL; diff --git a/source/gameengine/Ketsji/KX_CameraActuator.h b/source/gameengine/Ketsji/KX_CameraActuator.h index 5c2535f9c3d..c06904ea56b 100644 --- a/source/gameengine/Ketsji/KX_CameraActuator.h +++ b/source/gameengine/Ketsji/KX_CameraActuator.h @@ -77,7 +77,7 @@ private : float m_damping; /* get the KX_IGameObject with this name */ - CValue *findObject(char *obName); + CValue *findObject(const char *obName); /* parse x or y to a toggle pick */ bool string2axischoice(const char *axisString); diff --git a/source/gameengine/Ketsji/KX_IpoActuator.cpp b/source/gameengine/Ketsji/KX_IpoActuator.cpp index 563ceba1d64..878bdcedfda 100644 --- a/source/gameengine/Ketsji/KX_IpoActuator.cpp +++ b/source/gameengine/Ketsji/KX_IpoActuator.cpp @@ -382,7 +382,8 @@ void KX_IpoActuator::ResetStartTime() this->m_starttime = -2.0*fabs(this->m_endframe - this->m_startframe) - 1.0; } -int KX_IpoActuator::string2mode(char* modename) { +int KX_IpoActuator::string2mode(const char *modename) +{ IpoActType res = KX_ACT_IPO_NODEF; if (strcmp(modename, S_KX_ACT_IPO_PLAY_STRING)==0) { diff --git a/source/gameengine/Ketsji/KX_IpoActuator.h b/source/gameengine/Ketsji/KX_IpoActuator.h index e9820fa0eeb..5ee008ac5e3 100644 --- a/source/gameengine/Ketsji/KX_IpoActuator.h +++ b/source/gameengine/Ketsji/KX_IpoActuator.h @@ -118,7 +118,7 @@ public: static const char *S_KX_ACT_IPO_KEY2KEY_STRING; static const char *S_KX_ACT_IPO_FROM_PROP_STRING; - int string2mode(char* modename); + int string2mode(const char *modename); int m_type; diff --git a/source/gameengine/Ketsji/KX_PythonInit.cpp b/source/gameengine/Ketsji/KX_PythonInit.cpp index 2f7b0c06dcd..25145e87b78 100644 --- a/source/gameengine/Ketsji/KX_PythonInit.cpp +++ b/source/gameengine/Ketsji/KX_PythonInit.cpp @@ -1089,7 +1089,7 @@ static PyObject* gPyDisableMotionBlur(PyObject*) Py_RETURN_NONE; } -int getGLSLSettingFlag(char *setting) +static int getGLSLSettingFlag(const char *setting) { if(strcmp(setting, "lights") == 0) return GAME_GLSL_NO_LIGHTS; @@ -1725,7 +1725,7 @@ static void backupPySysObjects(void) * * "/home/me/foo.blend" -> "/home/me/scripts" */ -static void initPySysObjects__append(PyObject *sys_path, char *filename) +static void initPySysObjects__append(PyObject *sys_path, const char *filename) { PyObject *item; char expanded[FILE_MAXDIR + FILE_MAXFILE]; @@ -2325,7 +2325,7 @@ int loadGamePythonConfig(char *marshal_buffer, int marshal_length) return 0; } -void pathGamePythonConfig( char *path ) +void pathGamePythonConfig(char *path) { int len = strlen(gp_GamePythonPathOrig); // Always use the first loaded blend filename @@ -2339,7 +2339,7 @@ void pathGamePythonConfig( char *path ) } } -void setGamePythonPath(char *path) +void setGamePythonPath(const char *path) { BLI_strncpy(gp_GamePythonPath, path, sizeof(gp_GamePythonPath)); BLI_cleanup_file(NULL, gp_GamePythonPath); /* not absolutely needed but makes resolving path problems less confusing later */ diff --git a/source/gameengine/Ketsji/KX_PythonInit.h b/source/gameengine/Ketsji/KX_PythonInit.h index dd2a75d793e..40d2d38a465 100644 --- a/source/gameengine/Ketsji/KX_PythonInit.h +++ b/source/gameengine/Ketsji/KX_PythonInit.h @@ -54,7 +54,7 @@ void exitGamePythonScripting(); void setupGamePython(KX_KetsjiEngine* ketsjiengine, KX_Scene* startscene, Main *blenderdata, PyObject *pyGlobalDict, PyObject **gameLogic, PyObject **gameLogic_keys, int argc, char** argv); -void setGamePythonPath(char *path); +void setGamePythonPath(const char *path); void resetGamePythonPath(); void pathGamePythonConfig( char *path ); int saveGamePythonConfig( char **marshal_buffer); diff --git a/source/gameengine/Ketsji/KX_SceneActuator.cpp b/source/gameengine/Ketsji/KX_SceneActuator.cpp index af6de882c99..16474437142 100644 --- a/source/gameengine/Ketsji/KX_SceneActuator.cpp +++ b/source/gameengine/Ketsji/KX_SceneActuator.cpp @@ -190,7 +190,7 @@ bool KX_SceneActuator::Update() /* returns a camera if the name is valid */ -KX_Camera* KX_SceneActuator::FindCamera(char *camName) +KX_Camera* KX_SceneActuator::FindCamera(const char *camName) { KX_SceneList* sl = m_KetsjiEngine->CurrentScenes(); STR_String name = STR_String(camName); @@ -208,7 +208,7 @@ KX_Camera* KX_SceneActuator::FindCamera(char *camName) -KX_Scene* KX_SceneActuator::FindScene(char * sceneName) +KX_Scene* KX_SceneActuator::FindScene(const char * sceneName) { return m_KetsjiEngine->FindScene(sceneName); } diff --git a/source/gameengine/Ketsji/KX_SceneActuator.h b/source/gameengine/Ketsji/KX_SceneActuator.h index 4dbd489d0c8..30f325a775e 100644 --- a/source/gameengine/Ketsji/KX_SceneActuator.h +++ b/source/gameengine/Ketsji/KX_SceneActuator.h @@ -54,9 +54,9 @@ class KX_SceneActuator : public SCA_IActuator class KX_Camera* m_camera; /** Is this a valid scene? */ - class KX_Scene* FindScene(char* sceneName); + class KX_Scene* FindScene(const char* sceneName); /** Is this a valid camera? */ - class KX_Camera* FindCamera(char* cameraName); + class KX_Camera* FindCamera(const char* cameraName); public: enum SCA_SceneActuatorMode diff --git a/source/gameengine/VideoTexture/Texture.cpp b/source/gameengine/VideoTexture/Texture.cpp index 2066afbbf27..ba9922d455f 100644 --- a/source/gameengine/VideoTexture/Texture.cpp +++ b/source/gameengine/VideoTexture/Texture.cpp @@ -107,7 +107,7 @@ RAS_IPolyMaterial * getMaterial (PyObject *obj, short matID) // get material ID -short getMaterialID (PyObject * obj, char * name) +short getMaterialID(PyObject * obj, const char *name) { // search for material for (short matID = 0;; ++matID) diff --git a/source/gameengine/VideoTexture/Texture.h b/source/gameengine/VideoTexture/Texture.h index 52e1dfeb148..4dce0021509 100644 --- a/source/gameengine/VideoTexture/Texture.h +++ b/source/gameengine/VideoTexture/Texture.h @@ -85,7 +85,7 @@ void loadTexture (unsigned int texId, unsigned int * texture, short * size, RAS_IPolyMaterial * getMaterial (PyObject *obj, short matID); // get material ID -short getMaterialID (PyObject * obj, char * name); +short getMaterialID (PyObject * obj, const char *name); // Exceptions extern ExceptionID MaterialNotAvail;