https://github.com/shader-slang/slang
Tip revision: e24c5a6cb9c3347477b83abe084a09ae8f9fde0a authored by Tim Foley on 08 January 2021, 00:01:48 UTC
Fill in some missing bits of capability API (#1652)
Fill in some missing bits of capability API (#1652)
Tip revision: e24c5a6
slang-include-system.h
#ifndef SLANG_INCLUDE_SYSTEM_H
#define SLANG_INCLUDE_SYSTEM_H
// slang-include-system.h
#include "slang-source-loc.h"
namespace Slang
{
// A directory to be searched when looking for files (e.g., `#include`)
struct SearchDirectory
{
SearchDirectory() = default;
SearchDirectory(SearchDirectory const& other) = default;
SearchDirectory(String const& path)
: path(path)
{}
String path;
};
/// A list of directories to search for files (e.g., `#include`)
struct SearchDirectoryList
{
// A parent list that should also be searched
SearchDirectoryList* parent = nullptr;
// Directories to be searched
List<SearchDirectory> searchDirectories;
};
/* A helper class that builds basic include handling on top of searchDirectories/fileSystemExt and optionally a sourceManager */
struct IncludeSystem
{
IncludeSystem(SearchDirectoryList* searchDirectories, ISlangFileSystemExt* fileSystemExt, SourceManager* sourceManager = nullptr) :
m_searchDirectories(searchDirectories),
m_fileSystemExt(fileSystemExt),
m_sourceManager(sourceManager)
{
}
SlangResult findFile(const String& pathToInclude, const String& pathIncludedFrom, PathInfo& outPathInfo);
SlangResult findFile(SlangPathType fromPathType, const String& fromPath, const String& path, PathInfo& outPathInfo);
String simplifyPath(const String& path);
SlangResult loadFile(const PathInfo& pathInfo, ComPtr<ISlangBlob>& outBlob);
SlangResult findAndLoadFile(const String& pathToInclude, const String& pathIncludedFrom, PathInfo& outPathInfo, ComPtr<ISlangBlob>& outBlob);
SearchDirectoryList* getSearchDirectoryList() const { return m_searchDirectories; }
ISlangFileSystemExt* getFileSystem() const { return m_fileSystemExt; }
SourceManager* getSourceManager() const { return m_sourceManager; }
protected:
SearchDirectoryList* m_searchDirectories;
ISlangFileSystemExt* m_fileSystemExt;
SourceManager* m_sourceManager; ///< If not set, will not look up the content in the source manager
};
}
#endif // SLANG_INCLUDE_HANDLER_H