summaryrefslogtreecommitdiff
path: root/source/slang/slang-repro.cpp
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2022-09-01 16:39:08 -0400
committerGitHub <noreply@github.com>2022-09-01 16:39:08 -0400
commitcc0b81350f6b681c794b4ac7c0f3b5fe73cb19eb (patch)
tree7fd935748f4da5daa381f6cf4ef5d06c6adfc0a6 /source/slang/slang-repro.cpp
parentf64d8748d4396a90d27adbdc17db3bac4a58d666 (diff)
Make ISlangFileSystem derive from ICastable (#2386)
* #include an absolute path didn't work - because paths were taken to always be relative. * Make ISlangFileSystem derive from ICastable. * Make ArchiveFileSystem into an interface Make file systems atomically reference counted. * Small fix. * Some small fixes to work around issues of ICastable on ISlangFileSystem * Use ISlangFileSystem derived type instead of IArchiveFileSystem. Can always get other interface with castAs. * Some small fixes around change of interface returned from archive type functions. * Remove CacheFileSystem member from linkage. Can access easily from m_fileSystemExt if necessary with as cast. * Fix RiffFileSystem casting issue. * Add a check around CacheFileSystem.
Diffstat (limited to 'source/slang/slang-repro.cpp')
-rw-r--r--source/slang/slang-repro.cpp18
1 files changed, 10 insertions, 8 deletions
diff --git a/source/slang/slang-repro.cpp b/source/slang/slang-repro.cpp
index 1597366d6..f0df86129 100644
--- a/source/slang/slang-repro.cpp
+++ b/source/slang/slang-repro.cpp
@@ -527,7 +527,7 @@ static String _scrubName(const String& in)
// Find files from the file system, and mapping paths to files
{
- CacheFileSystem* cacheFileSystem = linkage->getCacheFileSystem();
+ CacheFileSystem* cacheFileSystem = as<CacheFileSystem>(linkage->getFileSystemExt());
if (!cacheFileSystem)
{
return SLANG_FAIL;
@@ -831,11 +831,13 @@ struct LoadContext
} // anonymous
-/* static */SlangResult ReproUtil::loadFileSystem(OffsetBase& base, RequestState* requestState, ISlangFileSystem* fileSystem, RefPtr<CacheFileSystem>& outFileSystem)
+/* static */SlangResult ReproUtil::loadFileSystem(OffsetBase& base, RequestState* requestState, ISlangFileSystem* replaceFileSystem, ComPtr<ISlangFileSystemExt>& outFileSystem)
{
- LoadContext context(nullptr, fileSystem, &base);
+ LoadContext context(nullptr, replaceFileSystem, &base);
+
+ CacheFileSystem* cacheFileSystem = new CacheFileSystem(nullptr);
+ ComPtr<ISlangFileSystemExt> scopeCacheFileSystem(cacheFileSystem);
- RefPtr<CacheFileSystem> cacheFileSystem = new CacheFileSystem(nullptr);
auto& dstUniqueMap = cacheFileSystem->getUniqueMap();
auto& dstPathMap = cacheFileSystem->getPathMap();
@@ -880,7 +882,7 @@ struct LoadContext
}
}
- outFileSystem = cacheFileSystem;
+ outFileSystem.swap(scopeCacheFileSystem);
return SLANG_OK;
}
@@ -1042,7 +1044,8 @@ struct LoadContext
}
{
- RefPtr<CacheFileSystem> cacheFileSystem = new CacheFileSystem(nullptr);
+ auto cacheFileSystem = new CacheFileSystem(nullptr);
+ ComPtr<ISlangFileSystemExt> fileSystemExt(cacheFileSystem);
auto& dstUniqueMap = cacheFileSystem->getUniqueMap();
auto& dstPathMap = cacheFileSystem->getPathMap();
@@ -1070,8 +1073,7 @@ struct LoadContext
// This is a bit of a hack, we are going to replace the file system, with our one which is filled in
// with what was read from the file.
- linkage->m_fileSystemExt = cacheFileSystem;
- linkage->m_cacheFileSystem = cacheFileSystem;
+ linkage->m_fileSystemExt.swap(fileSystemExt);
}
return SLANG_OK;