diff options
| author | Tim Foley <tfoley@nvidia.com> | 2017-06-19 08:47:23 -0700 |
|---|---|---|
| committer | Tim Foley <tfoley@nvidia.com> | 2017-06-19 09:56:42 -0700 |
| commit | 634522da69b14b38c15b14d6b717b1289812e9bb (patch) | |
| tree | 04f502283ed818f661e368b3d8d1ba5ce875d1d2 /slang.h | |
| parent | cafed774d99f95bce6f182599913f3417dc68a3a (diff) | |
Allow for automatic importing of Slang code
The basic idea of this change is that user code can just write:
#include "foo.h"
and then if `foo.h` gets found in a list of registered directories for "auto-import," then it actually gets interpreted as if the user had writte, more or less:
__import foo;
That is, the code in `foo.h` will be treated as Slang, and will be fully parsed and checked (no matter what the source language had been), and the scoping rules will be those of `__import` instead of `#include`.
This is a really big hammer, and I could imagine it smashing fingers if used poorly.
I'm not sure this feature will pan out, but we need to try things to know.
One big piece of that that I'll likely keep in either case is an overhaul of command-line options parsing for `slangc`. In particular, this logic has been moved into the core `slang` library (so that users can just pass options in via the API), and it is all done on UTF-8 strings rather than wide strings (which was always going to be Windows-specific).
Diffstat (limited to 'slang.h')
| -rw-r--r-- | slang.h | 22 |
1 files changed, 20 insertions, 2 deletions
@@ -194,8 +194,8 @@ extern "C" void const* userData); /*! - @brief Add a path in which source files are being search. When the programmer specifies @code using <file_name> @endcode in code, the compiler searches the file - in all search pathes in order. + @brief Add a path to use when searching for referenced files. + This will be used for both `#include` directives and also for explicit `__import` declarations. @param ctx The compilation context. @param searchDir The additional search directory. */ @@ -204,6 +204,16 @@ extern "C" const char* searchDir); /*! + @brief Add a path to use when searching for referenced files, that automatically treats `#include` as `__import` + This behaves just like `spAddSearchPath()` except that any `#include` file found through this path + will be treated as if it was referenced with `__import`. + @param ctx The compilation context. + @param searchDir The additional search directory. + */ + SLANG_API void spAddAutoImportPath( + SlangCompileRequest* request, + const char* searchDir); + /*! @brief Add a macro definition to be used during preprocessing. @param key The name of the macro to define. @param value The value of the macro to define. @@ -213,6 +223,13 @@ extern "C" const char* key, const char* value); + /*! + @brief Set options using arguments as if specified via command line. + */ + SLANG_API int spProcessCommandLineArguments( + SlangCompileRequest* request, + char const* const* args, + int argCount); /** Add a distinct translation unit to the compilation request @@ -890,6 +907,7 @@ namespace slang #include "source/slang/diagnostics.cpp" #include "source/slang/emit.cpp" #include "source/slang/lexer.cpp" +#include "source/slang/options.cpp" #include "source/slang/parameter-binding.cpp" #include "source/slang/parser.cpp" #include "source/slang/preprocessor.cpp" |
