diff options
| author | Yong He <yonghe@outlook.com> | 2023-02-28 15:09:19 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-02-28 15:09:19 -0800 |
| commit | f7db44a236bb867003395d1a91d6907901653528 (patch) | |
| tree | 84d65caea539337bf19fb4435a1fe6fa5de589fb /source/compiler-core/slang-artifact-representation-impl.cpp | |
| parent | f23e36243e9c59c02f66ec2e18b80ba4ea540f45 (diff) | |
Add `SourceBlobWithPathInfoArtifactRepresentation`. (#2682)
Diffstat (limited to 'source/compiler-core/slang-artifact-representation-impl.cpp')
| -rw-r--r-- | source/compiler-core/slang-artifact-representation-impl.cpp | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/source/compiler-core/slang-artifact-representation-impl.cpp b/source/compiler-core/slang-artifact-representation-impl.cpp index 950ce5d7d..3fae154bb 100644 --- a/source/compiler-core/slang-artifact-representation-impl.cpp +++ b/source/compiler-core/slang-artifact-representation-impl.cpp @@ -67,6 +67,52 @@ bool ExtFileArtifactRepresentation::exists() return SLANG_SUCCEEDED(res) && pathType == getPathType(); } +/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!! SourceBlobWithPathArtifactRepresentation !!!!!!!!!!!!!!!!!!!!!!!!!!! */ + +void* SourceBlobWithPathInfoArtifactRepresentation::getInterface(const Guid& guid) +{ + if (guid == ISlangUnknown::getTypeGuid() || + guid == ICastable::getTypeGuid() || + guid == IArtifactRepresentation::getTypeGuid() || + guid == IPathArtifactRepresentation::getTypeGuid()) + { + return static_cast<IPathArtifactRepresentation*>(this); + } + return nullptr; +} + +void* SourceBlobWithPathInfoArtifactRepresentation::getObject(const Guid& guid) +{ + SLANG_UNUSED(guid); + return nullptr; +} + +void* SourceBlobWithPathInfoArtifactRepresentation::castAs(const Guid& guid) +{ + if (auto intf = getInterface(guid)) + { + return intf; + } + return getObject(guid); +} + +SlangResult SourceBlobWithPathInfoArtifactRepresentation::createRepresentation(const Guid& typeGuid, ICastable** outCastable) +{ + // We can convert into a blob only. + if (typeGuid != ISlangBlob::getTypeGuid()) + { + return SLANG_E_NOT_AVAILABLE; + } + + if (!m_blob) + { + return SLANG_E_NOT_AVAILABLE; + } + + *outCastable = CastableUtil::getCastable(m_blob).detach(); + return SLANG_OK; +} + /* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!! FileArtifactRepresentation !!!!!!!!!!!!!!!!!!!!!!!!!!! */ void* OSFileArtifactRepresentation::getInterface(const Guid& guid) |
