From 6b69996713ae712813fcb2dc2bcd5a11e216a868 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Dreptin?= <44998961+ClementDreptin@users.noreply.github.com> Date: Sat, 13 Jan 2024 16:53:19 +0100 Subject: [PATCH] feat(preprocessor): add engine name builtin macro (#179) --- src/arc/preprocessor.cpp | 3 ++- src/gsc/preprocessor.cpp | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/arc/preprocessor.cpp b/src/arc/preprocessor.cpp index d8f94800..79ab00f8 100644 --- a/src/arc/preprocessor.cpp +++ b/src/arc/preprocessor.cpp @@ -13,11 +13,12 @@ namespace xsk::arc preprocessor::preprocessor(context* ctx, std::string const& name, char const* data, usize size) : ctx_{ ctx }, curr_expr_{ 0 }, expand_{ 0 }, skip_{ false } { lexer_.push(lexer{ ctx, name, data, size }); - defines_.reserve(4); + defines_.reserve(5); defines_.insert({ "__FILE__", { define::BUILTIN,/* false,*/ {}, {} }}); defines_.insert({ "__LINE__", { define::BUILTIN,/* false,*/ {}, {} }}); defines_.insert({ "__DATE__", { define::BUILTIN,/* false,*/ {}, {} }}); defines_.insert({ "__TIME__", { define::BUILTIN,/* false,*/ {}, {} }}); + defines_.insert({ std::string(ctx->engine_name()), { define::BUILTIN,/* false,*/ {}, {} }}); directives_.reserve(15); directives_.insert({ "if", directive::IF }); directives_.insert({ "ifdef", directive::IFDEF }); diff --git a/src/gsc/preprocessor.cpp b/src/gsc/preprocessor.cpp index 4a0128cb..24892094 100644 --- a/src/gsc/preprocessor.cpp +++ b/src/gsc/preprocessor.cpp @@ -13,11 +13,12 @@ namespace xsk::gsc preprocessor::preprocessor(context* ctx, std::string const& name, char const* data, usize size) : ctx_{ ctx }, curr_expr_{ 0 }, expand_{ 0 }, skip_{ false } { lexer_.push(lexer{ ctx, name, data, size }); - defines_.reserve(4); + defines_.reserve(5); defines_.insert({ "__FILE__", { define::BUILTIN,/* false,*/ {}, {} }}); defines_.insert({ "__LINE__", { define::BUILTIN,/* false,*/ {}, {} }}); defines_.insert({ "__DATE__", { define::BUILTIN,/* false,*/ {}, {} }}); defines_.insert({ "__TIME__", { define::BUILTIN,/* false,*/ {}, {} }}); + defines_.insert({ std::string(ctx->engine_name()), { define::BUILTIN,/* false,*/ {}, {} }}); directives_.reserve(15); directives_.insert({ "if", directive::IF }); directives_.insert({ "ifdef", directive::IFDEF });