summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2021-04-01 18:59:24 -0400
committerGitHub <noreply@github.com>2021-04-01 15:59:24 -0700
commit9475b11045089c9bc9773b16f7eb84f843db70c4 (patch)
treef2855e1283a3811fd771d646f6e2532ca9cb5e21
parent2a32fae2ca766862ad76973ab37605edf9ec0faa (diff)
Associating GUID (or UUID) with types (#1776)
* #include an absolute path didn't work - because paths were taken to always be relative. * Add mechanism to embed guid inside of type.
-rw-r--r--slang.h89
-rw-r--r--source/core/slang-blob.cpp8
-rw-r--r--source/core/slang-compression-system.h4
-rw-r--r--source/core/slang-deflate-compression-system.cpp4
-rw-r--r--source/core/slang-file-system.cpp20
-rw-r--r--source/core/slang-file-system.h3
-rw-r--r--source/core/slang-lz4-compression-system.cpp4
-rw-r--r--source/core/slang-riff-file-system.cpp8
-rw-r--r--source/core/slang-shared-library.cpp9
-rw-r--r--source/core/slang-writer.cpp4
-rw-r--r--source/core/slang-zip-file-system.cpp8
-rw-r--r--source/slang/slang-check.cpp5
-rwxr-xr-xsource/slang/slang-compiler.cpp4
-rwxr-xr-xsource/slang/slang-compiler.h9
-rwxr-xr-xsource/slang/slang-dxc-support.cpp5
-rw-r--r--source/slang/slang.cpp37
16 files changed, 97 insertions, 124 deletions
diff --git a/slang.h b/slang.h
index b354e6b12..da4b359c4 100644
--- a/slang.h
+++ b/slang.h
@@ -844,6 +844,27 @@ extern "C"
uint8_t data4[8];
};
+// Place at the start of an interface with the guid.
+// Guid should be specified as SLANG_COM_INTERFACE(0x00000000, 0x0000, 0x0000, { 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46 })
+// NOTE: it's the typical guid struct definition, without the surrounding {}
+// It is not necessary to use the multiple parameters (we can wrap in parens), but this is simple.
+#define SLANG_COM_INTERFACE(a, b, c, d0, d1, d2, d3, d4, d5, d6, d7) \
+ public: \
+ SLANG_FORCE_INLINE static const SlangUUID& getTypeGuid() \
+ { \
+ static const SlangUUID guid = { a, b, c, d0, d1, d2, d3, d4, d5, d6, d7 }; \
+ return guid; \
+ }
+
+// Sometimes it's useful to associate a guid with a class to identify it. This macro can used for this,
+// and the guid extracted via the getTypeGuid() function defined in the type
+#define SLANG_CLASS_GUID(a, b, c, d0, d1, d2, d3, d4, d5, d6, d7) \
+ SLANG_FORCE_INLINE static const SlangUUID& getTypeGuid() \
+ { \
+ static const SlangUUID guid = { a, b, c, d0, d1, d2, d3, d4, d5, d6, d7 }; \
+ return guid; \
+ }
+
/** Base interface for components exchanged through the API.
This interface definition is compatible with the COM `IUnknown`,
@@ -852,7 +873,8 @@ extern "C"
*/
struct ISlangUnknown
{
- public:
+ SLANG_COM_INTERFACE(0x00000000, 0x0000, 0x0000, { 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46 })
+
virtual SLANG_NO_THROW SlangResult SLANG_MCALL queryInterface(SlangUUID const& uuid, void** outObject) = 0;
virtual SLANG_NO_THROW uint32_t SLANG_MCALL addRef() = 0;
virtual SLANG_NO_THROW uint32_t SLANG_MCALL release() = 0;
@@ -865,7 +887,7 @@ extern "C"
uint32_t AddRef() { return addRef(); }
uint32_t Release() { return release(); }
};
- #define SLANG_UUID_ISlangUnknown { 0x00000000, 0x0000, 0x0000, { 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46 } }
+ #define SLANG_UUID_ISlangUnknown ISlangUnknown::getTypeGuid()
/** A "blob" of binary data.
@@ -873,11 +895,12 @@ extern "C"
*/
struct ISlangBlob : public ISlangUnknown
{
- public:
+ SLANG_COM_INTERFACE(0x8BA5FB08, 0x5195, 0x40e2, { 0xAC, 0x58, 0x0D, 0x98, 0x9C, 0x3A, 0x01, 0x02 })
+
virtual SLANG_NO_THROW void const* SLANG_MCALL getBufferPointer() = 0;
virtual SLANG_NO_THROW size_t SLANG_MCALL getBufferSize() = 0;
};
- #define SLANG_UUID_ISlangBlob { 0x8BA5FB08, 0x5195, 0x40e2, { 0xAC, 0x58, 0x0D, 0x98, 0x9C, 0x3A, 0x01, 0x02 } }
+ #define SLANG_UUID_ISlangBlob ISlangBlob::getTypeGuid()
/** A (real or virtual) file system.
@@ -892,7 +915,8 @@ extern "C"
struct ISlangFileSystem : public ISlangUnknown
{
- public:
+ SLANG_COM_INTERFACE(0x003A09FC, 0x3A4D, 0x4BA0, { 0xAD, 0x60, 0x1F, 0xD8, 0x63, 0xA9, 0x15, 0xAB })
+
/** Load a file from `path` and return a blob of its contents
@param path The path to load from, as a null-terminated UTF-8 string.
@param outBlob A destination pointer to receive the blob of the file contents.
@@ -910,7 +934,7 @@ extern "C"
char const* path,
ISlangBlob** outBlob) = 0;
};
- #define SLANG_UUID_ISlangFileSystem { 0x003A09FC, 0x3A4D, 0x4BA0, { 0xAD, 0x60, 0x1F, 0xD8, 0x63, 0xA9, 0x15, 0xAB } }
+ #define SLANG_UUID_ISlangFileSystem ISlangFileSystem::getTypeGuid()
typedef void(*SlangFuncPtr)(void);
@@ -920,7 +944,8 @@ extern "C"
*/
struct ISlangSharedLibrary: public ISlangUnknown
{
- public:
+ SLANG_COM_INTERFACE( 0x9c9d5bc5, 0xeb61, 0x496f,{ 0x80, 0xd7, 0xd1, 0x47, 0xc4, 0xa2, 0x37, 0x30 })
+
/** Get a function by name. If the library is unloaded will only return nullptr.
@param name The name of the function
@return The function pointer related to the name or nullptr if not found
@@ -935,11 +960,12 @@ extern "C"
*/
virtual SLANG_NO_THROW void* SLANG_MCALL findSymbolAddressByName(char const* name) = 0;
};
- #define SLANG_UUID_ISlangSharedLibrary { 0x9c9d5bc5, 0xeb61, 0x496f,{ 0x80, 0xd7, 0xd1, 0x47, 0xc4, 0xa2, 0x37, 0x30 } };
+ #define SLANG_UUID_ISlangSharedLibrary ISlangSharedLibrary::getTypeGuid()
struct ISlangSharedLibraryLoader: public ISlangUnknown
{
- public:
+ SLANG_COM_INTERFACE(0x6264ab2b, 0xa3e8, 0x4a06, { 0x97, 0xf1, 0x49, 0xbc, 0x2d, 0x2a, 0xb1, 0x4d })
+
/** Load a shared library. In typical usage the library name should *not* contain any platform
specific elements. For example on windows a dll name should *not* be passed with a '.dll' extension,
and similarly on linux a shared library should *not* be passed with the 'lib' prefix and '.so' extension
@@ -949,7 +975,7 @@ extern "C"
const char* path,
ISlangSharedLibrary** sharedLibraryOut) = 0;
};
- #define SLANG_UUID_ISlangSharedLibraryLoader { 0x6264ab2b, 0xa3e8, 0x4a06, { 0x97, 0xf1, 0x49, 0xbc, 0x2d, 0x2a, 0xb1, 0x4d } };
+ #define SLANG_UUID_ISlangSharedLibraryLoader ISlangSharedLibraryLoader::getTypeGuid()
/* Type that identifies how a path should be interpreted */
typedef unsigned int SlangPathType;
@@ -973,7 +999,8 @@ extern "C"
*/
struct ISlangFileSystemExt : public ISlangFileSystem
{
- public:
+ SLANG_COM_INTERFACE(0x5fb632d2, 0x979d, 0x4481, { 0x9f, 0xee, 0x66, 0x3c, 0x3f, 0x14, 0x49, 0xe1 })
+
/** Get a uniqueIdentity which uniquely identifies an object of the file system.
Given a path, returns a 'uniqueIdentity' which ideally is the same value for the same file on the file system.
@@ -1075,10 +1102,12 @@ extern "C"
void* userData) = 0;
};
- #define SLANG_UUID_ISlangFileSystemExt { 0x5fb632d2, 0x979d, 0x4481, { 0x9f, 0xee, 0x66, 0x3c, 0x3f, 0x14, 0x49, 0xe1 } }
+ #define SLANG_UUID_ISlangFileSystemExt ISlangFileSystemExt::getTypeGuid()
struct ISlangMutableFileSystem : public ISlangFileSystemExt
{
+ SLANG_COM_INTERFACE(0xa058675c, 0x1d65, 0x452a, { 0x84, 0x58, 0xcc, 0xde, 0xd1, 0x42, 0x71, 0x5 })
+
/** Write the data specified with data and size to the specified path.
@param path The path for data to be saved to
@@ -1111,7 +1140,7 @@ extern "C"
const char* path) = 0;
};
- #define SLANG_UUID_ISlangMutableFileSystem { 0xa058675c, 0x1d65, 0x452a, { 0x84, 0x58, 0xcc, 0xde, 0xd1, 0x42, 0x71, 0x5 } }
+ #define SLANG_UUID_ISlangMutableFileSystem ISlangMutableFileSystem::getTypeGuid()
/* Identifies different types of writer target*/
typedef unsigned int SlangWriterChannel;
@@ -1134,7 +1163,8 @@ extern "C"
*/
struct ISlangWriter : public ISlangUnknown
{
- public:
+ SLANG_COM_INTERFACE(0xec457f0e, 0x9add, 0x4e6b,{ 0x85, 0x1c, 0xd7, 0xfa, 0x71, 0x6d, 0x15, 0xfd })
+
/** Begin an append buffer.
NOTE! Only one append buffer can be active at any time.
@param maxNumChars The maximum of chars that will be appended
@@ -1162,7 +1192,7 @@ extern "C"
virtual SLANG_NO_THROW SlangResult SLANG_MCALL setMode(SlangWriterMode mode) = 0;
};
- #define SLANG_UUID_ISlangWriter { 0xec457f0e, 0x9add, 0x4e6b,{ 0x85, 0x1c, 0xd7, 0xfa, 0x71, 0x6d, 0x15, 0xfd } };
+ #define SLANG_UUID_ISlangWriter ISlangWriter::getTypeGuid()
namespace slang {
struct IGlobalSession;
@@ -2991,7 +3021,8 @@ namespace slang
*/
struct IGlobalSession : public ISlangUnknown
{
- public:
+ SLANG_COM_INTERFACE(0xc140b5fd, 0xc78, 0x452e, { 0xba, 0x7c, 0x1a, 0x1e, 0x70, 0xc7, 0xf7, 0x1c })
+
/** Create a new session for loading and compiling code.
*/
virtual SLANG_NO_THROW SlangResult SLANG_MCALL createSession(
@@ -3164,15 +3195,15 @@ namespace slang
char const* name) = 0;
};
- #define SLANG_UUID_IGlobalSession { 0xc140b5fd, 0xc78, 0x452e, { 0xba, 0x7c, 0x1a, 0x1e, 0x70, 0xc7, 0xf7, 0x1c } };
+ #define SLANG_UUID_IGlobalSession IGlobalSession::getTypeGuid()
/*!
@brief A request for one or more compilation actions to be performed.
*/
struct ICompileRequest : public ISlangUnknown
{
- public:
-
+ SLANG_COM_INTERFACE( 0x96d33993, 0x317c, 0x4db5, { 0xaf, 0xd8, 0x66, 0x6e, 0xe7, 0x72, 0x48, 0xe2 } )
+
/** Set the filesystem hook to use for a compile request
The provided `fileSystem` will be used to load any files that
@@ -3716,7 +3747,7 @@ namespace slang
};
- #define SLANG_UUID_ICompileRequest { 0x96d33993, 0x317c, 0x4db5, { 0xaf, 0xd8, 0x66, 0x6e, 0xe7, 0x72, 0x48, 0xe2 } };
+ #define SLANG_UUID_ICompileRequest ICompileRequest::getTypeGuid()
/** Description of a code generation target.
*/
@@ -3816,7 +3847,8 @@ namespace slang
*/
struct ISession : public ISlangUnknown
{
- public:
+ SLANG_COM_INTERFACE( 0x67618701, 0xd116, 0x468f, { 0xab, 0x3b, 0x47, 0x4b, 0xed, 0xce, 0xe, 0x3d } )
+
/** Get the global session thas was used to create this session.
*/
virtual SLANG_NO_THROW IGlobalSession* SLANG_MCALL getGlobalSession() = 0;
@@ -3905,7 +3937,7 @@ namespace slang
SlangCompileRequest** outCompileRequest) = 0;
};
- #define SLANG_UUID_ISession { 0x67618701, 0xd116, 0x468f, { 0xab, 0x3b, 0x47, 0x4b, 0xed, 0xce, 0xe, 0x3d } }
+ #define SLANG_UUID_ISession ISession::getTypeGuid()
/** A component type is a unit of shader code layout, reflection, and linking.
@@ -3970,6 +4002,8 @@ namespace slang
*/
struct IComponentType : public ISlangUnknown
{
+ SLANG_COM_INTERFACE(0x5bc42be8, 0x5c50, 0x4929, { 0x9e, 0x5e, 0xd1, 0x5e, 0x7c, 0x24, 0x1, 0x5f })
+
/** Get the runtime session that this component type belongs to.
*/
virtual SLANG_NO_THROW ISession* SLANG_MCALL getSession() = 0;
@@ -4073,14 +4107,14 @@ namespace slang
ISlangSharedLibrary** outSharedLibrary,
slang::IBlob** outDiagnostics = 0) = 0;
};
- #define SLANG_UUID_IComponentType { 0x5bc42be8, 0x5c50, 0x4929, { 0x9e, 0x5e, 0xd1, 0x5e, 0x7c, 0x24, 0x1, 0x5f } };
+ #define SLANG_UUID_IComponentType IComponentType::getTypeGuid()
struct IEntryPoint : public IComponentType
{
- public:
+ SLANG_COM_INTERFACE(0x8f241361, 0xf5bd, 0x4ca0, { 0xa3, 0xac, 0x2, 0xf7, 0xfa, 0x24, 0x2, 0xb8 })
};
- #define SLANG_UUID_IEntryPoint { 0x8f241361, 0xf5bd, 0x4ca0, { 0xa3, 0xac, 0x2, 0xf7, 0xfa, 0x24, 0x2, 0xb8 } }
+ #define SLANG_UUID_IEntryPoint IEntryPoint::getTypeGuid()
/** A module is the granularity of shader code compilation and loading.
@@ -4097,13 +4131,14 @@ namespace slang
*/
struct IModule : public IComponentType
{
- public:
+ SLANG_COM_INTERFACE(0xc720e64, 0x8722, 0x4d31, { 0x89, 0x90, 0x63, 0x8a, 0x98, 0xb1, 0xc2, 0x79 })
+
virtual SLANG_NO_THROW SlangResult SLANG_MCALL findEntryPointByName(
char const* name,
IEntryPoint** outEntryPoint) = 0;
};
- #define SLANG_UUID_IModule { 0xc720e64, 0x8722, 0x4d31, { 0x89, 0x90, 0x63, 0x8a, 0x98, 0xb1, 0xc2, 0x79 } }
+ #define SLANG_UUID_IModule IModule::getTypeGuid()
/** Argument used for specialization to types/values.
*/
diff --git a/source/core/slang-blob.cpp b/source/core/slang-blob.cpp
index becccf51c..569991508 100644
--- a/source/core/slang-blob.cpp
+++ b/source/core/slang-blob.cpp
@@ -2,18 +2,14 @@
namespace Slang {
-// Allocate static const storage for the various interface IDs that the Slang API needs to expose
-static const Guid IID_ISlangUnknown = SLANG_UUID_ISlangUnknown;
-static const Guid IID_ISlangBlob = SLANG_UUID_ISlangBlob;
-
ISlangUnknown* BlobBase::getInterface(const Guid& guid)
{
- return (guid == IID_ISlangUnknown || guid == IID_ISlangBlob) ? static_cast<ISlangBlob*>(this) : nullptr;
+ return (guid == ISlangUnknown::getTypeGuid() || guid == ISlangBlob::getTypeGuid()) ? static_cast<ISlangBlob*>(this) : nullptr;
}
SlangResult StaticBlob::queryInterface(SlangUUID const& guid, void** outObject)
{
- if (guid == IID_ISlangUnknown || guid == IID_ISlangBlob)
+ if (guid == ISlangUnknown::getTypeGuid() || guid == ISlangBlob::getTypeGuid())
{
*outObject = static_cast<ISlangBlob*>(this);
return SLANG_OK;
diff --git a/source/core/slang-compression-system.h b/source/core/slang-compression-system.h
index f9fe9dfe1..ecc5b1be9 100644
--- a/source/core/slang-compression-system.h
+++ b/source/core/slang-compression-system.h
@@ -29,7 +29,7 @@ enum class CompressionSystemType
class ICompressionSystem : public ISlangUnknown
{
-public:
+ SLANG_COM_INTERFACE(0xcc935840, 0xe059, 0x4bb8, { 0xa2, 0x2d, 0x92, 0x7b, 0x3c, 0x73, 0x8f, 0x85 })
/** Get the compression system type
@return The compression system type */
@@ -51,8 +51,6 @@ public:
virtual SLANG_NO_THROW SlangResult SLANG_MCALL decompress(const void* compressed, size_t compressedSizeInBytes, size_t decompressedSizeInBytes, void* outDecompressed) = 0;
};
-#define SLANG_UUID_ICompressionSystem { 0xcc935840, 0xe059, 0x4bb8, { 0xa2, 0x2d, 0x92, 0x7b, 0x3c, 0x73, 0x8f, 0x85 } };
-
}
#endif
diff --git a/source/core/slang-deflate-compression-system.cpp b/source/core/slang-deflate-compression-system.cpp
index a316be122..dab6654f7 100644
--- a/source/core/slang-deflate-compression-system.cpp
+++ b/source/core/slang-deflate-compression-system.cpp
@@ -17,8 +17,6 @@ namespace Slang
{
// Allocate static const storage for the various interface IDs that the Slang API needs to expose
-static const Guid IID_ISlangUnknown = SLANG_UUID_ISlangUnknown;
-static const Guid IID_ICompressionSystem = SLANG_UUID_ICompressionSystem;
class DeflateCompressionSystemImpl : public RefObject, public ICompressionSystem
{
@@ -42,7 +40,7 @@ protected:
ICompressionSystem* DeflateCompressionSystemImpl::getInterface(const Guid& guid)
{
- return (guid == IID_ISlangUnknown || guid == IID_ICompressionSystem) ? static_cast<ICompressionSystem*>(this) : nullptr;
+ return (guid == ISlangUnknown::getTypeGuid() || guid == ICompressionSystem::getTypeGuid()) ? static_cast<ICompressionSystem*>(this) : nullptr;
}
SlangResult DeflateCompressionSystemImpl::compress(const CompressionStyle* style, const void* src, size_t srcSizeInBytes, ISlangBlob** outBlob)
diff --git a/source/core/slang-file-system.cpp b/source/core/slang-file-system.cpp
index 992ae4155..91dd09ff9 100644
--- a/source/core/slang-file-system.cpp
+++ b/source/core/slang-file-system.cpp
@@ -8,27 +8,21 @@ namespace Slang
{
// Allocate static const storage for the various interface IDs that the Slang API needs to expose
-static const Guid IID_ISlangUnknown = SLANG_UUID_ISlangUnknown;
-static const Guid IID_ISlangFileSystem = SLANG_UUID_ISlangFileSystem;
-static const Guid IID_ISlangFileSystemExt = SLANG_UUID_ISlangFileSystemExt;
-static const Guid IID_ISlangMutableFileSystem = SLANG_UUID_ISlangMutableFileSystem;
-
-static const Guid IID_SlangCacheFileSystem = SLANG_UUID_CacheFileSystem;
SLANG_FORCE_INLINE static SlangResult _checkExt(FileSystemStyle style) { return Index(style) >= Index(FileSystemStyle::Ext) ? SLANG_OK : SLANG_E_NOT_IMPLEMENTED; }
SLANG_FORCE_INLINE static SlangResult _checkMutable(FileSystemStyle style) { return Index(style) >= Index(FileSystemStyle::Mutable) ? SLANG_OK : SLANG_E_NOT_IMPLEMENTED; }
SLANG_FORCE_INLINE static bool _canCast(FileSystemStyle style, const Guid& guid)
{
- if (guid == IID_ISlangUnknown || guid == IID_ISlangFileSystem)
+ if (guid == ISlangUnknown::getTypeGuid() || guid == ISlangFileSystem::getTypeGuid())
{
return true;
}
- else if (guid == IID_ISlangFileSystemExt)
+ else if (guid == ISlangFileSystemExt::getTypeGuid())
{
return Index(style) >= Index(FileSystemStyle::Ext);
}
- else if (guid == IID_ISlangMutableFileSystem)
+ else if (guid == ISlangMutableFileSystem::getTypeGuid())
{
return Index(style) >= Index(FileSystemStyle::Mutable);
}
@@ -41,11 +35,11 @@ static FileSystemStyle _getFileSystemStyle(ISlangFileSystem* system, ComPtr<ISla
FileSystemStyle style = FileSystemStyle::Load;
- if (SLANG_SUCCEEDED(system->queryInterface(IID_ISlangMutableFileSystem, (void**)out.writeRef())))
+ if (SLANG_SUCCEEDED(system->queryInterface(ISlangMutableFileSystem::getTypeGuid(), (void**)out.writeRef())))
{
style = FileSystemStyle::Mutable;
}
- else if (SLANG_SUCCEEDED(system->queryInterface(IID_ISlangFileSystemExt, (void**)out.writeRef())))
+ else if (SLANG_SUCCEEDED(system->queryInterface(ISlangFileSystemExt::getTypeGuid(), (void**)out.writeRef())))
{
style = FileSystemStyle::Ext;
}
@@ -269,7 +263,7 @@ SlangResult OSFileSystem::createDirectory(const char* path)
SLANG_NO_THROW SlangResult SLANG_MCALL CacheFileSystem::queryInterface(SlangUUID const& uuid, void** outObject)
{
- if (uuid == IID_SlangCacheFileSystem)
+ if (uuid == CacheFileSystem::getTypeGuid())
{
*outObject = this;
return SLANG_OK;
@@ -310,7 +304,7 @@ void CacheFileSystem::setInnerFileSystem(ISlangFileSystem* fileSystem, UniqueIde
if (fileSystem)
{
// Try to get the more sophisticated interface
- fileSystem->queryInterface(IID_ISlangFileSystemExt, (void**)m_fileSystemExt.writeRef());
+ fileSystem->queryInterface(ISlangFileSystemExt::getTypeGuid(), (void**)m_fileSystemExt.writeRef());
}
switch (m_uniqueIdentityMode)
diff --git a/source/core/slang-file-system.h b/source/core/slang-file-system.h
index d5145404d..caf7ffc23 100644
--- a/source/core/slang-file-system.h
+++ b/source/core/slang-file-system.h
@@ -70,8 +70,6 @@ private:
static OSFileSystem g_mutable;
};
- #define SLANG_UUID_CacheFileSystem { 0x2f4d1d03, 0xa0d1, 0x434b, { 0x87, 0x7a, 0x65, 0x5, 0xa4, 0xa0, 0x9a, 0x3b } };
-
/* Wraps an underlying ISlangFileSystem or ISlangFileSystemExt and provides caching,
as well as emulation of methods if only has ISlangFileSystem interface. Will query capabilities
of the interface on the constructor.
@@ -83,6 +81,7 @@ NOTE! That this behavior is the same as previously in that....
class CacheFileSystem: public ISlangFileSystemExt, public RefObject
{
public:
+ SLANG_CLASS_GUID(0x2f4d1d03, 0xa0d1, 0x434b, { 0x87, 0x7a, 0x65, 0x5, 0xa4, 0xa0, 0x9a, 0x3b })
enum class PathStyle
{
diff --git a/source/core/slang-lz4-compression-system.cpp b/source/core/slang-lz4-compression-system.cpp
index fa5c5f5ab..fd360ce2e 100644
--- a/source/core/slang-lz4-compression-system.cpp
+++ b/source/core/slang-lz4-compression-system.cpp
@@ -11,8 +11,6 @@ namespace Slang
{
// Allocate static const storage for the various interface IDs that the Slang API needs to expose
-static const Guid IID_ISlangUnknown = SLANG_UUID_ISlangUnknown;
-static const Guid IID_ICompressionSystem = SLANG_UUID_ICompressionSystem;
class LZ4CompressionSystemImpl : public RefObject, public ICompressionSystem
{
@@ -35,7 +33,7 @@ protected:
ICompressionSystem* LZ4CompressionSystemImpl::getInterface(const Guid& guid)
{
- return (guid == IID_ISlangUnknown || guid == IID_ICompressionSystem) ? static_cast<ICompressionSystem*>(this) : nullptr;
+ return (guid == ISlangUnknown::getTypeGuid() || guid == ICompressionSystem::getTypeGuid()) ? static_cast<ICompressionSystem*>(this) : nullptr;
}
SlangResult LZ4CompressionSystemImpl::compress(const CompressionStyle* style, const void* src, size_t srcSizeInBytes, ISlangBlob** outBlob)
diff --git a/source/core/slang-riff-file-system.cpp b/source/core/slang-riff-file-system.cpp
index 7084e1346..d52015fb3 100644
--- a/source/core/slang-riff-file-system.cpp
+++ b/source/core/slang-riff-file-system.cpp
@@ -16,12 +16,6 @@
namespace Slang
{
-// Allocate static const storage for the various interface IDs that the Slang API needs to expose
-static const Guid IID_ISlangUnknown = SLANG_UUID_ISlangUnknown;
-static const Guid IID_ISlangFileSystem = SLANG_UUID_ISlangFileSystem;
-static const Guid IID_ISlangFileSystemExt = SLANG_UUID_ISlangFileSystemExt;
-static const Guid IID_ISlangMutableFileSystem = SLANG_UUID_ISlangMutableFileSystem;
-
RiffFileSystem::RiffFileSystem(ICompressionSystem* compressionSystem):
m_compressionSystem(compressionSystem)
{
@@ -29,7 +23,7 @@ RiffFileSystem::RiffFileSystem(ICompressionSystem* compressionSystem):
ISlangMutableFileSystem* RiffFileSystem::getInterface(const Guid& guid)
{
- return (guid == IID_ISlangUnknown || guid == IID_ISlangFileSystem || guid == IID_ISlangFileSystemExt || guid == IID_ISlangMutableFileSystem) ? static_cast<ISlangMutableFileSystem*>(this) : nullptr;
+ return (guid == ISlangUnknown::getTypeGuid() || guid == ISlangFileSystem::getTypeGuid() || guid == ISlangFileSystemExt::getTypeGuid() || guid == ISlangMutableFileSystem::getTypeGuid()) ? static_cast<ISlangMutableFileSystem*>(this) : nullptr;
}
SlangResult RiffFileSystem::_calcCanonicalPath(const char* path, StringBuilder& out)
diff --git a/source/core/slang-shared-library.cpp b/source/core/slang-shared-library.cpp
index 8d362fd89..17b881540 100644
--- a/source/core/slang-shared-library.cpp
+++ b/source/core/slang-shared-library.cpp
@@ -20,18 +20,13 @@
namespace Slang
{
-// Allocate static const storage for the various interface IDs that the Slang API needs to expose
-static const Guid IID_ISlangUnknown = SLANG_UUID_ISlangUnknown;
-static const Guid IID_ISlangSharedLibrary = SLANG_UUID_ISlangSharedLibrary;
-static const Guid IID_ISlangSharedLibraryLoader = SLANG_UUID_ISlangSharedLibraryLoader;
-
/* !!!!!!!!!!!!!!!!!!!!!!!!!! DefaultSharedLibraryLoader !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
/* static */DefaultSharedLibraryLoader DefaultSharedLibraryLoader::s_singleton;
ISlangUnknown* DefaultSharedLibraryLoader::getInterface(const Guid& guid)
{
- return (guid == IID_ISlangUnknown || guid == IID_ISlangSharedLibraryLoader) ? static_cast<ISlangSharedLibraryLoader*>(this) : nullptr;
+ return (guid == ISlangUnknown::getTypeGuid() || guid == ISlangSharedLibraryLoader::getTypeGuid()) ? static_cast<ISlangSharedLibraryLoader*>(this) : nullptr;
}
SlangResult DefaultSharedLibraryLoader::loadSharedLibrary(const char* path, ISlangSharedLibrary** outSharedLibrary)
@@ -83,7 +78,7 @@ TemporarySharedLibrary::~TemporarySharedLibrary()
ISlangUnknown* DefaultSharedLibrary::getInterface(const Guid& guid)
{
- return (guid == IID_ISlangUnknown || guid == IID_ISlangSharedLibrary) ? static_cast<ISlangSharedLibrary*>(this) : nullptr;
+ return (guid == ISlangUnknown::getTypeGuid() || guid == ISlangSharedLibrary::getTypeGuid()) ? static_cast<ISlangSharedLibrary*>(this) : nullptr;
}
DefaultSharedLibrary::~DefaultSharedLibrary()
diff --git a/source/core/slang-writer.cpp b/source/core/slang-writer.cpp
index 0f8286553..3b1a5756a 100644
--- a/source/core/slang-writer.cpp
+++ b/source/core/slang-writer.cpp
@@ -18,8 +18,6 @@
namespace Slang
{
-static const Guid IID_ISlangWriter = SLANG_UUID_ISlangWriter;
-static const Guid IID_ISlangUnknown = SLANG_UUID_ISlangUnknown;
/* !!!!!!!!!!!!!!!!!!!!!!!!! WriterHelper !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
@@ -66,7 +64,7 @@ SlangResult WriterHelper::put(const UnownedStringSlice& text)
ISlangUnknown* BaseWriter::getInterface(const Guid& guid)
{
- return (guid == IID_ISlangUnknown || guid == IID_ISlangWriter) ? static_cast<ISlangWriter*>(this) : nullptr;
+ return (guid == ISlangUnknown::getTypeGuid() || guid == ISlangWriter::getTypeGuid()) ? static_cast<ISlangWriter*>(this) : nullptr;
}
/* !!!!!!!!!!!!!!!!!!!!!!!!! AppendBufferWriter !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
diff --git a/source/core/slang-zip-file-system.cpp b/source/core/slang-zip-file-system.cpp
index a56ba09db..1ed003d55 100644
--- a/source/core/slang-zip-file-system.cpp
+++ b/source/core/slang-zip-file-system.cpp
@@ -19,12 +19,6 @@
namespace Slang
{
-// Allocate static const storage for the various interface IDs that the Slang API needs to expose
-static const Guid IID_ISlangUnknown = SLANG_UUID_ISlangUnknown;
-static const Guid IID_ISlangFileSystem = SLANG_UUID_ISlangFileSystem;
-static const Guid IID_ISlangFileSystemExt = SLANG_UUID_ISlangFileSystemExt;
-static const Guid IID_ISlangMutableFileSystem = SLANG_UUID_ISlangMutableFileSystem;
-
class ZipFileSystemImpl : public ArchiveFileSystem
{
public:
@@ -108,7 +102,7 @@ protected:
ISlangMutableFileSystem* ZipFileSystemImpl::getInterface(const Guid& guid)
{
- return (guid == IID_ISlangUnknown || guid == IID_ISlangFileSystem || guid == IID_ISlangFileSystemExt || guid == IID_ISlangMutableFileSystem) ? static_cast<ISlangMutableFileSystem*>(this) : nullptr;
+ return (guid == ISlangUnknown::getTypeGuid() || guid == ISlangFileSystem::getTypeGuid() || guid == ISlangFileSystemExt::getTypeGuid() || guid == ISlangMutableFileSystem::getTypeGuid()) ? static_cast<ISlangMutableFileSystem*>(this) : nullptr;
}
// This is a very awkward hack to make it so we can get a read func, without having to implement all of the tracking etc.
diff --git a/source/slang/slang-check.cpp b/source/slang/slang-check.cpp
index cfc8c504c..600578297 100644
--- a/source/slang/slang-check.cpp
+++ b/source/slang/slang-check.cpp
@@ -18,9 +18,6 @@ namespace Slang
PassThroughMode compilerType;
};
- const Guid IID_ISlangSharedLibraryLoader = SLANG_UUID_ISlangSharedLibraryLoader;
- const Guid IID_ISlangUnknown = SLANG_UUID_ISlangUnknown;
-
class SinkSharedLibraryLoader : public RefObject, public ISlangSharedLibraryLoader
{
public:
@@ -57,7 +54,7 @@ namespace Slang
protected:
ISlangUnknown* getInterface(const Guid& guid)
{
- return (guid == IID_ISlangUnknown || guid == IID_ISlangSharedLibraryLoader) ? static_cast<ISlangSharedLibraryLoader*>(this) : nullptr;
+ return (guid == ISlangUnknown::getTypeGuid() || guid == ISlangSharedLibraryLoader::getTypeGuid()) ? static_cast<ISlangSharedLibraryLoader*>(this) : nullptr;
}
ISlangSharedLibraryLoader* m_loader;
DiagnosticSink* m_sink;
diff --git a/source/slang/slang-compiler.cpp b/source/slang/slang-compiler.cpp
index c034f5f7d..44cfebf13 100755
--- a/source/slang/slang-compiler.cpp
+++ b/source/slang/slang-compiler.cpp
@@ -185,11 +185,9 @@ namespace Slang
// EntryPoint
//
- static const Guid IID_IEntryPoint = SLANG_UUID_IEntryPoint;
-
ISlangUnknown* EntryPoint::getInterface(const Guid& guid)
{
- if(guid == IID_IEntryPoint)
+ if(guid == slang::IEntryPoint::getTypeGuid())
return static_cast<slang::IEntryPoint*>(this);
return Super::getInterface(guid);
diff --git a/source/slang/slang-compiler.h b/source/slang/slang-compiler.h
index b1e3c3a70..a3eac6fa6 100755
--- a/source/slang/slang-compiler.h
+++ b/source/slang/slang-compiler.h
@@ -37,8 +37,6 @@ namespace Slang
class TargetRequest;
class TypeLayout;
- extern const Guid IID_EndToEndCompileRequest;
-
enum class CompilerMode
{
ProduceLibrary,
@@ -1872,9 +1870,6 @@ namespace Slang
RefPtr<ComponentType> m_program;
};
- // UUID to identify EndToEndCompileRequest from an interface
- #define SLANG_UUID_EndToEndCompileRequest { 0xce6d2383, 0xee1b, 0x4fd7, { 0xa0, 0xf, 0xb8, 0xb6, 0x33, 0x12, 0x95, 0xc8 } };
-
/// A compile request that spans the front and back ends of the compiler
///
/// This is what the command-line `slangc` uses, as well as the legacy
@@ -1886,6 +1881,8 @@ namespace Slang
class EndToEndCompileRequest : public RefObject, public slang::ICompileRequest
{
public:
+ SLANG_CLASS_GUID(0xce6d2383, 0xee1b, 0x4fd7, { 0xa0, 0xf, 0xb8, 0xb6, 0x33, 0x12, 0x95, 0xc8 })
+
// ISlangUnknown
SLANG_NO_THROW SlangResult SLANG_MCALL queryInterface(SlangUUID const& uuid, void** outObject) SLANG_OVERRIDE;
SLANG_REF_OBJECT_IUNKNOWN_ADD_REF
@@ -2402,7 +2399,7 @@ SLANG_FORCE_INLINE EndToEndCompileRequest* asInternal(SlangCompileRequest* reque
SLANG_ASSERT(request);
EndToEndCompileRequest* endToEndRequest = nullptr;
// NOTE! We aren't using to access an interface, so *doesn't* return with a refcount
- request->queryInterface(IID_EndToEndCompileRequest, (void**)&endToEndRequest);
+ request->queryInterface(EndToEndCompileRequest::getTypeGuid(), (void**)&endToEndRequest);
SLANG_ASSERT(endToEndRequest);
return endToEndRequest;
}
diff --git a/source/slang/slang-dxc-support.cpp b/source/slang/slang-dxc-support.cpp
index 9abc4331e..4e5e4080e 100755
--- a/source/slang/slang-dxc-support.cpp
+++ b/source/slang/slang-dxc-support.cpp
@@ -48,8 +48,7 @@ namespace Slang
// IDxcIncludeHandler
// 7f61fc7d-950d-467f-b3e3-3c02fb49187c
static const Guid IID_IDxcIncludeHandler = { 0x7f61fc7d, 0x950d, 0x467f, { 0x3c, 0x02, 0xfb, 0x49, 0x18, 0x7c } };
- static const Guid IID_IUnknown = SLANG_UUID_ISlangUnknown;
-
+
class DxcIncludeHandler : public IDxcIncludeHandler
{
public:
@@ -109,7 +108,7 @@ namespace Slang
// Used by QueryInterface for casting
ISlangUnknown* getInterface(const Guid& guid)
{
- if (guid == IID_IUnknown || guid == IID_IDxcIncludeHandler)
+ if (guid == ISlangUnknown::getTypeGuid() || guid == IID_IDxcIncludeHandler)
{
return (ISlangUnknown*)(static_cast<IDxcIncludeHandler*>(this));
}
diff --git a/source/slang/slang.cpp b/source/slang/slang.cpp
index 5c04777de..8c6bf403e 100644
--- a/source/slang/slang.cpp
+++ b/source/slang/slang.cpp
@@ -108,20 +108,6 @@ namespace Slang {
}
}
-// Allocate static const storage for the various interface IDs that the Slang API needs to expose
-static const Guid IID_IComponentType = SLANG_UUID_IComponentType;
-static const Guid IID_IEntryPoint = SLANG_UUID_IEntryPoint;
-static const Guid IID_IGlobalSession = SLANG_UUID_IGlobalSession;
-static const Guid IID_IModule = SLANG_UUID_IModule;
-static const Guid IID_ISession = SLANG_UUID_ISession;
-static const Guid IID_ISlangBlob = SLANG_UUID_ISlangBlob;
-static const Guid IID_ISlangUnknown = SLANG_UUID_ISlangUnknown;
-
-static const Guid IID_ICompileRequest = SLANG_UUID_ICompileRequest;
-
-// Available to other modules so not static
-const Guid IID_EndToEndCompileRequest = SLANG_UUID_EndToEndCompileRequest;
-
const char* getBuildTagString()
{
return SLANG_TAG_VERSION;
@@ -447,7 +433,7 @@ SlangResult Session::_readBuiltinModule(ISlangFileSystem* fileSystem, Scope* sco
ISlangUnknown* Session::getInterface(const Guid& guid)
{
- if(guid == IID_ISlangUnknown || guid == IID_IGlobalSession)
+ if(guid == ISlangUnknown::getTypeGuid() || guid == IGlobalSession::getTypeGuid())
return asExternal(this);
return nullptr;
}
@@ -750,7 +736,7 @@ Linkage::Linkage(Session* session, ASTBuilder* astBuilder, Linkage* builtinLinka
ISlangUnknown* Linkage::getInterface(const Guid& guid)
{
- if(guid == IID_ISlangUnknown || guid == IID_ISession)
+ if(guid == ISlangUnknown::getTypeGuid() || guid == ISession::getTypeGuid())
return asExternal(this);
return nullptr;
@@ -1969,7 +1955,7 @@ EndToEndCompileRequest::EndToEndCompileRequest(
SLANG_NO_THROW SlangResult SLANG_MCALL EndToEndCompileRequest::queryInterface(SlangUUID const& uuid, void** outObject)
{
- if (uuid == IID_EndToEndCompileRequest)
+ if (uuid == EndToEndCompileRequest::getTypeGuid())
{
// Special case to cast directly into internal type
// NOTE! No addref(!)
@@ -1977,7 +1963,7 @@ SLANG_NO_THROW SlangResult SLANG_MCALL EndToEndCompileRequest::queryInterface(Sl
return SLANG_OK;
}
- if (uuid == IID_ISlangUnknown && uuid == IID_ICompileRequest)
+ if (uuid == ISlangUnknown::getTypeGuid() && uuid == ICompileRequest::getTypeGuid())
{
addReference();
*outObject = static_cast<slang::ICompileRequest*>(this);
@@ -2566,7 +2552,7 @@ Module::Module(Linkage* linkage, ASTBuilder* astBuilder)
ISlangUnknown* Module::getInterface(const Guid& guid)
{
- if(guid == IID_IModule)
+ if(guid == IModule::getTypeGuid())
return asExternal(this);
return Super::getInterface(guid);
}
@@ -2711,14 +2697,14 @@ ComponentType* asInternal(slang::IComponentType* inComponentType)
// (without even `addRef`-ing it).
//
ComPtr<slang::IComponentType> componentType;
- inComponentType->queryInterface(IID_IComponentType, (void**) componentType.writeRef());
+ inComponentType->queryInterface(slang::IComponentType::getTypeGuid(), (void**) componentType.writeRef());
return static_cast<ComponentType*>(componentType.get());
}
ISlangUnknown* ComponentType::getInterface(Guid const& guid)
{
- if(guid == IID_ISlangUnknown
- || guid == IID_IComponentType)
+ if(guid == ISlangUnknown::getTypeGuid()
+ || guid == slang::IComponentType::getTypeGuid())
{
return static_cast<slang::IComponentType*>(this);
}
@@ -3632,9 +3618,6 @@ Session* CompileRequestBase::getSession()
return getLinkage()->getSessionImpl();
}
-static const Slang::Guid IID_ISlangFileSystemExt = SLANG_UUID_ISlangFileSystemExt;
-static const Slang::Guid IID_SlangCacheFileSystem = SLANG_UUID_CacheFileSystem;
-
void Linkage::setFileSystem(ISlangFileSystem* inFileSystem)
{
// Set the fileSystem
@@ -3653,7 +3636,7 @@ void Linkage::setFileSystem(ISlangFileSystem* inFileSystem)
else
{
CacheFileSystem* cacheFileSystemPtr = nullptr;
- inFileSystem->queryInterface(IID_SlangCacheFileSystem, (void**)&cacheFileSystemPtr);
+ inFileSystem->queryInterface(CacheFileSystem::getTypeGuid(), (void**)&cacheFileSystemPtr);
if (cacheFileSystemPtr)
{
m_cacheFileSystem = cacheFileSystemPtr;
@@ -3669,7 +3652,7 @@ void Linkage::setFileSystem(ISlangFileSystem* inFileSystem)
else
{
// See if we have the full ISlangFileSystemExt interface, if we do just use it
- inFileSystem->queryInterface(IID_ISlangFileSystemExt, (void**)m_fileSystemExt.writeRef());
+ inFileSystem->queryInterface(ISlangFileSystemExt::getTypeGuid(), (void**)m_fileSystemExt.writeRef());
// If not wrap with CacheFileSystem that emulates ISlangFileSystemExt from the ISlangFileSystem interface
if (!m_fileSystemExt)