py rna api: turn class.is_register into a class property rather then a class method.
authorCampbell Barton <ideasman42@gmail.com>
Mon, 14 Feb 2011 07:26:07 +0000 (07:26 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Mon, 14 Feb 2011 07:26:07 +0000 (07:26 +0000)
eg:

if MySybclass.is_registered:
    ...

build_files/package_spec/pacman/PKGBUILD
release/scripts/modules/bpy/utils.py
release/scripts/modules/bpy_types.py
source/blender/python/intern/bpy_rna.c

index 4a96580e0c5f5bcb821c8aacde627a95cb888c72..50e435045cc3b7440cc31c50e7cd68a1cad758e3 100644 (file)
@@ -1,7 +1,7 @@
 # Maintainer: Campbell Barton <ideasman42 at gmail dot com>
 
 # custom blender vars
-blender_srcdir=$(dirname $srcdir)"/../../.."
+blender_srcdir=$(dirname $startdir)"/../.."
 blender_revision=$(svnversion $blender_srcdir)
 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)
index e00c12e3c0659b3f287d01a0ac77aaa81573e9cf..56f365db7d8f1afdc25eeb7c0c0f3311a95ece70 100644 (file)
@@ -589,7 +589,7 @@ def _bpy_module_classes(module, is_registered=False):
         if cls is None:
             del typemap_list[i]
         else:
-            if is_registered == ("bl_rna" in cls.__dict__):
+            if is_registered == cls.is_registered:
                 yield (cls, path, line)
             i += 1
 
index 4eb712a65ccc59d467a463f5fb941542ed8bd9d0..38dc037a61d4cc51264895adf023e4381def799c 100644 (file)
@@ -572,6 +572,9 @@ class RNAMeta(type):
 
         return result
 
+    @property
+    def is_registered(cls):
+        return "bl_rna" in cls.__dict__
 
 import collections
 
index 184e20a9a4bfb90e871b60aafadd1975b5ee04be..9758f0706b16602047ec41e02874668c16505d8c 100644 (file)
@@ -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));
 }
 
+#if 0
 static PyObject *pyrna_struct_meta_idprop_getattro(PyObject *cls, PyObject *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;
 }
+#endif
 
 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;
 }
 
-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 */
@@ -3646,9 +3643,6 @@ 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}
 };
 
@@ -4152,7 +4146,7 @@ PyTypeObject pyrna_struct_meta_idprop_Type = {
        NULL,                                           /* hashfunc tp_hash; */
        NULL,                                           /* ternaryfunc tp_call; */
        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; */
 
        /* 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 ***/
        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
 };