diff options
author | Lukas Toenne <lukas.toenne@googlemail.com> | 2012-12-20 13:33:12 +0400 |
---|---|---|
committer | Lukas Toenne <lukas.toenne@googlemail.com> | 2012-12-20 13:33:12 +0400 |
commit | 35c2267aee84d086c00574496b52e9c0641e320d (patch) | |
tree | 1cf49651a6a77424563afa9c68ef1c46f7dda5d4 /source/blender/makesrna/intern/rna_rna.c | |
parent | b3dc1d585a5d5f976691c2a6a9fd432b1c6162e0 (diff) |
Support for actual class methods in the RNA/bpy. Previously all functions with FUNC_NO_SELF were treated as static methods, which is not sufficient for getting actual type information if the function can not be generated in advance in makesrna. Now the FUNC_USE_SELF_TYPE flag can be set in addition to FUNC_NO_SELF (if FUNC_NO_SELF is not set, FUNC_USE_SELF_TYPE has no effect). Such functions will be interpreted as class methods and must take a StructRNA pointer argument. This pointer is the same as the type member in PointerRNA, but can be passed without an actual data/id instance.
Diffstat (limited to 'source/blender/makesrna/intern/rna_rna.c')
-rw-r--r-- | source/blender/makesrna/intern/rna_rna.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/source/blender/makesrna/intern/rna_rna.c b/source/blender/makesrna/intern/rna_rna.c index 7355e464fc3..3f03445635f 100644 --- a/source/blender/makesrna/intern/rna_rna.c +++ b/source/blender/makesrna/intern/rna_rna.c @@ -939,6 +939,12 @@ static int rna_Function_no_self_get(PointerRNA *ptr) return !(func->flag & FUNC_NO_SELF); } +static int rna_Function_use_self_type_get(PointerRNA *ptr) +{ + FunctionRNA *func = (FunctionRNA *)ptr->data; + return (func->flag & FUNC_USE_SELF_TYPE); +} + /* Blender RNA */ static void rna_BlenderRNA_structs_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) @@ -1230,7 +1236,13 @@ static void rna_def_function(BlenderRNA *brna) RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_boolean_funcs(prop, "rna_Function_no_self_get", NULL); RNA_def_property_ui_text(prop, "No Self", - "Function does not pass its self as an argument (becomes a class method in python)"); + "Function does not pass its self as an argument (becomes a static method in python)"); + + prop = RNA_def_property(srna, "use_self_type", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_boolean_funcs(prop, "rna_Function_use_self_type_get", NULL); + RNA_def_property_ui_text(prop, "Use Self Type", + "Function passes its self type as an argument (becomes a class method in python if use_self is false)"); } static void rna_def_number_property(StructRNA *srna, PropertyType type) |