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>2012-03-17 14:46:02 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-03-17 14:46:02 +0400
commit02f707e9dac91d60f75ebd0ef48200cfb32c0d7d (patch)
tree99dcbd818d0c435108980b71faa18abdbcbeb2b2 /source/blender/python/mathutils
parent1fc345cd326d10ceceb60d61bfd5c386f79b1ee5 (diff)
minor mathutils code cleanup - use mathutils callbacks as unsigned chars everywhere.
Diffstat (limited to 'source/blender/python/mathutils')
-rw-r--r--source/blender/python/mathutils/mathutils.c11
-rw-r--r--source/blender/python/mathutils/mathutils.h2
-rw-r--r--source/blender/python/mathutils/mathutils_Matrix.c6
-rw-r--r--source/blender/python/mathutils/mathutils_Matrix.h6
-rw-r--r--source/blender/python/mathutils/mathutils_Vector.c8
-rw-r--r--source/blender/python/mathutils/mathutils_Vector.h2
6 files changed, 19 insertions, 16 deletions
diff --git a/source/blender/python/mathutils/mathutils.c b/source/blender/python/mathutils/mathutils.c
index 2aabcaee04c..ff551206fae 100644
--- a/source/blender/python/mathutils/mathutils.c
+++ b/source/blender/python/mathutils/mathutils.c
@@ -284,18 +284,21 @@ PyObject *mathutils_dynstr_to_py(struct DynStr *ds)
/* Mathutils Callbacks */
/* for mathutils internal use only, eventually should re-alloc but to start with we only have a few users */
-static Mathutils_Callback *mathutils_callbacks[8] = {NULL};
+#define MATHUTILS_TOT_CB 8
+static Mathutils_Callback *mathutils_callbacks[MATHUTILS_TOT_CB] = {NULL};
-int Mathutils_RegisterCallback(Mathutils_Callback *cb)
+unsigned char Mathutils_RegisterCallback(Mathutils_Callback *cb)
{
- int i;
+ unsigned char i;
/* find the first free slot */
for (i = 0; mathutils_callbacks[i]; i++) {
if (mathutils_callbacks[i] == cb) /* already registered? */
return i;
}
-
+
+ BLI_assert(i < MATHUTILS_TOT_CB);
+
mathutils_callbacks[i] = cb;
return i;
}
diff --git a/source/blender/python/mathutils/mathutils.h b/source/blender/python/mathutils/mathutils.h
index 6fe5a0cca0e..75ea18c2df1 100644
--- a/source/blender/python/mathutils/mathutils.h
+++ b/source/blender/python/mathutils/mathutils.h
@@ -98,7 +98,7 @@ struct Mathutils_Callback {
BaseMathSetIndexFunc set_index;
};
-int Mathutils_RegisterCallback(Mathutils_Callback *cb);
+unsigned char Mathutils_RegisterCallback(Mathutils_Callback *cb);
int _BaseMathObject_ReadCallback(BaseMathObject *self);
int _BaseMathObject_WriteCallback(BaseMathObject *self);
diff --git a/source/blender/python/mathutils/mathutils_Matrix.c b/source/blender/python/mathutils/mathutils_Matrix.c
index 78e6138efff..359f24e0d02 100644
--- a/source/blender/python/mathutils/mathutils_Matrix.c
+++ b/source/blender/python/mathutils/mathutils_Matrix.c
@@ -78,7 +78,7 @@ static int matrix_col_vector_check(MatrixObject *mat, VectorObject *vec, int col
* matrix row callbacks
* this is so you can do matrix[i][j] = val OR matrix.row[i][j] = val */
-int mathutils_matrix_row_cb_index = -1;
+unsigned char mathutils_matrix_row_cb_index = -1;
static int mathutils_matrix_row_check(BaseMathObject *bmo)
{
@@ -162,7 +162,7 @@ Mathutils_Callback mathutils_matrix_row_cb = {
* matrix row callbacks
* this is so you can do matrix.col[i][j] = val */
-int mathutils_matrix_col_cb_index = -1;
+unsigned char mathutils_matrix_col_cb_index = -1;
static int mathutils_matrix_col_check(BaseMathObject *bmo)
{
@@ -255,7 +255,7 @@ Mathutils_Callback mathutils_matrix_col_cb = {
* this is so you can do matrix.translation = val
* note, this is _exactly like matrix.col except the 4th component is always omitted */
-int mathutils_matrix_translation_cb_index = -1;
+unsigned char mathutils_matrix_translation_cb_index = -1;
static int mathutils_matrix_translation_check(BaseMathObject *bmo)
{
diff --git a/source/blender/python/mathutils/mathutils_Matrix.h b/source/blender/python/mathutils/mathutils_Matrix.h
index e8719e947ec..5e5a0dd10b5 100644
--- a/source/blender/python/mathutils/mathutils_Matrix.h
+++ b/source/blender/python/mathutils/mathutils_Matrix.h
@@ -73,9 +73,9 @@ PyObject *Matrix_CreatePyObject_cb(PyObject *user,
const unsigned short num_col, const unsigned short num_row,
int cb_type, int cb_subtype);
-extern int mathutils_matrix_row_cb_index; /* default */
-extern int mathutils_matrix_col_cb_index;
-extern int mathutils_matrix_translation_cb_index;
+extern unsigned char mathutils_matrix_row_cb_index; /* default */
+extern unsigned char mathutils_matrix_col_cb_index;
+extern unsigned char mathutils_matrix_translation_cb_index;
extern struct Mathutils_Callback mathutils_matrix_row_cb; /* default */
extern struct Mathutils_Callback mathutils_matrix_col_cb;
diff --git a/source/blender/python/mathutils/mathutils_Vector.c b/source/blender/python/mathutils/mathutils_Vector.c
index 73cd8d6516b..771db838c69 100644
--- a/source/blender/python/mathutils/mathutils_Vector.c
+++ b/source/blender/python/mathutils/mathutils_Vector.c
@@ -2913,15 +2913,15 @@ PyObject *Vector_CreatePyObject(float *vec, const int size, const int type, PyTy
return (PyObject *) self;
}
-PyObject *Vector_CreatePyObject_cb(PyObject *cb_user, int size, int cb_type, int cb_subtype)
+PyObject *Vector_CreatePyObject_cb(PyObject *cb_user, int size, unsigned char cb_type, unsigned char cb_subtype)
{
float dummy[4] = {0.0, 0.0, 0.0, 0.0}; /* dummy init vector, callbacks will be used on access */
VectorObject *self = (VectorObject *)Vector_CreatePyObject(dummy, size, Py_NEW, NULL);
if (self) {
Py_INCREF(cb_user);
- self->cb_user = cb_user;
- self->cb_type = (unsigned char)cb_type;
- self->cb_subtype = (unsigned char)cb_subtype;
+ self->cb_user = cb_user;
+ self->cb_type = cb_type;
+ self->cb_subtype = cb_subtype;
PyObject_GC_Track(self);
}
diff --git a/source/blender/python/mathutils/mathutils_Vector.h b/source/blender/python/mathutils/mathutils_Vector.h
index 88de991ba43..5567e2b757a 100644
--- a/source/blender/python/mathutils/mathutils_Vector.h
+++ b/source/blender/python/mathutils/mathutils_Vector.h
@@ -46,7 +46,7 @@ typedef struct {
/*prototypes*/
PyObject *Vector_CreatePyObject(float *vec, const int size, const int type, PyTypeObject *base_type);
-PyObject *Vector_CreatePyObject_cb(PyObject *user, int size, int callback_type, int subtype);
+PyObject *Vector_CreatePyObject_cb(PyObject *user, int size, unsigned char callback_type, unsigned char subtype);
PyObject *Vector_CreatePyObject_alloc(float *vec, const int size, PyTypeObject *base_type);
#endif /* __MATHUTILS_VECTOR_H__ */