diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2010-01-22 13:58:02 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2010-01-22 13:58:02 +0300 |
commit | 00318eaa2eedfd0f1b8af12bd4a7f664b6ef1b89 (patch) | |
tree | 102c51718f741076319070edc2f5bb6babe44d0b /source/blender/makesrna | |
parent | 0c2d03e69f427a3b2285c5b26267004befbcc2a9 (diff) |
RNA: added option to pass self ID to RNA functions.
Diffstat (limited to 'source/blender/makesrna')
-rw-r--r-- | source/blender/makesrna/RNA_types.h | 1 | ||||
-rw-r--r-- | source/blender/makesrna/intern/makesrna.c | 29 |
2 files changed, 23 insertions, 7 deletions
diff --git a/source/blender/makesrna/RNA_types.h b/source/blender/makesrna/RNA_types.h index 913c387c824..ebb0a0b4c51 100644 --- a/source/blender/makesrna/RNA_types.h +++ b/source/blender/makesrna/RNA_types.h @@ -266,6 +266,7 @@ typedef enum FunctionFlag { FUNC_NO_SELF = 1, /* for static functions */ FUNC_USE_CONTEXT = 2, FUNC_USE_REPORTS = 4, + FUNC_USE_SELF_ID = 2048, /* registering */ FUNC_REGISTER = 8, diff --git a/source/blender/makesrna/intern/makesrna.c b/source/blender/makesrna/intern/makesrna.c index b139de873ad..f1f0510f7ec 100644 --- a/source/blender/makesrna/intern/makesrna.c +++ b/source/blender/makesrna/intern/makesrna.c @@ -1293,7 +1293,7 @@ static void rna_def_function_funcs(FILE *f, StructDefRNA *dsrna, FunctionDefRNA srna= dsrna->srna; func= dfunc->func; - if(func->flag & FUNC_REGISTER) + if(!dfunc->call) return; funcname= rna_alloc_function_name(srna->identifier, func->identifier, "call"); @@ -1304,6 +1304,9 @@ static void rna_def_function_funcs(FILE *f, StructDefRNA *dsrna, FunctionDefRNA /* variable definitions */ if((func->flag & FUNC_NO_SELF)==0) { + if(func->flag & FUNC_USE_SELF_ID) + fprintf(f, "\tstruct ID *_selfid;\n"); + if(dsrna->dnaname) fprintf(f, "\tstruct %s *_self;\n", dsrna->dnaname); else fprintf(f, "\tstruct %s *_self;\n", srna->identifier); } @@ -1332,6 +1335,9 @@ static void rna_def_function_funcs(FILE *f, StructDefRNA *dsrna, FunctionDefRNA /* assign self */ if((func->flag & FUNC_NO_SELF)==0) { + if(func->flag & FUNC_USE_SELF_ID) + fprintf(f, "\t_selfid= (struct ID*)_ptr->id.data;\n"); + 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); } @@ -1375,6 +1381,9 @@ static void rna_def_function_funcs(FILE *f, StructDefRNA *dsrna, FunctionDefRNA first= 1; if((func->flag & FUNC_NO_SELF)==0) { + if(func->flag & FUNC_USE_SELF_ID) + fprintf(f, "_selfid, "); + fprintf(f, "_self"); first= 0; } @@ -1672,6 +1681,9 @@ static void rna_generate_static_parameter_prototypes(BlenderRNA *brna, StructRNA /* self, context and reports parameters */ if((func->flag & FUNC_NO_SELF)==0) { + if(func->flag & FUNC_USE_SELF_ID) + fprintf(f, "struct ID *_selfid, "); + if(dsrna->dnaname) fprintf(f, "struct %s *_self", dsrna->dnaname); else fprintf(f, "struct %s *_self", srna->identifier); first= 0; @@ -1719,16 +1731,19 @@ static void rna_generate_static_function_prototypes(BlenderRNA *brna, StructRNA { FunctionRNA *func; FunctionDefRNA *dfunc; - - fprintf(f, "/* Repeated prototypes to detect errors */\n\n"); + int first= 1; for(func= srna->functions.first; func; func= func->cont.next) { - if(func->flag & FUNC_REGISTER) - continue; - dfunc= rna_find_function_def(func); - if(dfunc->call) + + if(dfunc->call) { + if(first) { + fprintf(f, "/* Repeated prototypes to detect errors */\n\n"); + first= 0; + } + rna_generate_static_parameter_prototypes(brna, srna, dfunc, f); + } } fprintf(f, "\n"); |