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-list-impl.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-list-impl.cpp')
| -rw-r--r-- | source/core/slang-castable-list-impl.cpp | 136 |
1 files changed, 0 insertions, 136 deletions
diff --git a/source/core/slang-castable-list-impl.cpp b/source/core/slang-castable-list-impl.cpp deleted file mode 100644 index 4f4b07790..000000000 --- a/source/core/slang-castable-list-impl.cpp +++ /dev/null @@ -1,136 +0,0 @@ -// slang-castable-list-impl.cpp -#include "slang-castable-list-impl.h" - -#include "slang-castable-util.h" - -namespace Slang { - -/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! CastableList !!!!!!!!!!!!!!!!!!!!!!!!!!! */ - -CastableList::~CastableList() -{ - for (auto castable : m_list) - { - castable->release(); - } -} - -void* CastableList::castAs(const Guid& guid) -{ - if (auto intf = getInterface(guid)) - { - return intf; - } - return getObject(guid); -} - -void* CastableList::getInterface(const Guid& guid) -{ - if (guid == ISlangUnknown::getTypeGuid() || - guid == ICastable::getTypeGuid() || - guid == ICastableList::getTypeGuid()) - { - return static_cast<ICastableList*>(this); - } - return nullptr; -} - -void* CastableList::getObject(const Guid& guid) -{ - SLANG_UNUSED(guid); - return nullptr; -} - -void* CastableList::find(const Guid& guid) -{ - for (ICastable* castable : m_list) - { - if (auto ptr = castable->castAs(guid)) - { - return ptr; - } - } - return nullptr; -} - -ICastable* SLANG_MCALL CastableList::findWithPredicate(FindFunc func, void* data) -{ - for (ICastable* castable : m_list) - { - if (func(castable, data)) - { - return castable; - } - } - return nullptr; -} - -Index CastableList::indexOf(ICastable* castable) -{ - const Count count = m_list.getCount(); - for (Index i = 0; i < count; ++i) - { - ICastable* cur = m_list[i]; - if (cur == castable) - { - return i; - } - } - return -1; -} - -void CastableList::add(ICastable* castable) -{ - SLANG_ASSERT(castable); - castable->addRef(); - m_list.add(castable); -} - -void CastableList::removeAt(Index i) -{ - auto castable = m_list[i]; - m_list.removeAt(i); - castable->release(); -} - -void CastableList::clear() -{ - for (auto castable : m_list) - { - castable->release(); - } - m_list.clear(); -} - -void CastableList::addUnknown(ISlangUnknown* unk) -{ - add(CastableUtil::getCastable(unk)); -} - -Index CastableList::indexOfUnknown(ISlangUnknown* unk) -{ - SLANG_ASSERT(unk); - // If it has a castable interface we can just look for that - { - ComPtr<ICastable> castable; - if (SLANG_SUCCEEDED(unk->queryInterface(SLANG_IID_PPV_ARGS(castable.writeRef()))) && castable) - { - return indexOf(castable); - } - } - - // It's not derived from ICastable, so can only be in list via an adapter - const Count count = m_list.getCount(); - for (Index i = 0; i < count; ++i) - { - auto adapter = as<IUnknownCastableAdapter>(m_list[i]); - if (adapter && adapter->getContained() == unk) - { - return i; - } - } - - return -1; -} - -} // namespace Slang |
