summaryrefslogtreecommitdiff
path: root/source/slang-capture-replay/slang-global-session.cpp
diff options
context:
space:
mode:
authorSai Praveen Bangaru <31557731+saipraveenb25@users.noreply.github.com>2024-07-18 13:11:19 -0400
committerGitHub <noreply@github.com>2024-07-18 13:11:19 -0400
commit0d06ebcefb36a19710d87832fc1ea027e21281af (patch)
tree05ac5af6fa26a658348335eac3d63199b6949507 /source/slang-capture-replay/slang-global-session.cpp
parent89e836d42822e69dcaa4eb0a366d8c66e5aaa7e4 (diff)
Initial implementation for decl-tree reflection API (#4666)
* Initial implementation for decl-tree reflection API This patch adds Slang API methods for walking all the declarations in the AST. We expose this functionality through an abstract `DeclReflection` class that can be a type, function or a variable declaration. We also provide ways to cast the decl to a `FunctionReflection`, `TypeReflection` or `VariableReflection` and traverse through the child nodes (for instance, a struct type will have component variable declarations) This patch also adds `ISlangInternal` as an internal COM interface to allow us to cast IGlobalSession to the internal Session pointer while bypassing any wrappers (such as the capture interface) * Update slang.h * Remove `ISlangInternal` (its causing a diamond pattern w.r.t `ISlangUnknown`) and use `ComPtr` for proper ref management. * Update unit-test-decl-tree-reflection.cpp * Change `FunctionDeclBase` to use `DeclRef` instead of directly using the decl. * Update slang-reflection-api.cpp
Diffstat (limited to 'source/slang-capture-replay/slang-global-session.cpp')
-rw-r--r--source/slang-capture-replay/slang-global-session.cpp20
1 files changed, 16 insertions, 4 deletions
diff --git a/source/slang-capture-replay/slang-global-session.cpp b/source/slang-capture-replay/slang-global-session.cpp
index b8dfd7d40..d8f1e361d 100644
--- a/source/slang-capture-replay/slang-global-session.cpp
+++ b/source/slang-capture-replay/slang-global-session.cpp
@@ -28,11 +28,23 @@ namespace SlangCapture
m_actualGlobalSession->release();
}
- ISlangUnknown* GlobalSessionCapture::getInterface(const Guid& guid)
+ SLANG_NO_THROW SlangResult SLANG_MCALL GlobalSessionCapture::queryInterface(SlangUUID const& uuid, void** outObject)
{
- if(guid == ISlangUnknown::getTypeGuid() || guid == IGlobalSession::getTypeGuid())
- return asExternal(this);
- return nullptr;
+ if (uuid == Session::getTypeGuid())
+ {
+ // no add-ref here, the query will cause the inner session to handle the add-ref.
+ this->m_actualGlobalSession->queryInterface(uuid, outObject);
+ return SLANG_OK;
+ }
+
+ if (uuid == ISlangUnknown::getTypeGuid() && uuid == IGlobalSession::getTypeGuid())
+ {
+ addReference();
+ *outObject = static_cast<slang::IGlobalSession*>(this);
+ return SLANG_OK;
+ }
+
+ return SLANG_E_NO_INTERFACE;
}
SLANG_NO_THROW SlangResult SLANG_MCALL GlobalSessionCapture::createSession(slang::SessionDesc const& desc, slang::ISession** outSession)