diff options
Diffstat (limited to 'source/blender/python/generic')
-rw-r--r-- | source/blender/python/generic/IDProp.c | 26 | ||||
-rw-r--r-- | source/blender/python/generic/bgl.c | 16 | ||||
-rw-r--r-- | source/blender/python/generic/bpy_internal_import.c | 40 | ||||
-rw-r--r-- | source/blender/python/generic/noise_py_api.c | 58 | ||||
-rw-r--r-- | source/blender/python/generic/py_capi_utils.c | 72 |
5 files changed, 106 insertions, 106 deletions
diff --git a/source/blender/python/generic/IDProp.c b/source/blender/python/generic/IDProp.c index e6883eb30af..1524812086b 100644 --- a/source/blender/python/generic/IDProp.c +++ b/source/blender/python/generic/IDProp.c @@ -254,7 +254,7 @@ static PyObject *BPy_IDGroup_Map_GetItem(BPy_IDProperty *self, PyObject *item) idprop= IDP_GetPropertyFromGroup(self->prop, name); - if(idprop==NULL) { + if (idprop==NULL) { PyErr_SetString(PyExc_KeyError, "key not in subgroup dict"); return NULL; } @@ -273,20 +273,20 @@ static int idp_sequence_type(PyObject *seq) for (i=0; i < len; i++) { item = PySequence_GetItem(seq, i); if (PyFloat_Check(item)) { - if(type == IDP_IDPARRAY) { /* mixed dict/int */ + if (type == IDP_IDPARRAY) { /* mixed dict/int */ Py_DECREF(item); return -1; } type= IDP_DOUBLE; } else if (PyLong_Check(item)) { - if(type == IDP_IDPARRAY) { /* mixed dict/int */ + if (type == IDP_IDPARRAY) { /* mixed dict/int */ Py_DECREF(item); return -1; } } else if (PyMapping_Check(item)) { - if(i != 0 && (type != IDP_IDPARRAY)) { /* mixed dict/int */ + if (i != 0 && (type != IDP_IDPARRAY)) { /* mixed dict/int */ Py_DECREF(item); return -1; } @@ -309,7 +309,7 @@ const char *BPy_IDProperty_Map_ValidateAndCreate(const char *name, IDProperty *g IDProperty *prop = NULL; IDPropertyTemplate val = {0}; - if(strlen(name) >= sizeof(group->name)) + if (strlen(name) >= sizeof(group->name)) return "the length of IDProperty names is limited to 31 characters"; if (PyFloat_Check(ob)) { @@ -335,7 +335,7 @@ const char *BPy_IDProperty_Map_ValidateAndCreate(const char *name, IDProperty *g PyObject *item; int i; - if((val.array.type= idp_sequence_type(ob)) == -1) + if ((val.array.type= idp_sequence_type(ob)) == -1) return "only floats, ints and dicts are allowed in ID property arrays"; /*validate sequence and derive type. @@ -369,7 +369,7 @@ const char *BPy_IDProperty_Map_ValidateAndCreate(const char *name, IDProperty *g error= BPy_IDProperty_Map_ValidateAndCreate("", prop, item); Py_DECREF(item); - if(error) + if (error) return error; } break; @@ -415,7 +415,7 @@ const char *BPy_IDProperty_Map_ValidateAndCreate(const char *name, IDProperty *g } else return "invalid property value"; - if(group->type==IDP_IDPARRAY) { + if (group->type==IDP_IDPARRAY) { IDP_AppendArray(group, prop); // IDP_FreeProperty(item); // IDP_AppendArray does a shallow copy (memcpy), only free memory MEM_freeN(prop); @@ -598,7 +598,7 @@ static PyObject *BPy_IDGroup_Pop(BPy_IDProperty *self, PyObject *value) idprop= IDP_GetPropertyFromGroup(self->prop, name); - if(idprop) { + if (idprop) { pyform = BPy_IDGroup_MapDataToPy(idprop); if (!pyform) { @@ -1050,7 +1050,7 @@ static PyObject *BPy_IDArray_slice(BPy_IDArray *self, int begin, int end) case IDP_FLOAT: { float *array= (float*)IDP_Array(prop); - for(count = begin; count < end; count++) { + for (count = begin; count < end; count++) { PyTuple_SET_ITEM(tuple, count - begin, PyFloat_FromDouble(array[count])); } break; @@ -1058,7 +1058,7 @@ static PyObject *BPy_IDArray_slice(BPy_IDArray *self, int begin, int end) case IDP_DOUBLE: { double *array= (double*)IDP_Array(prop); - for(count = begin; count < end; count++) { + for (count = begin; count < end; count++) { PyTuple_SET_ITEM(tuple, count - begin, PyFloat_FromDouble(array[count])); } break; @@ -1066,7 +1066,7 @@ static PyObject *BPy_IDArray_slice(BPy_IDArray *self, int begin, int end) case IDP_INT: { int *array= (int*)IDP_Array(prop); - for(count = begin; count < end; count++) { + for (count = begin; count < end; count++) { PyTuple_SET_ITEM(tuple, count - begin, PyLong_FromLong(array[count])); } break; @@ -1094,7 +1094,7 @@ static int BPy_IDArray_ass_slice(BPy_IDArray *self, int begin, int end, PyObject alloc_len= size * elem_size; vec= MEM_mallocN(alloc_len, "array assignment"); /* NOTE: we count on int/float being the same size here */ - if(PyC_AsArray(vec, seq, size, py_type, is_double, "slice assignment: ") == -1) { + if (PyC_AsArray(vec, seq, size, py_type, is_double, "slice assignment: ") == -1) { MEM_freeN(vec); return -1; } diff --git a/source/blender/python/generic/bgl.c b/source/blender/python/generic/bgl.c index 35c211d5424..e8dd0274568 100644 --- a/source/blender/python/generic/bgl.c +++ b/source/blender/python/generic/bgl.c @@ -95,7 +95,7 @@ static PyObject *Buffer_to_list_recursive(Buffer *self) { PyObject *list; - if(self->ndimensions > 1) { + if (self->ndimensions > 1) { int i, len= self->dimensions[0]; list= PyList_New(len); @@ -213,7 +213,7 @@ PyTypeObject BGL_bufferType = { static PyObject *Method_##funcname (PyObject *UNUSED(self), PyObject *args) {\ arg_def##nargs arg_list; \ ret_def_##ret; \ - if(!PyArg_ParseTuple(args, arg_str##nargs arg_list, arg_ref##nargs arg_list)) return NULL;\ + if (!PyArg_ParseTuple(args, arg_str##nargs arg_list, arg_ref##nargs arg_list)) return NULL;\ ret_set_##ret gl##funcname (arg_var##nargs arg_list);\ ret_ret_##ret; \ } @@ -222,7 +222,7 @@ static PyObject *Method_##funcname (PyObject *UNUSED(self), PyObject *args) {\ static PyObject *Method_##funcname (PyObject *UNUSED(self), PyObject *args) {\ arg_def##nargs arg_list; \ ret_def_##ret; \ - if(!PyArg_ParseTuple(args, arg_str##nargs arg_list, arg_ref##nargs arg_list)) return NULL;\ + if (!PyArg_ParseTuple(args, arg_str##nargs arg_list, arg_ref##nargs arg_list)) return NULL;\ ret_set_##ret glu##funcname (arg_var##nargs arg_list);\ ret_ret_##ret; \ } @@ -289,7 +289,7 @@ static PyObject *Buffer_new(PyTypeObject *UNUSED(type), PyObject *args, PyObject int type; Py_ssize_t i, ndimensions = 0; - if(kwds && PyDict_Size(kwds)) { + if (kwds && PyDict_Size(kwds)) { PyErr_SetString(PyExc_TypeError, "bgl.Buffer(): takes no keyword args"); return NULL; @@ -307,7 +307,7 @@ static PyObject *Buffer_new(PyTypeObject *UNUSED(type), PyObject *args, PyObject if (PyLong_Check(length_ob)) { ndimensions= 1; - if(((dimensions[0]= PyLong_AsLong(length_ob)) < 1)) { + if (((dimensions[0]= PyLong_AsLong(length_ob)) < 1)) { PyErr_SetString(PyExc_AttributeError, "dimensions must be between 1 and "STRINGIFY(MAX_DIMENSIONS)); return NULL; @@ -332,7 +332,7 @@ static PyObject *Buffer_new(PyTypeObject *UNUSED(type), PyObject *args, PyObject else dimensions[i]= PyLong_AsLong(ob); Py_DECREF(ob); - if(dimensions[i] < 1) { + if (dimensions[i] < 1) { PyErr_SetString(PyExc_AttributeError, "dimensions must be between 1 and "STRINGIFY(MAX_DIMENSIONS)); return NULL; @@ -490,7 +490,7 @@ static int Buffer_ass_slice(Buffer *self, int begin, int end, PyObject *seq) for (count= begin; count < end; count++) { item= PySequence_GetItem(seq, count - begin); - if(item) { + if (item) { err= Buffer_ass_item(self, count, item); Py_DECREF(item); } @@ -1293,7 +1293,7 @@ PyObject *BPyInit_bgl(void) submodule= PyModule_Create(&BGL_module_def); dict= PyModule_GetDict(submodule); - if(PyType_Ready(&BGL_bufferType) < 0) + if (PyType_Ready(&BGL_bufferType) < 0) return NULL; /* should never happen */ diff --git a/source/blender/python/generic/bpy_internal_import.c b/source/blender/python/generic/bpy_internal_import.c index d29bc798399..0346c421f68 100644 --- a/source/blender/python/generic/bpy_internal_import.c +++ b/source/blender/python/generic/bpy_internal_import.c @@ -62,7 +62,7 @@ void bpy_import_init(PyObject *builtins) /* move reload here * XXX, use import hooks */ mod= PyImport_ImportModuleLevel((char *)"imp", NULL, NULL, NULL, 0); - if(mod) { + if (mod) { PyDict_SetItemString(PyModule_GetDict(mod), "reload", item=PyCFunction_New(&bpy_reload_meth, NULL)); Py_DECREF(item); Py_DECREF(mod); } @@ -74,7 +74,7 @@ void bpy_import_init(PyObject *builtins) static void free_compiled_text(Text *text) { - if(text->compiled) { + if (text->compiled) { Py_DECREF((PyObject *)text->compiled); } text->compiled= NULL; @@ -102,7 +102,7 @@ PyObject *bpy_text_import(Text *text) char modulename[24]; int len; - if(!text->compiled) { + if (!text->compiled) { char fn_dummy[256]; bpy_text_filename_get(fn_dummy, sizeof(fn_dummy), text); @@ -110,7 +110,7 @@ PyObject *bpy_text_import(Text *text) text->compiled= Py_CompileString(buf, fn_dummy, Py_file_input); MEM_freeN(buf); - if(PyErr_Occurred()) { + if (PyErr_Occurred()) { PyErr_Print(); PyErr_Clear(); PySys_SetObject("last_traceback", NULL); @@ -135,7 +135,7 @@ PyObject *bpy_text_import_name(char *name, int *found) *found= 0; - if(!maggie) { + if (!maggie) { printf("ERROR: bpy_import_main_set() was not called before running python. this is a bug.\n"); return NULL; } @@ -147,7 +147,7 @@ PyObject *bpy_text_import_name(char *name, int *found) text= BLI_findstring(&maggie->text, txtname, offsetof(ID, name) + 2); - if(!text) + if (!text) return NULL; else *found= 1; @@ -169,7 +169,7 @@ PyObject *bpy_text_reimport(PyObject *module, int *found) //XXX Main *maggie= bpy_import_main ? bpy_import_main:G.main; Main *maggie= bpy_import_main; - if(!maggie) { + if (!maggie) { printf("ERROR: bpy_import_main_set() was not called before running python. this is a bug.\n"); return NULL; } @@ -177,24 +177,24 @@ PyObject *bpy_text_reimport(PyObject *module, int *found) *found= 0; /* get name, filename from the module itself */ - if((name= PyModule_GetName(module)) == NULL) + if ((name= PyModule_GetName(module)) == NULL) return NULL; - if((filepath= (char *)PyModule_GetFilename(module)) == NULL) + if ((filepath= (char *)PyModule_GetFilename(module)) == NULL) return NULL; /* look up the text object */ text= BLI_findstring(&maggie->text, BLI_path_basename(filepath), offsetof(ID, name) + 2); /* uh-oh.... didn't find it */ - if(!text) + if (!text) return NULL; else *found= 1; /* if previously compiled, free the object */ /* (can't see how could be NULL, but check just in case) */ - if(text->compiled){ + if (text->compiled) { Py_DECREF((PyObject *)text->compiled); } @@ -204,7 +204,7 @@ PyObject *bpy_text_reimport(PyObject *module, int *found) MEM_freeN(buf); /* if compile failed.... return this error */ - if(PyErr_Occurred()) { + if (PyErr_Occurred()) { PyErr_Print(); PyErr_Clear(); PySys_SetObject("last_traceback", NULL); @@ -229,14 +229,14 @@ static PyObject *blender_import(PyObject *UNUSED(self), PyObject *args, PyObject //PyObject_Print(args, stderr, 0); static const char *kwlist[]= {"name", "globals", "locals", "fromlist", "level", NULL}; - if(!PyArg_ParseTupleAndKeywords(args, kw, "s|OOOi:bpy_import_meth", (char **)kwlist, + if (!PyArg_ParseTupleAndKeywords(args, kw, "s|OOOi:bpy_import_meth", (char **)kwlist, &name, &globals, &locals, &fromlist, &level)) return NULL; /* import existing builtin modules or modules that have been imported already */ newmodule= PyImport_ImportModuleLevel(name, globals, locals, fromlist, level); - if(newmodule) + if (newmodule) return newmodule; PyErr_Fetch(&exception, &err, &tb); /* get the python error incase we cant import as blender text either */ @@ -244,7 +244,7 @@ static PyObject *blender_import(PyObject *UNUSED(self), PyObject *args, PyObject /* importing from existing modules failed, see if we have this module as blender text */ newmodule= bpy_text_import_name(name, &found); - if(newmodule) {/* found module as blender text, ignore above exception */ + if (newmodule) {/* found module as blender text, ignore above exception */ PyErr_Clear(); Py_XDECREF(exception); Py_XDECREF(err); @@ -278,14 +278,14 @@ static PyObject *blender_reload(PyObject *UNUSED(self), PyObject *module) /* try reimporting from file */ newmodule= PyImport_ReloadModule(module); - if(newmodule) + if (newmodule) return newmodule; /* no file, try importing from memory */ PyErr_Fetch(&exception, &err, &tb); /*restore for probable later use */ newmodule= bpy_text_reimport(module, &found); - if(newmodule) {/* found module as blender text, ignore above exception */ + if (newmodule) {/* found module as blender text, ignore above exception */ PyErr_Clear(); Py_XDECREF(exception); Py_XDECREF(err); @@ -359,10 +359,10 @@ void bpy_text_clear_modules(int clear_all) */ while (PyDict_Next(modules, &pos, &key, &value)) { fname= PyModule_GetFilename(value); - if(fname) { + if (fname) { if (clear_all || ((strstr(fname, SEPSTR))==0)) { /* no path ? */ file_extension= strstr(fname, ".py"); - if(file_extension && (*(file_extension + 3) == '\0' || *(file_extension + 4) == '\0')) { /* .py or pyc extension? */ + if (file_extension && (*(file_extension + 3) == '\0' || *(file_extension + 4) == '\0')) { /* .py or pyc extension? */ /* now we can be fairly sure its a python import from the blendfile */ PyList_Append(list, key); /* free'd with the list */ } @@ -374,7 +374,7 @@ void bpy_text_clear_modules(int clear_all) } /* remove all our modules */ - for(pos=0; pos < PyList_GET_SIZE(list); pos++) { + for (pos=0; pos < PyList_GET_SIZE(list); pos++) { /* PyObject_Print(key, stderr, 0); */ key= PyList_GET_ITEM(list, pos); PyDict_DelItem(modules, key); diff --git a/source/blender/python/generic/noise_py_api.c b/source/blender/python/generic/noise_py_api.c index 7be0998c0a1..2171f1f7f39 100644 --- a/source/blender/python/generic/noise_py_api.c +++ b/source/blender/python/generic/noise_py_api.c @@ -136,7 +136,7 @@ static void init_genrand(unsigned long s) { int j; state[0] = s & 0xffffffffUL; - for(j = 1; j < N; j++) { + for (j = 1; j < N; j++) { state[j] = (1812433253UL * (state[j - 1] ^ (state[j - 1] >> 30)) + j); @@ -157,16 +157,16 @@ static void next_state(void) /* if init_genrand() has not been called, */ /* a default initial seed is used */ - if(initf == 0) + if (initf == 0) init_genrand(5489UL); left = N; next = state; - for(j = N - M + 1; --j; p++) + for (j = N - M + 1; --j; p++) *p = p[M] ^ TWIST(p[0], p[1]); - for(j = M; --j; p++) + for (j = M; --j; p++) *p = p[M - N] ^ TWIST(p[0], p[1]); *p = p[M - N] ^ TWIST(p[0], state[0]); @@ -176,7 +176,7 @@ static void next_state(void) static void setRndSeed(int seed) { - if(seed == 0) + if (seed == 0) init_genrand(time(NULL)); else init_genrand(seed); @@ -187,7 +187,7 @@ static float frand(void) { unsigned long y; - if(--left == 0) + if (--left == 0) next_state(); y = *next++; @@ -207,7 +207,7 @@ static void randuvec(float v[3]) { float r; v[2] = 2.f * frand() - 1.f; - if((r = 1.f - v[2] * v[2]) > 0.f) { + if ((r = 1.f - v[2] * v[2]) > 0.f) { float a = (float)(6.283185307f * frand()); r = (float)sqrt(r); v[0] = (float)(r * cosf(a)); @@ -237,7 +237,7 @@ static PyObject *Noise_random_unit_vector(PyObject *UNUSED(self)) static PyObject *Noise_seed_set(PyObject *UNUSED(self), PyObject *args) { int s; - if(!PyArg_ParseTuple(args, "i:seed_set", &s)) + if (!PyArg_ParseTuple(args, "i:seed_set", &s)) return NULL; setRndSeed(s); Py_RETURN_NONE; @@ -251,7 +251,7 @@ static PyObject *Noise_noise(PyObject *UNUSED(self), PyObject *args) { float x, y, z; int nb = 1; - if(!PyArg_ParseTuple(args, "(fff)|i:noise", &x, &y, &z, &nb)) + if (!PyArg_ParseTuple(args, "(fff)|i:noise", &x, &y, &z, &nb)) return NULL; return PyFloat_FromDouble((2.0f * BLI_gNoise(1.0f, x, y, z, 0, nb) - 1.0f)); @@ -275,7 +275,7 @@ static PyObject *Noise_vector(PyObject *UNUSED(self), PyObject *args) { float x, y, z, v[3]; int nb = 1; - if(!PyArg_ParseTuple(args, "(fff)|i:vector", &x, &y, &z, &nb)) + if (!PyArg_ParseTuple(args, "(fff)|i:vector", &x, &y, &z, &nb)) return NULL; noise_vector(x, y, z, nb, v); return Py_BuildValue("[fff]", v[0], v[1], v[2]); @@ -292,15 +292,15 @@ static float turb(float x, float y, float z, int oct, int hard, int nb, int i; amp = 1.f; out = (float)(2.0f * BLI_gNoise(1.f, x, y, z, 0, nb) - 1.0f); - if(hard) + if (hard) out = (float)fabs(out); - for(i = 1; i < oct; i++) { + for (i = 1; i < oct; i++) { amp *= ampscale; x *= freqscale; y *= freqscale; z *= freqscale; t = (float)(amp * (2.0f * BLI_gNoise(1.f, x, y, z, 0, nb) - 1.0f)); - if(hard) + if (hard) t = (float)fabs(t); out += t; } @@ -312,7 +312,7 @@ static PyObject *Noise_turbulence(PyObject *UNUSED(self), PyObject *args) float x, y, z; int oct, hd, nb = 1; float as = 0.5, fs = 2.0; - if(!PyArg_ParseTuple(args, "(fff)ii|iff:turbulence", &x, &y, &z, &oct, &hd, &nb, &as, &fs)) + if (!PyArg_ParseTuple(args, "(fff)ii|iff:turbulence", &x, &y, &z, &oct, &hd, &nb, &as, &fs)) return NULL; return PyFloat_FromDouble(turb(x, y, z, oct, hd, nb, as, fs)); @@ -329,18 +329,18 @@ static void vTurb(float x, float y, float z, int oct, int hard, int nb, int i; amp = 1.f; noise_vector(x, y, z, nb, v); - if(hard) { + if (hard) { v[0] = (float)fabs(v[0]); v[1] = (float)fabs(v[1]); v[2] = (float)fabs(v[2]); } - for(i = 1; i < oct; i++) { + for (i = 1; i < oct; i++) { amp *= ampscale; x *= freqscale; y *= freqscale; z *= freqscale; noise_vector(x, y, z, nb, t); - if(hard) { + if (hard) { t[0] = (float)fabs(t[0]); t[1] = (float)fabs(t[1]); t[2] = (float)fabs(t[2]); @@ -356,7 +356,7 @@ static PyObject *Noise_turbulence_vector(PyObject *UNUSED(self), PyObject *args) float x, y, z, v[3]; int oct, hd, nb = 1; float as = 0.5, fs = 2.0; - if(!PyArg_ParseTuple(args, "(fff)ii|iff:turbulence_vector", &x, &y, &z, &oct, &hd, &nb, &as, &fs)) + if (!PyArg_ParseTuple(args, "(fff)ii|iff:turbulence_vector", &x, &y, &z, &oct, &hd, &nb, &as, &fs)) return NULL; vTurb(x, y, z, oct, hd, nb, as, fs, v); return Py_BuildValue("[fff]", v[0], v[1], v[2]); @@ -370,7 +370,7 @@ static PyObject *Noise_fractal(PyObject *UNUSED(self), PyObject *args) { float x, y, z, H, lac, oct; int nb = 1; - if(!PyArg_ParseTuple(args, "(fff)fff|i:fractal", &x, &y, &z, &H, &lac, &oct, &nb)) + if (!PyArg_ParseTuple(args, "(fff)fff|i:fractal", &x, &y, &z, &H, &lac, &oct, &nb)) return NULL; return PyFloat_FromDouble(mg_fBm(x, y, z, H, lac, oct, nb)); } @@ -381,7 +381,7 @@ static PyObject *Noise_multi_fractal(PyObject *UNUSED(self), PyObject *args) { float x, y, z, H, lac, oct; int nb = 1; - if(!PyArg_ParseTuple(args, "(fff)fff|i:multi_fractal", &x, &y, &z, &H, &lac, &oct, &nb)) + if (!PyArg_ParseTuple(args, "(fff)fff|i:multi_fractal", &x, &y, &z, &H, &lac, &oct, &nb)) return NULL; return PyFloat_FromDouble(mg_MultiFractal(x, y, z, H, lac, oct, nb)); @@ -393,7 +393,7 @@ static PyObject *Noise_vl_vector(PyObject *UNUSED(self), PyObject *args) { float x, y, z, d; int nt1 = 1, nt2 = 1; - if(!PyArg_ParseTuple(args, "(fff)f|ii:vl_vector", &x, &y, &z, &d, &nt1, &nt2)) + if (!PyArg_ParseTuple(args, "(fff)f|ii:vl_vector", &x, &y, &z, &d, &nt1, &nt2)) return NULL; return PyFloat_FromDouble(mg_VLNoise(x, y, z, d, nt1, nt2)); } @@ -404,7 +404,7 @@ static PyObject *Noise_hetero_terrain(PyObject *UNUSED(self), PyObject *args) { float x, y, z, H, lac, oct, ofs; int nb = 1; - if(!PyArg_ParseTuple(args, "(fff)ffff|i:hetero_terrain", &x, &y, &z, &H, &lac, &oct, &ofs, &nb)) + if (!PyArg_ParseTuple(args, "(fff)ffff|i:hetero_terrain", &x, &y, &z, &H, &lac, &oct, &ofs, &nb)) return NULL; return PyFloat_FromDouble(mg_HeteroTerrain(x, y, z, H, lac, oct, ofs, nb)); @@ -416,7 +416,7 @@ static PyObject *Noise_hybrid_multi_fractal(PyObject *UNUSED(self), PyObject *ar { float x, y, z, H, lac, oct, ofs, gn; int nb = 1; - if(!PyArg_ParseTuple(args, "(fff)fffff|i:hybrid_multi_fractal", &x, &y, &z, &H, &lac, &oct, &ofs, &gn, &nb)) + if (!PyArg_ParseTuple(args, "(fff)fffff|i:hybrid_multi_fractal", &x, &y, &z, &H, &lac, &oct, &ofs, &gn, &nb)) return NULL; return PyFloat_FromDouble(mg_HybridMultiFractal(x, y, z, H, lac, oct, ofs, gn, nb)); @@ -428,7 +428,7 @@ static PyObject *Noise_ridged_multi_fractal(PyObject *UNUSED(self), PyObject *ar { float x, y, z, H, lac, oct, ofs, gn; int nb = 1; - if(!PyArg_ParseTuple(args, "(fff)fffff|i:ridged_multi_fractal", &x, &y, &z, &H, &lac, &oct, &ofs, &gn, &nb)) + if (!PyArg_ParseTuple(args, "(fff)fffff|i:ridged_multi_fractal", &x, &y, &z, &H, &lac, &oct, &ofs, &gn, &nb)) return NULL; return PyFloat_FromDouble(mg_RidgedMultiFractal(x, y, z, H, lac, oct, ofs, gn, nb)); } @@ -440,7 +440,7 @@ static PyObject *Noise_voronoi(PyObject *UNUSED(self), PyObject *args) float x, y, z, da[4], pa[12]; int dtype = 0; float me = 2.5; /* default minkovsky exponent */ - if(!PyArg_ParseTuple(args, "(fff)|if:voronoi", &x, &y, &z, &dtype, &me)) + if (!PyArg_ParseTuple(args, "(fff)|if:voronoi", &x, &y, &z, &dtype, &me)) return NULL; voronoi(x, y, z, da, pa, me, dtype); return Py_BuildValue("[[ffff][[fff][fff][fff][fff]]]", @@ -455,7 +455,7 @@ static PyObject *Noise_voronoi(PyObject *UNUSED(self), PyObject *args) static PyObject *Noise_cell(PyObject *UNUSED(self), PyObject *args) { float x, y, z; - if(!PyArg_ParseTuple(args, "(fff):cell", &x, &y, &z)) + if (!PyArg_ParseTuple(args, "(fff):cell", &x, &y, &z)) return NULL; return PyFloat_FromDouble(cellNoise(x, y, z)); @@ -466,7 +466,7 @@ static PyObject *Noise_cell(PyObject *UNUSED(self), PyObject *args) static PyObject *Noise_cell_vector(PyObject *UNUSED(self), PyObject *args) { float x, y, z, ca[3]; - if(!PyArg_ParseTuple(args, "(fff):cell_vector", &x, &y, &z)) + if (!PyArg_ParseTuple(args, "(fff):cell_vector", &x, &y, &z)) return NULL; cellNoiseV(x, y, z, ca); return Py_BuildValue("[fff]", ca[0], ca[1], ca[2]); @@ -698,7 +698,7 @@ PyObject *BPyInit_noise(void) setRndSeed(0); /* Constant noisetype dictionary */ - if(submodule) { + if (submodule) { static PyStructSequence_Field noise_types_fields[] = { {(char *)"BLENDER", NULL}, {(char *)"STDPERLIN", NULL}, @@ -747,7 +747,7 @@ PyObject *BPyInit_noise(void) PyModule_AddObject(submodule, "types", noise_types); } - if(submodule) { + if (submodule) { static PyStructSequence_Field distance_metrics_fields[] = { {(char *)"DISTANCE", NULL}, {(char *)"DISTANCE_SQUARED", NULL}, diff --git a/source/blender/python/generic/py_capi_utils.c b/source/blender/python/generic/py_capi_utils.c index bf14102bb0d..1bccc8a24c4 100644 --- a/source/blender/python/generic/py_capi_utils.c +++ b/source/blender/python/generic/py_capi_utils.c @@ -43,13 +43,13 @@ int PyC_AsArray(void *array, PyObject *value, const int length, const PyTypeObje int value_len; int i; - if(!(value_fast=PySequence_Fast(value, error_prefix))) { + if (!(value_fast=PySequence_Fast(value, error_prefix))) { return -1; } value_len= PySequence_Fast_GET_SIZE(value_fast); - if(value_len != length) { + if (value_len != length) { Py_DECREF(value); PyErr_Format(PyExc_TypeError, "%.200s: invalid sequence length. expected %d, got %d", @@ -58,30 +58,30 @@ int PyC_AsArray(void *array, PyObject *value, const int length, const PyTypeObje } /* for each type */ - if(type == &PyFloat_Type) { - if(is_double) { + if (type == &PyFloat_Type) { + if (is_double) { double *array_double= array; - for(i=0; i<length; i++) { + for (i=0; i<length; i++) { array_double[i]= PyFloat_AsDouble(PySequence_Fast_GET_ITEM(value_fast, i)); } } else { float *array_float= array; - for(i=0; i<length; i++) { + for (i=0; i<length; i++) { array_float[i]= PyFloat_AsDouble(PySequence_Fast_GET_ITEM(value_fast, i)); } } } - else if(type == &PyLong_Type) { + else if (type == &PyLong_Type) { /* could use is_double for 'long int' but no use now */ int *array_int= array; - for(i=0; i<length; i++) { + for (i=0; i<length; i++) { array_int[i]= PyLong_AsSsize_t(PySequence_Fast_GET_ITEM(value_fast, i)); } } - else if(type == &PyBool_Type) { + else if (type == &PyBool_Type) { int *array_bool= array; - for(i=0; i<length; i++) { + for (i=0; i<length; i++) { array_bool[i]= (PyLong_AsSsize_t(PySequence_Fast_GET_ITEM(value_fast, i)) != 0); } } @@ -95,7 +95,7 @@ int PyC_AsArray(void *array, PyObject *value, const int length, const PyTypeObje Py_DECREF(value_fast); - if(PyErr_Occurred()) { + if (PyErr_Occurred()) { PyErr_Format(PyExc_TypeError, "%s: one or more items could not be used as a %s", error_prefix, type->tp_name); @@ -119,7 +119,7 @@ void PyC_ObSpit(const char *name, PyObject *var) fprintf(stderr, " ptr:%p", (void *)var); fprintf(stderr, " type:"); - if(Py_TYPE(var)) + if (Py_TYPE(var)) fprintf(stderr, "%s", Py_TYPE(var)->tp_name); else fprintf(stderr, "<NIL>"); @@ -134,7 +134,7 @@ void PyC_LineSpit(void) int lineno; /* Note, allow calling from outside python (RNA) */ - if(!PYC_INTERPRETER_ACTIVE) { + if (!PYC_INTERPRETER_ACTIVE) { fprintf(stderr, "python line lookup failed, interpreter inactive\n"); return; } @@ -162,18 +162,18 @@ void PyC_FileAndNum(const char **filename, int *lineno) } /* when executing a module */ - if(filename && *filename == NULL) { + if (filename && *filename == NULL) { /* try an alternative method to get the filename - module based * references below are all borrowed (double checked) */ PyObject *mod_name= PyDict_GetItemString(PyEval_GetGlobals(), "__name__"); - if(mod_name) { + if (mod_name) { PyObject *mod= PyDict_GetItem(PyImport_GetModuleDict(), mod_name); - if(mod) { + if (mod) { *filename= PyModule_GetFilename(mod); } /* unlikely, fallback */ - if(*filename == NULL) { + if (*filename == NULL) { *filename= _PyUnicode_AsString(mod_name); } } @@ -225,7 +225,7 @@ PyObject *PyC_Err_Format_Prefix(PyObject *exception_type_prefix, const char *for error_value_prefix= PyUnicode_FromFormatV(format, args); /* can fail and be NULL */ va_end(args); - if(PyErr_Occurred()) { + if (PyErr_Occurred()) { PyObject *error_type, *error_value, *error_traceback; PyErr_Fetch(&error_type, &error_value, &error_traceback); PyErr_Format(exception_type_prefix, @@ -259,7 +259,7 @@ PyObject *PyC_ExceptionBuffer(void) PyObject *format_tb_func= NULL; PyObject *ret= NULL; - if(! (traceback_mod= PyImport_ImportModule("traceback")) ) { + if (! (traceback_mod= PyImport_ImportModule("traceback")) ) { goto error_cleanup; } else if (! (format_tb_func= PyObject_GetAttrString(traceback_mod, "format_exc"))) { @@ -268,7 +268,7 @@ PyObject *PyC_ExceptionBuffer(void) ret= PyObject_CallObject(format_tb_func, NULL); - if(ret == Py_None) { + if (ret == Py_None) { Py_DECREF(ret); ret= NULL; } @@ -303,7 +303,7 @@ PyObject *PyC_ExceptionBuffer(void) * string_io = io.StringIO() */ - if(! (string_io_mod= PyImport_ImportModule("io")) ) { + if (! (string_io_mod= PyImport_ImportModule("io")) ) { goto error_cleanup; } else if (! (string_io = PyObject_CallMethod(string_io_mod, (char *)"StringIO", NULL))) { @@ -360,7 +360,7 @@ const char *PyC_UnicodeAsByte(PyObject *py_str, PyObject **coerce) result= _PyUnicode_AsString(py_str); - if(result) { + if (result) { /* 99% of the time this is enough but we better support non unicode * chars since blender doesnt limit this */ return result; @@ -368,7 +368,7 @@ const char *PyC_UnicodeAsByte(PyObject *py_str, PyObject **coerce) else { PyErr_Clear(); - if(PyBytes_Check(py_str)) { + if (PyBytes_Check(py_str)) { return PyBytes_AS_STRING(py_str); } else { @@ -380,7 +380,7 @@ const char *PyC_UnicodeAsByte(PyObject *py_str, PyObject **coerce) PyObject *PyC_UnicodeFromByte(const char *str) { PyObject *result= PyUnicode_FromString(str); - if(result) { + if (result) { /* 99% of the time this is enough but we better support non unicode * chars since blender doesnt limit this */ return result; @@ -412,7 +412,7 @@ PyObject *PyC_DefaultNameSpace(const char *filename) PyDict_SetItemString(interp->modules, "__main__", mod_main); Py_DECREF(mod_main); /* sys.modules owns now */ PyModule_AddStringConstant(mod_main, "__name__", "__main__"); - if(filename) + if (filename) PyModule_AddStringConstant(mod_main, "__file__", filename); /* __file__ only for nice UI'ness */ PyModule_AddObject(mod_main, "__builtins__", interp->builtins); Py_INCREF(interp->builtins); /* AddObject steals a reference */ @@ -437,7 +437,7 @@ void PyC_MainModule_Restore(PyObject *main_mod) /* must be called before Py_Initialize, expects output of BLI_get_folder(BLENDER_PYTHON, NULL) */ void PyC_SetHomePath(const char *py_path_bundle) { - if(py_path_bundle==NULL) { + if (py_path_bundle==NULL) { /* Common enough to have bundled *nix python but complain on OSX/Win */ #if defined(__APPLE__) || defined(_WIN32) fprintf(stderr, "Warning! bundled python not found and is expected on this platform. (if you built with CMake: 'install' target may have not been built)\n"); @@ -450,7 +450,7 @@ void PyC_SetHomePath(const char *py_path_bundle) #ifdef __APPLE__ /* OSX allow file/directory names to contain : character (represented as / in the Finder) but current Python lib (release 3.1.1) doesn't handle these correctly */ - if(strchr(py_path_bundle, ':')) + if (strchr(py_path_bundle, ':')) printf("Warning : Blender application is located in a path containing : or / chars\ \nThis may make python import function fail\n"); #endif @@ -481,7 +481,7 @@ void PyC_RunQuicky(const char *filepath, int n, ...) { FILE *fp= fopen(filepath, "r"); - if(fp) { + if (fp) { PyGILState_STATE gilstate= PyGILState_Ensure(); va_list vargs; @@ -508,13 +508,13 @@ void PyC_RunQuicky(const char *filepath, int n, ...) ret= PyObject_CallFunction(calcsize, (char *)"s", format); - if(ret) { + if (ret) { sizes[i]= PyLong_AsSsize_t(ret); Py_DECREF(ret); ret = PyObject_CallFunction(unpack, (char *)"sy#", format, (char *)ptr, sizes[i]); } - if(ret == NULL) { + if (ret == NULL) { printf("PyC_InlineRun error, line:%d\n", __LINE__); PyErr_Print(); PyErr_Clear(); @@ -525,7 +525,7 @@ void PyC_RunQuicky(const char *filepath, int n, ...) sizes[i]= 0; } else { - if(PyTuple_GET_SIZE(ret) == 1) { + if (PyTuple_GET_SIZE(ret) == 1) { /* convenience, convert single tuples into single values */ PyObject *tmp= PyTuple_GET_ITEM(ret, 0); Py_INCREF(tmp); @@ -545,13 +545,13 @@ void PyC_RunQuicky(const char *filepath, int n, ...) fclose(fp); - if(py_result) { + if (py_result) { /* we could skip this but then only slice assignment would work * better not be so strict */ values= PyDict_GetItemString(py_dict, "values"); - if(values && PyList_Check(values)) { + if (values && PyList_Check(values)) { /* dont use the result */ Py_DECREF(py_result); @@ -567,10 +567,10 @@ void PyC_RunQuicky(const char *filepath, int n, ...) PyObject *item_new; /* prepend the string formatting and remake the tuple */ item= PyList_GET_ITEM(values, i); - if(PyTuple_CheckExact(item)) { + if (PyTuple_CheckExact(item)) { int ofs= PyTuple_GET_SIZE(item); item_new= PyTuple_New(ofs + 1); - while(ofs--) { + while (ofs--) { PyObject *member= PyTuple_GET_ITEM(item, ofs); PyTuple_SET_ITEM(item_new, ofs + 1, member); Py_INCREF(member); @@ -584,7 +584,7 @@ void PyC_RunQuicky(const char *filepath, int n, ...) ret = PyObject_Call(pack, item_new, NULL); - if(ret) { + if (ret) { /* copy the bytes back into memory */ memcpy(ptr, PyBytes_AS_STRING(ret), sizes[i]); Py_DECREF(ret); |