-
Notifications
You must be signed in to change notification settings - Fork 1
Closed
Labels
enhancementNew feature or requestNew feature or request
Milestone
Description
Determining what type a preprocessor macro is from parsing alone is non-trivial.
Macros can either be used as typenames, statements, attributes, etc.
Right now the library supports the user defining custom keywords/macros as specifiers or attributes, however macros beyond that are just distinguished if they are functional or not (take arguments).
This is problematic for macros that behave as statements but do not have an end statement token ;.
clang-format lets the user specify these distinctions in their specification file:
AttributeMacros: [
GEN_API
]
StatementMacros: [
GEN_NS_BEGIN,
GEN_NS_END,
GEN_NS_PARSER_BEGIN,
GEN_NS_PARSER_END,
GEN_API_C_BEGIN,
GEN_API_C_END,
GEN_IF_MACRO_DEFINED_INCLUDE_THIS_SLOT
]
Macros:
- enum_underlying(type)=type
- gen_enum_underlying(type)=type
# WhitespaceSensitiveMacros: [
# ]
TypenameMacros: [Array, Hashtable]gencpp should support in PreprocessorDefines indicating whether a macro should be considered a statement macro by expanding the Array type form a Str to a struct:
enum MacroType : u32
{
// We cannot add specifiers or attributes here as they are handled by their respective enums, parsing, etc
...
Block_Start, // Indicating the start of a scope
Block_End, // Indicating the end of a scope
Statement, // Behaves a statement (may or may not have ; )
Statement_With_Body, // Behaves a statement that expects a braced body after.
Typename, // Macro that may be used as a typename
};
struct PreprocessorMacros
{
MacroType Type;
b32 IsFunctional;
StrCached Name;
};
// and in context...
struct Context
{
...
// Rename: PreprocessorDefines -> PreprocessorMacros
Array(PreprocessorMacro) PreprocessorMacros;
...
};Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request
Projects
Status
Done