summaryrefslogtreecommitdiffstats
path: root/source/slang/slang-module-library.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/slang/slang-module-library.cpp')
-rw-r--r--source/slang/slang-module-library.cpp22
1 files changed, 18 insertions, 4 deletions
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<IArtifactInstance*>(this);
+ return static_cast<IArtifactRepresentation*>(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<ModuleLibrary>& outLibrary)
{
RefPtr<ModuleLibrary> 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<ModuleLibrary>& 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;