From adf7bfa8bb530db8baf7c07dd296851658ee925e Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 8 Dec 2012 01:16:59 +0000 Subject: ifdef out dynstr so mathutils can be compiled as an external module again. --- source/blender/python/mathutils/mathutils.c | 7 ++++++- source/blender/python/mathutils/mathutils.h | 3 +++ source/blender/python/mathutils/mathutils_Color.c | 11 ++++++++++- source/blender/python/mathutils/mathutils_Euler.c | 11 ++++++++++- source/blender/python/mathutils/mathutils_Matrix.c | 11 ++++++++++- source/blender/python/mathutils/mathutils_Quaternion.c | 11 ++++++++++- source/blender/python/mathutils/mathutils_Vector.c | 12 ++++++++++-- source/blender/python/mathutils/mathutils_geometry.c | 6 ++++-- 8 files changed, 63 insertions(+), 9 deletions(-) diff --git a/source/blender/python/mathutils/mathutils.c b/source/blender/python/mathutils/mathutils.c index bc9b747f05e..202598233b6 100644 --- a/source/blender/python/mathutils/mathutils.c +++ b/source/blender/python/mathutils/mathutils.c @@ -35,7 +35,10 @@ #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 @@ int EXPP_VectorsAreEqual(const float *vecA, const float *vecB, int size, int flo 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 @@ PyObject *mathutils_dynstr_to_py(struct DynStr *ds) 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) diff --git a/source/blender/python/mathutils/mathutils.h b/source/blender/python/mathutils/mathutils.h index 92a4aac7093..7b03b149459 100644 --- a/source/blender/python/mathutils/mathutils.h +++ b/source/blender/python/mathutils/mathutils.h @@ -120,8 +120,11 @@ int mathutils_any_to_rotmat(float rmat[3][3], PyObject *value, const char *error 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__ */ diff --git a/source/blender/python/mathutils/mathutils_Color.c b/source/blender/python/mathutils/mathutils_Color.c index f16b488f9d0..4a29e72418b 100644 --- a/source/blender/python/mathutils/mathutils_Color.c +++ b/source/blender/python/mathutils/mathutils_Color.c @@ -31,7 +31,10 @@ #include "BLI_math.h" #include "BLI_utildefines.h" -#include "BLI_dynstr.h" + +#ifndef MATH_STANDALONE +# include "BLI_dynstr.h" +#endif #define COLOR_SIZE 3 @@ -131,6 +134,7 @@ static PyObject *Color_repr(ColorObject *self) return ret; } +#ifndef MATH_STANDALONE static PyObject *Color_str(ColorObject *self) { DynStr *ds; @@ -145,6 +149,7 @@ static PyObject *Color_str(ColorObject *self) return mathutils_dynstr_to_py(ds); /* frees ds */ } +#endif /* ------------------------tp_richcmpr */ /* returns -1 exception, 0 false, 1 true */ @@ -820,7 +825,11 @@ PyTypeObject color_Type = { &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 */ diff --git a/source/blender/python/mathutils/mathutils_Euler.c b/source/blender/python/mathutils/mathutils_Euler.c index 829d3ee27e1..1be8a5efe28 100644 --- a/source/blender/python/mathutils/mathutils_Euler.c +++ b/source/blender/python/mathutils/mathutils_Euler.c @@ -35,7 +35,10 @@ #include "BLI_math.h" #include "BLI_utildefines.h" -#include "BLI_dynstr.h" + +#ifndef MATH_STANDALONE +# include "BLI_dynstr.h" +#endif #define EULER_SIZE 3 @@ -323,6 +326,7 @@ static PyObject *Euler_repr(EulerObject *self) return ret; } +#ifndef MATH_STANDALONE static PyObject *Euler_str(EulerObject *self) { DynStr *ds; @@ -337,6 +341,7 @@ static PyObject *Euler_str(EulerObject *self) return mathutils_dynstr_to_py(ds); /* frees ds */ } +#endif static PyObject *Euler_richcmpr(PyObject *a, PyObject *b, int op) { @@ -663,7 +668,11 @@ PyTypeObject euler_Type = { &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 */ diff --git a/source/blender/python/mathutils/mathutils_Matrix.c b/source/blender/python/mathutils/mathutils_Matrix.c index 64112024dd1..05306f230d1 100644 --- a/source/blender/python/mathutils/mathutils_Matrix.c +++ b/source/blender/python/mathutils/mathutils_Matrix.c @@ -35,7 +35,10 @@ #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, @@ -1647,6 +1650,7 @@ static PyObject *Matrix_repr(MatrixObject *self) return NULL; } +#ifndef MATH_STANDALONE static PyObject *Matrix_str(MatrixObject *self) { DynStr *ds; @@ -1682,6 +1686,7 @@ static PyObject *Matrix_str(MatrixObject *self) return mathutils_dynstr_to_py(ds); /* frees ds */ } +#endif static PyObject *Matrix_richcmpr(PyObject *a, PyObject *b, int op) { @@ -2418,7 +2423,11 @@ PyTypeObject matrix_Type = { &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*/ diff --git a/source/blender/python/mathutils/mathutils_Quaternion.c b/source/blender/python/mathutils/mathutils_Quaternion.c index cda39932610..c28631e5045 100644 --- a/source/blender/python/mathutils/mathutils_Quaternion.c +++ b/source/blender/python/mathutils/mathutils_Quaternion.c @@ -35,7 +35,10 @@ #include "BLI_math.h" #include "BLI_utildefines.h" -#include "BLI_dynstr.h" + +#ifndef MATH_STANDALONE +# include "BLI_dynstr.h" +#endif #define QUAT_SIZE 4 @@ -496,6 +499,7 @@ static PyObject *Quaternion_repr(QuaternionObject *self) return ret; } +#ifndef MATH_STANDALONE static PyObject *Quaternion_str(QuaternionObject *self) { DynStr *ds; @@ -510,6 +514,7 @@ static PyObject *Quaternion_str(QuaternionObject *self) return mathutils_dynstr_to_py(ds); /* frees ds */ } +#endif static PyObject *Quaternion_richcmpr(PyObject *a, PyObject *b, int op) { @@ -1202,7 +1207,11 @@ PyTypeObject quaternion_Type = { &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 */ diff --git a/source/blender/python/mathutils/mathutils_Vector.c b/source/blender/python/mathutils/mathutils_Vector.c index e98af997507..f8159f6f187 100644 --- a/source/blender/python/mathutils/mathutils_Vector.c +++ b/source/blender/python/mathutils/mathutils_Vector.c @@ -35,7 +35,10 @@ #include "BLI_math.h" #include "BLI_utildefines.h" -#include "BLI_dynstr.h" + +#ifndef MATH_STANDALONE +# include "BLI_dynstr.h" +#endif #define MAX_DIMENSIONS 4 @@ -1231,6 +1234,7 @@ static PyObject *Vector_repr(VectorObject *self) return ret; } +#ifndef MATH_STANDALONE static PyObject *Vector_str(VectorObject *self) { int i; @@ -1252,7 +1256,7 @@ static PyObject *Vector_str(VectorObject *self) return mathutils_dynstr_to_py(ds); /* frees ds */ } - +#endif /* Sequence Protocol */ /* sequence length len(vector) */ @@ -2816,7 +2820,11 @@ PyTypeObject vector_Type = { 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; */ diff --git a/source/blender/python/mathutils/mathutils_geometry.c b/source/blender/python/mathutils/mathutils_geometry.c index 22317636faa..1db0538eb07 100644 --- a/source/blender/python/mathutils/mathutils_geometry.c +++ b/source/blender/python/mathutils/mathutils_geometry.c @@ -973,12 +973,14 @@ static PyObject *M_Geometry_points_in_planes(PyObject *UNUSED(self), PyObject *a 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 @@ static PyObject *M_Geometry_points_in_planes(PyObject *UNUSED(self), PyObject *a Py_DECREF(item); } } - MEM_freeN(planes_used); + PyMem_Free(planes_used); { PyObject *ret = PyTuple_New(2); -- cgit v1.2.3