Followup to r59536: make "is_argument_optional" available to py, and use it in API...
authorBastien Montagne <montagne29@wanadoo.fr>
Mon, 26 Aug 2013 21:39:06 +0000 (21:39 +0000)
committerBastien Montagne <montagne29@wanadoo.fr>
Mon, 26 Aug 2013 21:39:06 +0000 (21:39 +0000)
Thanks Campbell for the much better name suggestion!

release/scripts/modules/rna_info.py
source/blender/makesrna/intern/rna_rna.c

index bf15b472805d3439b14c69c2ac7f48954dfafaba..804055e61a5bde6d8b7b42e70c5a92d8c85361df 100644 (file)
@@ -296,6 +296,8 @@ class InfoPropertyRNA:
         elif as_arg:
             if not self.is_required:
                 type_info.append("optional")
+            if self.is_argument_optional:
+                type_info.append("optional argument")
         else:  # readonly is only useful for self's, not args
             if self.is_readonly:
                 type_info.append("readonly")
index 67fc3056485d10541db8c58a5bad374e4824a4c4..380bde90ff95bd1875bc4d88a8ed8549767d3fd8 100644 (file)
@@ -566,6 +566,12 @@ static int rna_Property_is_required_get(PointerRNA *ptr)
        return prop->flag & PROP_REQUIRED ? 1 : 0;
 }
 
+static int rna_Property_is_argument_optional_get(PointerRNA *ptr)
+{
+       PropertyRNA *prop = (PropertyRNA *)ptr->data;
+       return prop->flag & PROP_PYFUNC_OPTIONAL ? 1 : 0;
+}
+
 static int rna_Property_is_never_none_get(PointerRNA *ptr)
 {
        PropertyRNA *prop = (PropertyRNA *)ptr->data;
@@ -1171,6 +1177,12 @@ static void rna_def_property(BlenderRNA *brna)
        RNA_def_property_boolean_funcs(prop, "rna_Property_is_required_get", NULL);
        RNA_def_property_ui_text(prop, "Required", "False when this property is an optional argument in an RNA function");
 
+       prop = RNA_def_property(srna, "is_argument_optional", PROP_BOOLEAN, PROP_NONE);
+       RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+       RNA_def_property_boolean_funcs(prop, "rna_Property_is_argument_optional_get", NULL);
+       RNA_def_property_ui_text(prop, "Optional Argument",
+                                "True when the property is optional in a Python function implementing an RNA function");
+
        prop = RNA_def_property(srna, "is_never_none", PROP_BOOLEAN, PROP_NONE);
        RNA_def_property_clear_flag(prop, PROP_EDITABLE);
        RNA_def_property_boolean_funcs(prop, "rna_Property_is_never_none_get", NULL);