From 65b922ad888faa937f056305a7522682b18d0e26 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 11 Feb 2011 02:40:14 +0000 Subject: cls.is_registered() class method for python subclasses of internal types. Synonymous with ('bl_rna' in cls.__dict__) --- source/blender/python/intern/bpy_rna.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'source/blender/python') diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c index 78873b825d5..c21fbaae9c0 100644 --- a/source/blender/python/intern/bpy_rna.c +++ b/source/blender/python/intern/bpy_rna.c @@ -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} }; -- cgit v1.2.3