diff options
| author | jsmall-nvidia <jsmall@nvidia.com> | 2022-08-22 10:08:25 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-08-22 10:08:25 -0400 |
| commit | 15055d20c143cb398bd3e269541eebf24777390a (patch) | |
| tree | 81f96a53824765fabc1fbb81d2d588476996eaa9 /source/core | |
| parent | af70651a4843b16dd24e14b5cedffe399ebeb862 (diff) | |
Replace DownstreamCompileResult with Artifact (#2369)
* #include an absolute path didn't work - because paths were taken to always be relative.
* WIP replacing DownstreamCompileResult.
* First attempt at replacing DownstreamCompileResult with IArtifact and associated types.
* Small renaming around CharSlice.
* ICastable -> ISlangCastable
Added IClonable
Fix issue with cloning in ArtifactDiagnostics.
* Only add the blob if one is defined in DXC.
* Guard adding blob representation.
* Make cloneInterface available across code base.
Set enums backing type for ArtifactDiagnostic.
* Added ::create for ArtifactDiagnostics.
Diffstat (limited to 'source/core')
| -rw-r--r-- | source/core/slang-common.h | 10 | ||||
| -rw-r--r-- | source/core/slang-destroyable.h | 15 |
2 files changed, 25 insertions, 0 deletions
diff --git a/source/core/slang-common.h b/source/core/slang-common.h index 694162f1d..7fddb067e 100644 --- a/source/core/slang-common.h +++ b/source/core/slang-common.h @@ -13,6 +13,7 @@ namespace Slang { + typedef int32_t Int32; typedef uint32_t UInt32; @@ -67,6 +68,15 @@ namespace Slang v1 = _Move(tmp); } + // Make these interfaces have more convenient names + typedef ISlangCastable ICastable; + typedef ISlangClonable IClonable; + + // Convenience function for using clonable + template <typename T> + SLANG_FORCE_INLINE T* clone(IClonable* clonable) { return (T*)clonable->clone(T::getTypeGuid()); } + + // TODO: Shouldn't these be SLANG_ prefixed? #ifdef _MSC_VER #define UNREACHABLE_RETURN(x) diff --git a/source/core/slang-destroyable.h b/source/core/slang-destroyable.h index 390b16e7c..f2c967071 100644 --- a/source/core/slang-destroyable.h +++ b/source/core/slang-destroyable.h @@ -48,6 +48,21 @@ SLANG_FORCE_INLINE T* as(ICastable* castable) return nullptr; } +// A way to clone an interface (that derives from IClonable) such that it returns an interface +// of the same type. +template <typename T> +SLANG_FORCE_INLINE ComPtr<T> cloneInterface(T* in) +{ + SLANG_ASSERT(in); + // Must be derivable from clonable + IClonable* clonable = in; + // We can clone with the same interface + T* clone = (T*)clonable->clone(T::getTypeGuid()); + // Clone must exist + SLANG_ASSERT(clone); + return ComPtr<T>(clone); +} + } #endif // SLANG_CORE_DESTROYABLE_H |
