diff options
author | Rico Tzschichholz <ricotz@ubuntu.com> | 2021-05-26 18:39:20 +0200 |
---|---|---|
committer | Rico Tzschichholz <ricotz@ubuntu.com> | 2021-06-08 10:48:57 +0200 |
commit | 75b0117dfbbedea75fd91e4ced8d24e499db4b07 (patch) | |
tree | a5ec085a0459bd2ca87210e17ee0c42d19344886 /codegen | |
parent | 9bd652886ad889213ca7c94a0b846947fdb226d3 (diff) | |
download | vala-75b0117dfbbedea75fd91e4ced8d24e499db4b07.tar.gz |
codegen: Implementing GLib.Source.prepare/check is optional since 2.36
Diffstat (limited to 'codegen')
-rw-r--r-- | codegen/valaccodemethodcallmodule.vala | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/codegen/valaccodemethodcallmodule.vala b/codegen/valaccodemethodcallmodule.vala index bbd08e00f..ceb9370ec 100644 --- a/codegen/valaccodemethodcallmodule.vala +++ b/codegen/valaccodemethodcallmodule.vala @@ -188,10 +188,27 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule { // g_source_new string class_prefix = get_ccode_lower_case_name (current_class); + string prepare_func = "NULL"; + string check_func = "NULL"; + foreach (Method impl in current_class.get_methods ()) { + if (!impl.overrides) { + continue; + } + switch (impl.name) { + case "prepare": + prepare_func = "%s_real_prepare".printf (class_prefix); + break; + case "check": + check_func = "%s_real_check".printf (class_prefix); + break; + default: + break; + } + } var funcs = new CCodeDeclaration ("const GSourceFuncs"); funcs.modifiers = CCodeModifiers.STATIC; - funcs.add_declarator (new CCodeVariableDeclarator ("_source_funcs", new CCodeConstant ("{ %s_real_prepare, %s_real_check, %s_real_dispatch, %s_finalize}".printf (class_prefix, class_prefix, class_prefix, class_prefix)))); + funcs.add_declarator (new CCodeVariableDeclarator ("_source_funcs", new CCodeConstant ("{ %s, %s, %s_real_dispatch, %s_finalize}".printf (prepare_func, check_func, class_prefix, class_prefix)))); ccode.add_statement (funcs); ccall.add_argument (new CCodeCastExpression (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, new CCodeIdentifier ("_source_funcs")), "GSourceFuncs *")); |