py rna api: turn class.is_register into a class property rather then a class method.
eg:
if MySybclass.is_registered:
...
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
# Maintainer: Campbell Barton <ideasman42 at gmail dot com>
|
# Maintainer: Campbell Barton <ideasman42 at gmail dot com>
|
||||||
|
|
||||||
# custom blender vars
|
# custom blender vars
|
||||||
blender_srcdir=$(dirname $srcdir)"/../../.."
|
blender_srcdir=$(dirname $startdir)"/../.."
|
||||||
blender_revision=$(svnversion $blender_srcdir)
|
blender_revision=$(svnversion $blender_srcdir)
|
||||||
blender_version=$(grep BLENDER_VERSION $blender_srcdir/source/blender/blenkernel/BKE_blender.h | tr -dc 0-9)
|
blender_version=$(grep BLENDER_VERSION $blender_srcdir/source/blender/blenkernel/BKE_blender.h | tr -dc 0-9)
|
||||||
# blender_subversion=$(grep BLENDER_SUBVERSION $blender_srcdir/source/blender/blenkernel/BKE_blender.h | tr -dc 0-9)
|
# blender_subversion=$(grep BLENDER_SUBVERSION $blender_srcdir/source/blender/blenkernel/BKE_blender.h | tr -dc 0-9)
|
||||||
|
|||||||
@@ -589,7 +589,7 @@ def _bpy_module_classes(module, is_registered=False):
|
|||||||
if cls is None:
|
if cls is None:
|
||||||
del typemap_list[i]
|
del typemap_list[i]
|
||||||
else:
|
else:
|
||||||
if is_registered == ("bl_rna" in cls.__dict__):
|
if is_registered == cls.is_registered:
|
||||||
yield (cls, path, line)
|
yield (cls, path, line)
|
||||||
i += 1
|
i += 1
|
||||||
|
|
||||||
|
|||||||
@@ -572,6 +572,9 @@ class RNAMeta(type):
|
|||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
@property
|
||||||
|
def is_registered(cls):
|
||||||
|
return "bl_rna" in cls.__dict__
|
||||||
|
|
||||||
import collections
|
import collections
|
||||||
|
|
||||||
|
|||||||
@@ -2864,6 +2864,7 @@ static int pyrna_is_deferred_prop(PyObject *value)
|
|||||||
return PyTuple_CheckExact(value) && PyTuple_GET_SIZE(value)==2 && PyCallable_Check(PyTuple_GET_ITEM(value, 0)) && PyDict_CheckExact(PyTuple_GET_ITEM(value, 1));
|
return PyTuple_CheckExact(value) && PyTuple_GET_SIZE(value)==2 && PyCallable_Check(PyTuple_GET_ITEM(value, 0)) && PyDict_CheckExact(PyTuple_GET_ITEM(value, 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
static PyObject *pyrna_struct_meta_idprop_getattro(PyObject *cls, PyObject *attr)
|
static PyObject *pyrna_struct_meta_idprop_getattro(PyObject *cls, PyObject *attr)
|
||||||
{
|
{
|
||||||
PyObject *ret= PyType_Type.tp_getattro(cls, attr);
|
PyObject *ret= PyType_Type.tp_getattro(cls, attr);
|
||||||
@@ -2892,6 +2893,7 @@ static PyObject *pyrna_struct_meta_idprop_getattro(PyObject *cls, PyObject *attr
|
|||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static int pyrna_struct_meta_idprop_setattro(PyObject *cls, PyObject *attr, PyObject *value)
|
static int pyrna_struct_meta_idprop_setattro(PyObject *cls, PyObject *attr, PyObject *value)
|
||||||
{
|
{
|
||||||
@@ -3616,11 +3618,6 @@ static PyObject *pyrna_prop_collection_iter(BPy_PropertyRNA *self)
|
|||||||
return iter;
|
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[] = {
|
static struct PyMethodDef pyrna_struct_methods[] = {
|
||||||
|
|
||||||
/* only for PointerRNA's with ID'props */
|
/* only for PointerRNA's with ID'props */
|
||||||
@@ -3646,9 +3643,6 @@ static struct PyMethodDef pyrna_struct_methods[] = {
|
|||||||
/* experemental */
|
/* experemental */
|
||||||
{"callback_add", (PyCFunction)pyrna_callback_add, METH_VARARGS, NULL},
|
{"callback_add", (PyCFunction)pyrna_callback_add, METH_VARARGS, NULL},
|
||||||
{"callback_remove", (PyCFunction)pyrna_callback_remove, 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}
|
{NULL, NULL, 0, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -4152,7 +4146,7 @@ PyTypeObject pyrna_struct_meta_idprop_Type = {
|
|||||||
NULL, /* hashfunc tp_hash; */
|
NULL, /* hashfunc tp_hash; */
|
||||||
NULL, /* ternaryfunc tp_call; */
|
NULL, /* ternaryfunc tp_call; */
|
||||||
NULL, /* reprfunc tp_str; */
|
NULL, /* reprfunc tp_str; */
|
||||||
(getattrofunc) pyrna_struct_meta_idprop_getattro, /* getattrofunc tp_getattro; */
|
NULL /*(getattrofunc) pyrna_struct_meta_idprop_getattro*/, /* getattrofunc tp_getattro; */
|
||||||
(setattrofunc) pyrna_struct_meta_idprop_setattro, /* setattrofunc tp_setattro; */
|
(setattrofunc) pyrna_struct_meta_idprop_setattro, /* setattrofunc tp_setattro; */
|
||||||
|
|
||||||
/* Functions to access object as input/output buffer */
|
/* Functions to access object as input/output buffer */
|
||||||
@@ -4160,6 +4154,50 @@ PyTypeObject pyrna_struct_meta_idprop_Type = {
|
|||||||
|
|
||||||
/*** Flags to define presence of optional/expanded features ***/
|
/*** Flags to define presence of optional/expanded features ***/
|
||||||
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* long tp_flags; */
|
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* long tp_flags; */
|
||||||
|
|
||||||
|
NULL, /* char *tp_doc; Documentation string */
|
||||||
|
/*** Assigned meaning in release 2.0 ***/
|
||||||
|
/* call function for all accessible objects */
|
||||||
|
NULL, /* traverseproc tp_traverse; */
|
||||||
|
|
||||||
|
/* delete references to contained objects */
|
||||||
|
NULL, /* inquiry tp_clear; */
|
||||||
|
|
||||||
|
/*** Assigned meaning in release 2.1 ***/
|
||||||
|
/*** rich comparisons ***/
|
||||||
|
NULL, /* richcmpfunc tp_richcompare; */
|
||||||
|
|
||||||
|
/*** weak reference enabler ***/
|
||||||
|
0, /* long tp_weaklistoffset; */
|
||||||
|
|
||||||
|
/*** Added in release 2.2 ***/
|
||||||
|
/* Iterators */
|
||||||
|
NULL, /* getiterfunc tp_iter; */
|
||||||
|
NULL, /* iternextfunc tp_iternext; */
|
||||||
|
|
||||||
|
/*** Attribute descriptor and subclassing stuff ***/
|
||||||
|
NULL, /* struct PyMethodDef *tp_methods; */
|
||||||
|
NULL, /* struct PyMemberDef *tp_members; */
|
||||||
|
NULL, /* struct PyGetSetDef *tp_getset; */
|
||||||
|
NULL, /* struct _typeobject *tp_base; */
|
||||||
|
NULL, /* PyObject *tp_dict; */
|
||||||
|
NULL, /* descrgetfunc tp_descr_get; */
|
||||||
|
NULL, /* descrsetfunc tp_descr_set; */
|
||||||
|
0, /* long tp_dictoffset; */
|
||||||
|
NULL, /* initproc tp_init; */
|
||||||
|
NULL, /* allocfunc tp_alloc; */
|
||||||
|
NULL, /* newfunc tp_new; */
|
||||||
|
/* Low-level free-memory routine */
|
||||||
|
NULL, /* freefunc tp_free; */
|
||||||
|
/* For PyObject_IS_GC */
|
||||||
|
NULL, /* inquiry tp_is_gc; */
|
||||||
|
NULL, /* PyObject *tp_bases; */
|
||||||
|
/* method resolution order */
|
||||||
|
NULL, /* PyObject *tp_mro; */
|
||||||
|
NULL, /* PyObject *tp_cache; */
|
||||||
|
NULL, /* PyObject *tp_subclasses; */
|
||||||
|
NULL, /* PyObject *tp_weaklist; */
|
||||||
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user