documentat & cross reference collection types

This commit is contained in:
Campbell Barton 2009-11-13 17:42:44 +00:00
parent c1d0f9179d
commit e12fe32feb
2 changed files with 34 additions and 7 deletions

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

View 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():