diff options
| author | Tim Foley <tfoleyNV@users.noreply.github.com> | 2018-03-08 12:35:00 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-03-08 12:35:00 -0800 |
| commit | a22b7520745334ecef3cbd920a0331f01c905935 (patch) | |
| tree | f5ecf29f957f6b40f3fb5a4f987b2a1d00dd3bed /source/slang/slang-stdlib.cpp | |
| parent | ed718ba1048ef856efbf0d02902e4d60f173b207 (diff) | |
Cleanups on slang-generate (#437)
* Cleanups on slang-generate
There is nothing too significant in these changes, but I'm trying to get
things in place so that we can:
- Clean up the stdlib code to do less explicit `StringBuilder`
operations and instead to use more of the "template engine" approach
- Start using slang-generate for code other than the slang stdlib, so
that we can generate more of our boilerplate.
The main new functionality here is that in a template/meta file, you can
now enclose an expression in `$(...)` to indicate that is should be
spliced into the result. E.g. instead of:
class ${{ sb << someClassName; }}
{
...
}
We can now write:
class $(someClassName)
{
...
}
The other bit of new functionality is support for a whole-line statement
escape, so that instead of:
${{ for( auto a : someCollection ) { }}
void $(a)() { ... }
${{ } }}
We can instead write:
$: for(auto a : someCollection) {
void $(a)() { ... }
$: }
I haven't yet tried to use that functionality in the stdlib meta-code,
but doing so would be an obvious next step.
* Fixup: change some $P to $p
The capitalization on some of the GLSL intrinsic mappings got messed up during a find-and-replace operation when removing the double `$` that used to be required to escape things.
Diffstat (limited to 'source/slang/slang-stdlib.cpp')
| -rw-r--r-- | source/slang/slang-stdlib.cpp | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/source/slang/slang-stdlib.cpp b/source/slang/slang-stdlib.cpp index bee823d69..69ae36a3f 100644 --- a/source/slang/slang-stdlib.cpp +++ b/source/slang/slang-stdlib.cpp @@ -246,6 +246,9 @@ namespace Slang String path = getStdlibPath(); +#define SLANG_RAW(TEXT) sb << TEXT; +#define SLANG_SPLICE(EXPR) sb << (EXPR); + #define EMIT_LINE_DIRECTIVE() sb << "#line " << (__LINE__+1) << " \"" << path << "\"\n" #include "core.meta.slang.h" |
