summaryrefslogtreecommitdiff
path: root/codegen/valagobjectmodule.vala
diff options
context:
space:
mode:
authorRico Tzschichholz <ricotz@ubuntu.com>2016-10-13 09:39:47 +0200
committerRico Tzschichholz <ricotz@ubuntu.com>2016-10-18 11:07:29 +0200
commitad87c4eb227c438a3bcadda9ee9b87aacb77adae (patch)
tree2a8ea0c35676f2957634bf344ebde81827ff3db4 /codegen/valagobjectmodule.vala
parentf1ddd5a6d201ccb90563e4b46fe500b72841d6f1 (diff)
downloadvala-ad87c4eb227c438a3bcadda9ee9b87aacb77adae.tar.gz
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 <simon.werbeck@gmail.com> https://bugzilla.gnome.org/show_bug.cgi?id=732449
Diffstat (limited to 'codegen/valagobjectmodule.vala')
-rw-r--r--codegen/valagobjectmodule.vala19
1 files changed, 15 insertions, 4 deletions
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 ();
}