valaccodefunction.vala \
valaccodefunctioncall.vala \
valaccodefunctiondeclarator.vala \
+ valaccodeggnucsection.vala \
valaccodegotostatement.vala \
valaccodeidentifier.vala \
valaccodeifstatement.vala \
--- /dev/null
+/* valaccodeggnucsection.vala
+ *
+ * Copyright (C) 2016 Rico Tzschichholz
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Author:
+ * Rico Tzschichholz <ricotz@ubuntu.com>
+ */
+
+using GLib;
+
+/**
+ * Represents a section that should be processed on condition.
+ */
+public class Vala.CCodeGGnucSection : CCodeFragment {
+ /**
+ * The expression
+ */
+ public GGnucSectionType section_type { get; set; }
+
+ public CCodeGGnucSection (GGnucSectionType t) {
+ section_type = t;
+ }
+
+ public override void write (CCodeWriter writer) {
+ writer.write_string ("G_GNUC_BEGIN_");
+ writer.write_string (section_type.to_string ());
+ foreach (CCodeNode node in get_children ()) {
+ node.write_combined (writer);
+ }
+ writer.write_string ("G_GNUC_END_");
+ writer.write_string (section_type.to_string ());
+ writer.write_newline ();
+ }
+
+ public override void write_declaration (CCodeWriter writer) {
+ }
+}
+
+public enum Vala.GGnucSectionType {
+ IGNORE_DEPRECATIONS;
+
+ public unowned string to_string () {
+ switch (this) {
+ case IGNORE_DEPRECATIONS:
+ return "IGNORE_DEPRECATIONS";
+ default:
+ assert_not_reached ();
+ }
+ }
+}
}
}
+ if (prop.version.deprecated) {
+ function.modifiers |= CCodeModifiers.DEPRECATED;
+ }
+
if (prop.is_private_symbol () || (!acc.readable && !acc.writable) || acc.access == SymbolAccessibility.PRIVATE) {
function.modifiers |= CCodeModifiers.STATIC;
} else if (context.hide_internal && (prop.is_internal_symbol () || acc.access == SymbolAccessibility.INTERNAL)) {
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;
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)));
}
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 ();
}
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 ();
}
cgetcall.add_argument (new CCodeIdentifier ("value"));
ccall.add_argument (cgetcall);
- ccode.add_expression (ccall);
+ add_guarded_expression (prop, ccall);
}
ccode.add_break ();
}
}
}
}
+ if (prop.version.deprecated) {
+ pflags = "%s%s".printf (pflags, " | G_PARAM_DEPRECATED");
+ }
cspec.add_argument (new CCodeConstant (pflags));
return cspec;