summaryrefslogtreecommitdiffstats
path: root/tools/slang-embed
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2021-10-04 14:15:51 -0400
committerGitHub <noreply@github.com>2021-10-04 14:15:51 -0400
commit97bb82ebcdf8f1391b9d93b5a8d7b1dfc4e88e52 (patch)
treef120ba282cbea96d23ed179737984a4610d3b520 /tools/slang-embed
parentb3dfe383c6d31ff3dbd76dcfb32de8d536382f3e (diff)
Removing exceptions from core/compiler-core (#1953)
* #include an absolute path didn't work - because paths were taken to always be relative. * Refactor Stream. Working on all tests. * Split out CharEncode. * Make method names lower camel. m_prefix in Writer/Reader * Tidy up around CharEncode interface. * Small improvements around encode/decode. * Better use of types. * Remove readLine from TextReader. * Remove exceptions from Stream/Text handling. * Fix some typos. * Fix tabbing. * Fix missing override. * Remove remaining exception throw/catch via using signal mechanism. * Remove exceptions that are not used anymore. * Document the Stream interface. * Remove index for decoding 'get byte' function. * Fix CharReader -> ByteReader.
Diffstat (limited to 'tools/slang-embed')
-rw-r--r--tools/slang-embed/slang-embed.cpp20
1 files changed, 15 insertions, 5 deletions
diff --git a/tools/slang-embed/slang-embed.cpp b/tools/slang-embed/slang-embed.cpp
index 17b71d216..4a81c1b95 100644
--- a/tools/slang-embed/slang-embed.cpp
+++ b/tools/slang-embed/slang-embed.cpp
@@ -19,6 +19,7 @@
#include "../../source/core/slang-string-util.h"
#include "../../source/core/slang-io.h"
+
// Utility to free pointers on scope exit
struct ScopedMemory
{
@@ -86,6 +87,8 @@ struct App
bool useNewStringLit = true;
void processInputFile(FILE* outputFile, Slang::String inputPath)
{
+ using namespace Slang;
+
// We open the input file in text mode because we are currently
// embedding textual source files. If/when this utility gets
// used for binary files another mode could be called for.
@@ -94,15 +97,22 @@ struct App
// could lead to a difference in the embedded bytes based on
// the line ending convention of the host platform)
//
- Slang::StreamReader streamReader(inputPath);
- while (!streamReader.IsEnd())
+
+ String contents;
+ {
+ auto res = File::readAllText(inputPath, contents);
+ SLANG_ASSERT(SLANG_SUCCEEDED(res));
+ }
+
+ LineParser lineReader(contents.getUnownedSlice());
+
+ for (auto line : lineReader)
{
- auto line = streamReader.ReadLine();
- Slang::String trimedLine = line.trimStart();
+ auto trimedLine = line.trimStart();
if (trimedLine.startsWith("#include"))
{
auto fileName =
- Slang::StringUtil::getAtInSplit(trimedLine.getUnownedSlice(), ' ', 1);
+ Slang::StringUtil::getAtInSplit(trimedLine, ' ', 1);
if (fileName[0] == '<')
goto normalProcess;
fileName = Slang::UnownedStringSlice(fileName.begin() + 1, fileName.end() - 1);