diff options
| author | Ellie Hermaszewska <ellieh@nvidia.com> | 2024-10-29 14:49:26 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-10-29 14:49:26 +0800 |
| commit | f65d756bff8d4c5cbc15bd0322a2ae8e6b896a21 (patch) | |
| tree | ea1d61342cd29368e19135000ec2948813096205 /source/slang/slang-module-library.cpp | |
| parent | a729c15e9dce9f5116a38afc66329ab2ca4cea54 (diff) | |
format
* format
* Minor test fixes
* enable checking cpp format in ci
Diffstat (limited to 'source/slang/slang-module-library.cpp')
| -rw-r--r-- | source/slang/slang-module-library.cpp | 44 |
1 files changed, 30 insertions, 14 deletions
diff --git a/source/slang/slang-module-library.cpp b/source/slang/slang-module-library.cpp index 02ace07d3..060c9007c 100644 --- a/source/slang/slang-module-library.cpp +++ b/source/slang/slang-module-library.cpp @@ -1,24 +1,23 @@ // slang-module-library.cpp #include "slang-module-library.h" -#include <assert.h> #include "../core/slang-blob.h" #include "../core/slang-riff.h" - #include "../core/slang-type-text-util.h" +#include <assert.h> + // Serialization -#include "slang-serialize-ir.h" #include "slang-serialize-container.h" +#include "slang-serialize-ir.h" -namespace Slang { +namespace Slang +{ void* ModuleLibrary::getInterface(const Guid& uuid) { - if (uuid == ISlangUnknown::getTypeGuid() || - uuid == ICastable::getTypeGuid() || - uuid == IArtifactRepresentation::getTypeGuid() || - uuid == IModuleLibrary::getTypeGuid()) + if (uuid == ISlangUnknown::getTypeGuid() || uuid == ICastable::getTypeGuid() || + uuid == IArtifactRepresentation::getTypeGuid() || uuid == IModuleLibrary::getTypeGuid()) { return static_cast<IModuleLibrary*>(this); } @@ -39,7 +38,12 @@ void* ModuleLibrary::castAs(const Guid& guid) return getObject(guid); } -SlangResult loadModuleLibrary(const Byte* inBytes, size_t bytesCount, String path, EndToEndCompileRequest* req, ComPtr<IModuleLibrary>& outLibrary) +SlangResult loadModuleLibrary( + const Byte* inBytes, + size_t bytesCount, + String path, + EndToEndCompileRequest* req, + ComPtr<IModuleLibrary>& outLibrary) { auto library = new ModuleLibrary; ComPtr<IModuleLibrary> scopeLibrary(library); @@ -63,7 +67,8 @@ SlangResult loadModuleLibrary(const Byte* inBytes, size_t bytesCount, String pat options.sink = req->getSink(); options.astBuilder = linkage->getASTBuilder(); options.modulePath = path; - SLANG_RETURN_ON_FAIL(SerialContainerUtil::read(&riffContainer, options, nullptr, containerData)); + SLANG_RETURN_ON_FAIL( + SerialContainerUtil::read(&riffContainer, options, nullptr, containerData)); DiagnosticSink sink; // Modules in the container should be serialized in its depedency order, @@ -80,7 +85,8 @@ SlangResult loadModuleLibrary(const Byte* inBytes, size_t bytesCount, String pat auto loadedModule = linkage->loadDeserializedModule( as<ModuleDecl>(module.astRootNode)->getName(), PathInfo::makePath(module.dependentFiles.getFirst()), - module, &sink); + module, + &sink); if (!loadedModule) return SLANG_FAIL; library->m_modules.add(loadedModule); @@ -103,7 +109,12 @@ SlangResult loadModuleLibrary(const Byte* inBytes, size_t bytesCount, String pat return SLANG_OK; } -SlangResult loadModuleLibrary(ArtifactKeep keep, IArtifact* artifact, String path, EndToEndCompileRequest* req, ComPtr<IModuleLibrary>& outLibrary) +SlangResult loadModuleLibrary( + ArtifactKeep keep, + IArtifact* artifact, + String path, + EndToEndCompileRequest* req, + ComPtr<IModuleLibrary>& outLibrary) { if (auto foundLibrary = findRepresentation<IModuleLibrary>(artifact)) { @@ -117,8 +128,13 @@ SlangResult loadModuleLibrary(ArtifactKeep keep, IArtifact* artifact, String pat // Load the module ComPtr<IModuleLibrary> library; - SLANG_RETURN_ON_FAIL(loadModuleLibrary((const Byte*)blob->getBufferPointer(), blob->getBufferSize(), path, req, library)); - + SLANG_RETURN_ON_FAIL(loadModuleLibrary( + (const Byte*)blob->getBufferPointer(), + blob->getBufferSize(), + path, + req, + library)); + if (canKeep(keep)) { artifact->addRepresentation(library); |
