summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/wixl/preprocessor.vala17
1 files changed, 14 insertions, 3 deletions
diff --git a/tools/wixl/preprocessor.vala b/tools/wixl/preprocessor.vala
index d00e705..fe75244 100644
--- a/tools/wixl/preprocessor.vala
+++ b/tools/wixl/preprocessor.vala
@@ -3,14 +3,17 @@ namespace Wixl {
class Preprocessor: Object {
unowned List<File> includedirs;
- HashTable<string, string> globals;
HashTable<string, string> variables;
construct {
variables = new HashTable<string, string> (str_hash, str_equal);
}
public Preprocessor (HashTable<string, string> globals, List<File> includedirs) {
- this.globals = globals;
+ string name, value;
+ var it = HashTableIter <string, string> (globals);
+ while (it.next (out name, out value))
+ define_variable (name, value);
+
this.includedirs = includedirs;
}
@@ -18,8 +21,12 @@ namespace Wixl {
variables.insert (name, value);
}
+ public void undefine_variable (string name) {
+ variables.remove (name);
+ }
+
public string? lookup_variable (string name) {
- return variables.lookup (name) ?? globals.lookup (name);
+ return variables.lookup (name);
}
public string eval_variable (string str, File? file, bool needed = true) throws GLib.Error {
@@ -188,6 +195,10 @@ namespace Wixl {
} else
throw new Wixl.Error.FAILED ("invalid define");
break;
+ case "undef":
+ var value = reader.const_value ().strip ();
+ undefine_variable (value);
+ break;
case "include":
var value = eval (reader.const_value (), file).strip ();
var success = false;