cls.is_registered() class method for python subclasses of internal types.
authorCampbell Barton <ideasman42@gmail.com>
Fri, 11 Feb 2011 02:40:14 +0000 (02:40 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Fri, 11 Feb 2011 02:40:14 +0000 (02:40 +0000)
Synonymous with ('bl_rna' in cls.__dict__)

source/blender/python/intern/bpy_rna.c

index 78873b825d5b63ff478514fd1bf87c677bb73755..c21fbaae9c0d55f10f43aefad237807247fda9d8 100644 (file)
@@ -3607,6 +3607,11 @@ PyObject *pyrna_prop_collection_iter(BPy_PropertyRNA *self)
        return iter;
 }
 
+static PyObject *pyrna_struct_is_registered(PyObject *cls)
+{
+       return PyBool_FromLong(PyDict_GetItemString((((PyTypeObject *)cls)->tp_dict), "bl_rna") != NULL);
+}
+
 static struct PyMethodDef pyrna_struct_methods[] = {
 
        /* only for PointerRNA's with ID'props */
@@ -3632,6 +3637,9 @@ static struct PyMethodDef pyrna_struct_methods[] = {
        /* experemental */
        {"callback_add", (PyCFunction)pyrna_callback_add, METH_VARARGS, NULL},
        {"callback_remove", (PyCFunction)pyrna_callback_remove, METH_VARARGS, NULL},
+
+       /* class method */
+       {"is_registered", (PyCFunction) pyrna_struct_is_registered, METH_NOARGS | METH_CLASS, NULL},
        {NULL, NULL, 0, NULL}
 };