[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [52812] trunk/blender/source/blender/ python/mathutils: ifdef out dynstr so mathutils can be compiled as an external module again.

Campbell Barton ideasman42 at gmail.com
Sat Dec 8 02:17:02 CET 2012


Revision: 52812
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=52812
Author:   campbellbarton
Date:     2012-12-08 01:16:59 +0000 (Sat, 08 Dec 2012)
Log Message:
-----------
ifdef out dynstr so mathutils can be compiled as an external module again.

Modified Paths:
--------------
    trunk/blender/source/blender/python/mathutils/mathutils.c
    trunk/blender/source/blender/python/mathutils/mathutils.h
    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_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

Modified: trunk/blender/source/blender/python/mathutils/mathutils.c
===================================================================
--- trunk/blender/source/blender/python/mathutils/mathutils.c	2012-12-08 00:21:29 UTC (rev 52811)
+++ trunk/blender/source/blender/python/mathutils/mathutils.c	2012-12-08 01:16:59 UTC (rev 52812)
@@ -35,8 +35,11 @@
 
 #include "BLI_math.h"
 #include "BLI_utildefines.h"
-#include "BLI_dynstr.h"
 
+#ifndef MATH_STANDALONE
+#  include "BLI_dynstr.h"
+#endif
+
 PyDoc_STRVAR(M_Mathutils_doc,
 "This module provides access to matrices, eulers, quaternions and vectors."
 );
@@ -312,6 +315,7 @@
 	return 1;
 }
 
+#ifndef MATH_STANDALONE
 /* dynstr as python string utility funcions, frees 'ds'! */
 PyObject *mathutils_dynstr_to_py(struct DynStr *ds)
 {
@@ -324,6 +328,7 @@
 	PyMem_Free(ds_buf);
 	return ret;
 }
+#endif
 
 /* silly function, we dont use arg. just check its compatible with __deepcopy__ */
 int mathutils_deepcopy_args_check(PyObject *args)

Modified: trunk/blender/source/blender/python/mathutils/mathutils.h
===================================================================
--- trunk/blender/source/blender/python/mathutils/mathutils.h	2012-12-08 00:21:29 UTC (rev 52811)
+++ trunk/blender/source/blender/python/mathutils/mathutils.h	2012-12-08 01:16:59 UTC (rev 52812)
@@ -120,8 +120,11 @@
 
 int column_vector_multiplication(float rvec[4], VectorObject *vec, MatrixObject *mat);
 
+#ifndef MATH_STANDALONE
 /* dynstr as python string utility funcions */
 PyObject *mathutils_dynstr_to_py(struct DynStr *ds);
+#endif
+
 int mathutils_deepcopy_args_check(PyObject *args);
 
 #endif /* __MATHUTILS_H__ */

Modified: trunk/blender/source/blender/python/mathutils/mathutils_Color.c
===================================================================
--- trunk/blender/source/blender/python/mathutils/mathutils_Color.c	2012-12-08 00:21:29 UTC (rev 52811)
+++ trunk/blender/source/blender/python/mathutils/mathutils_Color.c	2012-12-08 01:16:59 UTC (rev 52812)
@@ -31,8 +31,11 @@
 
 #include "BLI_math.h"
 #include "BLI_utildefines.h"
-#include "BLI_dynstr.h"
 
+#ifndef MATH_STANDALONE
+#  include "BLI_dynstr.h"
+#endif
+
 #define COLOR_SIZE 3
 
 /* ----------------------------------mathutils.Color() ------------------- */
@@ -131,6 +134,7 @@
 	return ret;
 }
 
+#ifndef MATH_STANDALONE
 static PyObject *Color_str(ColorObject *self)
 {
 	DynStr *ds;
@@ -145,6 +149,7 @@
 
 	return mathutils_dynstr_to_py(ds); /* frees ds */
 }
+#endif
 
 /* ------------------------tp_richcmpr */
 /* returns -1 exception, 0 false, 1 true */
@@ -820,7 +825,11 @@
 	&Color_AsMapping,               /* tp_as_mapping */
 	NULL,                           /* tp_hash */
 	NULL,                           /* tp_call */
+#ifndef MATH_STANDALONE
 	(reprfunc) Color_str,           /* tp_str */
+#else
+	NULL,                           /* tp_str */
+#endif
 	NULL,                           /* tp_getattro */
 	NULL,                           /* tp_setattro */
 	NULL,                           /* tp_as_buffer */

Modified: trunk/blender/source/blender/python/mathutils/mathutils_Euler.c
===================================================================
--- trunk/blender/source/blender/python/mathutils/mathutils_Euler.c	2012-12-08 00:21:29 UTC (rev 52811)
+++ trunk/blender/source/blender/python/mathutils/mathutils_Euler.c	2012-12-08 01:16:59 UTC (rev 52812)
@@ -35,8 +35,11 @@
 
 #include "BLI_math.h"
 #include "BLI_utildefines.h"
-#include "BLI_dynstr.h"
 
+#ifndef MATH_STANDALONE
+#  include "BLI_dynstr.h"
+#endif
+
 #define EULER_SIZE 3
 
 /* ----------------------------------mathutils.Euler() ------------------- */
@@ -323,6 +326,7 @@
 	return ret;
 }
 
+#ifndef MATH_STANDALONE
 static PyObject *Euler_str(EulerObject *self)
 {
 	DynStr *ds;
@@ -337,6 +341,7 @@
 
 	return mathutils_dynstr_to_py(ds); /* frees ds */
 }
+#endif
 
 static PyObject *Euler_richcmpr(PyObject *a, PyObject *b, int op)
 {
@@ -663,7 +668,11 @@
 	&Euler_AsMapping,               /* tp_as_mapping */
 	NULL,                           /* tp_hash */
 	NULL,                           /* tp_call */
+#ifndef MATH_STANDALONE
 	(reprfunc) Euler_str,           /* tp_str */
+#else
+	NULL,                           /* tp_str */
+#endif
 	NULL,                           /* tp_getattro */
 	NULL,                           /* tp_setattro */
 	NULL,                           /* tp_as_buffer */

Modified: trunk/blender/source/blender/python/mathutils/mathutils_Matrix.c
===================================================================
--- trunk/blender/source/blender/python/mathutils/mathutils_Matrix.c	2012-12-08 00:21:29 UTC (rev 52811)
+++ trunk/blender/source/blender/python/mathutils/mathutils_Matrix.c	2012-12-08 01:16:59 UTC (rev 52812)
@@ -35,8 +35,11 @@
 #include "BLI_math.h"
 #include "BLI_utildefines.h"
 #include "BLI_string.h"
-#include "BLI_dynstr.h"
 
+#ifndef MATH_STANDALONE
+#  include "BLI_dynstr.h"
+#endif
+
 typedef enum eMatrixAccess_t {
 	MAT_ACCESS_ROW,
 	MAT_ACCESS_COL
@@ -1647,6 +1650,7 @@
 	return NULL;
 }
 
+#ifndef MATH_STANDALONE
 static PyObject *Matrix_str(MatrixObject *self)
 {
 	DynStr *ds;
@@ -1682,6 +1686,7 @@
 
 	return mathutils_dynstr_to_py(ds); /* frees ds */
 }
+#endif
 
 static PyObject *Matrix_richcmpr(PyObject *a, PyObject *b, int op)
 {
@@ -2418,7 +2423,11 @@
 	&Matrix_AsMapping,                  /*tp_as_mapping*/
 	NULL,                               /*tp_hash*/
 	NULL,                               /*tp_call*/
+#ifndef MATH_STANDALONE
 	(reprfunc) Matrix_str,              /*tp_str*/
+#else
+	NULL,                               /*tp_str*/
+#endif
 	NULL,                               /*tp_getattro*/
 	NULL,                               /*tp_setattro*/
 	NULL,                               /*tp_as_buffer*/

Modified: trunk/blender/source/blender/python/mathutils/mathutils_Quaternion.c
===================================================================
--- trunk/blender/source/blender/python/mathutils/mathutils_Quaternion.c	2012-12-08 00:21:29 UTC (rev 52811)
+++ trunk/blender/source/blender/python/mathutils/mathutils_Quaternion.c	2012-12-08 01:16:59 UTC (rev 52812)
@@ -35,8 +35,11 @@
 
 #include "BLI_math.h"
 #include "BLI_utildefines.h"
-#include "BLI_dynstr.h"
 
+#ifndef MATH_STANDALONE
+#  include "BLI_dynstr.h"
+#endif
+
 #define QUAT_SIZE 4
 
 static PyObject *quat__apply_to_copy(PyNoArgsFunction quat_func, QuaternionObject *self);
@@ -496,6 +499,7 @@
 	return ret;
 }
 
+#ifndef MATH_STANDALONE
 static PyObject *Quaternion_str(QuaternionObject *self)
 {
 	DynStr *ds;
@@ -510,6 +514,7 @@
 
 	return mathutils_dynstr_to_py(ds); /* frees ds */
 }
+#endif
 
 static PyObject *Quaternion_richcmpr(PyObject *a, PyObject *b, int op)
 {
@@ -1202,7 +1207,11 @@
 	&Quaternion_AsMapping,              /* tp_as_mapping */
 	NULL,                               /* tp_hash */
 	NULL,                               /* tp_call */
+#ifndef MATH_STANDALONE
 	(reprfunc) Quaternion_str,          /* tp_str */
+#else
+	NULL,                               /* tp_str */
+#endif
 	NULL,                               /* tp_getattro */
 	NULL,                               /* tp_setattro */
 	NULL,                               /* tp_as_buffer */

Modified: trunk/blender/source/blender/python/mathutils/mathutils_Vector.c
===================================================================
--- trunk/blender/source/blender/python/mathutils/mathutils_Vector.c	2012-12-08 00:21:29 UTC (rev 52811)
+++ trunk/blender/source/blender/python/mathutils/mathutils_Vector.c	2012-12-08 01:16:59 UTC (rev 52812)
@@ -35,8 +35,11 @@
 
 #include "BLI_math.h"
 #include "BLI_utildefines.h"
-#include "BLI_dynstr.h"
 
+#ifndef MATH_STANDALONE
+#  include "BLI_dynstr.h"
+#endif
+
 #define MAX_DIMENSIONS 4
 
 /* Swizzle axes get packed into a single value that is used as a closure. Each
@@ -1231,6 +1234,7 @@
 	return ret;
 }
 
+#ifndef MATH_STANDALONE
 static PyObject *Vector_str(VectorObject *self)
 {
 	int i;
@@ -1252,8 +1256,8 @@
 
 	return mathutils_dynstr_to_py(ds); /* frees ds */
 }
+#endif
 
-
 /* Sequence Protocol */
 /* sequence length len(vector) */
 static int Vector_len(VectorObject *self)
@@ -2816,7 +2820,11 @@
 
 	NULL,                       /* hashfunc tp_hash; */
 	NULL,                       /* ternaryfunc tp_call; */
+#ifndef MATH_STANDALONE
 	(reprfunc)Vector_str,       /* reprfunc tp_str; */
+#else
+	NULL,                       /* reprfunc tp_str; */
+#endif
 	NULL,                       /* getattrofunc tp_getattro; */
 	NULL,                       /* setattrofunc tp_setattro; */
 

Modified: trunk/blender/source/blender/python/mathutils/mathutils_geometry.c
===================================================================
--- trunk/blender/source/blender/python/mathutils/mathutils_geometry.c	2012-12-08 00:21:29 UTC (rev 52811)
+++ trunk/blender/source/blender/python/mathutils/mathutils_geometry.c	2012-12-08 01:16:59 UTC (rev 52812)
@@ -973,12 +973,14 @@
 
 		float n1n2[3], n2n3[3], n3n1[3];
 		float potentialVertex[3];
-		char *planes_used = MEM_callocN(sizeof(char) * len, __func__);
+		char *planes_used = PyMem_Malloc(sizeof(char) * len);
 
 		/* python */
 		PyObject *py_verts = PyList_New(0);
 		PyObject *py_plene_index = PyList_New(0);
 
+		memset(planes_used, 0, sizeof(char) * len);
+
 		for (i = 0; i < len; i++) {
 			const float *N1 = planes[i];
 			for (j = i + 1; j < len; j++) {
@@ -1031,7 +1033,7 @@
 				Py_DECREF(item);
 			}
 		}
-		MEM_freeN(planes_used);
+		PyMem_Free(planes_used);
 
 		{
 			PyObject *ret = PyTuple_New(2);




More information about the Bf-blender-cvs mailing list