aboutsummaryrefslogtreecommitdiff
path: root/source/20-codegen-compiler/CodegenMacros.hpp
diff options
context:
space:
mode:
authorrtk0c <[email protected]>2022-05-30 23:42:02 -0700
committerrtk0c <[email protected]>2022-05-30 23:42:02 -0700
commit8a0f2cd0b398ee0b7740e44a0e5fb2f75d090ccb (patch)
tree2838fd73313948f4db156b60c079468314eb1564 /source/20-codegen-compiler/CodegenMacros.hpp
parent3571627772b245e3e1a45b66e9a8fe4d50d06c8c (diff)
Changeset: 59 Integrate enum codegen into the actual project
Diffstat (limited to 'source/20-codegen-compiler/CodegenMacros.hpp')
-rw-r--r--source/20-codegen-compiler/CodegenMacros.hpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/source/20-codegen-compiler/CodegenMacros.hpp b/source/20-codegen-compiler/CodegenMacros.hpp
index 84c9d09..e56aed0 100644
--- a/source/20-codegen-compiler/CodegenMacros.hpp
+++ b/source/20-codegen-compiler/CodegenMacros.hpp
@@ -5,7 +5,12 @@
// I give up, hopefully nothing overflows this buffer
// TODO handle buffer sizing properly
-#define APPEND_LIT(out, str) out += str
+#define INPLACE_FMT(varName, format, ...) \
+ char varName[2048]; \
+ snprintf(varName, sizeof(varName), format, __VA_ARGS__);
+
+#define APPEND_LIT(out, str) \
+ out += str
#define APPEND_FMT(out, format, ...) \
{ \
@@ -14,7 +19,8 @@
out += buffer; \
}
-#define WRITE_LIT(file, str) fwrite(str, sizeof(char), sizeof(str) - 1, file)
+#define WRITE_LIT(file, str) \
+ fwrite(str, sizeof(char), sizeof(str) - 1, file)
// NOTE: snprintf() returns the size written (given an infinite buffer) not including \0
#define WRITE_FMT(file, format, ...) \