diff options
| author | jsmall-nvidia <jsmall@nvidia.com> | 2022-08-03 17:10:46 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-08-03 17:10:46 -0400 |
| commit | e43ef82e288afe486f45ef2736d378e88f40cc90 (patch) | |
| tree | 356841a992263d6a5d03e9d6704868c2cc12190c /source/compiler-core/slang-artifact-util.cpp | |
| parent | e81a5fe56f3177fc3c7040e2320ae083e3746eb7 (diff) | |
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.
Diffstat (limited to 'source/compiler-core/slang-artifact-util.cpp')
| -rw-r--r-- | source/compiler-core/slang-artifact-util.cpp | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/source/compiler-core/slang-artifact-util.cpp b/source/compiler-core/slang-artifact-util.cpp new file mode 100644 index 000000000..3ca10446c --- /dev/null +++ b/source/compiler-core/slang-artifact-util.cpp @@ -0,0 +1,63 @@ +// slang-artifact.cpp +#include "slang-artifact-util.h" + +#include "slang-artifact-info.h" + +namespace Slang { + +/* static */ArtifactUtilImpl ArtifactUtilImpl::g_singleton; + +SlangResult ArtifactUtilImpl::queryInterface(SlangUUID const& uuid, void** outObject) +{ + if (auto intf = getInterface(uuid)) + { + *outObject = intf; + return SLANG_OK; + } + return SLANG_E_NO_INTERFACE; +} + +void* ArtifactUtilImpl::getInterface(const Guid& guid) +{ + if (guid == ISlangUnknown::getTypeGuid() || guid == IArtifactUtil::getTypeGuid()) + { + return static_cast<IArtifactUtil*>(this); + } + return nullptr; +} + + +SlangResult ArtifactUtilImpl::createArtifact(const ArtifactDesc& desc, const char* inName, IArtifact** outArtifact) +{ + String name; + if (inName) + { + name = inName; + } + + ComPtr<IArtifact> artifact(new Artifact(desc, name)); + + *outArtifact = artifact.detach(); + return SLANG_OK; +} + +SlangResult ArtifactUtilImpl::createArtifactList(IArtifact* parent, IArtifactList** outArtifactList) +{ + ComPtr<IArtifactList> artifactList(new ArtifactList(parent)); + *outArtifactList = artifactList.detach(); + return SLANG_OK; +} + +ArtifactKind ArtifactUtilImpl::getKindParent(ArtifactKind kind) { return getParent(kind); } +UnownedStringSlice ArtifactUtilImpl::getKindName(ArtifactKind kind) { return getName(kind); } +bool ArtifactUtilImpl::isKindDerivedFrom(ArtifactKind kind, ArtifactKind base) { return isDerivedFrom(kind, base); } + +ArtifactPayload ArtifactUtilImpl::getPayloadParent(ArtifactPayload payload) { return getParent(payload); } +UnownedStringSlice ArtifactUtilImpl::getPayloadName(ArtifactPayload payload) { return getName(payload); } +bool ArtifactUtilImpl::isPayloadDerivedFrom(ArtifactPayload payload, ArtifactPayload base) { return isDerivedFrom(payload, base); } + +ArtifactStyle ArtifactUtilImpl::getStyleParent(ArtifactStyle style) { return getParent(style); } +UnownedStringSlice ArtifactUtilImpl::getStyleName(ArtifactStyle style) { return getName(style); } +bool ArtifactUtilImpl::isStyleDerivedFrom(ArtifactStyle style, ArtifactStyle base) { return isDerivedFrom(style, base); } + +} // namespace Slang |
