From ad87c4eb227c438a3bcadda9ee9b87aacb77adae Mon Sep 17 00:00:00 2001 From: Rico Tzschichholz Date: Thu, 13 Oct 2016 09:39:47 +0200 Subject: codegen: Support deprecating properties and their accessors Use G_PARAM_DEPRECATED for properties and in addition their accessor methods will be marked as deprecated. Guard internal accessors calls with G_GNUC_BEGIN/END_IGNORED_DEPRECATIONS to silence unavoidable warnings. Based on patch by Simon Werbeck https://bugzilla.gnome.org/show_bug.cgi?id=732449 --- codegen/valagobjectmodule.vala | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'codegen/valagobjectmodule.vala') diff --git a/codegen/valagobjectmodule.vala b/codegen/valagobjectmodule.vala index cc1413639..d4b888708 100644 --- a/codegen/valagobjectmodule.vala +++ b/codegen/valagobjectmodule.vala @@ -166,6 +166,17 @@ public class Vala.GObjectModule : GTypeModule { return false; } + private void add_guarded_expression (Symbol sym, CCodeExpression expression) { + // prevent deprecation warnings + if (sym.version.deprecated) { + var guard = new CCodeGGnucSection (GGnucSectionType.IGNORE_DEPRECATIONS); + ccode.add_statement (guard); + guard.append (new CCodeExpressionStatement (expression)); + } else { + ccode.add_expression (expression); + } + } + private void add_get_property_function (Class cl) { var get_prop = new CCodeFunction ("_vala_%s_get_property".printf (get_ccode_lower_case_name (cl, null)), "void"); get_prop.modifiers = CCodeModifiers.STATIC; @@ -231,7 +242,7 @@ public class Vala.GObjectModule : GTypeModule { csetcall.call = get_value_setter_function (prop.property_type); csetcall.add_argument (new CCodeIdentifier ("value")); csetcall.add_argument (boxed_addr); - ccode.add_expression (csetcall); + add_guarded_expression (prop, csetcall); if (requires_destroy (prop.get_accessor.value_type)) { ccode.add_expression (destroy_value (new GLibValue (prop.get_accessor.value_type, new CCodeIdentifier ("boxed"), true))); @@ -255,7 +266,7 @@ public class Vala.GObjectModule : GTypeModule { } csetcall.add_argument (new CCodeIdentifier ("value")); csetcall.add_argument (ccall); - ccode.add_expression (csetcall); + add_guarded_expression (prop, csetcall); if (array_type != null && array_type.element_type.data_type == string_type.data_type) { ccode.close (); } @@ -339,7 +350,7 @@ public class Vala.GObjectModule : GTypeModule { var ccond = new CCodeConditionalExpression (cisnull, new CCodeConstant ("0"), cstrvlen); ccall.add_argument (ccond); - ccode.add_expression (ccall); + add_guarded_expression (prop, ccall); ccode.close (); } else { var cgetcall = new CCodeFunctionCall (); @@ -350,7 +361,7 @@ public class Vala.GObjectModule : GTypeModule { } cgetcall.add_argument (new CCodeIdentifier ("value")); ccall.add_argument (cgetcall); - ccode.add_expression (ccall); + add_guarded_expression (prop, ccall); } ccode.add_break (); } -- cgit v1.2.1