Code cleanup: use 'const' for arrays (python)
authorCampbell Barton <ideasman42@gmail.com>
Sat, 26 Apr 2014 14:21:23 +0000 (00:21 +1000)
committerCampbell Barton <ideasman42@gmail.com>
Sat, 26 Apr 2014 14:25:15 +0000 (00:25 +1000)
14 files changed:
source/blender/python/bmesh/bmesh_py_ops_call.c
source/blender/python/generic/bgl.c
source/blender/python/generic/blf_py_api.c
source/blender/python/generic/bpy_internal_import.c
source/blender/python/generic/idprop_py_api.c
source/blender/python/generic/py_capi_utils.c
source/blender/python/intern/bpy.c
source/blender/python/intern/bpy_operator.c
source/blender/python/intern/bpy_operator_wrap.c
source/blender/python/intern/bpy_props.c
source/blender/python/intern/bpy_rna.c
source/blender/python/intern/bpy_rna_callback.c
source/blender/python/intern/bpy_util.c
source/blender/python/mathutils/mathutils_geometry.c

index f4fe1ed..9c9b691 100644 (file)
@@ -768,7 +768,7 @@ PyObject *BPy_BMO_call(BPy_BMeshOpFunc *self, PyObject *args, PyObject *kw)
                        /* temp code, strip off '.out' while we keep this convention */
                        {
                                char slot_name_strip[MAX_SLOTNAME];
-                               char *ch = strchr(slot->slot_name, '.');  /* can't fail! */
+                               const char *ch = strchr(slot->slot_name, '.');  /* can't fail! */
                                int tot = ch - slot->slot_name;
                                BLI_assert(ch != NULL);
                                memcpy(slot_name_strip, slot->slot_name, tot);
index d1d0ec9..292d331 100644 (file)
@@ -1905,7 +1905,7 @@ PyObject *BPyInit_bgl(void)
 static PyObject *Method_ShaderSource(PyObject *UNUSED(self), PyObject *args)
 {
        unsigned int shader;
-       char *source;
+       const char *source;
 
        if (!PyArg_ParseTuple(args, "Is", &shader, &source))
                return NULL;
index 768c550..655542e 100644 (file)
@@ -146,7 +146,7 @@ PyDoc_STRVAR(py_blf_draw_doc,
 );
 static PyObject *py_blf_draw(PyObject *UNUSED(self), PyObject *args)
 {
-       char *text;
+       const char *text;
        int text_length;
        int fontid;
 
@@ -172,7 +172,7 @@ PyDoc_STRVAR(py_blf_dimensions_doc,
 );
 static PyObject *py_blf_dimensions(PyObject *UNUSED(self), PyObject *args)
 {
-       char *text;
+       const char *text;
        float r_width, r_height;
        PyObject *ret;
        int fontid;
@@ -356,7 +356,7 @@ PyDoc_STRVAR(py_blf_load_doc,
 );
 static PyObject *py_blf_load(PyObject *UNUSED(self), PyObject *args)
 {
-       char *filename;
+       const char *filename;
 
        if (!PyArg_ParseTuple(args, "s:blf.load", &filename))
                return NULL;
@@ -374,7 +374,7 @@ PyDoc_STRVAR(py_blf_unload_doc,
 );
 static PyObject *py_blf_unload(PyObject *UNUSED(self), PyObject *args)
 {
-       char *filename;
+       const char *filename;
 
        if (!PyArg_ParseTuple(args, "s:blf.unload", &filename))
                return NULL;
index af41c3b..a0e6204 100644 (file)
@@ -226,7 +226,7 @@ PyObject *bpy_text_reimport(PyObject *module, int *found)
 {
        Text *text;
        const char *name;
-       char *filepath;
+       const char *filepath;
 //XXX  Main *maggie = bpy_import_main ? bpy_import_main:G.main;
        Main *maggie = bpy_import_main;
        
@@ -265,7 +265,7 @@ PyObject *bpy_text_reimport(PyObject *module, int *found)
 static PyObject *blender_import(PyObject *UNUSED(self), PyObject *args, PyObject *kw)
 {
        PyObject *exception, *err, *tb;
-       char *name;
+       const char *name;
        int found = 0;
        PyObject *globals = NULL, *locals = NULL, *fromlist = NULL;
        int level = 0; /* relative imports */
index 5821d48..54fed9e 100644 (file)
@@ -599,7 +599,7 @@ static PyObject *BPy_IDGroup_MapDataToPy(IDProperty *prop)
                        switch (prop->subtype) {
                                case IDP_FLOAT:
                                {
-                                       float *array = (float *)IDP_Array(prop);
+                                       const float *array = (float *)IDP_Array(prop);
                                        for (i = 0; i < prop->len; i++) {
                                                PyList_SET_ITEM(seq, i, PyFloat_FromDouble(array[i]));
                                        }
@@ -607,7 +607,7 @@ static PyObject *BPy_IDGroup_MapDataToPy(IDProperty *prop)
                                }
                                case IDP_DOUBLE:
                                {
-                                       double *array = (double *)IDP_Array(prop);
+                                       const double *array = (double *)IDP_Array(prop);
                                        for (i = 0; i < prop->len; i++) {
                                                PyList_SET_ITEM(seq, i, PyFloat_FromDouble(array[i]));
                                        }
@@ -615,7 +615,7 @@ static PyObject *BPy_IDGroup_MapDataToPy(IDProperty *prop)
                                }
                                case IDP_INT:
                                {
-                                       int *array = (int *)IDP_Array(prop);
+                                       const int *array = (int *)IDP_Array(prop);
                                        for (i = 0; i < prop->len; i++) {
                                                PyList_SET_ITEM(seq, i, PyLong_FromLong(array[i]));
                                        }
@@ -881,7 +881,7 @@ static PyObject *BPy_IDGroup_clear(BPy_IDProperty *self)
 static PyObject *BPy_IDGroup_Get(BPy_IDProperty *self, PyObject *args)
 {
        IDProperty *idprop;
-       char *key;
+       const char *key;
        PyObject *def = Py_None;
 
        if (!PyArg_ParseTuple(args, "s|O:get", &key, &def))
@@ -1158,7 +1158,7 @@ static PyObject *BPy_IDArray_slice(BPy_IDArray *self, int begin, int end)
        switch (prop->subtype) {
                case IDP_FLOAT:
                {
-                       float *array = (float *)IDP_Array(prop);
+                       const float *array = (float *)IDP_Array(prop);
                        for (count = begin; count < end; count++) {
                                PyTuple_SET_ITEM(tuple, count - begin, PyFloat_FromDouble(array[count]));
                        }
@@ -1166,7 +1166,7 @@ static PyObject *BPy_IDArray_slice(BPy_IDArray *self, int begin, int end)
                }
                case IDP_DOUBLE:
                {
-                       double *array = (double *)IDP_Array(prop);
+                       const double *array = (double *)IDP_Array(prop);
                        for (count = begin; count < end; count++) {
                                PyTuple_SET_ITEM(tuple, count - begin, PyFloat_FromDouble(array[count]));
                        }
@@ -1174,7 +1174,7 @@ static PyObject *BPy_IDArray_slice(BPy_IDArray *self, int begin, int end)
                }
                case IDP_INT:
                {
-                       int *array = (int *)IDP_Array(prop);
+                       const int *array = (int *)IDP_Array(prop);
                        for (count = begin; count < end; count++) {
                                PyTuple_SET_ITEM(tuple, count - begin, PyLong_FromLong(array[count]));
                        }
index a37933d..6f72a29 100644 (file)
@@ -284,7 +284,7 @@ PyObject *PyC_Object_GetAttrStringArgs(PyObject *o, Py_ssize_t n, ...)
 {
        Py_ssize_t i;
        PyObject *item = o;
-       char *attr;
+       const char *attr;
        
        va_list vargs;
 
@@ -647,7 +647,7 @@ void PyC_RunQuicky(const char *filepath, int n, ...)
 
                va_start(vargs, n);
                for (i = 0; i * 2 < n; i++) {
-                       char *format = va_arg(vargs, char *);
+                       const char *format = va_arg(vargs, char *);
                        void *ptr = va_arg(vargs, void *);
 
                        ret = PyObject_CallFunction(calcsize, (char *)"s", format);
@@ -704,7 +704,7 @@ void PyC_RunQuicky(const char *filepath, int n, ...)
                                /* now get the values back */
                                va_start(vargs, n);
                                for (i = 0; i * 2 < n; i++) {
-                                       char *format = va_arg(vargs, char *);
+                                       const char *format = va_arg(vargs, char *);
                                        void *ptr = va_arg(vargs, void *);
                                        
                                        PyObject *item;
index ae57588..8910482 100644 (file)
@@ -144,8 +144,8 @@ static PyObject *bpy_blend_paths(PyObject *UNUSED(self), PyObject *args, PyObjec
 // PyDoc_STRVAR(bpy_user_resource_doc[] = // now in bpy/utils.py
 static PyObject *bpy_user_resource(PyObject *UNUSED(self), PyObject *args, PyObject *kw)
 {
-       char *type;
-       char *subdir = NULL;
+       const char *type;
+       const char *subdir = NULL;
        int folder_id;
        static const char *kwlist[] = {"type", "subdir", NULL};
 
@@ -189,7 +189,7 @@ PyDoc_STRVAR(bpy_resource_path_doc,
 );
 static PyObject *bpy_resource_path(PyObject *UNUSED(self), PyObject *args, PyObject *kw)
 {
-       char *type;
+       const char *type;
        int major = BLENDER_VERSION / 100, minor = BLENDER_VERSION % 100;
        static const char *kwlist[] = {"type", "major", "minor", NULL};
        int folder_id;
index e867aa0..2c52660 100644 (file)
 static PyObject *pyop_poll(PyObject *UNUSED(self), PyObject *args)
 {
        wmOperatorType *ot;
-       char     *opname;
+       const char *opname;
        PyObject *context_dict = NULL; /* optional args */
        PyObject *context_dict_back;
-       char     *context_str = NULL;
+       const char *context_str = NULL;
        PyObject *ret;
 
        int context = WM_OP_EXEC_DEFAULT;
@@ -139,8 +139,8 @@ static PyObject *pyop_call(PyObject *UNUSED(self), PyObject *args)
        PointerRNA ptr;
        int operator_ret = OPERATOR_CANCELLED;
 
-       char     *opname;
-       char     *context_str = NULL;
+       const char *opname;
+       const char *context_str = NULL;
        PyObject *kw = NULL; /* optional args */
        PyObject *context_dict = NULL; /* optional args */
        PyObject *context_dict_back;
@@ -310,7 +310,7 @@ static PyObject *pyop_as_string(PyObject *UNUSED(self), PyObject *args)
        wmOperatorType *ot;
        PointerRNA ptr;
 
-       char     *opname;
+       const char *opname;
        PyObject *kw = NULL; /* optional args */
        int all_args = 1;
        int macro_args = 1;
index efee9b1..11e27ca 100644 (file)
@@ -163,7 +163,7 @@ PyObject *PYOP_wrap_macro_define(PyObject *UNUSED(self), PyObject *args)
        PointerRNA ptr_otmacro;
        StructRNA *srna;
 
-       char *opname;
+       const char *opname;
        const char *macroname;
 
        if (!PyArg_ParseTuple(args, "Os:_bpy.ops.macro_define", &macro, &opname))
index b2f9547..6e36680 100644 (file)
@@ -1881,7 +1881,7 @@ static PyObject *BPy_BoolProperty(PyObject *self, PyObject *args, PyObject *kw)
                PropertyRNA *prop;
                PyObject *pyopts = NULL;
                int opts = 0;
-               char *pysubtype = NULL;
+               const char *pysubtype = NULL;
                int subtype = PROP_NONE;
                PyObject *update_cb = NULL;
                PyObject *get_cb = NULL;
@@ -1967,7 +1967,7 @@ static PyObject *BPy_BoolVectorProperty(PyObject *self, PyObject *args, PyObject
                PyObject *pydef = NULL;
                PyObject *pyopts = NULL;
                int opts = 0;
-               char *pysubtype = NULL;
+               const char *pysubtype = NULL;
                int subtype = PROP_NONE;
                PyObject *update_cb = NULL;
                PyObject *get_cb = NULL;
@@ -2062,7 +2062,7 @@ static PyObject *BPy_IntProperty(PyObject *self, PyObject *args, PyObject *kw)
                PropertyRNA *prop;
                PyObject *pyopts = NULL;
                int opts = 0;
-               char *pysubtype = NULL;
+               const char *pysubtype = NULL;
                int subtype = PROP_NONE;
                PyObject *update_cb = NULL;
                PyObject *get_cb = NULL;
@@ -2154,7 +2154,7 @@ static PyObject *BPy_IntVectorProperty(PyObject *self, PyObject *args, PyObject
                PyObject *pydef = NULL;
                PyObject *pyopts = NULL;
                int opts = 0;
-               char *pysubtype = NULL;
+               const char *pysubtype = NULL;
                int subtype = PROP_NONE;
                PyObject *update_cb = NULL;
                PyObject *get_cb = NULL;
@@ -2259,9 +2259,9 @@ static PyObject *BPy_FloatProperty(PyObject *self, PyObject *args, PyObject *kw)
                PropertyRNA *prop;
                PyObject *pyopts = NULL;
                int opts = 0;
-               char *pysubtype = NULL;
+               const char *pysubtype = NULL;
                int subtype = PROP_NONE;
-               char *pyunit = NULL;
+               const char *pyunit = NULL;
                int unit = PROP_UNIT_NONE;
                PyObject *update_cb = NULL;
                PyObject *get_cb = NULL;
@@ -2365,9 +2365,9 @@ static PyObject *BPy_FloatVectorProperty(PyObject *self, PyObject *args, PyObjec
                PyObject *pydef = NULL;
                PyObject *pyopts = NULL;
                int opts = 0;
-               char *pysubtype = NULL;
+               const char *pysubtype = NULL;
                int subtype = PROP_NONE;
-               char *pyunit = NULL;
+               const char *pyunit = NULL;
                int unit = PROP_UNIT_NONE;
                PyObject *update_cb = NULL;
                PyObject *get_cb = NULL;
@@ -2468,7 +2468,7 @@ static PyObject *BPy_StringProperty(PyObject *self, PyObject *args, PyObject *kw
                PropertyRNA *prop;
                PyObject *pyopts = NULL;
                int opts = 0;
-               char *pysubtype = NULL;
+               const char *pysubtype = NULL;
                int subtype = PROP_NONE;
                PyObject *update_cb = NULL;
                PyObject *get_cb = NULL;
@@ -2847,7 +2847,7 @@ static PyObject *BPy_RemoveProperty(PyObject *self, PyObject *args, PyObject *kw
        else {
                static const char *kwlist[] = {"attr", NULL};
                
-               char *id = NULL;
+               const char *id = NULL;
 
                if (!PyArg_ParseTupleAndKeywords(args, kw,
                                                 "s:RemoveProperty",
index cf13efa..e0c8df7 100644 (file)
@@ -2171,7 +2171,7 @@ static int pyrna_prop_collection_subscript_str_lib_pair_ptr(BPy_PropertyRNA *sel
                                                             PointerRNA *r_ptr
                                                             )
 {
-       char *keyname;
+       const char *keyname;
 
        /* first validate the args, all we know is that they are a tuple */
        if (PyTuple_GET_SIZE(key) != 2) {
@@ -4883,7 +4883,7 @@ static PyObject *pyrna_param_to_py(PointerRNA *ptr, PropertyRNA *prop, void *dat
                                break;
                        case PROP_STRING:
                        {
-                               char *data_ch;
+                               const char *data_ch;
                                PyObject *value_coerce = NULL;
                                const int subtype = RNA_property_subtype(prop);
 
index 9aefe5a..87c3a6e 100644 (file)
@@ -182,8 +182,8 @@ PyObject *pyrna_callback_classmethod_add(PyObject *UNUSED(self), PyObject *args)
        void *handle;
        PyObject *cls;
        PyObject *cb_func, *cb_args;
-       char *cb_regiontype_str;
-       char *cb_event_str;
+       const char *cb_regiontype_str;
+       const char *cb_event_str;
        int cb_event;
        int cb_regiontype;
        StructRNA *srna;
@@ -248,7 +248,7 @@ PyObject *pyrna_callback_classmethod_remove(PyObject *UNUSED(self), PyObject *ar
        void *handle;
        void *customdata;
        StructRNA *srna;
-       char *cb_regiontype_str;
+       const char *cb_regiontype_str;
        int cb_regiontype;
 
        if (PyTuple_GET_SIZE(args) < 2) {
index b0b0f34..93183a4 100644 (file)
@@ -86,7 +86,7 @@ short BPy_errors_to_report(ReportList *reports)
 {
        PyObject *pystring;
        PyObject *pystring_format = NULL;  /* workaround, see below */
-       char *cstring;
+       const char *cstring;
 
        const char *filename;
        int lineno;
index 142e5ca..139764a 100644 (file)
@@ -269,7 +269,7 @@ static PyObject *M_Geometry_intersect_sphere_sphere_2d(PyObject *UNUSED(self), P
 {
        PyObject *ret;
        VectorObject *vec_a, *vec_b;
-       float *v_a, *v_b;
+       const float *v_a, *v_b;
        float rad_a, rad_b;
        float v_ab[2];
        float dist;