summaryrefslogtreecommitdiffstats
path: root/source/compiler-core/slang-artifact-handler-impl.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/compiler-core/slang-artifact-handler-impl.cpp')
-rw-r--r--source/compiler-core/slang-artifact-handler-impl.cpp72
1 files changed, 2 insertions, 70 deletions
diff --git a/source/compiler-core/slang-artifact-handler-impl.cpp b/source/compiler-core/slang-artifact-handler-impl.cpp
index f324a1d43..c342becec 100644
--- a/source/compiler-core/slang-artifact-handler-impl.cpp
+++ b/source/compiler-core/slang-artifact-handler-impl.cpp
@@ -15,78 +15,10 @@
#include "../core/slang-shared-library.h"
// For workaround for DownstreamResult
-#include "slang-downstream-compiler.h"
+#include "slang-downstream-dep1.h"
namespace Slang {
-// A temporary class that adapts `ISlangSharedLibrary_Dep1` to ISlangSharedLibrary
-
-class SharedLibraryDep1Adapter : public ComBaseObject, public ISlangSharedLibrary
-{
-public:
- SLANG_COM_BASE_IUNKNOWN_ALL
-
- // ICastable
- virtual SLANG_NO_THROW void* SLANG_MCALL castAs(const SlangUUID& guid) SLANG_OVERRIDE;
-
- // ISlangSharedLibrary
- virtual SLANG_NO_THROW void* SLANG_MCALL findSymbolAddressByName(char const* name) SLANG_OVERRIDE { return m_contained->findSymbolAddressByName(name); }
-
- SharedLibraryDep1Adapter(ISlangSharedLibrary_Dep1* dep1) :
- m_contained(dep1)
- {
- }
-
-protected:
- void* getInterface(const Guid& guid)
- {
- if (guid == ISlangUnknown::getTypeGuid() ||
- guid == ICastable::getTypeGuid() ||
- guid == ISlangSharedLibrary::getTypeGuid())
- {
- return static_cast<ISlangSharedLibrary*>(this);
- }
- return nullptr;
- }
- void* getObject(const Guid& guid)
- {
- SLANG_UNUSED(guid);
- return nullptr;
- }
-
- ComPtr<ISlangSharedLibrary_Dep1> m_contained;
-};
-
-void* SharedLibraryDep1Adapter::castAs(const SlangUUID& guid)
-{
- if (auto intf = getInterface(guid))
- {
- return intf;
- }
- return getObject(guid);
-}
-
-/* Hack to take into account downstream compilers shared library interface might need an adapter */
-static SlangResult _getDownstreamSharedLibrary(DownstreamCompileResult* downstreamResult, ComPtr<ISlangSharedLibrary>& outSharedLibrary)
-{
- ComPtr<ISlangSharedLibrary> lib;
- SLANG_RETURN_ON_FAIL(downstreamResult->getHostCallableSharedLibrary(lib));
-
- if (SLANG_SUCCEEDED(lib->queryInterface(ISlangSharedLibrary::getTypeGuid(), (void**)outSharedLibrary.writeRef())))
- {
- return SLANG_OK;
- }
-
- ComPtr<ISlangSharedLibrary_Dep1> libDep1;
- if (SLANG_SUCCEEDED(lib->queryInterface(ISlangSharedLibrary_Dep1::getTypeGuid(), (void**)libDep1.writeRef())))
- {
- // Okay, we need to adapt for now
- outSharedLibrary = new SharedLibraryDep1Adapter(libDep1);
- return SLANG_OK;
- }
- return SLANG_E_NOT_FOUND;
-}
-
/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!! DefaultArtifactHandler !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
/* static */DefaultArtifactHandler DefaultArtifactHandler::g_singleton;
@@ -210,7 +142,7 @@ SlangResult DefaultArtifactHandler::getOrCreateRepresentation(IArtifact* artifac
else if (guid == ISlangSharedLibrary::getTypeGuid())
{
ComPtr<ISlangSharedLibrary> lib;
- SLANG_RETURN_ON_FAIL(_getDownstreamSharedLibrary(downstreamResult, lib));
+ SLANG_RETURN_ON_FAIL(DownstreamUtil_Dep1::getDownstreamSharedLibrary(downstreamResult, lib));
return _addRepresentation(artifact, keep, lib, outCastable);
}
}