From 6ab0baf910dea838dca2d29557c3361297180a34 Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Mon, 22 Aug 2022 17:39:56 -0400 Subject: Improve binary compatibility for DownstreamCompiler types (#2371) * #include an absolute path didn't work - because paths were taken to always be relative. * WIP replacing DownstreamCompileResult. * First attempt at replacing DownstreamCompileResult with IArtifact and associated types. * Small renaming around CharSlice. * ICastable -> ISlangCastable Added IClonable Fix issue with cloning in ArtifactDiagnostics. * Only add the blob if one is defined in DXC. * Guard adding blob representation. * Make cloneInterface available across code base. Set enums backing type for ArtifactDiagnostic. * Added ::create for ArtifactDiagnostics. * Use SemanticVersion for DownstreamCompilerDesc. Set sizes for enum types. * Depreciate old incompatible CompileOptions. Change SemanticVersion use 32 bits for the patch. * Split out CastableUtil. * Change IDownstreamCompiler to use canConvert and convert to use artifact types. * Fix typos. * Fix typo bug. Allow trafficing in PTX assembly/binaries * struct DownstreamCompilerBaseUtil -> struct DownstreamCompilerUtilBase Co-authored-by: Yong He --- source/core/slang-castable-list-impl.cpp | 80 ++------------------------------ 1 file changed, 4 insertions(+), 76 deletions(-) (limited to 'source/core/slang-castable-list-impl.cpp') diff --git a/source/core/slang-castable-list-impl.cpp b/source/core/slang-castable-list-impl.cpp index dcc58e37b..1cc5dc2d4 100644 --- a/source/core/slang-castable-list-impl.cpp +++ b/source/core/slang-castable-list-impl.cpp @@ -1,71 +1,9 @@ // slang-castable-list-impl.cpp #include "slang-castable-list-impl.h" -namespace Slang { - -/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! CastableUtil !!!!!!!!!!!!!!!!!!!!!!!!!!! */ +#include "slang-castable-util.h" -/* static */ComPtr CastableUtil::getCastable(ISlangUnknown* unk) -{ - SLANG_ASSERT(unk); - ComPtr castable; - if (SLANG_SUCCEEDED(unk->queryInterface(ICastable::getTypeGuid(), (void**)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 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(this); - } - return nullptr; -} - -void* UnknownCastableAdapter::getObject(const Guid& guid) -{ - SLANG_UNUSED(guid); - return nullptr; -} +namespace Slang { /* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! CastableList !!!!!!!!!!!!!!!!!!!!!!!!!!! */ @@ -166,18 +104,7 @@ void CastableList::clear() void CastableList::addUnknown(ISlangUnknown* unk) { - // If it has ICastable interface we can just add as that - { - ComPtr castable; - if (SLANG_SUCCEEDED(unk->queryInterface(ICastable::getTypeGuid(), (void**)castable.writeRef())) && castable) - { - return add(castable); - } - } - - // Wrap it in an adapter - IUnknownCastableAdapter* adapter = new UnknownCastableAdapter(unk); - add(adapter); + add(CastableUtil::getCastable(unk)); } Index CastableList::indexOfUnknown(ISlangUnknown* unk) @@ -202,6 +129,7 @@ Index CastableList::indexOfUnknown(ISlangUnknown* unk) return i; } } + return -1; } -- cgit v1.2.3