diff options
Diffstat (limited to 'source/core/slang-castable-util.cpp')
| -rw-r--r-- | source/core/slang-castable-util.cpp | 70 |
1 files changed, 0 insertions, 70 deletions
diff --git a/source/core/slang-castable-util.cpp b/source/core/slang-castable-util.cpp deleted file mode 100644 index 38652d47b..000000000 --- a/source/core/slang-castable-util.cpp +++ /dev/null @@ -1,70 +0,0 @@ -// slang-castable-util.cpp -#include "slang-castable-util.h" - -namespace Slang { - -/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! CastableUtil !!!!!!!!!!!!!!!!!!!!!!!!!!! */ - -/* static */ComPtr<ICastable> CastableUtil::getCastable(ISlangUnknown* unk) -{ - SLANG_ASSERT(unk); - ComPtr<ICastable> castable; - if (SLANG_SUCCEEDED(unk->queryInterface(SLANG_IID_PPV_ARGS(castable.writeRef())))) - { - SLANG_ASSERT(castable); - } - else - { - castable = new UnknownCastableAdapter(unk); - } - return castable; -} - -/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! UnknownCastableAdapter !!!!!!!!!!!!!!!!!!!!!!!!!!! */ - -void* UnknownCastableAdapter::castAs(const Guid& guid) -{ - if (auto intf = getInterface(guid)) - { - return intf; - } - if (auto obj = getObject(guid)) - { - return obj; - } - - if (m_found && guid == m_foundGuid) - { - return m_found; - } - - ComPtr<ISlangUnknown> cast; - if (SLANG_SUCCEEDED(m_contained->queryInterface(guid, (void**)cast.writeRef())) && cast) - { - // Save the interface in the cache - m_found = cast; - m_foundGuid = guid; - - return cast; - } - return nullptr; -} - -void* UnknownCastableAdapter::getInterface(const Guid& guid) -{ - if (guid == ISlangUnknown::getTypeGuid() || - guid == ICastable::getTypeGuid() || - guid == IUnknownCastableAdapter::getTypeGuid()) - { - return static_cast<IUnknownCastableAdapter*>(this); - } - return nullptr; -} - -void* UnknownCastableAdapter::getObject(const Guid& guid) -{ - SLANG_UNUSED(guid); - return nullptr; -} - -} // namespace Slang |
