Added rna functions so they get included in a dir(rna_struct) from python.

Added a check that a panel panel is a subclass of bpy.types.Panel (need a better way to access this type)
This commit is contained in:
2009-04-09 16:52:18 +00:00
parent 26568d0303
commit bca1ca9d1e
2 changed files with 35 additions and 4 deletions

View 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 */
}

View 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);
}