diff options
| author | jsmall-nvidia <jsmall@nvidia.com> | 2022-03-15 10:45:24 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-03-15 10:45:24 -0400 |
| commit | 8533dd2344d8be040a992a86f23e7cf696d59c4a (patch) | |
| tree | 9121a5a5fa98eb4f5101421341142616ac703ba8 /tools/slang-cpp-extractor/node.h | |
| parent | 06d04ab5e63ad43d7ad9de3fbc4c8ed64b13265a (diff) | |
C++ extractor callable support (#2159)
* #include an absolute path didn't work - because paths were taken to always be relative.
* Split doc extractor such that can be used in C++ extractor.
* Compiles. Update the stdlib docs.
* Fix issue on release builds.
* Add support for extracting documentation to C++ extractor.
* Dump out markup.
Make enum value backing type take tokens.
* Node::Type -> Node::Kind
* More improvements around Node::Type -> Node::Kind
* Support for parsing callable types.
* Fix issue params for callable, and default value for variable.
* Add support for static.
* Improve handling parsing of contained types.
* Small improvements around template consumption.
* Improve dumping with markup/static.
* Small improvements around reflection.
* Add more flexible handling of markers.
Allow reflection without markers.
Diffstat (limited to 'tools/slang-cpp-extractor/node.h')
| -rw-r--r-- | tools/slang-cpp-extractor/node.h | 49 |
1 files changed, 46 insertions, 3 deletions
diff --git a/tools/slang-cpp-extractor/node.h b/tools/slang-cpp-extractor/node.h index f649f1adb..db9a10e36 100644 --- a/tools/slang-cpp-extractor/node.h +++ b/tools/slang-cpp-extractor/node.h @@ -41,6 +41,11 @@ public: TypeDef, + Callable, ///< Functions/methods + + Other, ///< Used 'other' parsing like for TYPE + Unknown, ///< Used for marking tokens consumed but usage is not known + CountOf, }; @@ -64,7 +69,7 @@ public: /// Returns true if kind can cast to this type /// Used for implementing as<T> casting - static bool isOfKind(Kind type) { return true; } + static bool isOfKind(Kind kind) { SLANG_UNUSED(kind); return true; } static bool isKindScope(Kind kind) { return int(kind) >= int(KindRange::ScopeStart) && int(kind) <= int(KindRange::ScopeEnd); } static bool isKindClassLike(Kind kind) { return int(kind) >= int(KindRange::ClassLikeStart) && int(kind) <= int(KindRange::ClassLikeEnd); } @@ -95,7 +100,10 @@ public: return false; } + bool isNamespace() const { return m_kind == Kind::Namespace; } bool isClassLike() const { return isKindClassLike(m_kind); } + bool isScope() const { return isKindScope(m_kind); } + bool isEnumLike() const { return isKindEnumLike(m_kind); } /// These are useful for the filter static bool isClassLikeAndReflected(Node* node) { return node->isClassLike() && node->isReflected(); } @@ -175,8 +183,12 @@ struct ScopeNode : public Node virtual void dump(int indent, StringBuilder& out) SLANG_OVERRIDE; virtual void calcScopeDepthFirst(List<Node*>& outNodes) SLANG_OVERRIDE; + /// True if can contain callable entries + bool canContainCallable() const { return isClassLike() || isNamespace(); } + /// True if can accept fields (class like types can) bool canContainFields() const { return isClassLike(); } + /// True if the scope can accept types bool canContainTypes() const { return canKindContainTypes(m_kind); } @@ -185,6 +197,8 @@ struct ScopeNode : public Node /// Add a child node to this nodes scope void addChild(Node* child); + /// Adds the child but does not add the name to the map + void addChildIgnoringName(Node* child); /// Find a child node in this scope with the specified name. Return nullptr if not found Node* findChild(const UnownedStringSlice& name) const; @@ -216,7 +230,7 @@ struct FieldNode : public Node { typedef Node Super; - static bool isOfKind(Kind type) { return type == Kind::Field; } + static bool isOfKind(Kind kind) { return kind == Kind::Field; } virtual void dump(int indent, StringBuilder& out) SLANG_OVERRIDE; @@ -227,7 +241,9 @@ struct FieldNode : public Node UnownedStringSlice m_fieldType; - // We may want to add initializer tokens + bool m_isStatic = false; + + /// TODO(JS): We may want to add initializer tokens }; struct ClassLikeNode : public ScopeNode @@ -281,6 +297,33 @@ struct ClassLikeNode : public ScopeNode ClassLikeNode* m_superNode; ///< If this is a class/struct, the type it is derived from (or nullptr if base) }; +struct CallableNode : public Node +{ + typedef Node Super; + + static bool isOfKind(Kind kind) { return kind == Kind::Callable; } + + virtual void dump(int indent, StringBuilder& out) SLANG_OVERRIDE; + + CallableNode() :Super(Kind::Callable) {} + + struct Param + { + UnownedStringSlice m_type; + Token m_name; + }; + + UnownedStringSlice m_returnType; + + CallableNode* m_nextOverload = nullptr; + + List<Param> m_params; + + bool m_isStatic = false; + bool m_isVirtual = false; + bool m_isPure = false; +}; + struct EnumCaseNode : public Node { typedef Node Super; |
