summaryrefslogtreecommitdiff
path: root/slang.h
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2019-02-04 17:30:51 -0500
committerGitHub <noreply@github.com>2019-02-04 17:30:51 -0500
commit9b80537bc0272a9caf93f146d8964d9bdd4a407e (patch)
tree13c2e92adca1b78b632bd8dd6cc1fecb5a12ded9 /slang.h
parent0d206996cd68b9f08ae1b4d9da6f16293984302c (diff)
Feature/view path (#824)
* Use 'is' over 'as' where appropriate. * dynamic_cast -> dynamicCast * Replace 'dynamicCast' with 'as' where has no change in behavior/ambiguity. * Replace dynamicCast with as where doesn't change behavior/non ambiguous. * Keep a per view path to the file loaded - such that diagnostic messages always display the path to the requested file. * Add simplifyPath to ISlangFileSystemExt Simplify (if possible) paths that are set on SourceFile and SourcView - doing so makes reading paths simpler. * Fix small typo. * Improve documentation in source for getFileUniqueIdentity * Fix override warning.
Diffstat (limited to 'slang.h')
-rw-r--r--slang.h35
1 files changed, 28 insertions, 7 deletions
diff --git a/slang.h b/slang.h
index 9a1880536..7abaebfe1 100644
--- a/slang.h
+++ b/slang.h
@@ -780,8 +780,15 @@ extern "C"
public:
/** Get a uniqueIdentity which uniquely identifies an object of the file system.
- Given a path, returns a 'uniqueIdentity' path will return the same value for the same file/directory on the file system.
- The uniqueIdentity is used to compare if two includes are the same file.
+ Given a path, returns a 'uniqueIdentity' which ideally is the same value for the same file on the file system.
+
+ The uniqueIdentity is used to compare if files are the same - which allows slang to cache source contents internally. It is also used
+ for #pragma once functionality.
+
+ A *requirement* is for any implementation is that two paths can only return the same uniqueIdentity if the
+ contents of the two files are *identical*. If an implementation breaks this constraint it can produce incorrect compilation.
+ If an implementation cannot *strictly* identify *the same* files, this will only have an effect on #pragma once behavior.
+
The string for the uniqueIdentity is held zero terminated in the ISlangBlob of outUniqueIdentity.
Note that there are many ways a uniqueIdentity may be generated for a file. For example it could be the
@@ -823,18 +830,32 @@ extern "C"
const char* path,
SlangPathType* pathTypeOut) = 0;
+ /** Get a simplified path.
+ Given a path, returns a simplified version of that path - typically removing '..' and/or '.'. A simplified
+ path must point to the same object as the original.
+
+ This method is optional, if not implemented return SLANG_E_NOT_IMPLEMENTED.
+
+ @param path
+ @param outSimplifiedPath
+ @returns SLANG_OK if successfully simplified the path (SLANG_E_NOT_IMPLEMENTED if not implemented, or some other error code)
+ */
+ virtual SLANG_NO_THROW SlangResult SLANG_MCALL getSimplifiedPath(
+ const char* path,
+ ISlangBlob** outSimplifiedPath) = 0;
+
/** Get a canonical path identifies an object of the file system.
- Given a path, returns a 'canonicalPath' the file. This may be a file system 'canonical path' to
- show where a file was read from. Also though if the filesystem is say a zip file - it might include the path to the zip
+ Given a path, returns a 'canonicalPath' to the file. This may be a file system 'canonical path' to
+ show where a file was read from. If the file system is say a zip file - it might include the path to the zip
container as well as the absolute path to the specific file. The main purpose of the method is to be able
- to display to users unambiguously where a file was read from in diagnostics.
+ to display to uses unambiguously where a file was read from.
- This method is optional and if not implemented will display 'found paths'. If not implemented return SLANG_E_NOT_IMPLEMENTED.
+ This method is optional, if not implemented return SLANG_E_NOT_IMPLEMENTED.
@param path
@param outCanonicalPath
- @returns A `SlangResult`
+ @returns SLANG_OK if successfully canonicalized the path (SLANG_E_NOT_IMPLEMENTED if not implemented, or some other error code)
*/
virtual SLANG_NO_THROW SlangResult SLANG_MCALL getCanonicalPath(
const char* path,