summaryrefslogtreecommitdiff
path: root/source/core/slang-destroyable.h
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2022-08-22 10:08:25 -0400
committerGitHub <noreply@github.com>2022-08-22 10:08:25 -0400
commit15055d20c143cb398bd3e269541eebf24777390a (patch)
tree81f96a53824765fabc1fbb81d2d588476996eaa9 /source/core/slang-destroyable.h
parentaf70651a4843b16dd24e14b5cedffe399ebeb862 (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/slang-destroyable.h')
-rw-r--r--source/core/slang-destroyable.h15
1 files changed, 15 insertions, 0 deletions
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