summaryrefslogtreecommitdiffstats
path: root/tools/slang-cpp-extractor/identifier-lookup.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tools/slang-cpp-extractor/identifier-lookup.cpp')
-rw-r--r--tools/slang-cpp-extractor/identifier-lookup.cpp110
1 files changed, 66 insertions, 44 deletions
diff --git a/tools/slang-cpp-extractor/identifier-lookup.cpp b/tools/slang-cpp-extractor/identifier-lookup.cpp
index 6b60f573c..c7255aa1f 100644
--- a/tools/slang-cpp-extractor/identifier-lookup.cpp
+++ b/tools/slang-cpp-extractor/identifier-lookup.cpp
@@ -1,41 +1,42 @@
#include "identifier-lookup.h"
-namespace CppExtract {
+namespace CppExtract
+{
using namespace Slang;
-/* static */const IdentifierFlags IdentifierLookup::kIdentifierFlags[Index(IdentifierStyle::CountOf)] =
-{
- 0, /// None
- 0, /// Identifier
- 0, /// Declare type
- 0, /// Type set
- IdentifierFlag::Keyword, /// TypeModifier
- IdentifierFlag::Keyword, /// Keyword
+/* static */ const IdentifierFlags
+ IdentifierLookup::kIdentifierFlags[Index(IdentifierStyle::CountOf)] = {
+ 0, /// None
+ 0, /// Identifier
+ 0, /// Declare type
+ 0, /// Type set
+ IdentifierFlag::Keyword, /// TypeModifier
+ IdentifierFlag::Keyword, /// Keyword
- IdentifierFlag::Keyword | IdentifierFlag::StartScope | IdentifierFlag::ClassLike, /// Class
- IdentifierFlag::Keyword | IdentifierFlag::StartScope | IdentifierFlag::ClassLike, /// Struct
- IdentifierFlag::Keyword | IdentifierFlag::StartScope, /// Namespace
- IdentifierFlag::Keyword | IdentifierFlag::StartScope, /// Enum
+ IdentifierFlag::Keyword | IdentifierFlag::StartScope | IdentifierFlag::ClassLike, /// Class
+ IdentifierFlag::Keyword | IdentifierFlag::StartScope | IdentifierFlag::ClassLike, /// Struct
+ IdentifierFlag::Keyword | IdentifierFlag::StartScope, /// Namespace
+ IdentifierFlag::Keyword | IdentifierFlag::StartScope, /// Enum
- IdentifierFlag::Keyword, /// Typedef
+ IdentifierFlag::Keyword, /// Typedef
- IdentifierFlag::Keyword, /// Access
- IdentifierFlag::Reflection, /// Reflected
- IdentifierFlag::Reflection, /// Unreflected
+ IdentifierFlag::Keyword, /// Access
+ IdentifierFlag::Reflection, /// Reflected
+ IdentifierFlag::Reflection, /// Unreflected
- IdentifierFlag::Keyword, /// virtual
- 0, /// Calling convention
- IdentifierFlag::Keyword, /// template
- IdentifierFlag::Keyword, /// static
+ IdentifierFlag::Keyword, /// virtual
+ 0, /// Calling convention
+ IdentifierFlag::Keyword, /// template
+ IdentifierFlag::Keyword, /// static
- IdentifierFlag::Keyword, /// unsigned/signed
+ IdentifierFlag::Keyword, /// unsigned/signed
- IdentifierFlag::Keyword, /// extern
+ IdentifierFlag::Keyword, /// extern
- 0, /// Callable misc
- 0, /// IntegerType int, short, char, long
+ 0, /// Callable misc
+ 0, /// IntegerType int, short, char, long
- IdentifierFlag::Keyword, /// default
+ IdentifierFlag::Keyword, /// default
};
void IdentifierLookup::set(const UnownedStringSlice& name, IdentifierStyle style)
@@ -54,7 +55,7 @@ void IdentifierLookup::set(const UnownedStringSlice& name, IdentifierStyle style
}
}
-void IdentifierLookup::set(const char*const* names, size_t namesCount, IdentifierStyle style)
+void IdentifierLookup::set(const char* const* names, size_t namesCount, IdentifierStyle style)
{
for (size_t i = 0; i < namesCount; ++i)
{
@@ -77,20 +78,42 @@ void IdentifierLookup::initDefault(const UnownedStringSlice& markPrefix)
// Some keywords
{
- const char* names[] = { "continue", "if", "case", "break", "catch", "delete", "do", "else", "for", "new", "goto", "return", "switch", "throw", "using", "while", "operator", "explicit"};
+ const char* names[] = {
+ "continue",
+ "if",
+ "case",
+ "break",
+ "catch",
+ "delete",
+ "do",
+ "else",
+ "for",
+ "new",
+ "goto",
+ "return",
+ "switch",
+ "throw",
+ "using",
+ "while",
+ "operator",
+ "explicit"};
set(names, SLANG_COUNT_OF(names), IdentifierStyle::Keyword);
}
// Type modifier keywords
{
- const char* names[] = { "const", "volatile" };
+ const char* names[] = {"const", "volatile"};
set(names, SLANG_COUNT_OF(names), IdentifierStyle::TypeModifier);
}
// Special markers
{
- const char* names[] = { "PRE_DECLARE", "TYPE_SET", "REFLECTED", "UNREFLECTED" };
- const IdentifierStyle styles[] = { IdentifierStyle::PreDeclare, IdentifierStyle::TypeSet, IdentifierStyle::Reflected, IdentifierStyle::Unreflected };
+ const char* names[] = {"PRE_DECLARE", "TYPE_SET", "REFLECTED", "UNREFLECTED"};
+ const IdentifierStyle styles[] = {
+ IdentifierStyle::PreDeclare,
+ IdentifierStyle::TypeSet,
+ IdentifierStyle::Reflected,
+ IdentifierStyle::Unreflected};
SLANG_COMPILE_TIME_ASSERT(SLANG_COUNT_OF(names) == SLANG_COUNT_OF(styles));
StringBuilder buf;
@@ -104,7 +127,7 @@ void IdentifierLookup::initDefault(const UnownedStringSlice& markPrefix)
{
set("virtual", IdentifierStyle::Virtual);
-
+
set("template", IdentifierStyle::Template);
set("static", IdentifierStyle::Static);
set("extern", IdentifierStyle::Extern);
@@ -112,29 +135,28 @@ void IdentifierLookup::initDefault(const UnownedStringSlice& markPrefix)
}
{
- const char* names[] = { "char", "short", "int", "long"};
+ const char* names[] = {"char", "short", "int", "long"};
set(names, SLANG_COUNT_OF(names), IdentifierStyle::IntegerType);
}
{
- const char* names[] = { "SLANG_MCALL" };
+ const char* names[] = {"SLANG_MCALL"};
set(names, SLANG_COUNT_OF(names), IdentifierStyle::CallingConvention);
}
{
- const char* names[] = { "SLANG_NO_THROW", "inline"};
+ const char* names[] = {"SLANG_NO_THROW", "inline"};
set(names, SLANG_COUNT_OF(names), IdentifierStyle::CallableMisc);
}
// Keywords which introduce types/scopes
{
- const Pair pairs[] =
- {
- { "struct", IdentifierStyle::Struct },
- { "class", IdentifierStyle::Class },
- { "namespace", IdentifierStyle::Namespace },
- { "enum", IdentifierStyle::Enum },
- { "typedef", IdentifierStyle::TypeDef },
+ const Pair pairs[] = {
+ {"struct", IdentifierStyle::Struct},
+ {"class", IdentifierStyle::Class},
+ {"namespace", IdentifierStyle::Namespace},
+ {"enum", IdentifierStyle::Enum},
+ {"typedef", IdentifierStyle::TypeDef},
};
set(pairs, SLANG_COUNT_OF(pairs));
@@ -142,11 +164,11 @@ void IdentifierLookup::initDefault(const UnownedStringSlice& markPrefix)
// Keywords that control access
{
- const char* names[] = { "private", "protected", "public" };
+ const char* names[] = {"private", "protected", "public"};
set(names, SLANG_COUNT_OF(names), IdentifierStyle::Access);
}
{
- const char* names[] = { "signed", "unsigned"};
+ const char* names[] = {"signed", "unsigned"};
set(names, SLANG_COUNT_OF(names), IdentifierStyle::IntegerModifier);
}