documentat & cross reference collection types
authorCampbell Barton <ideasman42@gmail.com>
Fri, 13 Nov 2009 17:42:44 +0000 (17:42 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Fri, 13 Nov 2009 17:42:44 +0000 (17:42 +0000)
source/blender/makesrna/intern/rna_rna.c
source/blender/python/epy_doc_gen.py

index 29a95c998517c5106bd9646e18b0b286ed9e9315..f8109b9794d1dee1cde689dbb54a308bef9bad6f 100644 (file)
@@ -406,6 +406,13 @@ static int rna_Property_subtype_get(PointerRNA *ptr)
        return prop->subtype;
 }
 
+static PointerRNA rna_Property_srna_get(PointerRNA *ptr)
+{
+       PropertyRNA *prop= (PropertyRNA*)ptr->data;
+       rna_idproperty_check(&prop, ptr);
+       return rna_pointer_inherit_refine(ptr, &RNA_Struct, prop->srna);
+}
+
 static int rna_Property_unit_get(PointerRNA *ptr)
 {
        PropertyRNA *prop= (PropertyRNA*)ptr->data;
@@ -900,6 +907,12 @@ static void rna_def_property(BlenderRNA *brna)
        RNA_def_property_enum_funcs(prop, "rna_Property_subtype_get", NULL, NULL);
        RNA_def_property_ui_text(prop, "Subtype", "Semantic interpretation of the property.");
 
+       prop= RNA_def_property(srna, "srna", PROP_POINTER, PROP_NONE);
+       RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+       RNA_def_property_struct_type(prop, "Struct");
+       RNA_def_property_pointer_funcs(prop, "rna_Property_srna_get", NULL, NULL);
+       RNA_def_property_ui_text(prop, "Base", "Struct definition used for properties assigned to this item.");
+
        prop= RNA_def_property(srna, "unit", PROP_ENUM, PROP_NONE);
        RNA_def_property_clear_flag(prop, PROP_EDITABLE);
        RNA_def_property_enum_items(prop, unit_items);
index b0126a0b9a0e7327e389d1ba0c968d2513a4b910..f16c7504cb2e25e287ab09119ee6308355666fa3 100644 (file)
@@ -194,7 +194,15 @@ def write_func(rna, ident, out, func_type):
         if rna_prop_type=='pointer':
             rna_prop_type_refine = "L{%s}" % rna_prop.fixed_type.identifier
         else:
-            rna_prop_type_refine = rna_prop_type
+            # Collections/Arrays can have a srna type
+            rna_prop_srna_type = rna_prop.srna
+            if rna_prop_srna_type:
+                print(rna_prop_srna_type.identifier)
+                rna_prop_type_refine = "L{%s}" % rna_prop_srna_type.identifier
+            else:
+                rna_prop_type_refine = rna_prop_type
+            
+            del rna_prop_srna_type
 
 
         try:           length = rna_prop.array_length
@@ -373,6 +381,13 @@ def rna2epy(BASEPATH):
 
             if rna_prop_type=='collection':    collection_str = 'Collection of '
             else:                                                      collection_str = ''
+            
+            # some collections have a srna for their own properties
+            # TODO - arrays, however this isnt used yet
+            rna_prop_srna_type = rna_prop.srna
+            if rna_prop_srna_type:
+                collection_str =  "L{%s} %s" % (rna_prop_srna_type.identifier, collection_str)
+            del rna_prop_srna_type
 
             try:               rna_prop_ptr = rna_prop.fixed_type
             except:    rna_prop_ptr = None
@@ -530,12 +545,11 @@ def rna2epy(BASEPATH):
             if rna_id_ignore(rna_prop_identifier):                     continue
             if rna_prop_identifier in rna_base_prop_keys:      continue
 
-            try:               rna_prop_ptr = rna_prop.fixed_type
-            except:    rna_prop_ptr = None
-
-            # Does this property point to me?
-            if rna_prop_ptr:
-                rna_references_dict[rna_prop_ptr.identifier].append( "%s.%s" % (rna_struct_path, rna_prop_identifier) )
+            
+            for rna_prop_ptr in (getattr(rna_prop, "fixed_type", None), getattr(rna_prop, "srna", None)):
+                # Does this property point to me?
+                if rna_prop_ptr:
+                    rna_references_dict[rna_prop_ptr.identifier].append( "%s.%s" % (rna_struct_path, rna_prop_identifier) )
 
         for rna_func in rna_struct.functions:
             for rna_prop_identifier, rna_prop in rna_func.parameters.items():