From e43ef82e288afe486f45ef2736d378e88f40cc90 Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Wed, 3 Aug 2022 17:10:46 -0400 Subject: Improvements around Artifact (#2346) * #include an absolute path didn't work - because paths were taken to always be relative. * WIP with hierarchical enums. * Some small fixes and improvements around artifact desc related types. * Improvements around hierarchical enum. * Fixes to get Artifact types refactor to be able to execute tests. * Attempt to better categorize PTX. * Work around for potentially unused function warning. * Typo fix. * Simplify Artifact header. * Small improvements around Artifact kind/payload/style. * Added IDestroyable/ICastable * Add IArtifactList. * First impl of IArtifactUtil. * Use the ICastable interface for IArtifactRepresentation. * Added IArtifactRepresentation & IArtifactAssociated. * Add SLANG_OVERRIDE to avoid gcc/clang warning. * Fix calling convention issue on win32. * Fix missing SLANG_OVERRIDE. --- source/slang/slang-module-library.cpp | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'source/slang/slang-module-library.cpp') diff --git a/source/slang/slang-module-library.cpp b/source/slang/slang-module-library.cpp index 140be4d64..b60555766 100644 --- a/source/slang/slang-module-library.cpp +++ b/source/slang/slang-module-library.cpp @@ -15,13 +15,27 @@ namespace Slang { void* ModuleLibrary::getInterface(const Guid& uuid) { - if (uuid == ISlangUnknown::getTypeGuid() || uuid == IArtifactInstance::getTypeGuid()) + if (uuid == ISlangUnknown::getTypeGuid() || uuid == ICastable::getTypeGuid() || uuid == IArtifactRepresentation::getTypeGuid()) { - return static_cast(this); + return static_cast(this); } return nullptr; } +void* ModuleLibrary::getObject(const Guid& uuid) +{ + return uuid == getTypeGuid() ? this : nullptr; +} + +void* ModuleLibrary::castAs(const Guid& guid) +{ + if (auto intf = getInterface(guid)) + { + return intf; + } + return getObject(guid); +} + SlangResult loadModuleLibrary(const Byte* inBytes, size_t bytesCount, EndToEndCompileRequest* req, RefPtr& outLibrary) { RefPtr library = new ModuleLibrary; @@ -77,7 +91,7 @@ SlangResult loadModuleLibrary(const Byte* inBytes, size_t bytesCount, EndToEndCo SlangResult loadModuleLibrary(ArtifactKeep keep, IArtifact* artifact, EndToEndCompileRequest* req, RefPtr& outLibrary) { - if (auto foundLibrary = (ModuleLibrary*)artifact->findElementObject(ModuleLibrary::getTypeGuid())) + if (auto foundLibrary = (ModuleLibrary*)artifact->findItemObject(ModuleLibrary::getTypeGuid())) { outLibrary = foundLibrary; return SLANG_OK; @@ -93,7 +107,7 @@ SlangResult loadModuleLibrary(ArtifactKeep keep, IArtifact* artifact, EndToEndCo if (canKeep(keep)) { - artifact->addElement(artifact->getDesc(), library); + artifact->addItem(library); } outLibrary = library; -- cgit v1.2.3