PyAPI: add read-only 'is_valid' attribute to mathutils types
There was no convenient way to check if the owner of a mathutils type was valid. Added to support issue reported in T91111.
This commit is contained in:
@@ -599,6 +599,15 @@ uchar Mathutils_RegisterCallback(Mathutils_Callback *cb)
|
||||
return i;
|
||||
}
|
||||
|
||||
int _BaseMathObject_CheckCallback(BaseMathObject *self)
|
||||
{
|
||||
Mathutils_Callback *cb = mathutils_callbacks[self->cb_type];
|
||||
if (LIKELY(cb->check(self) != -1)) {
|
||||
return 0;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* use macros to check for NULL */
|
||||
int _BaseMathObject_ReadCallback(BaseMathObject *self)
|
||||
{
|
||||
@@ -687,6 +696,13 @@ PyObject *BaseMathObject_is_frozen_get(BaseMathObject *self, void *UNUSED(closur
|
||||
return PyBool_FromLong((self->flag & BASE_MATH_FLAG_IS_FROZEN) != 0);
|
||||
}
|
||||
|
||||
char BaseMathObject_is_valid_doc[] =
|
||||
"True when the owner of this data is valid.\n\n:type: boolean";
|
||||
PyObject *BaseMathObject_is_valid_get(BaseMathObject *self, void *UNUSED(closure))
|
||||
{
|
||||
return PyBool_FromLong(BaseMath_CheckCallback(self) == 0);
|
||||
}
|
||||
|
||||
char BaseMathObject_freeze_doc[] =
|
||||
".. function:: freeze()\n"
|
||||
"\n"
|
||||
|
||||
Reference in New Issue
Block a user