From 15055d20c143cb398bd3e269541eebf24777390a Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Mon, 22 Aug 2022 10:08:25 -0400 Subject: 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. --- source/core/slang-common.h | 10 ++++++++++ source/core/slang-destroyable.h | 15 +++++++++++++++ 2 files changed, 25 insertions(+) (limited to 'source/core') 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 + 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 +SLANG_FORCE_INLINE ComPtr 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(clone); +} + } #endif // SLANG_CORE_DESTROYABLE_H -- cgit v1.2.3