diff options
Diffstat (limited to 'source/blender/makesrna/intern')
-rw-r--r-- | source/blender/makesrna/intern/makesrna.c | 26 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_rna.c | 14 |
2 files changed, 38 insertions, 2 deletions
diff --git a/source/blender/makesrna/intern/makesrna.c b/source/blender/makesrna/intern/makesrna.c index 9b7872f0b4b..2785a95ddb0 100644 --- a/source/blender/makesrna/intern/makesrna.c +++ b/source/blender/makesrna/intern/makesrna.c @@ -1989,6 +1989,10 @@ static void rna_def_struct_function_call_impl_cpp(FILE *f, StructRNA *srna, Func if (dsrna->dnaname) fprintf(f, "(::%s *) this->ptr.data", dsrna->dnaname); else fprintf(f, "(::%s *) this->ptr.data", srna->identifier); } + else if (func->flag & FUNC_USE_SELF_TYPE) { + WRITE_COMMA; + fprintf(f, "this->ptr.type"); + } if (func->flag & FUNC_USE_MAIN) WRITE_PARAM("(::Main *) main"); @@ -2112,8 +2116,12 @@ static void rna_def_function_wrapper_funcs(FILE *f, StructDefRNA *dsrna, Functio if (func->flag & FUNC_USE_SELF_ID) WRITE_PARAM("_selfid"); - if ((func->flag & FUNC_NO_SELF) == 0) + if ((func->flag & FUNC_NO_SELF) == 0) { WRITE_PARAM("_self"); + } + else if (func->flag & FUNC_USE_SELF_TYPE) { + WRITE_PARAM("_type"); + } if (func->flag & FUNC_USE_MAIN) WRITE_PARAM("bmain"); @@ -2174,6 +2182,9 @@ static void rna_def_function_funcs(FILE *f, StructDefRNA *dsrna, FunctionDefRNA if (dsrna->dnaname) fprintf(f, "\tstruct %s *_self;\n", dsrna->dnaname); else fprintf(f, "\tstruct %s *_self;\n", srna->identifier); } + else if (func->flag & FUNC_USE_SELF_TYPE) { + fprintf(f, "\tstruct StructRNA *_type;\n"); + } dparm = dfunc->cont.properties.first; for (; dparm; dparm = dparm->next) { @@ -2223,6 +2234,9 @@ static void rna_def_function_funcs(FILE *f, StructDefRNA *dsrna, FunctionDefRNA if (dsrna->dnaname) fprintf(f, "\t_self= (struct %s *)_ptr->data;\n", dsrna->dnaname); else fprintf(f, "\t_self= (struct %s *)_ptr->data;\n", srna->identifier); } + else if (func->flag & FUNC_USE_SELF_TYPE) { + fprintf(f, "\t_type= _ptr->type;\n"); + } if (has_data) { fprintf(f, "\t_data= (char *)_parms->data;\n"); @@ -2300,6 +2314,11 @@ static void rna_def_function_funcs(FILE *f, StructDefRNA *dsrna, FunctionDefRNA fprintf(f, "_self"); first = 0; } + else if (func->flag & FUNC_USE_SELF_TYPE) { + if (!first) fprintf(f, ", "); + fprintf(f, "_type"); + first = 0; + } if (func->flag & FUNC_USE_MAIN) { if (!first) fprintf(f, ", "); @@ -2613,6 +2632,11 @@ static void rna_generate_static_parameter_prototypes(FILE *f, StructRNA *srna, F else fprintf(f, "struct %s *_self", srna->identifier); first = 0; } + else if (func->flag & FUNC_USE_SELF_TYPE) { + if (!first) fprintf(f, ", "); + fprintf(f, "struct StructRNA *_type"); + first = 0; + } if (func->flag & FUNC_USE_MAIN) { if (!first) fprintf(f, ", "); 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) |