Added rna functions so they get included in a dir(rna_struct) from python.
authorCampbell Barton <ideasman42@gmail.com>
Thu, 9 Apr 2009 16:52:18 +0000 (16:52 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Thu, 9 Apr 2009 16:52:18 +0000 (16:52 +0000)
Added a check that a panel panel is a subclass of bpy.types.Panel (need a better way to access this type)

source/blender/python/intern/bpy_panel_wrap.c
source/blender/python/intern/bpy_rna.c

index 25fcd34fea515b0e80553595ac488913b86301c6..4a33c90f819a271564e6c82168d43b0c11e98da3 100644 (file)
@@ -123,6 +123,7 @@ PyObject *PyPanel_wrap_add(PyObject *self, PyObject *args)
 {
        PyObject *item;
        PyObject *py_class;
+       PyObject *base_class;
        char *space_identifier;
        char *region_identifier;
        int space_value;
@@ -152,9 +153,12 @@ PyObject *PyPanel_wrap_add(PyObject *self, PyObject *args)
 
        if( !PyArg_ParseTuple( args, "Oss:addPanel", &py_class, &space_identifier, &region_identifier))
                return NULL;
+       
+       base_class = PyObject_GetAttrStringArgs(PyDict_GetItemString(PyEval_GetGlobals(), "bpy"), 2, "types", "Panel");
+       Py_DECREF(base_class);
 
        /* Should this use a base class? */
-       if (BPY_class_validate("Panel", py_class, NULL, pypnl_class_attr_values, pypnl_class_attrs) < 0) {
+       if (BPY_class_validate("Panel", py_class, base_class, pypnl_class_attr_values, pypnl_class_attrs) < 0) {
                return NULL; /* BPY_class_validate sets the error */
        }
 
index 4ba7214cf5c87d3a5956692d6bb9062b61e5517a..807b77cf1da4a31a897f812362d53f4258251424 100644 (file)
@@ -658,6 +658,10 @@ static PyObject *pyrna_struct_dir(BPy_StructRNA * self)
        PyObject *ret, *dict;
        PyObject *pystring;
        
+       /* for looping over attrs and funcs */
+       CollectionPropertyIterator iter;
+       PropertyRNA *iterprop;
+       
        /* Include this incase this instance is a subtype of a python class
         * In these instances we may want to return a function or variable provided by the subtype
         * */
@@ -681,8 +685,10 @@ static PyObject *pyrna_struct_dir(BPy_StructRNA * self)
        
        /* Collect RNA items*/
        {
-               PropertyRNA *iterprop, *nameprop;
-               CollectionPropertyIterator iter;
+               /*
+                * Collect RNA attributes
+                */
+               PropertyRNA *nameprop;
                char name[256], *nameptr;
 
                iterprop= RNA_struct_iterator_property(&self->ptr);
@@ -700,7 +706,28 @@ static PyObject *pyrna_struct_dir(BPy_StructRNA * self)
                                        MEM_freeN(nameptr);
                        }
                }
-               
+               RNA_property_collection_end(&iter);
+       
+       }
+       
+       
+       {
+               /*
+                * Collect RNA function items
+                */
+               PointerRNA tptr;
+
+               RNA_pointer_create(NULL, &RNA_Struct, self->ptr.type, &tptr);
+               iterprop= RNA_struct_find_property(&tptr, "functions");
+
+               RNA_property_collection_begin(&tptr, iterprop, &iter);
+
+               for(; iter.valid; RNA_property_collection_next(&iter)) {
+                       pystring = PyUnicode_FromString(RNA_function_identifier(&tptr, iter.ptr.data));
+                       PyList_Append(ret, pystring);
+                       Py_DECREF(pystring);
+               }
+
                RNA_property_collection_end(&iter);
        }