diff options
author | Dr. Michael Lauer <mickey@vanille-media.de> | 2018-02-20 16:47:34 +0100 |
---|---|---|
committer | Rico Tzschichholz <ricotz@ubuntu.com> | 2018-02-20 22:16:19 +0100 |
commit | fcda327ebfc946de971ce7fd9c2715b6d28b518b (patch) | |
tree | dc922404216544cff4f2b77175e436c4c5888cd2 /ccode/valaccodefile.vala | |
parent | 00791762328402bb337448b5082c4da126d8b29d (diff) | |
download | vala-fcda327ebfc946de971ce7fd9c2715b6d28b518b.tar.gz |
codegen: Add support for feature test macros
This adds new CCode string attribute 'feature_test_macro = "VALUE"'. Such
values will be added before the headers section as '#define VALUE'.
https://www.gnu.org/software/libc/manual/html_node/Feature-Test-Macros.html
https://bugzilla.gnome.org/show_bug.cgi?id=793444
Diffstat (limited to 'ccode/valaccodefile.vala')
-rw-r--r-- | ccode/valaccodefile.vala | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/ccode/valaccodefile.vala b/ccode/valaccodefile.vala index 128cd3938..aa5be219e 100644 --- a/ccode/valaccodefile.vala +++ b/ccode/valaccodefile.vala @@ -24,9 +24,11 @@ public class Vala.CCodeFile { public bool is_header { get; set; } + Set<string> features = new HashSet<string> (str_hash, str_equal); Set<string> declarations = new HashSet<string> (str_hash, str_equal); Set<string> includes = new HashSet<string> (str_hash, str_equal); CCodeFragment comments = new CCodeFragment (); + CCodeFragment feature_test_macros = new CCodeFragment (); CCodeFragment include_directives = new CCodeFragment (); CCodeFragment type_declaration = new CCodeFragment (); CCodeFragment type_definition = new CCodeFragment (); @@ -46,6 +48,13 @@ public class Vala.CCodeFile { comments.append (comment); } + public void add_feature_test_macro (string feature_test_macro) { + if (!(feature_test_macro in features)) { + feature_test_macros.append (new CCodeFeatureTestMacro (feature_test_macro)); + features.add (feature_test_macro); + } + } + public void add_include (string filename, bool local = false) { if (!(filename in includes)) { include_directives.append (new CCodeIncludeDirective (filename, local)); @@ -133,6 +142,8 @@ public class Vala.CCodeFile { comments.write (writer); writer.write_newline (); + feature_test_macros.write (writer); + writer.write_newline (); include_directives.write (writer); writer.write_newline (); type_declaration.write_combined (writer); |