mathutils: refactor instantiation

remove 'type' argument, very few mathutils objects are wrapped,
add new function for creating wrapped objects.

also fixes unlikely memory leak if the data-array can't be allocated.
This commit is contained in:
Campbell Barton
2015-01-04 17:03:54 +11:00
parent c41431f1e9
commit 8106a6b75d
29 changed files with 499 additions and 331 deletions

View File

@@ -451,7 +451,7 @@ PyObject *BaseMathObject_owner_get(BaseMathObject *self, void *UNUSED(closure))
char BaseMathObject_is_wrapped_doc[] = "True when this object wraps external data (read-only).\n\n:type: boolean";
PyObject *BaseMathObject_is_wrapped_get(BaseMathObject *self, void *UNUSED(closure))
{
return PyBool_FromLong((self->wrapped == Py_WRAP) ? 1 : 0);
return PyBool_FromLong((self->flag & BASE_MATH_FLAG_IS_WRAP) != 0);
}
int BaseMathObject_traverse(BaseMathObject *self, visitproc visit, void *arg)
@@ -469,7 +469,7 @@ int BaseMathObject_clear(BaseMathObject *self)
void BaseMathObject_dealloc(BaseMathObject *self)
{
/* only free non wrapped */
if (self->wrapped != Py_WRAP) {
if ((self->flag & BASE_MATH_FLAG_IS_WRAP) == 0) {
PyMem_Free(self->data);
}