summaryrefslogtreecommitdiffstats
path: root/source/core/slang-file-system.cpp
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 /source/core/slang-file-system.cpp
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.
Diffstat (limited to 'source/core/slang-file-system.cpp')
-rw-r--r--source/core/slang-file-system.cpp20
1 files changed, 7 insertions, 13 deletions
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)