aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/makamys/neodymium/util/Preprocessor.java
diff options
context:
space:
mode:
authorFalsePattern <me@falsepattern.com>2023-11-28 09:41:56 +0100
committermakamys <makamys@outlook.com>2023-12-01 18:34:00 +0100
commitfbe408c777dcf6ea5d2d784b739287d6db2bf52c (patch)
tree77e4023ef11829d36adf1095a5f20bc8845b32f6 /src/main/java/makamys/neodymium/util/Preprocessor.java
parenta4ec946f5931f8fe6e6271b22c553f99b9d5afb8 (diff)
downloadNeodymium-fbe408c777dcf6ea5d2d784b739287d6db2bf52c.tar.gz
Neodymium-fbe408c777dcf6ea5d2d784b739287d6db2bf52c.tar.bz2
Neodymium-fbe408c777dcf6ea5d2d784b739287d6db2bf52c.zip
abstraction layer for attribute index/stride/offset
Diffstat (limited to 'src/main/java/makamys/neodymium/util/Preprocessor.java')
-rw-r--r--src/main/java/makamys/neodymium/util/Preprocessor.java10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/main/java/makamys/neodymium/util/Preprocessor.java b/src/main/java/makamys/neodymium/util/Preprocessor.java
index d2fb0ba..cd5d8df 100644
--- a/src/main/java/makamys/neodymium/util/Preprocessor.java
+++ b/src/main/java/makamys/neodymium/util/Preprocessor.java
@@ -1,10 +1,11 @@
package makamys.neodymium.util;
+import java.util.Map;
import java.util.Set;
public class Preprocessor {
- public static String preprocess(String text, Set<String> defines) {
+ public static String preprocess(String text, Map<String, String> defines) {
String[] lines = text.replaceAll("\\r\\n", "\n").split("\\n");
IfElseBlockStatus ifElseBlockStatus = IfElseBlockStatus.NONE;
@@ -17,7 +18,7 @@ public class Preprocessor {
if(line.startsWith("#ifdef ")) {
ifElseBlockStatus = IfElseBlockStatus.IF;
- ifElseConditionMet = defines.contains(line.split(" ")[1]);
+ ifElseConditionMet = defines.containsKey(line.split(" ")[1]);
commentLine = true;
} else if(line.startsWith("#else")) {
ifElseBlockStatus = IfElseBlockStatus.ELSE;
@@ -36,6 +37,11 @@ public class Preprocessor {
if(commentLine) {
lines[i] = "//" + line;
+ } else {
+ for (Map.Entry<String, String> define: defines.entrySet()) {
+ line = line.replace(define.getKey(), define.getValue());
+ }
+ lines[i] = line;
}
}