Revision: 22523
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=22523
Author:   campbellbarton
Date:     2009-08-16 17:46:09 +0200 (Sun, 16 Aug 2009)

Log Message:
-----------
rna function return values in generated docs,
added prop.use_return so you can tell if a prop is a return value.

Modified Paths:
--------------
    branches/blender2.5/blender/source/blender/makesrna/intern/rna_access.c
    branches/blender2.5/blender/source/blender/makesrna/intern/rna_rna.c
    branches/blender2.5/blender/source/blender/python/epy_doc_gen.py

Modified: 
branches/blender2.5/blender/source/blender/makesrna/intern/rna_access.c
===================================================================
--- branches/blender2.5/blender/source/blender/makesrna/intern/rna_access.c     
2009-08-16 15:45:27 UTC (rev 22522)
+++ branches/blender2.5/blender/source/blender/makesrna/intern/rna_access.c     
2009-08-16 15:46:09 UTC (rev 22523)
@@ -1989,9 +1989,10 @@
 {
        ArrayIterator *internal= iter->internal;
        
-       if(internal->free_ptr)
+       if(internal->free_ptr) {
                MEM_freeN(internal->free_ptr);
-
+               internal->free_ptr= NULL;
+       }
        MEM_freeN(iter->internal);
        iter->internal= NULL;
 }

Modified: branches/blender2.5/blender/source/blender/makesrna/intern/rna_rna.c
===================================================================
--- branches/blender2.5/blender/source/blender/makesrna/intern/rna_rna.c        
2009-08-16 15:45:27 UTC (rev 22522)
+++ branches/blender2.5/blender/source/blender/makesrna/intern/rna_rna.c        
2009-08-16 15:46:09 UTC (rev 22523)
@@ -420,6 +420,12 @@
        return RNA_property_editable(ptr, prop);
 }
 
+static int rna_Property_use_return_get(PointerRNA *ptr)
+{
+       PropertyRNA *prop= (PropertyRNA*)ptr->data;
+       return prop->flag & PROP_RETURN ? 1:0;
+}
+
 static int rna_Property_array_length_get(PointerRNA *ptr)
 {
        PropertyRNA *prop= (PropertyRNA*)ptr->data;
@@ -848,6 +854,11 @@
        RNA_def_property_boolean_funcs(prop, "rna_Property_editable_get", NULL);
        RNA_def_property_ui_text(prop, "Editable", "Property is editable 
through RNA.");
 
+       prop= RNA_def_property(srna, "use_return", PROP_BOOLEAN, PROP_NONE);
+       RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+       RNA_def_property_boolean_funcs(prop, "rna_Property_use_return_get", 
NULL);
+       RNA_def_property_ui_text(prop, "Return", "True when this property is a 
return value from an rna function..");
+
        prop= RNA_def_property(srna, "registered", PROP_BOOLEAN, PROP_NONE);
        RNA_def_property_clear_flag(prop, PROP_EDITABLE);
        RNA_def_property_boolean_funcs(prop, "rna_Property_registered_get", 
NULL);

Modified: branches/blender2.5/blender/source/blender/python/epy_doc_gen.py
===================================================================
--- branches/blender2.5/blender/source/blender/python/epy_doc_gen.py    
2009-08-16 15:45:27 UTC (rev 22522)
+++ branches/blender2.5/blender/source/blender/python/epy_doc_gen.py    
2009-08-16 15:46:09 UTC (rev 22523)
@@ -76,6 +76,7 @@
                rna_func_desc = rna.description.strip()
                items = rna.parameters.items()
        
+       
        for rna_prop_identifier, rna_prop in items:
                if rna_prop_identifier=='rna_type':
                        continue
@@ -88,13 +89,25 @@
                rna_prop_type = rna_prop.type.lower() # enum, float, int, 
boolean
                
                
+               # only for rna funcions, operators should not get pointers as 
args
+               if rna_prop_type=='pointer':
+                       rna_prop_type_refine = "L{%s}" % 
rna_prop.fixed_type.identifier
+               else:
+                       rna_prop_type_refine = rna_prop_type
+               
+               
                try:            length = rna_prop.array_length
                except: length = 0
                
                array_str = get_array_str(length)
                
-               kw_type_str= "@type %s: %s%s" % (rna_prop_identifier, 
rna_prop_type, array_str)
-               kw_param_str= "@param %s: %s" % (rna_prop_identifier, 
rna_prop.description.strip())
+               if rna_prop.use_return:
+                       kw_type_str= "@rtype: %s%s" % (rna_prop_type_refine, 
array_str)
+                       kw_param_str= "@return: %s" % 
(rna_prop.description.strip())
+               else:
+                       kw_type_str= "@type %s: %s%s" % (rna_prop_identifier, 
rna_prop_type_refine, array_str)
+                       kw_param_str= "@param %s: %s" % (rna_prop_identifier, 
rna_prop.description.strip())
+               
                kw_param_set = False
                
                if func_type=='OPERATOR':
@@ -159,9 +172,12 @@
                        # stora 
                else:
                        # currently functions dont have a default value
-                       kw_args.append('%s' % (rna_prop_identifier))
+                       if not rna_prop.use_return:
+                               kw_args.append('%s' % (rna_prop_identifier))
+                       else:
+                               kw_param_set = True
+
                
-               
                # Same for operators and functions
                kw_arg_attrs.append(kw_type_str)
                if kw_param_set:
@@ -174,7 +190,8 @@
        out.write(ident+'\t%s\n' % rna_func_desc)
        for desc in kw_arg_attrs:
                out.write(ident+'\t%s\n' % desc)
-       out.write(ident+'\...@rtype: None\n')
+               
+       # out.write(ident+'\...@rtype: None\n') # implicit
        out.write(ident+'\t"""\n')
        
 
@@ -269,7 +286,8 @@
                                                out.write(ident+ '\...@ivar %s: 
%s in (%s)\n' %  (rna_prop_identifier, rna_desc, ', 
'.join(rna_prop.items.keys())))
                                        else:
                                                out.write(ident+ '\...@ivar %s: 
%s in...\n' %  (rna_prop_identifier, rna_desc))
-                                               for e in rna_prop.items.keys():
+                                               for e, e_rna_prop in 
rna_prop.items.items():
+                                                       #out.write(ident+ 
'\t\t- %s: %s\n' % (e, e_rna_prop.description)) # XXX - segfaults, FIXME
                                                        out.write(ident+ '\t\t- 
%s\n' % e)
                                                
                                        out.write(ident+ '\...@type %s: 
%s%s%s\n' %  (rna_prop_identifier, rna_prop_type,  array_str, readonly_str))


_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to