Makesrna: Fix function prototypes for struct used RNA_def_struct_sdna_from
authorSergey Sharybin <sergey.vfx@gmail.com>
Fri, 27 Mar 2015 13:44:11 +0000 (18:44 +0500)
committerSergey Sharybin <sergey.vfx@gmail.com>
Fri, 27 Mar 2015 13:44:11 +0000 (18:44 +0500)
Previously makesrna would have generated code expecting DNA structure from
RNA_def_struct_sdna_from() to be passed to it. This was wrong because actual
PointerRNA points to a "parent" structure, making it impossible to add
functions to certain RNA structures.

It so far never needed and we didn't notice this issue, but it's needed for
some ongoing development now.

source/blender/makesrna/intern/makesrna.c

index adeee3024637e1478d7172527255bdf905dabf94..829a70ef166e25615beb1e4d3a87a601e8467cec 100644 (file)
@@ -2027,7 +2027,8 @@ static void rna_def_struct_function_call_impl_cpp(FILE *f, StructRNA *srna, Func
 
        if ((func->flag & FUNC_NO_SELF) == 0) {
                WRITE_COMMA;
-               if (dsrna->dnaname) fprintf(f, "(::%s *) this->ptr.data", dsrna->dnaname);
+               if (dsrna->dnafromprop) fprintf(f, "(::%s *) this->ptr.data", dsrna->dnafromname);
+               else 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) {
@@ -2222,7 +2223,8 @@ static void rna_def_function_funcs(FILE *f, StructDefRNA *dsrna, FunctionDefRNA
        }
 
        if ((func->flag & FUNC_NO_SELF) == 0) {
-               if (dsrna->dnaname) fprintf(f, "\tstruct %s *_self;\n", dsrna->dnaname);
+               if (dsrna->dnafromprop) fprintf(f, "\tstruct %s *_self;\n", dsrna->dnafromname);
+               else 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) {
@@ -2274,7 +2276,8 @@ static void rna_def_function_funcs(FILE *f, StructDefRNA *dsrna, FunctionDefRNA
        }
        
        if ((func->flag & FUNC_NO_SELF) == 0) {
-               if (dsrna->dnaname) fprintf(f, "\t_self = (struct %s *)_ptr->data;\n", dsrna->dnaname);
+               if (dsrna->dnafromprop) fprintf(f, "\t_self = (struct %s *)_ptr->data;\n", dsrna->dnafromname);
+               else 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) {
@@ -2675,7 +2678,8 @@ static void rna_generate_static_parameter_prototypes(FILE *f, StructRNA *srna, F
 
        if ((func->flag & FUNC_NO_SELF) == 0) {
                if (!first) fprintf(f, ", ");
-               if (dsrna->dnaname) fprintf(f, "struct %s *_self", dsrna->dnaname);
+               if (dsrna->dnafromprop) fprintf(f, "struct %s *_self", dsrna->dnafromname);
+               else if (dsrna->dnaname) fprintf(f, "struct %s *_self", dsrna->dnaname);
                else fprintf(f, "struct %s *_self", srna->identifier);
                first = 0;
        }