summaryrefslogtreecommitdiffstats
path: root/source/core/slang-blob.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/core/slang-blob.cpp')
-rw-r--r--source/core/slang-blob.cpp65
1 files changed, 61 insertions, 4 deletions
diff --git a/source/core/slang-blob.cpp b/source/core/slang-blob.cpp
index 569991508..0da8f6292 100644
--- a/source/core/slang-blob.cpp
+++ b/source/core/slang-blob.cpp
@@ -2,19 +2,76 @@
namespace Slang {
+/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! BlobBase !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
+
ISlangUnknown* BlobBase::getInterface(const Guid& guid)
{
- return (guid == ISlangUnknown::getTypeGuid() || guid == ISlangBlob::getTypeGuid()) ? static_cast<ISlangBlob*>(this) : nullptr;
+ if (guid == ISlangUnknown::getTypeGuid() ||
+ guid == ISlangBlob::getTypeGuid())
+ {
+ return static_cast<ISlangBlob*>(this);
+ }
+ if (guid == ICastable::getTypeGuid())
+ {
+ return static_cast<ICastable*>(this);
+ }
+ return nullptr;
+}
+
+void* BlobBase::getObject(const Guid& guid)
+{
+ SLANG_UNUSED(guid);
+ return nullptr;
}
+void* BlobBase::castAs(const SlangUUID& guid)
+{
+ if (auto intf = getInterface(guid))
+ {
+ return intf;
+ }
+ return getObject(guid);
+}
+
+/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! StaticBlob !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
+
SlangResult StaticBlob::queryInterface(SlangUUID const& guid, void** outObject)
{
- if (guid == ISlangUnknown::getTypeGuid() || guid == ISlangBlob::getTypeGuid())
+ if (auto intf = getInterface(guid))
{
- *outObject = static_cast<ISlangBlob*>(this);
+ *outObject = intf;
return SLANG_OK;
}
return SLANG_E_NO_INTERFACE;
}
-
+
+void* StaticBlob::castAs(const SlangUUID& guid)
+{
+ if (auto intf = getInterface(guid))
+ {
+ return intf;
+ }
+ return getObject(guid);
+}
+
+ISlangUnknown* StaticBlob::getInterface(const Guid& guid)
+{
+ if (guid == ISlangUnknown::getTypeGuid() ||
+ guid == ISlangBlob::getTypeGuid())
+ {
+ return static_cast<ISlangBlob*>(this);
+ }
+ if (guid == ICastable::getTypeGuid())
+ {
+ return static_cast<ICastable*>(this);
+ }
+ return nullptr;
+}
+
+void* StaticBlob::getObject(const Guid& guid)
+{
+ SLANG_UNUSED(guid);
+ return nullptr;
+}
+
} // namespace Slang