summaryrefslogtreecommitdiff
path: root/src/bin
diff options
context:
space:
mode:
authorMarcel Hollerbach <mail@marcel-hollerbach.de>2020-07-16 12:39:23 +0200
committerMarcel Hollerbach <mail@marcel-hollerbach.de>2020-07-20 11:27:53 +0200
commita931e418234bc567d725c79a9e4d0462e02fa5a7 (patch)
tree7d7bafa17d4cae522ccad4d8c2b0d27bb88c4bfd /src/bin
parenta9710f54c1732543f57b9a44134e406b21eba93c (diff)
efl: make all _class_get() functions const
please note, not the return type, but the function. When appending __attribute__((const)) to a function, the compiler is told that its enough to call this function once in a function. This is quite often happening when we are efl_data_scope_get and efl_super in a function that is different from a implemented function. The compiler now starts to remove the calls that aggressivly that we need to ensure that these calls are not removed, which means, the static function calls, and the eo init are now checking the return value of these functions, to ensure that they are called. Please note that you now have to be carefull when your app calls eo_shutdown, if it does so, you *must* call it at the end of a function, or never call class_get after that anymore. Overall this improves elm test runs 0.1s which is fair i guess, the main thing that is faster is textrendering, where is also the point where this is the most beneficial. Please note, this replaces 42 occurences of double _class_get() ... THAT is a sign! Reviewed-by: Stefan Schmidt <stefan@datenfreihafen.org> Reviewed-by: Daniel Kolesa <daniel@octaforge.org> Differential Revision: https://phab.enlightenment.org/D12057
Diffstat (limited to 'src/bin')
-rw-r--r--src/bin/eolian/headers.c2
-rw-r--r--src/bin/eolian/sources.c23
2 files changed, 18 insertions, 7 deletions
diff --git a/src/bin/eolian/headers.c b/src/bin/eolian/headers.c
index 0ba05ee88e..6292fb4259 100644
--- a/src/bin/eolian/headers.c
+++ b/src/bin/eolian/headers.c
@@ -225,7 +225,7 @@ eo_gen_header_gen(const Eolian_State *state, const Eolian_Class *cl,
225 eina_strbuf_append_printf(buf, "#define %s %s()\n\n", mname, gname); 225 eina_strbuf_append_printf(buf, "#define %s %s()\n\n", mname, gname);
226 eina_stringshare_del(mname); 226 eina_stringshare_del(mname);
227 227
228 eina_strbuf_append_printf(buf, "EWAPI const Efl_Class *%s(void);\n", gname); 228 eina_strbuf_append_printf(buf, "EWAPI const Efl_Class *%s(void) EINA_CONST;\n", gname);
229 eina_stringshare_del(gname); 229 eina_stringshare_del(gname);
230 230
231 /* method section */ 231 /* method section */
diff --git a/src/bin/eolian/sources.c b/src/bin/eolian/sources.c
index dc79ee2daa..e5e8eb7a8b 100644
--- a/src/bin/eolian/sources.c
+++ b/src/bin/eolian/sources.c
@@ -472,7 +472,7 @@ _gen_reflect_set(Eina_Strbuf *buf, const char *cnamel,
472} 472}
473 473
474static void 474static void
475_emit_class_function(Eina_Strbuf *buf, const Eolian_Function *fid, const char *rtpn, Eina_Strbuf *params_full, 475_emit_class_function(Eina_Strbuf *buf, const Eolian_Function *fid, const Eolian_Function_Type ftype, const Eolian_Type *rtp, const char *rtpn, Eina_Strbuf *params_full,
476 const char *ocnamel, const char *func_suffix, Eina_Strbuf *params, const char *function_name) 476 const char *ocnamel, const char *func_suffix, Eina_Strbuf *params, const char *function_name)
477{ 477{
478 eina_strbuf_append(buf, "EOAPI "); 478 eina_strbuf_append(buf, "EOAPI ");
@@ -486,11 +486,22 @@ _emit_class_function(Eina_Strbuf *buf, const Eolian_Function *fid, const char *r
486 eina_strbuf_append_buffer(buf, params_full); 486 eina_strbuf_append_buffer(buf, params_full);
487 eina_strbuf_append(buf, ")\n"); 487 eina_strbuf_append(buf, ")\n");
488 eina_strbuf_append(buf, "{\n"); 488 eina_strbuf_append(buf, "{\n");
489 eina_strbuf_append_printf(buf, " %s();\n", eolian_class_c_get_function_name_get(eolian_function_class_get(fid))); 489 eina_strbuf_append_printf(buf, " const Efl_Class *klass = %s();\n", eolian_class_c_get_function_name_get(eolian_function_class_get(fid)));
490 if (strcmp(rtpn, "void")) 490 if (!!strcmp(rtpn, "void") && rtp)
491 eina_strbuf_append(buf, " return "); 491 {
492 const Eolian_Expression *default_value_expression = eolian_function_return_default_value_get(fid, ftype);
493
494 eina_strbuf_append_printf(buf, " EINA_SAFETY_ON_NULL_RETURN_VAL(klass,");
495 _append_defval(buf, default_value_expression, rtp, rtpn);
496 eina_strbuf_append_printf(buf, ");\n");
497
498 eina_strbuf_append(buf, " return ");
499 }
492 else 500 else
493 eina_strbuf_append(buf, " "); 501 {
502 eina_strbuf_append(buf, " EINA_SAFETY_ON_NULL_RETURN(klass);\n");
503 eina_strbuf_append(buf, " ");
504 }
494 eina_strbuf_append_printf(buf, "_%s", ocnamel); 505 eina_strbuf_append_printf(buf, "_%s", ocnamel);
495 eina_strbuf_append_char(buf, '_'); 506 eina_strbuf_append_char(buf, '_');
496 eina_strbuf_append(buf, eolian_function_name_get(fid)); 507 eina_strbuf_append(buf, eolian_function_name_get(fid));
@@ -925,7 +936,7 @@ _gen_func(const Eolian_Class *cl, const Eolian_Function *fid,
925 eina_stringshare_del(eofn); 936 eina_stringshare_del(eofn);
926 } 937 }
927 if (impl_same_class && eolian_function_is_static(fid)) 938 if (impl_same_class && eolian_function_is_static(fid))
928 _emit_class_function(buf, fid, rtpn, params_full, ocnamel, func_suffix, params, eolian_function_full_c_name_get(fid, ftype)); 939 _emit_class_function(buf, fid, ftype, rtp, rtpn, params_full, ocnamel, func_suffix, params, eolian_function_full_c_name_get(fid, ftype));
929 940
930 free(cname); 941 free(cname);
931 free(cnamel); 942 free(cnamel);