summaryrefslogtreecommitdiffstats
path: root/tools/slang-cpp-extractor/identifier-lookup.h
diff options
context:
space:
mode:
authorLauro Oyen <15063951+laurooyen@users.noreply.github.com>2024-12-02 20:46:43 +0100
committerGitHub <noreply@github.com>2024-12-02 11:46:43 -0800
commiteaa8dcfcc9deabb906cc09bf31fc17ab6f343ff4 (patch)
tree8e0f4658de3efb5e7696e8588c55471f9d65ba18 /tools/slang-cpp-extractor/identifier-lookup.h
parent7aaf7009e2c6055a714ba4a93ab3dd73d2d2cdb7 (diff)
Move c++ parsing code from slang-cpp-extractor to static library (#5675)
* Move c++ parsing code from slang-cpp-extractor to static library * Format code * Remove relative includes --------- Co-authored-by: slangbot <ellieh+slangbot@nvidia.com> Co-authored-by: Yong He <yonghe@outlook.com>
Diffstat (limited to 'tools/slang-cpp-extractor/identifier-lookup.h')
-rw-r--r--tools/slang-cpp-extractor/identifier-lookup.h124
1 files changed, 0 insertions, 124 deletions
diff --git a/tools/slang-cpp-extractor/identifier-lookup.h b/tools/slang-cpp-extractor/identifier-lookup.h
deleted file mode 100644
index f26220f1f..000000000
--- a/tools/slang-cpp-extractor/identifier-lookup.h
+++ /dev/null
@@ -1,124 +0,0 @@
-#ifndef CPP_EXTRACT_IDENTIFIER_LOOKUP_H
-#define CPP_EXTRACT_IDENTIFIER_LOOKUP_H
-
-#include "diagnostics.h"
-
-namespace CppExtract
-{
-using namespace Slang;
-
-enum class IdentifierStyle
-{
- None, ///< It's not an identifier
-
- Identifier, ///< Just an identifier
-
- PreDeclare, ///< Declare a type (not visible in C++ code)
- TypeSet, ///< TypeSet
-
- TypeModifier, ///< const, volatile etc
- Keyword, ///< A keyword C/C++ keyword that is not another type
-
- Class, ///< class
- Struct, ///< struct
- Namespace, ///< namespace
- Enum, ///< enum
-
- TypeDef, ///< typedef
-
- Access, ///< public, protected, private
-
- Reflected,
- Unreflected,
-
- CallingConvention, ///< Used on a method
- Virtual, ///<
-
- Template,
-
- Static,
-
- IntegerModifier,
-
- Extern,
-
- CallableMisc, ///< For SLANG_NO_THROW etc
-
- IntegerType, ///< Built in integer type
-
- Default, /// default
-
- CountOf,
-};
-
-typedef uint32_t IdentifierFlags;
-struct IdentifierFlag
-{
- enum Enum : IdentifierFlags
- {
- StartScope = 0x1, ///< namespace, struct or class
- ClassLike = 0x2, ///< Struct or class
- Keyword = 0x4,
- Reflection = 0x8,
- };
-};
-
-
-class IdentifierLookup
-{
-public:
- struct Pair
- {
- const char* name;
- IdentifierStyle style;
- };
-
- IdentifierStyle get(const UnownedStringSlice& slice) const
- {
- Index index = m_pool.findIndex(slice);
- return (index >= 0) ? m_styles[index] : IdentifierStyle::None;
- }
-
- void set(const char* name, IdentifierStyle style) { set(UnownedStringSlice(name), style); }
-
- void set(const UnownedStringSlice& name, IdentifierStyle style);
-
- void set(const char* const* names, size_t namesCount, IdentifierStyle style);
-
- void set(const Pair* pairs, Index pairsCount);
-
- void reset()
- {
- m_styles.clear();
- m_pool.clear();
- }
-
- void initDefault(const UnownedStringSlice& markPrefix);
-
- IdentifierLookup()
- : m_pool(StringSlicePool::Style::Empty)
- {
- SLANG_ASSERT(m_pool.getSlicesCount() == 0);
- }
-
- static const IdentifierFlags kIdentifierFlags[Index(IdentifierStyle::CountOf)];
-
-protected:
- List<IdentifierStyle> m_styles;
- StringSlicePool m_pool;
-};
-
-
-SLANG_FORCE_INLINE IdentifierFlags getFlags(IdentifierStyle style)
-{
- return IdentifierLookup::kIdentifierFlags[Index(style)];
-}
-
-SLANG_FORCE_INLINE bool hasFlag(IdentifierStyle style, IdentifierFlag::Enum flag)
-{
- return (getFlags(style) & flag) != 0;
-}
-
-} // namespace CppExtract
-
-#endif