From da0d295d6c8b6fb03245dea0583437c198890349 Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Thu, 22 Apr 2021 09:32:25 -0400 Subject: C++ extractor improvements (#1803) * #include an absolute path didn't work - because paths were taken to always be relative. * Split of NodeTree. Split out FileUtil. Split out MacroWriter. * Rename slang-cpp-extractor-main.cpp -> cpp-extractor-main.cpp * First pass at extractor unit-tests * Initial parsing of enum. * Ability to disable/enable parsing of scope types. * Initial support for typedef. * Added operator== != to ArrayVIew. Added test for splitting to unit tests. * Improve comment in StringUtil. * Fix comment. * Fix typo. --- source/core/slang-array-view.h | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'source/core/slang-array-view.h') diff --git a/source/core/slang-array-view.h b/source/core/slang-array-view.h index 56c936073..c67a53337 100644 --- a/source/core/slang-array-view.h +++ b/source/core/slang-array-view.h @@ -12,6 +12,8 @@ namespace Slang class ConstArrayView { public: + typedef ConstArrayView ThisType; + const T* begin() const { return m_buffer; } const T* end() const { return m_buffer + m_count; } @@ -70,6 +72,30 @@ namespace Slang return -1; } + bool operator==(const ThisType& rhs) const + { + if (&rhs == this) + { + return true; + } + const Index count = getCount(); + if (count != rhs.getCount()) + { + return false; + } + const T* thisEle = getBuffer(); + const T* rhsEle = rhs.getBuffer(); + for (Index i = 0; i < count; ++i) + { + if (thisEle[i] != rhsEle[i]) + { + return false; + } + } + return true; + } + SLANG_FORCE_INLINE bool operator!=(const ThisType& rhs) const { return !(*this == rhs); } + ConstArrayView() : m_buffer(nullptr), m_count(0) @@ -111,6 +137,8 @@ namespace Slang class ArrayView: public ConstArrayView { public: + typedef ArrayView ThisType; + typedef ConstArrayView Super; using Super::m_buffer; @@ -147,6 +175,7 @@ namespace Slang { return ArrayView(buffer, count); } + } #endif -- cgit v1.2.3