[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [19624] branches/blender2.5/blender/source /blender/python/intern: Added rna functions so they get included in a dir( rna_struct) from python.

Campbell Barton ideasman42 at gmail.com
Thu Apr 9 18:52:18 CEST 2009


Revision: 19624
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=19624
Author:   campbellbarton
Date:     2009-04-09 18:52:18 +0200 (Thu, 09 Apr 2009)

Log Message:
-----------
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)

Modified Paths:
--------------
    branches/blender2.5/blender/source/blender/python/intern/bpy_panel_wrap.c
    branches/blender2.5/blender/source/blender/python/intern/bpy_rna.c

Modified: branches/blender2.5/blender/source/blender/python/intern/bpy_panel_wrap.c
===================================================================
--- branches/blender2.5/blender/source/blender/python/intern/bpy_panel_wrap.c	2009-04-09 16:00:45 UTC (rev 19623)
+++ branches/blender2.5/blender/source/blender/python/intern/bpy_panel_wrap.c	2009-04-09 16:52:18 UTC (rev 19624)
@@ -123,6 +123,7 @@
 {
 	PyObject *item;
 	PyObject *py_class;
+	PyObject *base_class;
 	char *space_identifier;
 	char *region_identifier;
 	int space_value;
@@ -152,9 +153,12 @@
 
 	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 */
 	}
 

Modified: branches/blender2.5/blender/source/blender/python/intern/bpy_rna.c
===================================================================
--- branches/blender2.5/blender/source/blender/python/intern/bpy_rna.c	2009-04-09 16:00:45 UTC (rev 19623)
+++ branches/blender2.5/blender/source/blender/python/intern/bpy_rna.c	2009-04-09 16:52:18 UTC (rev 19624)
@@ -658,6 +658,10 @@
 	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 @@
 	
 	/* 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,10 +706,31 @@
 					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);
+	}
+	
 	return ret;
 }
 





More information about the Bf-blender-cvs mailing list