summaryrefslogtreecommitdiff
path: root/ccode
diff options
context:
space:
mode:
authorMarc-André Lureau <marcandre.lureau@gmail.com>2013-01-21 18:06:12 +0100
committerLuca Bruno <lucabru@src.gnome.org>2013-12-14 14:49:20 +0100
commit591340a3a06b9f25db7d1a5dba53270e543e55c1 (patch)
tree074364da4c9ae294152fc86a04fdc76a35b09d12 /ccode
parent5d96dcfc5f65da2ef2c3c04614bef7853eeebcf2 (diff)
downloadvala-591340a3a06b9f25db7d1a5dba53270e543e55c1.tar.gz
codegen: use #if GLIB_CHECK_VERSION for init functions
Tarballs with generated code should compile without warnings, and work with various versions of glib (assuming the rest of the code is correctly up to date, which is often the case if you don't use newer functions) https://bugzilla.gnome.org/show_bug.cgi?id=692218
Diffstat (limited to 'ccode')
-rw-r--r--ccode/Makefile.am1
-rw-r--r--ccode/valaccodeifsection.vala50
2 files changed, 51 insertions, 0 deletions
diff --git a/ccode/Makefile.am b/ccode/Makefile.am
index c63dd06e0..5be8d793f 100644
--- a/ccode/Makefile.am
+++ b/ccode/Makefile.am
@@ -46,6 +46,7 @@ libvalaccode_la_VALASOURCES = \
valaccodeinvalidexpression.vala \
valaccodelabel.vala \
valaccodelinedirective.vala \
+ valaccodeifsection.vala \
valaccodemacroreplacement.vala \
valaccodememberaccess.vala \
valaccodemodifiers.vala \
diff --git a/ccode/valaccodeifsection.vala b/ccode/valaccodeifsection.vala
new file mode 100644
index 000000000..dd51743e0
--- /dev/null
+++ b/ccode/valaccodeifsection.vala
@@ -0,0 +1,50 @@
+/* valaccodeifsection.vala
+ *
+ * Copyright (C) 2013 Jürg Billeter
+ *
+ * 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:
+ * Marc-André Lurau <marcandre.lureau@redhat.com>
+ */
+
+using GLib;
+
+/**
+ * Represents a section that should be processed on condition.
+ */
+public class Vala.CCodeIfSection : CCodeFragment {
+ /**
+ * The expression
+ */
+ public string expression { get; set; }
+
+ public CCodeIfSection (string expr) {
+ expression = expr;
+ }
+
+ public override void write (CCodeWriter writer) {
+ writer.write_string ("#if ");
+ writer.write_string (expression);
+ foreach (CCodeNode node in get_children ()) {
+ node.write_combined (writer);
+ }
+ writer.write_string ("#endif");
+ writer.write_newline ();
+ }
+
+ public override void write_declaration (CCodeWriter writer) {
+ }
+}