[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [42862] trunk/blender/source/blender/ python/mathutils: picky formatting of mathutils

Campbell Barton ideasman42 at gmail.com
Sat Dec 24 14:26:41 CET 2011


Revision: 42862
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=42862
Author:   campbellbarton
Date:     2011-12-24 13:26:30 +0000 (Sat, 24 Dec 2011)
Log Message:
-----------
picky formatting of mathutils

Modified Paths:
--------------
    trunk/blender/source/blender/python/mathutils/mathutils.c
    trunk/blender/source/blender/python/mathutils/mathutils_Color.c
    trunk/blender/source/blender/python/mathutils/mathutils_Euler.c
    trunk/blender/source/blender/python/mathutils/mathutils_Euler.h
    trunk/blender/source/blender/python/mathutils/mathutils_Matrix.c
    trunk/blender/source/blender/python/mathutils/mathutils_Quaternion.c
    trunk/blender/source/blender/python/mathutils/mathutils_Vector.c
    trunk/blender/source/blender/python/mathutils/mathutils_geometry.c
    trunk/blender/source/blender/python/mathutils/mathutils_noise.c

Modified: trunk/blender/source/blender/python/mathutils/mathutils.c
===================================================================
--- trunk/blender/source/blender/python/mathutils/mathutils.c	2011-12-24 11:56:13 UTC (rev 42861)
+++ trunk/blender/source/blender/python/mathutils/mathutils.c	2011-12-24 13:26:30 UTC (rev 42862)
@@ -49,10 +49,10 @@
 
 	int i;
 
-	i= size;
+	i = size;
 	do {
 		i--;
-		if ( ((array[i]= PyFloat_AsDouble((item= PySequence_Fast_GET_ITEM(value_fast, i)))) == -1.0f) &&
+		if ( ((array[i] = PyFloat_AsDouble((item = PySequence_Fast_GET_ITEM(value_fast, i)))) == -1.0f) &&
 		     PyErr_Occurred())
 		{
 			PyErr_Format(PyExc_TypeError,
@@ -75,10 +75,10 @@
 
 #if 1 /* approx 6x speedup for mathutils types */
 
-	if ( (size= VectorObject_Check(value)     ? ((VectorObject *)value)->size : 0) ||
-	     (size= EulerObject_Check(value)      ? 3 : 0) ||
-	     (size= QuaternionObject_Check(value) ? 4 : 0) ||
-	     (size= ColorObject_Check(value)      ? 3 : 0))
+	if ( (size = VectorObject_Check(value)     ? ((VectorObject *)value)->size : 0) ||
+	     (size = EulerObject_Check(value)      ? 3 : 0) ||
+	     (size = QuaternionObject_Check(value) ? 4 : 0) ||
+	     (size = ColorObject_Check(value)      ? 3 : 0))
 	{
 		if (BaseMath_ReadCallback((BaseMathObject *)value) == -1) {
 			return -1;
@@ -104,15 +104,15 @@
 	else
 #endif
 	{
-		PyObject *value_fast= NULL;
+		PyObject *value_fast = NULL;
 
 		/* non list/tuple cases */
-		if (!(value_fast=PySequence_Fast(value, error_prefix))) {
+		if (!(value_fast = PySequence_Fast(value, error_prefix))) {
 			/* PySequence_Fast sets the error */
 			return -1;
 		}
 
-		size= PySequence_Fast_GET_SIZE(value_fast);
+		size = PySequence_Fast_GET_SIZE(value_fast);
 
 		if (size > array_max || size < array_min) {
 			if (array_max == array_min)	{
@@ -139,10 +139,10 @@
 
 #if 1 /* approx 6x speedup for mathutils types */
 
-	if ( (size= VectorObject_Check(value)     ? ((VectorObject *)value)->size : 0) ||
-	     (size= EulerObject_Check(value)      ? 3 : 0) ||
-	     (size= QuaternionObject_Check(value) ? 4 : 0) ||
-	     (size= ColorObject_Check(value)      ? 3 : 0))
+	if ( (size = VectorObject_Check(value)     ? ((VectorObject *)value)->size : 0) ||
+	     (size = EulerObject_Check(value)      ? 3 : 0) ||
+	     (size = QuaternionObject_Check(value) ? 4 : 0) ||
+	     (size = ColorObject_Check(value)      ? 3 : 0))
 	{
 		if (BaseMath_ReadCallback((BaseMathObject *)value) == -1) {
 			return -1;
@@ -155,23 +155,23 @@
 			return -1;
 		}
 		
-		*array= PyMem_Malloc(size * sizeof(float));
+		*array = PyMem_Malloc(size * sizeof(float));
 		memcpy(*array, ((BaseMathObject *)value)->data, size * sizeof(float));
 		return size;
 	}
 	else
 #endif
 	{
-		PyObject *value_fast= NULL;
-		//*array= NULL;
+		PyObject *value_fast = NULL;
+		//*array = NULL;
 
 		/* non list/tuple cases */
-		if (!(value_fast=PySequence_Fast(value, error_prefix))) {
+		if (!(value_fast = PySequence_Fast(value, error_prefix))) {
 			/* PySequence_Fast sets the error */
 			return -1;
 		}
 
-		size= PySequence_Fast_GET_SIZE(value_fast);
+		size = PySequence_Fast_GET_SIZE(value_fast);
 
 		if (size < array_min) {
 			PyErr_Format(PyExc_ValueError,
@@ -180,7 +180,7 @@
 			return -1;
 		}
 
-		*array= PyMem_Malloc(size * sizeof(float));
+		*array = PyMem_Malloc(size * sizeof(float));
 
 		return mathutils_array_parse_fast(*array, size, value_fast, error_prefix);
 	}
@@ -261,7 +261,7 @@
 int EXPP_VectorsAreEqual(float *vecA, float *vecB, int size, int floatSteps)
 {
 	int x;
-	for (x=0; x< size; x++) {
+	for (x = 0; x < size; x++) {
 		if (EXPP_FloatsAreEqual(vecA[x], vecB[x], floatSteps) == 0)
 			return 0;
 	}
@@ -291,8 +291,8 @@
 	int i;
 	
 	/* find the first free slot */
-	for (i= 0; mathutils_callbacks[i]; i++) {
-		if (mathutils_callbacks[i]==cb) /* already registered? */
+	for (i = 0; mathutils_callbacks[i]; i++) {
+		if (mathutils_callbacks[i] == cb) /* already registered? */
 			return i;
 	}
 	
@@ -303,7 +303,7 @@
 /* use macros to check for NULL */
 int _BaseMathObject_ReadCallback(BaseMathObject *self)
 {
-	Mathutils_Callback *cb= mathutils_callbacks[self->cb_type];
+	Mathutils_Callback *cb = mathutils_callbacks[self->cb_type];
 	if (cb->get(self, self->cb_subtype) != -1)
 		return 0;
 
@@ -317,7 +317,7 @@
 
 int _BaseMathObject_WriteCallback(BaseMathObject *self)
 {
-	Mathutils_Callback *cb= mathutils_callbacks[self->cb_type];
+	Mathutils_Callback *cb = mathutils_callbacks[self->cb_type];
 	if (cb->set(self, self->cb_subtype) != -1)
 		return 0;
 
@@ -331,7 +331,7 @@
 
 int _BaseMathObject_ReadIndexCallback(BaseMathObject *self, int index)
 {
-	Mathutils_Callback *cb= mathutils_callbacks[self->cb_type];
+	Mathutils_Callback *cb = mathutils_callbacks[self->cb_type];
 	if (cb->get_index(self, self->cb_subtype, index) != -1)
 		return 0;
 
@@ -345,7 +345,7 @@
 
 int _BaseMathObject_WriteIndexCallback(BaseMathObject *self, int index)
 {
-	Mathutils_Callback *cb= mathutils_callbacks[self->cb_type];
+	Mathutils_Callback *cb = mathutils_callbacks[self->cb_type];
 	if (cb->set_index(self, self->cb_subtype, index) != -1)
 		return 0;
 
@@ -361,7 +361,7 @@
 char BaseMathObject_owner_doc[] = "The item this is wrapping or None  (readonly).";
 PyObject *BaseMathObject_owner_get(BaseMathObject *self, void *UNUSED(closure))
 {
-	PyObject *ret= self->cb_user ? self->cb_user : Py_None;
+	PyObject *ret = self->cb_user ? self->cb_user : Py_None;
 	Py_INCREF(ret);
 	return ret;
 }
@@ -420,7 +420,7 @@
 {
 	PyObject *submodule;
 	PyObject *item;
-	PyObject *sys_modules= PyThreadState_GET()->interp->modules;
+	PyObject *sys_modules = PyThreadState_GET()->interp->modules;
 
 	if (PyType_Ready(&vector_Type) < 0)
 		return NULL;
@@ -445,7 +445,7 @@
 	PyModule_AddObject(submodule, "Color",		(PyObject *)&color_Type);
 	
 	/* submodule */
-	PyModule_AddObject(submodule, "geometry",		(item=PyInit_mathutils_geometry()));
+	PyModule_AddObject(submodule, "geometry",		(item = PyInit_mathutils_geometry()));
 	/* XXX, python doesnt do imports with this usefully yet
 	 * 'from mathutils.geometry import PolyFill'
 	 * ...fails without this. */
@@ -453,12 +453,12 @@
 	Py_INCREF(item);
 
 	/* Noise submodule */
-	PyModule_AddObject(submodule, "noise",		(item=PyInit_mathutils_noise()));
+	PyModule_AddObject(submodule, "noise",		(item = PyInit_mathutils_noise()));
 	PyDict_SetItemString(sys_modules, "mathutils.noise", item);
 	Py_INCREF(item);
 
-	mathutils_matrix_row_cb_index= Mathutils_RegisterCallback(&mathutils_matrix_row_cb);
-	mathutils_matrix_col_cb_index= Mathutils_RegisterCallback(&mathutils_matrix_col_cb);
+	mathutils_matrix_row_cb_index = Mathutils_RegisterCallback(&mathutils_matrix_row_cb);
+	mathutils_matrix_col_cb_index = Mathutils_RegisterCallback(&mathutils_matrix_col_cb);
 
 	return submodule;
 }

Modified: trunk/blender/source/blender/python/mathutils/mathutils_Color.c
===================================================================
--- trunk/blender/source/blender/python/mathutils/mathutils_Color.c	2011-12-24 11:56:13 UTC (rev 42861)
+++ trunk/blender/source/blender/python/mathutils/mathutils_Color.c	2011-12-24 13:26:30 UTC (rev 42862)
@@ -40,7 +40,7 @@
 //makes a new color for you to play with
 static PyObject *Color_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
 {
-	float col[3]= {0.0f, 0.0f, 0.0f};
+	float col[3] = {0.0f, 0.0f, 0.0f};
 
 	if (kwds && PyDict_Size(kwds)) {
 		PyErr_SetString(PyExc_TypeError,
@@ -73,15 +73,15 @@
 	PyObject *ret;
 	int i;
 
-	ret= PyTuple_New(COLOR_SIZE);
+	ret = PyTuple_New(COLOR_SIZE);
 
 	if (ndigits >= 0) {
-		for (i= 0; i < COLOR_SIZE; i++) {
+		for (i = 0; i < COLOR_SIZE; i++) {
 			PyTuple_SET_ITEM(ret, i, PyFloat_FromDouble(double_round((double)self->col[i], ndigits)));
 		}
 	}
 	else {
-		for (i= 0; i < COLOR_SIZE; i++) {
+		for (i = 0; i < COLOR_SIZE; i++) {
 			PyTuple_SET_ITEM(ret, i, PyFloat_FromDouble(self->col[i]));
 		}
 	}
@@ -118,9 +118,9 @@
 	if (BaseMath_ReadCallback(self) == -1)
 		return NULL;
 
-	tuple= Color_ToTupleExt(self, -1);
+	tuple = Color_ToTupleExt(self, -1);
 
-	ret= PyUnicode_FromFormat("Color(%R)", tuple);
+	ret = PyUnicode_FromFormat("Color(%R)", tuple);
 
 	Py_DECREF(tuple);
 	return ret;
@@ -133,7 +133,7 @@
 	if (BaseMath_ReadCallback(self) == -1)
 		return NULL;
 
-	ds= BLI_dynstr_new();
+	ds = BLI_dynstr_new();
 
 	BLI_dynstr_appendf(ds, "<Color (r=%.4f, g=%.4f, b=%.4f)>",
 	                   self->col[0], self->col[1], self->col[2]);
@@ -143,19 +143,19 @@
 
 //------------------------tp_richcmpr
 //returns -1 execption, 0 false, 1 true
-static PyObject* Color_richcmpr(PyObject *a, PyObject *b, int op)
+static PyObject *Color_richcmpr(PyObject *a, PyObject *b, int op)
 {
 	PyObject *res;
-	int ok= -1; /* zero is true */
+	int ok = -1; /* zero is true */
 
 	if (ColorObject_Check(a) && ColorObject_Check(b)) {
-		ColorObject *colA= (ColorObject*)a;
-		ColorObject *colB= (ColorObject*)b;
+		ColorObject *colA = (ColorObject *)a;
+		ColorObject *colB = (ColorObject *)b;
 
 		if (BaseMath_ReadCallback(colA) == -1 || BaseMath_ReadCallback(colB) == -1)
 			return NULL;
 
-		ok= EXPP_VectorsAreEqual(colA->col, colB->col, COLOR_SIZE, 1) ? 0 : -1;
+		ok = EXPP_VectorsAreEqual(colA->col, colB->col, COLOR_SIZE, 1) ? 0 : -1;
 	}
 
 	switch (op) {
@@ -190,7 +190,7 @@
 //sequence accessor (get)
 static PyObject *Color_item(ColorObject * self, int i)
 {
-	if (i<0) i= COLOR_SIZE-i;
+	if (i < 0) i = COLOR_SIZE - i;
 
 	if (i < 0 || i >= COLOR_SIZE) {
 		PyErr_SetString(PyExc_IndexError,
@@ -218,7 +218,7 @@
 		return -1;
 	}
 
-	if (i<0) i= COLOR_SIZE-i;
+	if (i < 0) i= COLOR_SIZE - i;
 
 	if (i < 0 || i >= COLOR_SIZE) {
 		PyErr_SetString(PyExc_IndexError, "color[attribute] = x: "
@@ -244,12 +244,12 @@
 		return NULL;
 
 	CLAMP(begin, 0, COLOR_SIZE);
-	if (end<0) end= (COLOR_SIZE + 1) + end;
+	if (end < 0) end = (COLOR_SIZE + 1) + end;
 	CLAMP(end, 0, COLOR_SIZE);
-	begin= MIN2(begin, end);
+	begin = MIN2(begin, end);
 
-	tuple= PyTuple_New(end - begin);
-	for (count= begin; count < end; count++) {
+	tuple = PyTuple_New(end - begin);
+	for (count = begin; count < end; count++) {
 		PyTuple_SET_ITEM(tuple, count - begin, PyFloat_FromDouble(self->col[count]));
 	}
 
@@ -266,11 +266,11 @@
 		return -1;
 
 	CLAMP(begin, 0, COLOR_SIZE);
-	if (end<0) end= (COLOR_SIZE + 1) + end;
+	if (end < 0) end = (COLOR_SIZE + 1) + end;
 	CLAMP(end, 0, COLOR_SIZE);
 	begin = MIN2(begin, end);
 
-	if ((size=mathutils_array_parse(col, 0, COLOR_SIZE, seq, "mathutils.Color[begin:end] = []")) == -1)

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list