diff options
| author | jsmall-nvidia <jsmall@nvidia.com> | 2023-04-11 10:18:18 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-04-11 10:18:18 -0400 |
| commit | 20ea33f3321738e7c1b4cad7bdcaedcdb54dd0f0 (patch) | |
| tree | 899484670ffacf3e884b5d670e2cc8ed6d5259e3 /source/core/slang-castable-util.cpp | |
| parent | d934bbcc5702ebd8964f65b1708c239c29320103 (diff) | |
Artifact simplification (#2781)
* #include an absolute path didn't work - because paths were taken to always be relative.
* WIP simplifying artifact interface.
* Use ContainedKind.
* Remove LazyCastableList.
Use ContainedKind for find.
* Remove ICastableList.
* Remove need for ICastableList.
* Remove IArtifactContainer.
* Small fixes.
* Small improvements around Artifact.
* Make explicit find is for *representations* that can cast.
Fix bug in handling casting in lookup.
* Made associated items artifacts too.
* Small fixes.
* Small improvements around writing a container.
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 |
