diff options
Diffstat (limited to 'source/core/slang-castable.cpp')
| -rw-r--r-- | source/core/slang-castable.cpp | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/source/core/slang-castable.cpp b/source/core/slang-castable.cpp index f3c6541dd..6b7644bf2 100644 --- a/source/core/slang-castable.cpp +++ b/source/core/slang-castable.cpp @@ -20,6 +20,37 @@ namespace Slang { return castable; } +/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ObjectCastableAdapter !!!!!!!!!!!!!!!!!!!!!!!!!!! */ + +void* ObjectCastableAdapter::castAs(const Guid& guid) +{ + if (auto intf = getInterface(guid)) + { + return intf; + } + return getObject(guid); +} + +void* ObjectCastableAdapter::getInterface(const Guid& guid) +{ + if (guid == ISlangUnknown::getTypeGuid() || + guid == ICastable::getTypeGuid() || + guid == IObjectCastableAdapter::getTypeGuid()) + { + return static_cast<IObjectCastableAdapter*>(this); + } + return nullptr; +} + +void* ObjectCastableAdapter::getObject(const Guid& guid) +{ + if (guid == m_containedGuid) + { + return m_contained; + } + return nullptr; +} + /* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! UnknownCastableAdapter !!!!!!!!!!!!!!!!!!!!!!!!!!! */ void* UnknownCastableAdapter::castAs(const Guid& guid) |
