From 5116265f701408ed6d7cfcb852d5f767655de6b5 Mon Sep 17 00:00:00 2001 From: Justin Pridgen Date: Tue, 10 Dec 2024 11:17:07 -0500 Subject: [PATCH] add nodefine --- include/ast.hpp | 1 + src/attribute.hpp | 27 ++++++++++++++++++++++++++- src/function.hpp | 1 + 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/include/ast.hpp b/include/ast.hpp index fcddf12..4ce053c 100644 --- a/include/ast.hpp +++ b/include/ast.hpp @@ -76,6 +76,7 @@ namespace broma { std::string docs; ///< Any docstring pulled from a `[[docs(...)]]` attribute. Platform links = Platform::None; ///< All the platforms that link the class or function Platform missing = Platform::None; ///< All the platforms that are missing the class or function + Platform nodefine = Platform::None; ///< All the platforms that should not define the class or function std::vector depends; ///< List of classes that this class or function depends on }; diff --git a/src/attribute.hpp b/src/attribute.hpp index efa28b3..52354b4 100644 --- a/src/attribute.hpp +++ b/src/attribute.hpp @@ -53,6 +53,13 @@ namespace broma { > >> {}; + struct nodefine_attribute : basic_attribute, + opt> + > + >> {}; + /// @brief All allowed C++ attributes. /// /// Currently, this includes the `docs(...)`, `depends(...)`, `link(...)` and `missing(...)` attributes. @@ -64,7 +71,7 @@ namespace broma { success, list, + sor, sep >, one<','>> >, @@ -134,4 +141,22 @@ namespace broma { } }; + // nodefine + + template <> + struct run_action> { + template + static void apply(T& input, Root* root, ScratchData* scratch) { + scratch->wip_attributes.nodefine = Platform::None; + } + }; + + template <> + struct run_action> { + template + static void apply(T& input, Root* root, ScratchData* scratch) { + scratch->wip_attributes.nodefine |= str_to_platform(input.string()); + } + }; + } // namespace broma diff --git a/src/function.hpp b/src/function.hpp index 2192cbd..aa702a8 100644 --- a/src/function.hpp +++ b/src/function.hpp @@ -99,6 +99,7 @@ namespace broma { scratch->wip_attributes = Attributes(); scratch->wip_attributes.links = scratch->wip_class.attributes.links; scratch->wip_attributes.missing = scratch->wip_class.attributes.missing; + scratch->wip_attributes.nodefine = scratch->wip_class.attributes.nodefine; scratch->wip_mem_fn_proto = MemberFunctionProto(); }