[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [40363] trunk/blender/source/blender/ python/mathutils: edits to argument parsing for Euler.rotate_axis, also corrected some exception messages and minor style edits.

Campbell Barton ideasman42 at gmail.com
Mon Sep 19 17:13:16 CEST 2011


Revision: 40363
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=40363
Author:   campbellbarton
Date:     2011-09-19 15:13:16 +0000 (Mon, 19 Sep 2011)
Log Message:
-----------
edits to argument parsing for Euler.rotate_axis, also corrected some exception messages and minor style edits.

Modified Paths:
--------------
    trunk/blender/source/blender/python/mathutils/mathutils_Euler.c
    trunk/blender/source/blender/python/mathutils/mathutils_Quaternion.c
    trunk/blender/source/blender/python/mathutils/mathutils_Vector.c

Modified: trunk/blender/source/blender/python/mathutils/mathutils_Euler.c
===================================================================
--- trunk/blender/source/blender/python/mathutils/mathutils_Euler.c	2011-09-19 15:11:01 UTC (rev 40362)
+++ trunk/blender/source/blender/python/mathutils/mathutils_Euler.c	2011-09-19 15:13:16 UTC (rev 40363)
@@ -196,16 +196,18 @@
 static PyObject *Euler_rotate_axis(EulerObject * self, PyObject *args)
 {
 	float angle = 0.0f;
-	const char *axis;
+	int axis; /* actually a character */
 
-	if(!PyArg_ParseTuple(args, "sf:rotate", &axis, &angle)){
+	if(!PyArg_ParseTuple(args, "Cf:rotate", &axis, &angle)){
 		PyErr_SetString(PyExc_TypeError,
-		                "euler.rotate(): "
-		                "expected angle (float) and axis (x, y, z)");
+		                "Euler.rotate_axis(): "
+		                "expected an axis 'X', 'Y', 'Z' and an angle (float)");
 		return NULL;
 	}
-	if(!(ELEM3(*axis, 'X', 'Y', 'Z') && axis[1]=='\0')){
-		PyErr_SetString(PyExc_ValueError, "euler.rotate(): "
+
+	if(!(ELEM3(axis, 'X', 'Y', 'Z'))){
+		PyErr_SetString(PyExc_ValueError,
+		                "Euler.rotate_axis(): "
 		                "expected axis to be 'X', 'Y' or 'Z'");
 		return NULL;
 	}
@@ -214,7 +216,7 @@
 		return NULL;
 
 
-	rotate_eulO(self->eul, self->order, *axis, angle);
+	rotate_eulO(self->eul, self->order, (char)axis, angle);
 
 	(void)BaseMath_WriteCallback(self);
 

Modified: trunk/blender/source/blender/python/mathutils/mathutils_Quaternion.c
===================================================================
--- trunk/blender/source/blender/python/mathutils/mathutils_Quaternion.c	2011-09-19 15:11:01 UTC (rev 40362)
+++ trunk/blender/source/blender/python/mathutils/mathutils_Quaternion.c	2011-09-19 15:13:16 UTC (rev 40363)
@@ -161,7 +161,7 @@
 	if(BaseMath_ReadCallback(self) == -1)
 		return NULL;
 
-	if(mathutils_array_parse(tquat, QUAT_SIZE, QUAT_SIZE, value, "quaternion.cross(other), invalid 'other' arg") == -1)
+	if(mathutils_array_parse(tquat, QUAT_SIZE, QUAT_SIZE, value, "Quaternion.cross(other), invalid 'other' arg") == -1)
 		return NULL;
 
 	mul_qt_qtqt(quat, self->quat, tquat);
@@ -186,7 +186,7 @@
 	if(BaseMath_ReadCallback(self) == -1)
 		return NULL;
 
-	if(mathutils_array_parse(tquat, QUAT_SIZE, QUAT_SIZE, value, "quaternion.dot(other), invalid 'other' arg") == -1)
+	if(mathutils_array_parse(tquat, QUAT_SIZE, QUAT_SIZE, value, "Quaternion.dot(other), invalid 'other' arg") == -1)
 		return NULL;
 
 	return PyFloat_FromDouble(dot_qtqt(self->quat, tquat));
@@ -209,7 +209,7 @@
 	if(BaseMath_ReadCallback(self) == -1)
 		return NULL;
 
-	if(mathutils_array_parse(tquat, QUAT_SIZE, QUAT_SIZE, value, "quaternion.difference(other), invalid 'other' arg") == -1)
+	if(mathutils_array_parse(tquat, QUAT_SIZE, QUAT_SIZE, value, "Quaternion.difference(other), invalid 'other' arg") == -1)
 		return NULL;
 
 	rotation_between_quats_to_quat(quat, self->quat, tquat);
@@ -244,7 +244,7 @@
 	if(BaseMath_ReadCallback(self) == -1)
 		return NULL;
 
-	if(mathutils_array_parse(tquat, QUAT_SIZE, QUAT_SIZE, value, "quaternion.slerp(other), invalid 'other' arg") == -1)
+	if(mathutils_array_parse(tquat, QUAT_SIZE, QUAT_SIZE, value, "Quaternion.slerp(other), invalid 'other' arg") == -1)
 		return NULL;
 
 	if(fac > 1.0f || fac < 0.0f) {
@@ -275,7 +275,7 @@
 	if(BaseMath_ReadCallback(self) == -1)
 		return NULL;
 
-	if(mathutils_any_to_rotmat(other_rmat, value, "quaternion.rotate(value)") == -1)
+	if(mathutils_any_to_rotmat(other_rmat, value, "Quaternion.rotate(value)") == -1)
 		return NULL;
 
 	length= normalize_qt_qt(tquat, self->quat);
@@ -909,7 +909,7 @@
 
 	if(angle==-1.0 && PyErr_Occurred()) { /* parsed item not a number */
 		PyErr_SetString(PyExc_TypeError,
-		                "quaternion.angle = value: float expected");
+		                "Quaternion.angle = value: float expected");
 		return -1;
 	}
 

Modified: trunk/blender/source/blender/python/mathutils/mathutils_Vector.c
===================================================================
--- trunk/blender/source/blender/python/mathutils/mathutils_Vector.c	2011-09-19 15:11:01 UTC (rev 40362)
+++ trunk/blender/source/blender/python/mathutils/mathutils_Vector.c	2011-09-19 15:13:16 UTC (rev 40363)
@@ -159,13 +159,13 @@
 {
 	if(self->wrapped==Py_WRAP) {
 		PyErr_SetString(PyExc_TypeError,
-		                "vector.resize_2d(): "
+		                "Vector.resize_2d(): "
 		                "cannot resize wrapped data - only python vectors");
 		return NULL;
 	}
 	if(self->cb_user) {
 		PyErr_SetString(PyExc_TypeError,
-		                "vector.resize_2d(): "
+		                "Vector.resize_2d(): "
 		                "cannot resize a vector that has an owner");
 		return NULL;
 	}
@@ -173,7 +173,7 @@
 	self->vec = PyMem_Realloc(self->vec, (sizeof(float) * 2));
 	if(self->vec == NULL) {
 		PyErr_SetString(PyExc_MemoryError,
-		                "vector.resize_2d(): "
+		                "Vector.resize_2d(): "
 		                "problem allocating pointer space");
 		return NULL;
 	}
@@ -194,13 +194,13 @@
 {
 	if (self->wrapped==Py_WRAP) {
 		PyErr_SetString(PyExc_TypeError,
-		                "vector.resize_3d(): "
+		                "Vector.resize_3d(): "
 		                "cannot resize wrapped data - only python vectors");
 		return NULL;
 	}
 	if(self->cb_user) {
 		PyErr_SetString(PyExc_TypeError,
-		                "vector.resize_3d(): "
+		                "Vector.resize_3d(): "
 		                "cannot resize a vector that has an owner");
 		return NULL;
 	}
@@ -208,7 +208,7 @@
 	self->vec = PyMem_Realloc(self->vec, (sizeof(float) * 3));
 	if(self->vec == NULL) {
 		PyErr_SetString(PyExc_MemoryError,
-		                "vector.resize_3d(): "
+		                "Vector.resize_3d(): "
 		                "problem allocating pointer space");
 		return NULL;
 	}
@@ -232,13 +232,13 @@
 {
 	if(self->wrapped==Py_WRAP) {
 		PyErr_SetString(PyExc_TypeError,
-		                "vector.resize_4d(): "
+		                "Vector.resize_4d(): "
 		                "cannot resize wrapped data - only python vectors");
 		return NULL;
 	}
 	if(self->cb_user) {
 		PyErr_SetString(PyExc_TypeError,
-		                "vector.resize_4d(): "
+		                "Vector.resize_4d(): "
 		                "cannot resize a vector that has an owner");
 		return NULL;
 	}
@@ -246,7 +246,7 @@
 	self->vec = PyMem_Realloc(self->vec, (sizeof(float) * 4));
 	if(self->vec == NULL) {
 		PyErr_SetString(PyExc_MemoryError,
-		                "vector.resize_4d(): "
+		                "Vector.resize_4d(): "
 		                "problem allocating pointer space");
 		return NULL;
 	}
@@ -354,7 +354,7 @@
 
 	if(ndigits > 22 || ndigits < 0) {
 		PyErr_SetString(PyExc_ValueError,
-		                "vector.to_tuple(ndigits): "
+		                "Vector.to_tuple(ndigits): "
 		                "ndigits must be between 0 and 21");
 		return NULL;
 	}
@@ -391,7 +391,7 @@
 
 	if (self->size != 3) {
 		PyErr_SetString(PyExc_TypeError,
-		                "vector.to_track_quat(): "
+		                "Vector.to_track_quat(): "
 		                "only for 3D vectors");
 		return NULL;
 	}
@@ -512,7 +512,7 @@
 	if(BaseMath_ReadCallback(self) == -1)
 		return NULL;
 
-	if((value_size= mathutils_array_parse(tvec, 2, 4, value, "vector.reflect(other), invalid 'other' arg")) == -1)
+	if((value_size= mathutils_array_parse(tvec, 2, 4, value, "Vector.reflect(other), invalid 'other' arg")) == -1)
 		return NULL;
 
 	mirror[0] = tvec[0];
@@ -551,7 +551,7 @@
 	if(BaseMath_ReadCallback(self) == -1)
 		return NULL;
 
-	if(mathutils_array_parse(tvec, self->size, self->size, value, "vector.cross(other), invalid 'other' arg") == -1)
+	if(mathutils_array_parse(tvec, self->size, self->size, value, "Vector.cross(other), invalid 'other' arg") == -1)
 		return NULL;
 
 	ret= (VectorObject *)newVectorObject(NULL, 3, Py_NEW, Py_TYPE(self));
@@ -578,7 +578,7 @@
 	if(BaseMath_ReadCallback(self) == -1)
 		return NULL;
 
-	if(mathutils_array_parse(tvec, self->size, self->size, value, "vector.dot(other), invalid 'other' arg") == -1)
+	if(mathutils_array_parse(tvec, self->size, self->size, value, "Vector.dot(other), invalid 'other' arg") == -1)
 		return NULL;
 
 	for(x = 0; x < self->size; x++) {
@@ -618,7 +618,7 @@
 	if(BaseMath_ReadCallback(self) == -1)
 		return NULL;
 
-	if(mathutils_array_parse(tvec, size, size, value, "vector.angle(other), invalid 'other' arg") == -1)
+	if(mathutils_array_parse(tvec, size, size, value, "Vector.angle(other), invalid 'other' arg") == -1)
 		return NULL;
 
 	for(x = 0; x < size; x++) {
@@ -633,7 +633,7 @@
 		}
 		else {
 			PyErr_SetString(PyExc_ValueError,
-			                "vector.angle(other): "
+			                "Vector.angle(other): "
 			                "zero length vectors have no valid angle");
 			return NULL;
 		}
@@ -675,7 +675,7 @@
 	if(BaseMath_ReadCallback(self) == -1)
 		return NULL;
 
-	if(mathutils_array_parse(vec_b, 3, MAX_DIMENSIONS, value, "vector.difference(other), invalid 'other' arg") == -1)
+	if(mathutils_array_parse(vec_b, 3, MAX_DIMENSIONS, value, "Vector.difference(other), invalid 'other' arg") == -1)
 		return NULL;
 
 	normalize_v3_v3(vec_a, self->vec);
@@ -707,7 +707,7 @@
 	if(BaseMath_ReadCallback(self) == -1)
 		return NULL;
 
-	if(mathutils_array_parse(tvec, size, size, value, "vector.project(other), invalid 'other' arg") == -1)
+	if(mathutils_array_parse(tvec, size, size, value, "Vector.project(other), invalid 'other' arg") == -1)
 		return NULL;
 
 	if(BaseMath_ReadCallback(self) == -1)
@@ -749,7 +749,7 @@
 	if(!PyArg_ParseTuple(args, "Of:lerp", &value, &fac))
 		return NULL;
 
-	if(mathutils_array_parse(tvec, size, size, value, "vector.lerp(other), invalid 'other' arg") == -1)
+	if(mathutils_array_parse(tvec, size, size, value, "Vector.lerp(other), invalid 'other' arg") == -1)
 		return NULL;
 
 	if(BaseMath_ReadCallback(self) == -1)
@@ -778,7 +778,7 @@
 	if(BaseMath_ReadCallback(self) == -1)
 		return NULL;
 
-	if(mathutils_any_to_rotmat(other_rmat, value, "vector.rotate(value)") == -1)
+	if(mathutils_any_to_rotmat(other_rmat, value, "Vector.rotate(value)") == -1)
 		return NULL;
 
 	if(self->size < 3) {
@@ -839,7 +839,7 @@
 	if(i < 0 || i >= self->size) {
 		if(is_attr)	{
 			PyErr_Format(PyExc_AttributeError,
-			             "vector.%c: unavailable on %dd vector",
+			             "Vector.%c: unavailable on %dd vector",
 			             *(((char *)"xyzw") + i), self->size);
 		}
 		else {
@@ -875,7 +875,7 @@

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list