From 10e1bae34733f1cdb5abc001666b1aafa1c1f406 Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Thu, 22 Oct 2020 08:46:12 -0400 Subject: Single pass C++ extraction (#1583) * #include an absolute path didn't work - because paths were taken to always be relative. * Added CharUtil. Added TypeSet to extractor. First pass at being able to specify all headers for multiple output headers. * Fix includes for new C++ extractor convension. Update premake5 to use new extractor mechanisms. * Small improvements around StringUtil. * Split out NameConventionUtil. * Use a 'convert' to convert between convention types. * Fix output of build message for C++ extractor. Improve NameConventionUtil interface. * Improve comments. * Fix warning on gcc. * Fix clang warning. * Fix some typos in NameConventionUtil. * Small fix to premake5.lua * Fix generated includes. * Remove m_reflectType as no longer applicable with TypeSet. * Fix .gitignore for slang-generated-* files. Added getConvention to determine convention from slice. Add versions of split and convert that infer the from convention * Fix typo in spliting camel. * LineWhitespace -> HorizontalWhitespace * Improve CharUtil comments. --- source/core/slang-string.cpp | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'source/core/slang-string.cpp') diff --git a/source/core/slang-string.cpp b/source/core/slang-string.cpp index bcf5853d5..3ce4c7ec9 100644 --- a/source/core/slang-string.cpp +++ b/source/core/slang-string.cpp @@ -1,6 +1,8 @@ #include "slang-string.h" #include "slang-text-io.h" +#include "slang-char-util.h" + namespace Slang { // TODO: this belongs in a different file: @@ -12,11 +14,6 @@ namespace Slang throw InternalError(message); } - SLANG_FORCE_INLINE static bool _isWhiteSpace(char c) - { - return c == ' ' || c == '\t'; - } - // OSString OSString::OSString() @@ -112,11 +109,20 @@ namespace Slang const char* start = m_begin; const char* end = m_end; - while (start < end && _isWhiteSpace(*start)) start++; - while (end > start && _isWhiteSpace(end[-1])) end--; + while (start < end && CharUtil::isHorizontalWhitespace(*start)) start++; + while (end > start && CharUtil::isHorizontalWhitespace(end[-1])) end--; return UnownedStringSlice(start, end); } + UnownedStringSlice UnownedStringSlice::trim(char c) const + { + const char* start = m_begin; + const char* end = m_end; + + while (start < end && *start == c) start++; + while (end > start && end[-1] == c) end--; + return UnownedStringSlice(start, end); + } // StringSlice -- cgit v1.2.3