Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2017-11-29 08:09:46 +0300
committerCampbell Barton <ideasman42@gmail.com>2017-11-29 08:13:26 +0300
commitc17c6557b4ea4bfeb4528b74703795798aedaa66 (patch)
tree04559e5492c946672bd45272e216be9c9f5cce7e /source/blender/python
parent26a64ba23a8e5586f2dfb72195a30bcf8acd9c90 (diff)
PyAPI: add function to check any mathutils type
Also add CheckExact versions of type checking macros.
Diffstat (limited to 'source/blender/python')
-rw-r--r--source/blender/python/mathutils/mathutils.h4
-rw-r--r--source/blender/python/mathutils/mathutils_Color.h3
-rw-r--r--source/blender/python/mathutils/mathutils_Euler.h3
-rw-r--r--source/blender/python/mathutils/mathutils_Matrix.h5
-rw-r--r--source/blender/python/mathutils/mathutils_Quaternion.h4
-rw-r--r--source/blender/python/mathutils/mathutils_Vector.h4
-rw-r--r--source/blender/python/mathutils/mathutils_bvhtree.h2
7 files changed, 19 insertions, 6 deletions
diff --git a/source/blender/python/mathutils/mathutils.h b/source/blender/python/mathutils/mathutils.h
index d1fb6dcdb82..ec927a9e316 100644
--- a/source/blender/python/mathutils/mathutils.h
+++ b/source/blender/python/mathutils/mathutils.h
@@ -78,6 +78,10 @@ typedef struct {
#include "mathutils_Euler.h"
#include "mathutils_Color.h"
+/* avoid checking all types */
+#define BaseMathObject_CheckExact(v) \
+ (Py_TYPE(v)->tp_dealloc == (destructor)BaseMathObject_dealloc)
+
PyObject *BaseMathObject_owner_get(BaseMathObject *self, void *);
PyObject *BaseMathObject_is_wrapped_get(BaseMathObject *self, void *);
PyObject *BaseMathObject_is_frozen_get(BaseMathObject *self, void *);
diff --git a/source/blender/python/mathutils/mathutils_Color.h b/source/blender/python/mathutils/mathutils_Color.h
index 1290f73da62..e1a392de3da 100644
--- a/source/blender/python/mathutils/mathutils_Color.h
+++ b/source/blender/python/mathutils/mathutils_Color.h
@@ -30,7 +30,8 @@
#define __MATHUTILS_COLOR_H__
extern PyTypeObject color_Type;
-#define ColorObject_Check(_v) PyObject_TypeCheck((_v), &color_Type)
+#define ColorObject_Check(v) PyObject_TypeCheck((v), &color_Type)
+#define ColorObject_CheckExact(v) (Py_TYPE(v) == &color_Type)
typedef struct {
BASE_MATH_MEMBERS(col);
diff --git a/source/blender/python/mathutils/mathutils_Euler.h b/source/blender/python/mathutils/mathutils_Euler.h
index 744f39faed1..4f5ba76b8df 100644
--- a/source/blender/python/mathutils/mathutils_Euler.h
+++ b/source/blender/python/mathutils/mathutils_Euler.h
@@ -29,7 +29,8 @@
*/
extern PyTypeObject euler_Type;
-#define EulerObject_Check(_v) PyObject_TypeCheck((_v), &euler_Type)
+#define EulerObject_Check(v) PyObject_TypeCheck((v), &euler_Type)
+#define EulerObject_CheckExact(v) (Py_TYPE(v) == &euler_Type)
typedef struct {
BASE_MATH_MEMBERS(eul);
diff --git a/source/blender/python/mathutils/mathutils_Matrix.h b/source/blender/python/mathutils/mathutils_Matrix.h
index 9c84716d307..d2fbe6a04d5 100644
--- a/source/blender/python/mathutils/mathutils_Matrix.h
+++ b/source/blender/python/mathutils/mathutils_Matrix.h
@@ -30,7 +30,10 @@
extern PyTypeObject matrix_Type;
extern PyTypeObject matrix_access_Type;
-#define MatrixObject_Check(_v) PyObject_TypeCheck((_v), &matrix_Type)
+
+#define MatrixObject_Check(v) PyObject_TypeCheck((v), &matrix_Type)
+#define MatrixObject_CheckExact(v) (Py_TYPE(v) == &matrix_Type)
+
#define MATRIX_MAX_DIM 4
/* matrix[row][col] == MATRIX_ITEM_INDEX(matrix, row, col) */
diff --git a/source/blender/python/mathutils/mathutils_Quaternion.h b/source/blender/python/mathutils/mathutils_Quaternion.h
index 66ee3362906..46f305b0f0e 100644
--- a/source/blender/python/mathutils/mathutils_Quaternion.h
+++ b/source/blender/python/mathutils/mathutils_Quaternion.h
@@ -28,7 +28,9 @@
*/
extern PyTypeObject quaternion_Type;
-#define QuaternionObject_Check(_v) PyObject_TypeCheck((_v), &quaternion_Type)
+
+#define QuaternionObject_Check(v) PyObject_TypeCheck((v), &quaternion_Type)
+#define QuaternionObject_CheckExact(v) (Py_TYPE(v) == &quaternion_Type)
typedef struct {
BASE_MATH_MEMBERS(quat);
diff --git a/source/blender/python/mathutils/mathutils_Vector.h b/source/blender/python/mathutils/mathutils_Vector.h
index 74ca3336f4b..9ebf9457f2b 100644
--- a/source/blender/python/mathutils/mathutils_Vector.h
+++ b/source/blender/python/mathutils/mathutils_Vector.h
@@ -29,7 +29,9 @@
#define __MATHUTILS_VECTOR_H__
extern PyTypeObject vector_Type;
-#define VectorObject_Check(_v) PyObject_TypeCheck((_v), &vector_Type)
+
+#define VectorObject_Check(v) PyObject_TypeCheck((v), &vector_Type)
+#define VectorObject_CheckExact(v) (Py_TYPE(v) == &vector_Type)
typedef struct {
BASE_MATH_MEMBERS(vec);
diff --git a/source/blender/python/mathutils/mathutils_bvhtree.h b/source/blender/python/mathutils/mathutils_bvhtree.h
index 634556d68f7..445a393b93e 100644
--- a/source/blender/python/mathutils/mathutils_bvhtree.h
+++ b/source/blender/python/mathutils/mathutils_bvhtree.h
@@ -30,7 +30,7 @@ PyMODINIT_FUNC PyInit_mathutils_bvhtree(void);
extern PyTypeObject PyBVHTree_Type;
-#define PyBVHTree_Check(_v) PyObject_TypeCheck((_v), &PyBVHTree_Type)
+#define PyBVHTree_Check(v) PyObject_TypeCheck((v), &PyBVHTree_Type)
#define PyBVHTree_CheckExact(v) (Py_TYPE(v) == &PyBVHTree_Type)
#endif /* __MATHUTILS_BVHTREE_H__ */