diff options
| author | Ellie Hermaszewska <ellieh@nvidia.com> | 2024-10-29 14:49:26 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-10-29 14:49:26 +0800 |
| commit | f65d756bff8d4c5cbc15bd0322a2ae8e6b896a21 (patch) | |
| tree | ea1d61342cd29368e19135000ec2948813096205 /tools/slang-cpp-extractor/file-util.cpp | |
| parent | a729c15e9dce9f5116a38afc66329ab2ca4cea54 (diff) | |
format
* format
* Minor test fixes
* enable checking cpp format in ci
Diffstat (limited to 'tools/slang-cpp-extractor/file-util.cpp')
| -rw-r--r-- | tools/slang-cpp-extractor/file-util.cpp | 37 |
1 files changed, 23 insertions, 14 deletions
diff --git a/tools/slang-cpp-extractor/file-util.cpp b/tools/slang-cpp-extractor/file-util.cpp index e73ba7f55..2980a22ce 100644 --- a/tools/slang-cpp-extractor/file-util.cpp +++ b/tools/slang-cpp-extractor/file-util.cpp @@ -2,10 +2,12 @@ #include "../../source/core/slang-io.h" -namespace CppExtract { +namespace CppExtract +{ using namespace Slang; -namespace { // anonymous +namespace +{ // anonymous struct DiagnosticReporter { SlangResult report(SlangResult res) @@ -27,9 +29,8 @@ struct DiagnosticReporter return res; } - DiagnosticReporter(const String& filename, DiagnosticSink* sink) : - m_filename(filename), - m_sink(sink) + DiagnosticReporter(const String& filename, DiagnosticSink* sink) + : m_filename(filename), m_sink(sink) { } @@ -37,14 +38,18 @@ struct DiagnosticReporter String m_filename; }; -} // anonymous +} // namespace -/* static */SlangResult FileUtil::readAllText(const Slang::String& fileName, DiagnosticSink* sink, String& outRead) +/* static */ SlangResult FileUtil::readAllText( + const Slang::String& fileName, + DiagnosticSink* sink, + String& outRead) { DiagnosticReporter reporter(fileName, sink); - + RefPtr<FileStream> stream = new FileStream; - SLANG_RETURN_ON_FAIL(reporter.report(stream->init(fileName, FileMode::Open, FileAccess::Read, FileShare::ReadWrite))); + SLANG_RETURN_ON_FAIL(reporter.report( + stream->init(fileName, FileMode::Open, FileAccess::Read, FileShare::ReadWrite))); StreamReader reader; SLANG_RETURN_ON_FAIL(reporter.report(reader.init(stream))); @@ -53,12 +58,16 @@ struct DiagnosticReporter return SLANG_OK; } -/* static */SlangResult FileUtil::writeAllText(const Slang::String& fileName, DiagnosticSink* sink, const UnownedStringSlice& text) +/* static */ SlangResult FileUtil::writeAllText( + const Slang::String& fileName, + DiagnosticSink* sink, + const UnownedStringSlice& text) { // TODO(JS): - // There is an optimization/behavior here,that checks if the contents has changed. It only writes if it hasn't - // That might not be what you want (both because of extra work of read, the file modified stamp or other reasons, file is write only etc) - // NOTE! That this also does the work of the comparison after it is decoded, but the *bytes* might actually be different. + // There is an optimization/behavior here,that checks if the contents has changed. It only + // writes if it hasn't That might not be what you want (both because of extra work of read, the + // file modified stamp or other reasons, file is write only etc) NOTE! That this also does the + // work of the comparison after it is decoded, but the *bytes* might actually be different. if (File::exists(fileName)) { @@ -78,7 +87,7 @@ struct DiagnosticReporter StreamWriter writer; SLANG_RETURN_ON_FAIL(reporter.report(writer.init(stream))); SLANG_RETURN_ON_FAIL(reporter.report(writer.write(text))) - return SLANG_OK; + return SLANG_OK; } /* static */ void FileUtil::indent(Index indentCount, StringBuilder& out) |
