From f63b39504307fdc26267febc74578a81e6f33366 Mon Sep 17 00:00:00 2001 From: qubka Date: Sun, 12 Oct 2025 16:55:16 +0100 Subject: [PATCH 01/16] fix: remove assume_valid from string --- include/plg/string.hpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/include/plg/string.hpp b/include/plg/string.hpp index c2dbacf..316673c 100644 --- a/include/plg/string.hpp +++ b/include/plg/string.hpp @@ -1890,7 +1890,7 @@ namespace plg { // starts_with constexpr bool starts_with(self_view sv) const noexcept { - return self_view(typename self_view::assume_valid(), data(), size()).starts_with(sv); + return self_view(data(), size()).starts_with(sv); } constexpr bool starts_with(value_type c) const noexcept { @@ -1904,7 +1904,7 @@ namespace plg { // ends_with constexpr bool ends_with(self_view sv) const noexcept { - return self_view(typename self_view::assume_valid(), data(), size()).ends_with(sv); + return self_view(data(), size()).ends_with(sv); } constexpr bool ends_with(value_type c) const noexcept { @@ -1918,15 +1918,15 @@ namespace plg { // contains constexpr bool contains(self_view sv) const noexcept { - return self_view(typename self_view::assume_valid(), data(), size()).contains(sv); + return self_view(data(), size()).contains(sv); } constexpr bool contains(value_type c) const noexcept { - return self_view(typename self_view::assume_valid(), data(), size()).contains(c); + return self_view(data(), size()).contains(c); } constexpr bool contains(const value_type* PLUGIFY_NO_NULL s) const { - return self_view(typename self_view::assume_valid(), data(), size()).contains(s); + return self_view(data(), size()).contains(s); } [[nodiscard]] constexpr bool invariants() const; From 1201020e00ea55970749f8457b33d9d969f88e4f Mon Sep 17 00:00:00 2001 From: qubka Date: Sun, 12 Oct 2025 19:48:26 +0100 Subject: [PATCH 02/16] fix: update plg includes --- include/plg/allocator.hpp | 10 +- include/plg/concepts.hpp | 1 + include/plg/config.hpp | 21 +- include/plg/enum.hpp | 6 +- include/plg/guards.hpp | 36 +- include/plg/hash.hpp | 30 +- include/plg/inplace_vector.hpp | 196 ++++----- include/plg/split_buffer.hpp | 240 +++++------ include/plg/string.hpp | 258 ++++++------ include/plg/uninitialized.hpp | 12 +- include/plg/variant.hpp | 58 +-- include/plg/vector.hpp | 398 +++++++++--------- include/plg/version.hpp | 242 +++++------ .../plugify/include/plg/allocator.hpp | 2 +- .../external/plugify/include/plg/config.hpp | 2 +- .../external/plugify/include/plg/enum.hpp | 6 +- .../external/plugify/include/plg/guards.hpp | 36 +- .../external/plugify/include/plg/hash.hpp | 30 +- .../plugify/include/plg/inplace_vector.hpp | 196 ++++----- .../plugify/include/plg/split_buffer.hpp | 240 +++++------ .../external/plugify/include/plg/string.hpp | 246 +++++------ .../plugify/include/plg/uninitialized.hpp | 12 +- .../external/plugify/include/plg/variant.hpp | 58 +-- .../external/plugify/include/plg/vector.hpp | 396 ++++++++--------- .../external/plugify/include/plg/version.hpp | 242 +++++------ .../plugify/include/plg/allocator.hpp | 2 +- .../external/plugify/include/plg/config.hpp | 2 +- .../external/plugify/include/plg/enum.hpp | 6 +- .../external/plugify/include/plg/guards.hpp | 36 +- .../external/plugify/include/plg/hash.hpp | 30 +- .../plugify/include/plg/inplace_vector.hpp | 196 ++++----- .../plugify/include/plg/split_buffer.hpp | 240 +++++------ .../external/plugify/include/plg/string.hpp | 246 +++++------ .../plugify/include/plg/uninitialized.hpp | 12 +- .../external/plugify/include/plg/variant.hpp | 58 +-- .../external/plugify/include/plg/vector.hpp | 396 ++++++++--------- .../external/plugify/include/plg/version.hpp | 242 +++++------ .../plugify/include/plg/allocator.hpp | 2 +- .../external/plugify/include/plg/config.hpp | 2 +- .../external/plugify/include/plg/enum.hpp | 6 +- .../external/plugify/include/plg/guards.hpp | 36 +- .../external/plugify/include/plg/hash.hpp | 30 +- .../plugify/include/plg/inplace_vector.hpp | 196 ++++----- .../plugify/include/plg/split_buffer.hpp | 240 +++++------ .../external/plugify/include/plg/string.hpp | 246 +++++------ .../plugify/include/plg/uninitialized.hpp | 12 +- .../external/plugify/include/plg/variant.hpp | 58 +-- .../external/plugify/include/plg/vector.hpp | 396 ++++++++--------- .../external/plugify/include/plg/version.hpp | 242 +++++------ 49 files changed, 2944 insertions(+), 2962 deletions(-) diff --git a/include/plg/allocator.hpp b/include/plg/allocator.hpp index ea025da..3bb603d 100644 --- a/include/plg/allocator.hpp +++ b/include/plg/allocator.hpp @@ -143,23 +143,23 @@ namespace plg { // asan_annotate_container_with_allocator determines whether containers with custom allocators are annotated. This is // a public customization point to disable annotations if the custom allocator assumes that the memory isn't poisoned. // See the https://libcxx.llvm.org/UsingLibcxx.html#turning-off-asan-annotation-in-containers for more information. -#if __has_feature(address_sanitizer) +#if PLUGIFY_INSTRUMENTED_WITH_ASAN template struct asan_annotate_container_with_allocator : std::true_type {}; -#endif +#endif // PLUGIFY_INSTRUMENTED_WITH_ASAN // Annotate a contiguous range. // [__first_storage, __last_storage) is the allocated memory region, // __old_last_contained is the previously last allowed (unpoisoned) element, and // __new_last_contained is the new last allowed (unpoisoned) element. template - void annotate_contiguous_container( + constexpr void annotate_contiguous_container( [[maybe_unused]] const void* first_storage, [[maybe_unused]] const void* last_storage, [[maybe_unused]] const void* old_last_contained, [[maybe_unused]] const void* new_last_contained ) { -#if __has_feature(address_sanitizer) +#if PLUGIFY_INSTRUMENTED_WITH_ASAN if (!std::is_constant_evaluated() && asan_annotate_container_with_allocator::value && first_storage != nullptr) { @@ -170,6 +170,6 @@ namespace plg { new_last_contained ); } -#endif +#endif // PLUGIFY_INSTRUMENTED_WITH_ASAN } } // namespace plg diff --git a/include/plg/concepts.hpp b/include/plg/concepts.hpp index e54e722..398018b 100644 --- a/include/plg/concepts.hpp +++ b/include/plg/concepts.hpp @@ -1,5 +1,6 @@ #pragma once +#include #include #include #include diff --git a/include/plg/config.hpp b/include/plg/config.hpp index 1054d97..a0e43c3 100644 --- a/include/plg/config.hpp +++ b/include/plg/config.hpp @@ -16,7 +16,7 @@ # define __has_builtin(x) 0 #endif -#ifndef __builtin_constant_p +#if !__has_builtin(__builtin_constant_p) # define __builtin_constant_p(x) std::is_constant_evaluated() #endif @@ -29,11 +29,7 @@ # define PLUGIFY_ASSERT(cond, mesg) assert((cond) && (mesg)) #endif -#if __has_feature(address_sanitizer) || defined(__SANITIZE_ADDRESS__) -# include -#endif - -#define PLUGIFY_HAS_EXCEPTIONS __cpp_exceptions || _CPPUNWIND || __EXCEPTIONS +#define PLUGIFY_HAS_EXCEPTIONS __cpp_exceptions || _CPPUNWIND || __EXCEPTIONS #if PLUGIFY_HAS_EXCEPTIONS # include # include @@ -47,11 +43,20 @@ namespace plg { } } } // namespace plg -# define PLUGIFY_THROW(str, exp, ...) ::plg::throw_exception(str, ##__VA_ARGS__); +# define PLUGIFY_THROW(str, exp, ...) ::plg::throw_exception(str __VA_OPT__(,) __VA_ARGS__); #else # include # include -# define PLUGIFY_THROW(str, ...) { std::fputs(str "\n", stderr); std::abort(); } +# define PLUGIFY_THROW(str, ...) \ + std::fputs(str "\n", stderr); \ + std::abort(); +#endif + +#if __has_feature(address_sanitizer) || defined(__SANITIZE_ADDRESS__) +# define PLUGIFY_INSTRUMENTED_WITH_ASAN 1 +# include +#else +# define PLUGIFY_INSTRUMENTED_WITH_ASAN 0 #endif # define PLUGIFY_COMPILER_MAKE_VERSION2(version, sp) ((version) * 100 + (sp)) diff --git a/include/plg/enum.hpp b/include/plg/enum.hpp index 802b7c1..0692a31 100644 --- a/include/plg/enum.hpp +++ b/include/plg/enum.hpp @@ -17,15 +17,15 @@ namespace plg { template struct static_string { constexpr static_string(std::string_view sv) noexcept { - std::copy(sv.begin(), sv.end(), _content.begin()); + std::copy(sv.begin(), sv.end(), content_.begin()); } constexpr operator std::string_view() const noexcept { - return { _content.data(), N }; + return { content_.data(), N }; } private: - std::array _content{}; + std::array content_{}; }; constexpr auto is_pretty(char ch) noexcept { diff --git a/include/plg/guards.hpp b/include/plg/guards.hpp index 4691341..a45e221 100644 --- a/include/plg/guards.hpp +++ b/include/plg/guards.hpp @@ -9,16 +9,16 @@ namespace plg { exception_guard_exceptions() = delete; constexpr explicit exception_guard_exceptions(Rollback rollback) - : _rollback(std::move(rollback)) - , _completed(false) { + : rollback_(std::move(rollback)) + , completed_(false) { } constexpr exception_guard_exceptions( exception_guard_exceptions&& other ) noexcept(std::is_nothrow_move_constructible_v) - : _rollback(std::move(other._rollback)) - , _completed(other._completed) { - other._completed = true; + : rollback_(std::move(other.rollback_)) + , completed_(other.completed_) { + other.completed_ = true; } exception_guard_exceptions(const exception_guard_exceptions&) = delete; @@ -26,18 +26,18 @@ namespace plg { exception_guard_exceptions& operator=(exception_guard_exceptions&&) = delete; constexpr void complete() noexcept { - _completed = true; + completed_ = true; } constexpr ~exception_guard_exceptions() { - if (!_completed) { - _rollback(); + if (!completed_) { + rollback_(); } } private: - PLUGIFY_NO_UNIQUE_ADDRESS Rollback _rollback; - bool _completed; + PLUGIFY_NO_UNIQUE_ADDRESS Rollback rollback_; + bool completed_; }; template @@ -53,8 +53,8 @@ namespace plg { constexpr exception_guard_noexceptions( exception_guard_noexceptions&& other ) noexcept(std::is_nothrow_move_constructible_v) - : _completed(other._completed) { - other._completed = true; + : completed_(other.completed_) { + other.completed_ = true; } exception_guard_noexceptions(const exception_guard_noexceptions&) = delete; @@ -62,15 +62,15 @@ namespace plg { exception_guard_noexceptions& operator=(exception_guard_noexceptions&&) = delete; constexpr void complete() noexcept { - _completed = true; + completed_ = true; } constexpr ~exception_guard_noexceptions() { - PLUGIFY_ASSERT(_completed, "exception_guard not completed with exceptions disabled"); + PLUGIFY_ASSERT(completed_, "exception_guard not completed with exceptions disabled"); } private: - bool _completed = false; + bool completed_ = false; }; template @@ -84,15 +84,15 @@ namespace plg { template class scope_guard { - PLUGIFY_NO_UNIQUE_ADDRESS Func _func; + PLUGIFY_NO_UNIQUE_ADDRESS Func func_; public: constexpr explicit scope_guard(Func func) - : _func(std::move(func)) { + : func_(std::move(func)) { } constexpr ~scope_guard() { - _func(); + func_(); } scope_guard(const scope_guard&) = delete; diff --git a/include/plg/hash.hpp b/include/plg/hash.hpp index 4028e57..982f796 100644 --- a/include/plg/hash.hpp +++ b/include/plg/hash.hpp @@ -3,6 +3,8 @@ #include #include #include +#include +#include #include "plg/string.hpp" @@ -58,11 +60,10 @@ namespace plg { using is_transparent = void; // Enables heterogeneous lookup template - auto operator()(const T& str_like) const noexcept { - std::string_view str = str_like; + std::size_t operator()(const T& str) const noexcept { std::size_t hash = active_hash_traits::fnv_basis; // FNV-1a - for (const char& c : str) { - hash ^= static_cast(std::tolower(static_cast(c))); + for (const auto& c : str) { + hash ^= static_cast(std::tolower(c)); hash *= active_hash_traits::fnv_prime; } return hash; @@ -73,21 +74,14 @@ namespace plg { using is_transparent = void; // Enables heterogeneous lookup template - bool operator()(const T1& lhs_like, const T2& rhs_like) const noexcept { - std::string_view lhs = lhs_like; - std::string_view rhs = rhs_like; - - if (lhs.size() != rhs.size()) { - return false; - } - - for (size_t i = 0; i < lhs.size(); ++i) { - if (std::tolower(static_cast(lhs[i])) - != std::tolower(static_cast(rhs[i]))) { - return false; + bool operator()(const T1& lhs, const T2& rhs) const noexcept { + return std::lexicographical_compare( + lhs.begin(), lhs.end(), + rhs.begin(), rhs.end(), + [](const auto& ac, const auto& bc) { + return std::tolower(ac) < std::tolower(bc); } - } - return true; + ); } }; diff --git a/include/plg/inplace_vector.hpp b/include/plg/inplace_vector.hpp index 71292c8..db59904 100644 --- a/include/plg/inplace_vector.hpp +++ b/include/plg/inplace_vector.hpp @@ -68,15 +68,15 @@ namespace plg { template struct PLUGIFY_INPLACE_VECTOR_TRIVIALLY_RELOCATABLE_IF(std::is_trivially_relocatable_v) ipvbase { - size_t _size = 0; + size_t size_ = 0; union { - [[maybe_unused]] char _dummy; - T _data[N]; + [[maybe_unused]] char dummy_; + T data_[N]; }; - constexpr T *base_data() { return _data; } - constexpr const T *base_data() const { return _data; } - constexpr void set_size(size_t n) { _size = n; } + constexpr T *base_data() { return data_; } + constexpr const T *base_data() const { return data_; } + constexpr void set_size(size_t n) { size_ = n; } constexpr explicit ipvbase() noexcept {} ipvbase(const ipvbase& rhs) @@ -85,8 +85,8 @@ namespace plg { if constexpr (std::is_trivially_copy_constructible_v) { std::memmove((void*)this, (const void*)std::addressof(rhs), sizeof(ipvbase)); } else { - std::uninitialized_copy_n(rhs._data, rhs._size, _data); - _size = rhs._size; + std::uninitialized_copy_n(rhs.data_, rhs.size_, data_); + size_ = rhs.size_; } } ipvbase(ipvbase&& rhs) @@ -100,13 +100,13 @@ namespace plg { std::memmove((void*)this, (const void*)std::addressof(rhs), sizeof(ipvbase)); #if defined(__cpp_lib_trivially_relocatable) } else if constexpr (std::is_trivially_relocatable_v) { - std::uninitialized_relocate_n(rhs._data, rhs._size, _data); - _size = rhs._size; - rhs._size = 0; + std::uninitialized_relocate_n(rhs.data_, rhs.size_, data_); + size_ = rhs.size_; + rhs.size_ = 0; #endif // __cpp_lib_trivially_relocatable } else { - std::uninitialized_move_n(rhs._data, rhs._size, _data); - _size = rhs._size; + std::uninitialized_move_n(rhs.data_, rhs.size_, data_); + size_ = rhs.size_; } } void operator=(const ipvbase& rhs) @@ -116,14 +116,14 @@ namespace plg { std::memmove((void*)this, (const void*)std::addressof(rhs), sizeof(ipvbase)); } else if (this == std::addressof(rhs)) { // do nothing - } else if (rhs._size <= _size) { - std::copy(rhs._data, rhs._data + rhs._size, _data); - std::destroy(_data + rhs._size, _data + _size); - _size = rhs._size; + } else if (rhs.size_ <= size_) { + std::copy(rhs.data_, rhs.data_ + rhs.size_, data_); + std::destroy(data_ + rhs.size_, data_ + size_); + size_ = rhs.size_; } else { - std::copy(rhs._data, rhs._data + _size, _data); - std::uninitialized_copy(rhs._data + _size, rhs._data + rhs._size, _data + _size); - _size = rhs._size; + std::copy(rhs.data_, rhs.data_ + size_, data_); + std::uninitialized_copy(rhs.data_ + size_, rhs.data_ + rhs.size_, data_ + size_); + size_ = rhs.size_; } } void operator=(ipvbase&& rhs) @@ -133,21 +133,21 @@ namespace plg { std::memmove((void*)this, (const void*)std::addressof(rhs), sizeof(ipvbase)); } else if (this == std::addressof(rhs)) { // do nothing - } else if (rhs._size <= _size) { - std::move(rhs._data, rhs._data + rhs._size, _data); - std::destroy(_data + rhs._size, _data + _size); - _size = rhs._size; + } else if (rhs.size_ <= size_) { + std::move(rhs.data_, rhs.data_ + rhs.size_, data_); + std::destroy(data_ + rhs.size_, data_ + size_); + size_ = rhs.size_; } else { - std::move(rhs._data, rhs._data + _size, _data); + std::move(rhs.data_, rhs.data_ + size_, data_); #if defined(__cpp_lib_trivially_relocatable) if constexpr (std::is_trivially_relocatable_v) { - std::uninitialized_relocate(rhs._data + _size, rhs._data + rhs._size, _data + _size); - std::swap(rhs._size, _size); + std::uninitialized_relocate(rhs.data_ + size_, rhs.data_ + rhs.size_, data_ + size_); + std::swap(rhs.size_, size_); return; } #endif // __cpp_lib_trivially_relocatable - std::uninitialized_move(rhs._data + _size, rhs._data + rhs._size, _data + _size); - _size = rhs._size; + std::uninitialized_move(rhs.data_ + size_, rhs.data_ + rhs.size_, data_ + size_); + size_ = rhs.size_; } } @@ -163,13 +163,13 @@ namespace plg { constexpr #endif // PLUGIFY_CPP_VERSION >= 202002L ~ipvbase() { - std::destroy(_data, _data + _size); + std::destroy(data_, data_ + size_); } }; template struct ipvbase_zero { - static constexpr size_t _size = 0; + static constexpr size_t size_ = 0; constexpr T *base_data() { return nullptr; } constexpr const T *base_data() const { return nullptr; } constexpr void set_size(size_t) { } @@ -177,15 +177,15 @@ namespace plg { template struct ipvbase_trivial { - size_t _size = 0; + size_t size_ = 0; union { - [[maybe_unused]] char _dummy; - T _data[N]; + [[maybe_unused]] char dummy_; + T data_[N]; }; constexpr explicit ipvbase_trivial() {} - constexpr T *base_data() { return _data; } - constexpr const T *base_data() const { return _data; } - constexpr void set_size(size_t n) { _size = n; } + constexpr T *base_data() { return data_; } + constexpr const T *base_data() const { return data_; } + constexpr void set_size(size_t n) { size_ = n; } }; template @@ -202,7 +202,7 @@ namespace plg { template class inplace_vector : detail::ipvbase_assignable, detail::ipvbase_t { - using detail::ipvbase_t::_size; + using detail::ipvbase_t::size_; using detail::ipvbase_t::set_size; public: using value_type = T; @@ -277,12 +277,12 @@ namespace plg { { if (n > N) { throw_bad_alloc(); - } else if (_size >= n) { + } else if (size_ >= n) { std::fill_n(data(), n, value); - std::destroy(data() + n, data() + _size); + std::destroy(data() + n, data() + size_); } else { - std::fill_n(data(), _size, value); - std::uninitialized_fill_n(data() + _size, n - _size, value); + std::fill_n(data(), size_, value); + std::uninitialized_fill_n(data() + size_, n - size_, value); } set_size(n); } @@ -293,12 +293,12 @@ namespace plg { const size_type n = static_cast(std::distance(first, last)); if (n > N) { throw_bad_alloc(); - } else if (_size >= n) { + } else if (size_ >= n) { std::copy(first, last, data()); - std::destroy(data() + n, data() + _size); + std::destroy(data() + n, data() + size_); } else { - std::copy(first, first + _size, data()); - std::uninitialized_copy(first + _size, last, data() + _size); + std::copy(first, first + size_, data()); + std::uninitialized_copy(first + size_, last, data() + size_); } set_size(n); } @@ -329,13 +329,13 @@ namespace plg { size_t n = std::ranges::size(rg); if (n > N) { throw_bad_alloc(); - } else if (_size >= n) { + } else if (size_ >= n) { std::ranges::copy(first, last, data()); - std::destroy(data() + n, data() + _size); + std::destroy(data() + n, data() + size_); } else { - auto mid = std::ranges::next(first, _size, last); + auto mid = std::ranges::next(first, size_, last); std::ranges::copy(first, mid, data()); - std::ranges::uninitialized_copy(mid, last, data() + _size); + std::ranges::uninitialized_copy(mid, last, data() + size_); } set_size(n); } @@ -344,15 +344,15 @@ namespace plg { // iterators constexpr iterator begin() noexcept { return data(); } - constexpr iterator end() noexcept { return data() + _size; } + constexpr iterator end() noexcept { return data() + size_; } constexpr const_iterator begin() const noexcept { return data(); } - constexpr const_iterator end() const noexcept { return data() + _size; } + constexpr const_iterator end() const noexcept { return data() + size_; } constexpr reverse_iterator rbegin() noexcept { return reverse_iterator(end()); } constexpr reverse_iterator rend() noexcept { return reverse_iterator(begin()); } constexpr const_reverse_iterator rbegin() const noexcept { return const_reverse_iterator(end()); } constexpr const_reverse_iterator rend() const noexcept { return const_reverse_iterator(begin()); } constexpr const_iterator cbegin() const noexcept { return data(); } - constexpr const_iterator cend() const noexcept { return data() + _size; } + constexpr const_iterator cend() const noexcept { return data() + size_; } constexpr const_reverse_iterator crbegin() const noexcept { return const_reverse_iterator(end()); } constexpr const_reverse_iterator crend() const noexcept { return const_reverse_iterator(begin()); } @@ -361,12 +361,12 @@ namespace plg { { if (n > N) { throw_bad_alloc(); - } else if (n < _size) { - std::destroy(data() + n, data() + _size); + } else if (n < size_) { + std::destroy(data() + n, data() + size_); set_size(n); } else { - std::uninitialized_value_construct(data() + _size, data() + n); - set_size(_size + n); + std::uninitialized_value_construct(data() + size_, data() + n); + set_size(size_ + n); } } @@ -375,12 +375,12 @@ namespace plg { { if (n > N) { throw_bad_alloc(); - } else if (n < _size) { - std::destroy(data() + n, data() + _size); + } else if (n < size_) { + std::destroy(data() + n, data() + size_); set_size(n); } else { - std::uninitialized_fill(data() + _size, data() + n, value); - set_size(_size + n); + std::uninitialized_fill(data() + size_, data() + n, value); + set_size(size_ + n); } } @@ -403,7 +403,7 @@ namespace plg { } constexpr reference back() { PLUGIFY_ASSERT(!empty(), "called on an empty vector"); - return data()[_size - 1]; + return data()[size_ - 1]; } constexpr const_reference operator[](size_type pos) const { @@ -416,17 +416,17 @@ namespace plg { } constexpr const_reference back() const { PLUGIFY_ASSERT(!empty(), "called on an empty vector"); - return data()[_size - 1]; + return data()[size_ - 1]; } constexpr reference at(size_type i) { - if (i >= _size) { + if (i >= size_) { throw_out_of_range(); } return data()[i]; } constexpr const_reference at(size_type i) const { - if (i >= _size) { + if (i >= size_) { throw_out_of_range(); } return data()[i]; @@ -436,20 +436,20 @@ namespace plg { constexpr T* data() noexcept { return this->base_data(); } constexpr const T* data() const noexcept { return this->base_data(); } - constexpr size_type size() const noexcept { return _size; } + constexpr size_type size() const noexcept { return size_; } static constexpr size_type max_size() noexcept { return N; } static constexpr size_type capacity() noexcept { return N; } - [[nodiscard]] constexpr bool empty() const noexcept { return _size == 0; }; + [[nodiscard]] constexpr bool empty() const noexcept { return size_ == 0; }; // [inplace.vector.modifiers] template requires std::is_constructible_v value_type& unchecked_emplace_back(Args&&... args) { - // Precondition: (_size < N) - value_type* p = data() + _size; + // Precondition: (size_ < N) + value_type* p = data() + size_; p = std::construct_at(p, std::forward(args)...); - set_size(_size + 1); + set_size(size_ + 1); return *p; } value_type& unchecked_push_back(const value_type& value) @@ -466,7 +466,7 @@ namespace plg { template requires std::is_constructible_v constexpr value_type* try_emplace_back(Args&&... args) { - if (_size == N) { + if (size_ == N) { return nullptr; } return std::addressof(unchecked_emplace_back(static_cast(args)...)); @@ -485,7 +485,7 @@ namespace plg { template requires std::is_constructible_v value_type& emplace_back(Args&&... args) { - if (_size == N) { + if (size_ == N) { throw_bad_alloc(); } return unchecked_emplace_back(static_cast(args)...); @@ -512,8 +512,8 @@ namespace plg { #endif // __cpp_lib_ranges >= 201911L && __cpp_lib_ranges_to_container >= 202202L void pop_back() { - std::destroy_at(data() + _size - 1); - set_size(_size - 1); + std::destroy_at(data() + size_ - 1); + set_size(size_ - 1); } template @@ -538,7 +538,7 @@ namespace plg { iterator insert(const_iterator pos, size_type n, const value_type& value) requires std::is_copy_constructible_v { - if (N - _size < n) { + if (N - size_ < n) { throw_bad_alloc(); } auto it = iterator(pos); @@ -549,7 +549,7 @@ namespace plg { std::uninitialized_relocate_backward(it, oldend, oldend + n); try { std::uninitialized_fill_n(it, n, value); - set_size(_size + n); + set_size(size_ + n); } catch (...) { std::uninitialized_relocate(it + n, oldend + n, it); throw; @@ -559,7 +559,7 @@ namespace plg { #endif // Fill at the end of the vector, then rotate into place. std::uninitialized_fill_n(oldend, n, value); - set_size(_size + n); + set_size(size_ + n); std::rotate(it, oldend, oldend + n); return it; } @@ -571,7 +571,7 @@ namespace plg { auto oldend = end(); if constexpr (std::random_access_iterator) { size_type n = static_cast(std::distance(first, last)); - if (N - _size < n) { + if (N - size_ < n) { throw_bad_alloc(); } #if defined(__cpp_lib_trivially_relocatable) @@ -580,7 +580,7 @@ namespace plg { std::uninitialized_relocate_backward(it, oldend, oldend + n); try { std::uninitialized_copy_n(first, n, it); - set_size(_size + n); + set_size(size_ + n); } catch (...) { std::uninitialized_relocate(it + n, oldend + n, it); throw; @@ -590,7 +590,7 @@ namespace plg { #endif // Fill at the end of the vector, then rotate into place. std::uninitialized_copy_n(first, n, oldend); - set_size(_size + n); + set_size(size_ + n); std::rotate(it, oldend, oldend + n); } else { for (; first != last; ++first) { @@ -609,7 +609,7 @@ namespace plg { auto oldend = end(); if constexpr (std::ranges::sized_range) { size_type n = std::ranges::size(rg); - if (N - _size < n) { + if (N - size_ < n) { throw_bad_alloc(); } #if defined(__cpp_lib_trivially_relocatable) @@ -618,7 +618,7 @@ namespace plg { std::uninitialized_relocate_backward(it, oldend, oldend + n); try { std::ranges::uninitialized_copy_n(std::ranges::begin(rg), n, it, std::unreachable_sentinel); - set_size(_size + n); + set_size(size_ + n); } catch (...) { std::uninitialized_relocate(it + n, oldend + n, it); throw; @@ -628,7 +628,7 @@ namespace plg { #endif // Fill at the end of the vector, then rotate into place. std::ranges::uninitialized_copy_n(std::ranges::begin(rg), n, oldend, std::unreachable_sentinel); - set_size(_size + n); + set_size(size_ + n); std::rotate(it, oldend, oldend + n); } else { auto [rgend, newend] = std::ranges::uninitialized_copy(rg, std::ranges::subrange(oldend, data() + N)); @@ -659,13 +659,13 @@ namespace plg { if constexpr (std::is_trivially_relocatable_v) { std::destroy_at(it); std::uninitialized_relocate(it + 1, oldend, it); - set_size(_size - 1); + set_size(size_ - 1); return it; } #endif std::move(it + 1, oldend, it); std::destroy_at(oldend - 1); - set_size(_size - 1); + set_size(size_ - 1); return it; } @@ -681,18 +681,18 @@ namespace plg { if constexpr (std::is_trivially_relocatable_v) { std::destroy(ifirst, ilast); std::uninitialized_relocate(ilast, oldend, ifirst); - set_size(_size - n); + set_size(size_ - n); return ifirst; } #endif // __cpp_lib_trivially_relocatable std::destroy(std::move(ilast, oldend, ifirst), oldend); - set_size(_size - n); + set_size(size_ - n); } return ifirst; } constexpr void clear() noexcept { - std::destroy(data(), data() + _size); + std::destroy(data(), data() + size_); set_size(0); } @@ -701,20 +701,20 @@ namespace plg { requires (!std::is_const_v) { auto& a = *this; - if (a._size < b._size) { + if (a.size_ < b.size_) { b.swap(a); } else { - std::swap_ranges(a.data(), a.data() + b._size, b.data()); + std::swap_ranges(a.data(), a.data() + b.size_, b.data()); #if defined(__cpp_lib_trivially_relocatable) - size_t n = a._size; - a.set_size(b._size); - std::uninitialized_relocate(a.data() + b._size, a.data() + n, b.data() + b._size); + size_t n = a.size_; + a.set_size(b.size_); + std::uninitialized_relocate(a.data() + b.size_, a.data() + n, b.data() + b.size_); b.set_size(n); #else - std::uninitialized_move(a.data() + b._size, a.data() + a._size, b.data() + b._size); - std::destroy(a.data() + b._size, a.data() + a._size); + std::uninitialized_move(a.data() + b.size_, a.data() + a.size_, b.data() + b.size_); + std::destroy(a.data() + b.size_, a.data() + a.size_); if constexpr (N != 0) { - std::swap(a._size, b._size); + std::swap(a.size_, b.size_); } #endif } @@ -737,7 +737,7 @@ namespace plg { constexpr friend bool operator<(const inplace_vector& a, const inplace_vector& b) { const T* adata = a.data(); const T* bdata = b.data(); - size_t n = (a._size < b._size) ? a._size : b._size; + size_t n = (a.size_ < b.size_) ? a.size_ : b.size_; for (size_t i = 0; i < n; ++i) { if (adata[i] < bdata[i]) { return true; @@ -745,7 +745,7 @@ namespace plg { return false; } } - return (a._size < b._size); + return (a.size_ < b.size_); } constexpr friend bool operator>(const inplace_vector& a, const inplace_vector& b) { return (b < a); } constexpr friend bool operator<=(const inplace_vector& a, const inplace_vector& b) { return !(b < a); } diff --git a/include/plg/split_buffer.hpp b/include/plg/split_buffer.hpp index 0568d15..ddae84f 100644 --- a/include/plg/split_buffer.hpp +++ b/include/plg/split_buffer.hpp @@ -26,115 +26,115 @@ namespace plg { public: constexpr split_buffer_pointer_layout() - : _back_cap(nullptr) { + : back_cap_(nullptr) { } constexpr explicit split_buffer_pointer_layout(const allocator_type& alloc) - : _back_cap(nullptr) - , _alloc(alloc) { + : back_cap_(nullptr) + , alloc_(alloc) { } constexpr pointer front_cap() noexcept { - return _front_cap; + return front_cap_; } constexpr const_pointer front_cap() const noexcept { - return _front_cap; + return front_cap_; } constexpr pointer begin() noexcept { - return _begin; + return begin_; } constexpr const_pointer begin() const noexcept { - return _begin; + return begin_; } constexpr pointer end() noexcept { - return _end; + return end_; } constexpr pointer end() const noexcept { - return _end; + return end_; } constexpr size_type size() const noexcept { - return static_cast(_end - _begin); + return static_cast(end_ - begin_); } constexpr bool empty() const noexcept { - return _begin == _end; + return begin_ == end_; } constexpr size_type capacity() const noexcept { - return static_cast(_back_cap - _front_cap); + return static_cast(back_cap_ - front_cap_); } constexpr allocator_type& get_allocator() noexcept { - return _alloc; + return alloc_; } constexpr const allocator_type& get_allocator() const noexcept { - return _alloc; + return alloc_; } // Returns the sentinel object directly. Should be used in conjunction with automatic type // deduction, not explicit types. constexpr sentinel_type raw_sentinel() const noexcept { - return _end; + return end_; } constexpr sentinel_type raw_capacity() const noexcept { - return _back_cap; + return back_cap_; } constexpr void set_data(pointer new_first) noexcept { - _front_cap = new_first; + front_cap_ = new_first; } constexpr void set_valid_range(pointer new_begin, pointer new_end) noexcept { - _begin = new_begin; - _end = new_end; + begin_ = new_begin; + end_ = new_end; } constexpr void set_valid_range(pointer new_begin, size_type new_size) noexcept { - _begin = new_begin; - _end = _begin + new_size; + begin_ = new_begin; + end_ = begin_ + new_size; } constexpr void set_sentinel(pointer new_end) noexcept { - PLUGIFY_ASSERT(_front_cap <= new_end, "new_end cannot precede _front_cap"); - _end = new_end; + PLUGIFY_ASSERT(front_cap_ <= new_end, "new_end cannot precede front_cap_"); + end_ = new_end; } constexpr void set_sentinel(size_type new_size) noexcept { - _end = _begin + new_size; + end_ = begin_ + new_size; } constexpr void set_capacity(size_type new_capacity) noexcept { - _back_cap = _front_cap + new_capacity; + back_cap_ = front_cap_ + new_capacity; } constexpr void set_capacity(pointer new_capacity) noexcept { - _back_cap = new_capacity; + back_cap_ = new_capacity; } constexpr size_type front_spare() const noexcept { - return static_cast(_begin - _front_cap); + return static_cast(begin_ - front_cap_); } constexpr size_type back_spare() const noexcept { - return static_cast(_back_cap - _end); + return static_cast(back_cap_ - end_); } constexpr reference back() noexcept { - return *(_end - 1); + return *(end_ - 1); } constexpr const_reference back() const noexcept { - return *(_end - 1); + return *(end_ - 1); } constexpr void swap_without_allocator( @@ -143,42 +143,42 @@ namespace plg { value_type, alloc_rr&>& other ) noexcept { - std::swap(_front_cap, other._front_cap); - std::swap(_begin, other._begin); - std::swap(_back_cap, other._back_cap); - std::swap(_end, other._end); + std::swap(front_cap_, other.front_cap_); + std::swap(begin_, other.begin_); + std::swap(back_cap_, other.back_cap_); + std::swap(end_, other.end_); } constexpr void swap(split_buffer_pointer_layout& other) noexcept { - std::swap(_front_cap, other._front_cap); - std::swap(_begin, other._begin); - std::swap(_back_cap, other._back_cap); - std::swap(_end, other._end); - swap_allocator(_alloc, other._alloc); + std::swap(front_cap_, other.front_cap_); + std::swap(begin_, other.begin_); + std::swap(back_cap_, other.back_cap_); + std::swap(end_, other.end_); + swap_allocator(alloc_, other.alloc_); } constexpr void reset() noexcept { - _front_cap = nullptr; - _begin = nullptr; - _end = nullptr; - _back_cap = nullptr; + front_cap_ = nullptr; + begin_ = nullptr; + end_ = nullptr; + back_cap_ = nullptr; } constexpr void copy_without_alloc( const split_buffer_pointer_layout& other ) noexcept(std::is_nothrow_copy_assignable::value) { - _front_cap = other._front_cap; - _begin = other._begin; - _end = other._end; - _back_cap = other._back_cap; + front_cap_ = other.front_cap_; + begin_ = other.begin_; + end_ = other.end_; + back_cap_ = other.back_cap_; } private: - pointer _front_cap = nullptr; - pointer _begin = nullptr; - pointer _end = nullptr; - pointer _back_cap = nullptr; - PLUGIFY_NO_UNIQUE_ADDRESS allocator_type _alloc; + pointer front_cap_ = nullptr; + pointer begin_ = nullptr; + pointer end_ = nullptr; + pointer back_cap_ = nullptr; + PLUGIFY_NO_UNIQUE_ADDRESS allocator_type alloc_; template friend class split_buffer_pointer_layout; @@ -205,73 +205,73 @@ namespace plg { constexpr split_buffer_size_layout() = default; constexpr explicit split_buffer_size_layout(const allocator_type& alloc) - : _alloc(alloc) { + : alloc_(alloc) { } constexpr pointer front_cap() noexcept { - return _front_cap; + return front_cap_; } constexpr const_pointer front_cap() const noexcept { - return _front_cap; + return front_cap_; } constexpr pointer begin() noexcept { - return _begin; + return begin_; } constexpr const_pointer begin() const noexcept { - return _begin; + return begin_; } constexpr pointer end() noexcept { - return _begin + _size; + return begin_ + size_; } constexpr pointer end() const noexcept { - return _begin + _size; + return begin_ + size_; } constexpr size_type size() const noexcept { - return _size; + return size_; } constexpr bool empty() const noexcept { - return _size == 0; + return size_ == 0; } constexpr size_type capacity() const noexcept { - return _cap; + return cap_; } constexpr allocator_type& get_allocator() noexcept { - return _alloc; + return alloc_; } constexpr const allocator_type& get_allocator() const noexcept { - return _alloc; + return alloc_; } // Returns the sentinel object directly. Should be used in conjunction with automatic type // deduction, not explicit types. constexpr sentinel_type raw_sentinel() const noexcept { - return _size; + return size_; } constexpr sentinel_type raw_capacity() const noexcept { - return _cap; + return cap_; } constexpr void set_data(pointer new_first) noexcept { - _front_cap = new_first; + front_cap_ = new_first; } constexpr void set_valid_range(pointer new_begin, pointer new_end) noexcept { // Size-based split_buffers track their size directly: we need to explicitly update the size // when the front is adjusted. - _size -= new_begin - _begin; - _begin = new_begin; + size_ -= new_begin - begin_; + begin_ = new_begin; set_sentinel(new_end); } @@ -279,44 +279,44 @@ namespace plg { set_valid_range(pointer new_begin, size_type new_size) noexcept { // Size-based split_buffers track their size directly: we need to explicitly update the size // when the front is adjusted. - _size -= new_begin - _begin; - _begin = new_begin; + size_ -= new_begin - begin_; + begin_ = new_begin; set_sentinel(new_size); } constexpr void set_sentinel(pointer new_end) noexcept { - _LIBCPP_ASSERT_INTERNAL(_front_cap <= new_end, "new_end cannot precede _front_cap"); - _size += new_end - end(); + _LIBCPP_ASSERT_INTERNAL(front_cap_ <= new_end, "new_end cannot precede front_cap_"); + size_ += new_end - end(); } constexpr void set_sentinel(size_type new_size) noexcept { - _size = new_size; + size_ = new_size; } constexpr void set_capacity(size_type new_capacity) noexcept { - _cap = new_capacity; + cap_ = new_capacity; } constexpr void set_capacity(pointer new_capacity) noexcept { - _cap = new_capacity - _begin; + cap_ = new_capacity - begin_; } constexpr size_type front_spare() const noexcept { - return static_cast(_begin - _front_cap); + return static_cast(begin_ - front_cap_); } constexpr size_type back_spare() const noexcept { - // `_cap - _end` tells us the total number of spares when in size-mode. We need to remove + // `cap_ - end_` tells us the total number of spares when in size-mode. We need to remove // the front_spare from the count. - return _cap - _size - front_spare(); + return cap_ - size_ - front_spare(); } constexpr reference back() noexcept { - return _begin[_size - 1]; + return begin_[size_ - 1]; } constexpr const_reference back() const noexcept { - return _begin[_size - 1]; + return begin_[size_ - 1]; } constexpr void swap_without_allocator( @@ -325,42 +325,42 @@ namespace plg { value_type, alloc_rr&>& other ) noexcept { - std::swap(_front_cap, other._front_cap); - std::swap(_begin, other._begin); - std::swap(_cap, other._cap); - std::swap(_size, other._size); + std::swap(front_cap_, other.front_cap_); + std::swap(begin_, other.begin_); + std::swap(cap_, other.cap_); + std::swap(size_, other.size_); } constexpr void swap(split_buffer_size_layout& other) noexcept { - std::swap(_front_cap, other._front_cap); - std::swap(_begin, other._begin); - std::swap(_cap, other._cap); - std::swap(_size, other._size); - swap_allocator(_alloc, other._alloc); + std::swap(front_cap_, other.front_cap_); + std::swap(begin_, other.begin_); + std::swap(cap_, other.cap_); + std::swap(size_, other.size_); + swap_allocator(alloc_, other.alloc_); } constexpr void reset() noexcept { - _front_cap = nullptr; - _begin = nullptr; - _size = 0; - _cap = 0; + front_cap_ = nullptr; + begin_ = nullptr; + size_ = 0; + cap_ = 0; } constexpr void copy_without_alloc( const split_buffer_size_layout& other ) noexcept(std::is_nothrow_copy_assignable::value) { - _front_cap = other._front_cap; - _begin = other._begin; - _cap = other._cap; - _size = other._size; + front_cap_ = other.front_cap_; + begin_ = other.begin_; + cap_ = other.cap_; + size_ = other.size_; } private: - pointer _front_cap = nullptr; - pointer _begin = nullptr; - size_type _size = 0; - size_type _cap = 0; - PLUGIFY_NO_UNIQUE_ADDRESS allocator_type _alloc; + pointer front_cap_ = nullptr; + pointer begin_ = nullptr; + size_type size_ = 0; + size_type cap_ = 0; + PLUGIFY_NO_UNIQUE_ADDRESS allocator_type alloc_; template friend class split_buffer_size_layout; @@ -377,11 +377,11 @@ namespace plg { // // |oooooooooooooooooooxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxoooooooooooooooooooooooo| // ^ ^ ^ ^ - // _front_cap _begin _end _back_cap + // front_cap_ begin_ end_ back_cap_ // - // The range [_front_cap, _begin) contains uninitialized memory. It is referred to as the "front - // spare capacity". The range [_begin, _end) contains valid objects. It is referred to as the "valid - // range". The range [_end, _back_cap) contains uninitialized memory. It is referred to as the "back + // The range [front_cap_, begin_) contains uninitialized memory. It is referred to as the "front + // spare capacity". The range [begin_, end_) contains valid objects. It is referred to as the "valid + // range". The range [end_, back_cap_) contains uninitialized memory. It is referred to as the "back // spare capacity". // // The layout of `split_buffer` is determined by the `Layout` template template parameter. This @@ -641,20 +641,20 @@ namespace plg { pointer p, size_type n ) noexcept - : _pos(p) - , _end(p + n) - , _parent(parent) { + : pos_(p) + , end_(p + n) + , parent_(parent) { } constexpr ~ConstructTransaction() { - _parent->set_sentinel(_pos); + parent_->set_sentinel(pos_); } - pointer _pos; - const pointer _end; + pointer pos_; + const pointer end_; private: - split_buffer* _parent; + split_buffer* parent_; }; template class L2> @@ -669,8 +669,8 @@ namespace plg { template class Layout> constexpr void split_buffer::construct_at_end(size_type n) { ConstructTransaction tx(this, end(), n); - for (; tx._pos != tx._end; ++tx._pos) { - alloc_traits::construct(get_allocator(), std::to_address(tx._pos)); + for (; tx.pos_ != tx.end_; ++tx.pos_) { + alloc_traits::construct(get_allocator(), std::to_address(tx.pos_)); } } @@ -684,8 +684,8 @@ namespace plg { constexpr void split_buffer::construct_at_end(size_type n, const_reference x) { ConstructTransaction tx(this, end(), n); - for (; tx._pos != tx._end; ++tx._pos) { - alloc_traits::construct(get_allocator(), std::to_address(tx._pos), x); + for (; tx.pos_ != tx.end_; ++tx.pos_) { + alloc_traits::construct(get_allocator(), std::to_address(tx.pos_), x); } } @@ -725,8 +725,8 @@ namespace plg { constexpr void split_buffer::construct_at_end_with_size(ForwardIterator first, size_type n) { ConstructTransaction tx(this, end(), n); - for (; tx._pos != tx._end; ++tx._pos, (void) ++first) { - alloc_traits::construct(get_allocator(), std::to_address(tx._pos), *first); + for (; tx.pos_ != tx.end_; ++tx.pos_, (void) ++first) { + alloc_traits::construct(get_allocator(), std::to_address(tx.pos_), *first); } } diff --git a/include/plg/string.hpp b/include/plg/string.hpp index 316673c..e6c08e8 100644 --- a/include/plg/string.hpp +++ b/include/plg/string.hpp @@ -650,7 +650,7 @@ namespace plg { template struct padding { - char _pad[N]; + char padding[N]; }; template <> @@ -687,7 +687,7 @@ namespace plg { // This string implementation doesn't contain any references into itself. It only contains a // bit that says whether it is in small or large string mode, so the entire structure is // trivially relocatable if its members are. -#if __has_feature(address_sanitizer) +#if PLUGIFY_INSTRUMENTED_WITH_ASAN // When compiling with AddressSanitizer (ASan), basic_string cannot be trivially // relocatable. Because the object's memory might be poisoned when its content // is kept inside objects memory (short string optimization), instead of in allocated @@ -704,9 +704,9 @@ namespace plg { is_trivially_relocatable::value, basic_string, void>; -#endif +#endif // PLUGIFY_INSTRUMENTED_WITH_ASAN -#if __has_cpp_attribute(__no_sanitize__) && __has_feature(address_sanitizer) +#if PLUGIFY_INSTRUMENTED_WITH_ASAN && __has_cpp_attribute(__no_sanitize__) # define PLUGIFY_INTERNAL_MEMORY_ACCESS __attribute__((__no_sanitize__("address"))) // This macro disables AddressSanitizer (ASan) instrumentation for a specific function, // allowing memory accesses that would normally trigger ASan errors to proceed without crashing. @@ -715,9 +715,9 @@ namespace plg { // by other parts of the program. #else # define PLUGIFY_INTERNAL_MEMORY_ACCESS -#endif +#endif // PLUGIFY_INSTRUMENTED_WITH_ASAN -#if __has_feature(address_sanitizer) +#if PLUGIFY_INSTRUMENTED_WITH_ASAN constexpr pointer asan_volatile_wrapper(pointer const& ptr) const { if (std::is_constant_evaluated()) { return ptr; @@ -741,7 +741,7 @@ namespace plg { # define PLUGIFY_ASAN_VOLATILE_WRAPPER(PTR) asan_volatile_wrapper(PTR) #else # define PLUGIFY_ASAN_VOLATILE_WRAPPER(PTR) PTR -#endif +#endif // PLUGIFY_INSTRUMENTED_WITH_ASAN static_assert(!std::is_array_v, "Character type of basic_string must not be an array"); static_assert( @@ -781,32 +781,32 @@ namespace plg { constexpr long_() = default; constexpr long_(alloc_result alloc, size_type size) - : _data(alloc.ptr) - , _size(size) - , _cap(alloc.count / endian_factor) - , _is_long(true) { + : data_(alloc.ptr) + , size_(size) + , cap_(alloc.count / endian_factor) + , is_long_(true) { PLUGIFY_ASSERT(!fits_in_sso(alloc.count), "Long capacity should always be larger than the SSO"); } - pointer _data; - size_type _size; - size_type _cap : sizeof(size_type) * char_bit - 1; - size_type _is_long : 1; + pointer data_; + size_type size_; + size_type cap_ : sizeof(size_type) * char_bit - 1; + size_type is_long_ : 1; }; static constexpr size_type min_cap = ((sizeof(long_) - 1) / sizeof(value_type) > 2 ? (sizeof(long_) - 1) / sizeof(value_type) : 2) + 1; struct short_ { constexpr short_() - : _data{} - , _spare_size(min_cap - 1) - , _is_long(false) { + : data_{} + , spare_size_(min_cap - 1) + , is_long_(false) { } - value_type _data[min_cap - 1]; - PLUGIFY_NO_UNIQUE_ADDRESS padding _padding; - uint8_t _spare_size : 7; - uint8_t _is_long : 1; + value_type data_[min_cap - 1]; + PLUGIFY_NO_UNIQUE_ADDRESS padding padding_; + uint8_t spare_size_ : 7; + uint8_t is_long_ : 1; }; // The endian_factor is required because the field we use to store the size @@ -836,21 +836,21 @@ namespace plg { union rep { short_ s{}; long_ l; - } _rep; + } rep_; PLUGIFY_NO_UNIQUE_ADDRESS - allocator_type _alloc; + allocator_type alloc_; // annotate the string with its size() at scope exit. The string has to be in a valid state // at that point. struct annotate_new_size { - basic_string& _str; + basic_string& str_; constexpr explicit annotate_new_size(basic_string& str) - : _str(str) { + : str_(str) { } constexpr void operator()() { - _str.annotate_new(_str.size()); + str_.annotate_new(str_.size()); } }; @@ -858,13 +858,13 @@ namespace plg { // but don't initialize the characters. The contents of the string, including the null // terminator, must be initialized separately. constexpr /*explicit*/ basic_string(uninitialized_size_tag, size_type size, const allocator_type& a) - : _alloc(a) { + : alloc_(a) { init_internal_buffer(size); } template constexpr basic_string(init_with_sentinel_tag, Iter first, Sent last, const allocator_type& a) - : _alloc(a) { + : alloc_(a) { init_with_sentinel(std::move(first), std::move(last)); } @@ -880,20 +880,20 @@ namespace plg { static const size_type npos = static_cast(-1); constexpr basic_string() noexcept(std::is_nothrow_default_constructible_v) - : _rep(short_()) { + : rep_(short_()) { annotate_new(0); } constexpr /*explicit*/ basic_string(const allocator_type& a) noexcept - : _rep(short_()) - , _alloc(a) { + : rep_(short_()) + , alloc_(a) { annotate_new(0); } constexpr PLUGIFY_INTERNAL_MEMORY_ACCESS basic_string(const basic_string& str) - : _alloc(alloc_traits::select_on_container_copy_construction(str._alloc)) { + : alloc_(alloc_traits::select_on_container_copy_construction(str.alloc_)) { if (!str.is_long()) { - _rep = str._rep; + rep_ = str.rep_; annotate_new(get_short_size()); } else { init_copy_ctor_external(std::to_address(str.get_long_pointer()), str.get_long_size()); @@ -902,9 +902,9 @@ namespace plg { constexpr PLUGIFY_INTERNAL_MEMORY_ACCESS basic_string(const basic_string& str, const allocator_type& a) - : _alloc(a) { + : alloc_(a) { if (!str.is_long()) { - _rep = str._rep; + rep_ = str.rep_; annotate_new(get_short_size()); } else { init_copy_ctor_external(std::to_address(str.get_long_pointer()), str.get_long_size()); @@ -916,14 +916,14 @@ namespace plg { // PLUGIFY_INTERNAL_MEMORY_ACCESS does not work consistently during // initialization of r_, so we instead unpoison str's memory manually first. str's // memory needs to be unpoisoned only in the case where it's a short string. - : _rep([](basic_string& s) -> decltype(s._rep)&& { + : rep_([](basic_string& s) -> decltype(s.rep_)&& { if (!s.is_long()) { s.annotate_delete(); } - return std::move(s._rep); + return std::move(s.rep_); }(str)) - , _alloc(std::move(str._alloc)) { - str._rep = rep(); + , alloc_(std::move(str.alloc_)) { + str.rep_ = rep(); str.annotate_new(0); if (!is_long()) { annotate_new(size()); @@ -931,18 +931,18 @@ namespace plg { } constexpr basic_string(basic_string&& str, const allocator_type& a) - : _alloc(a) { - if (str.is_long() && a != str._alloc) { // copy, not move + : alloc_(a) { + if (str.is_long() && a != str.alloc_) { // copy, not move init(std::to_address(str.get_long_pointer()), str.get_long_size()); } else { if (std::is_constant_evaluated()) { - _rep = rep(); + rep_ = rep(); } if (!str.is_long()) { str.annotate_delete(); } - _rep = str._rep; - str._rep = rep(); + rep_ = str.rep_; + str.rep_ = rep(); str.annotate_new(0); if (!is_long() && this != std::addressof(str)) { annotate_new(size()); @@ -959,7 +959,7 @@ namespace plg { constexpr basic_string(const CharT* PLUGIFY_NO_NULL s, const Allocator& a) requires(is_allocator) - : _alloc(a) { + : alloc_(a) { PLUGIFY_ASSERT(s != nullptr, "basic_string(const char*, allocator) detected nullptr"); init(s, traits_type::length(s)); } @@ -972,7 +972,7 @@ namespace plg { } constexpr basic_string(const CharT* s, size_type n, const Allocator& a) - : _alloc(a) { + : alloc_(a) { PLUGIFY_ASSERT( n == 0 || s != nullptr, "basic_string(const char*, n, allocator) detected nullptr" @@ -994,13 +994,13 @@ namespace plg { size_type n, const Allocator& alloc = Allocator() ) - : _alloc(alloc) { + : alloc_(alloc) { if (pos > str.size()) { this->throw_out_of_range(); } auto len = std::min(n, str.size() - pos); - if (alloc_traits::is_always_equal::value || alloc == str._alloc) { + if (alloc_traits::is_always_equal::value || alloc == str.alloc_) { move_assign(std::move(str), pos, len); } else { // Perform a copy because the allocators are not compatible. @@ -1010,7 +1010,7 @@ namespace plg { constexpr basic_string(size_type n, CharT c, const Allocator& a) requires(is_allocator) - : _alloc(a) { + : alloc_(a) { init(n, c); } @@ -1020,7 +1020,7 @@ namespace plg { size_type n, const Allocator& a = Allocator() ) - : _alloc(a) { + : alloc_(a) { size_type str_sz = str.size(); if (pos > str_sz) { this->throw_out_of_range(); @@ -1029,7 +1029,7 @@ namespace plg { } constexpr basic_string(const basic_string& str, size_type pos, const Allocator& a = Allocator()) - : _alloc(a) { + : alloc_(a) { size_type str_sz = str.size(); if (pos > str_sz) { this->throw_out_of_range(); @@ -1044,7 +1044,7 @@ namespace plg { size_type n, const allocator_type& a = allocator_type() ) - : _alloc(a) { + : alloc_(a) { self_view sv0 = t; self_view sv = sv0.substr(pos, n); init(sv.data(), sv.size()); @@ -1058,7 +1058,7 @@ namespace plg { template T> constexpr /*explicit*/ basic_string(const T& t, const allocator_type& a) - : _alloc(a) { + : alloc_(a) { self_view sv = t; init(sv.data(), sv.size()); } @@ -1070,14 +1070,14 @@ namespace plg { template constexpr basic_string(InputIterator first, InputIterator last, const allocator_type& a) - : _alloc(a) { + : alloc_(a) { init(first, last); } #if PLUGIFY_HAS_CXX23 template Range> constexpr basic_string(std::from_range_t, Range&& range, const allocator_type& a = allocator_type()) - : _alloc(a) { + : alloc_(a) { if constexpr (std::ranges::forward_range || std::ranges::sized_range) { init_with_size( std::ranges::begin(range), @@ -1095,7 +1095,7 @@ namespace plg { } constexpr basic_string(std::initializer_list il, const Allocator& a) - : _alloc(a) { + : alloc_(a) { init(il.begin(), il.end()); } @@ -1194,7 +1194,7 @@ namespace plg { constexpr size_type max_size() const noexcept { constexpr bool uses_lsb = endian_factor == 2; - if (size_type m = alloc_traits::max_size(_alloc); + if (size_type m = alloc_traits::max_size(alloc_); m <= std::numeric_limits::max() / 2) { size_type res = m - alignment; @@ -1317,7 +1317,7 @@ namespace plg { template constexpr basic_string& append(InputIterator first, InputIterator last) { - const basic_string temp(first, last, _alloc); + const basic_string temp(first, last, alloc_); append(temp.data(), temp.size()); return *this; } @@ -1341,7 +1341,7 @@ namespace plg { set_size(sz + n); return *this; } else { - const basic_string temp(first, last, _alloc); + const basic_string temp(first, last, alloc_); return append(temp.data(), temp.size()); } } @@ -1389,13 +1389,13 @@ namespace plg { constexpr void move_assign(basic_string&& str, size_type pos, size_type len) { // Pilfer the allocation from str. - PLUGIFY_ASSERT(_alloc == str._alloc, "move_assign called with wrong allocator"); + PLUGIFY_ASSERT(alloc_ == str.alloc_, "move_assign called with wrong allocator"); size_type old_sz = str.size(); if (!str.is_long()) { str.annotate_delete(); } - _rep = str._rep; - str._rep = rep(); + rep_ = str.rep_; + str.rep_ = rep(); str.annotate_new(0); Traits::move(data(), data() + pos, len); @@ -1510,7 +1510,7 @@ namespace plg { return insert_with_size(position, std::ranges::begin(range), std::ranges::end(range), n); } else { - basic_string temp(std::from_range, std::forward(range), _alloc); + basic_string temp(std::from_range, std::forward(range), alloc_); return insert(position, temp.data(), temp.data() + temp.size()); } } @@ -1524,7 +1524,7 @@ namespace plg { template constexpr iterator insert(const_iterator pos, InputIterator first, InputIterator last) { - const basic_string temp(first, last, _alloc); + const basic_string temp(first, last, alloc_); return insert(pos, temp.data(), temp.data() + temp.size()); } @@ -1605,7 +1605,7 @@ namespace plg { template constexpr basic_string& replace(const_iterator i1, const_iterator i2, InputIterator j1, InputIterator j2) { - const basic_string temp(j1, j2, _alloc); + const basic_string temp(j1, j2, alloc_); return replace(i1, i2, temp); } @@ -1613,7 +1613,7 @@ namespace plg { template Range> constexpr basic_string& replace_with_range(const_iterator i1, const_iterator i2, Range&& range) { - basic_string temp(std::from_range, std::forward(range), _alloc); + basic_string temp(std::from_range, std::forward(range), alloc_); return replace(i1, i2, temp); } #endif @@ -1651,7 +1651,7 @@ namespace plg { } constexpr allocator_type get_allocator() const noexcept { - return _alloc; + return alloc_; } // find @@ -1890,7 +1890,7 @@ namespace plg { // starts_with constexpr bool starts_with(self_view sv) const noexcept { - return self_view(data(), size()).starts_with(sv); + return self_view(typename self_view::assume_valid(), data(), size()).starts_with(sv); } constexpr bool starts_with(value_type c) const noexcept { @@ -1904,7 +1904,7 @@ namespace plg { // ends_with constexpr bool ends_with(self_view sv) const noexcept { - return self_view(data(), size()).ends_with(sv); + return self_view(typename self_view::assume_valid(), data(), size()).ends_with(sv); } constexpr bool ends_with(value_type c) const noexcept { @@ -1918,25 +1918,25 @@ namespace plg { // contains constexpr bool contains(self_view sv) const noexcept { - return self_view(data(), size()).contains(sv); + return self_view(typename self_view::assume_valid(), data(), size()).contains(sv); } constexpr bool contains(value_type c) const noexcept { - return self_view(data(), size()).contains(c); + return self_view(typename self_view::assume_valid(), data(), size()).contains(c); } constexpr bool contains(const value_type* PLUGIFY_NO_NULL s) const { - return self_view(data(), size()).contains(s); + return self_view(typename self_view::assume_valid(), data(), size()).contains(s); } [[nodiscard]] constexpr bool invariants() const; private: [[nodiscard]] constexpr PLUGIFY_INTERNAL_MEMORY_ACCESS bool is_long() const noexcept { - if (std::is_constant_evaluated() && __builtin_constant_p(_rep.l._is_long)) { - return _rep.l._is_long; + if (std::is_constant_evaluated() && __builtin_constant_p(rep_.l.is_long_)) { + return rep_.l.is_long_; } - return _rep.s._is_long; + return rep_.s.is_long_; } static constexpr bool fits_in_sso(size_type sz) { @@ -2008,22 +2008,22 @@ namespace plg { s < min_cap, "s should never be greater than or equal to the short string capacity" ); - _rep.s._spare_size = (min_cap - 1) - s; - _rep.s._is_long = false; + rep_.s.spare_size_ = (min_cap - 1) - s; + rep_.s.is_long_ = false; } constexpr PLUGIFY_INTERNAL_MEMORY_ACCESS size_type get_short_size() const noexcept { - PLUGIFY_ASSERT(!_rep.s._is_long, "String has to be short when trying to get the short size"); - return (min_cap - 1) - _rep.s._spare_size; + PLUGIFY_ASSERT(!rep_.s.is_long_, "String has to be short when trying to get the short size"); + return (min_cap - 1) - rep_.s.spare_size_; } constexpr void set_long_size(size_type s) noexcept { - _rep.l._size = s; + rep_.l.size_ = s; } constexpr size_type get_long_size() const noexcept { - PLUGIFY_ASSERT(_rep.l._is_long, "String has to be long when trying to get the long size"); - return _rep.l._size; + PLUGIFY_ASSERT(rep_.l.is_long_, "String has to be long when trying to get the long size"); + return rep_.l.size_; } constexpr void set_size(size_type s) noexcept { @@ -2035,29 +2035,29 @@ namespace plg { } constexpr size_type get_long_cap() const noexcept { - PLUGIFY_ASSERT(_rep.l._is_long, "String has to be long when trying to get the long capacity"); - return _rep.l._cap * endian_factor; + PLUGIFY_ASSERT(rep_.l.is_long_, "String has to be long when trying to get the long capacity"); + return rep_.l.cap_ * endian_factor; } constexpr pointer get_long_pointer() noexcept { - PLUGIFY_ASSERT(_rep.l._is_long, "String has to be long when trying to get the long pointer"); - return PLUGIFY_ASAN_VOLATILE_WRAPPER(_rep.l._data); + PLUGIFY_ASSERT(rep_.l.is_long_, "String has to be long when trying to get the long pointer"); + return PLUGIFY_ASAN_VOLATILE_WRAPPER(rep_.l.data_); } constexpr const_pointer get_long_pointer() const noexcept { - PLUGIFY_ASSERT(_rep.l._is_long, "String has to be long when trying to get the long pointer"); - return PLUGIFY_ASAN_VOLATILE_WRAPPER(_rep.l._data); + PLUGIFY_ASSERT(rep_.l.is_long_, "String has to be long when trying to get the long pointer"); + return PLUGIFY_ASAN_VOLATILE_WRAPPER(rep_.l.data_); } constexpr PLUGIFY_INTERNAL_MEMORY_ACCESS pointer get_short_pointer() noexcept { return PLUGIFY_ASAN_VOLATILE_WRAPPER( - std::pointer_traits::pointer_to(_rep.s._data[0]) + std::pointer_traits::pointer_to(rep_.s.data_[0]) ); } constexpr PLUGIFY_INTERNAL_MEMORY_ACCESS const_pointer get_short_pointer() const noexcept { return PLUGIFY_ASAN_VOLATILE_WRAPPER( - std::pointer_traits::pointer_to(_rep.s._data[0]) + std::pointer_traits::pointer_to(rep_.s.data_[0]) ); } @@ -2094,22 +2094,22 @@ namespace plg { constexpr void reset_internal_buffer() { annotate_delete(); if (is_long()) { - alloc_traits::deallocate(_alloc, get_long_pointer(), get_long_cap()); + alloc_traits::deallocate(alloc_, get_long_pointer(), get_long_cap()); } - _rep.s = short_(); + rep_.s = short_(); } // Replace the current buffer with alloc; the first size elements constitute a string constexpr void replace_internal_buffer(long_ alloc) { reset_internal_buffer(); - _rep.l = alloc; + rep_.l = alloc; } // Initialize the internal buffer to hold size elements // The elements and null terminator have to be set by the caller constexpr pointer init_internal_buffer(size_type size) { if (std::is_constant_evaluated()) { - _rep = rep(); + rep_ = rep(); } if (size > max_size()) { @@ -2121,7 +2121,7 @@ namespace plg { annotate_new(size); return get_short_pointer(); } else { - _rep.l = allocate_long_buffer(_alloc, size); + rep_.l = allocate_long_buffer(alloc_, size); annotate_new(size); return get_long_pointer(); } @@ -2270,18 +2270,18 @@ namespace plg { } constexpr void copy_assign_alloc(const basic_string& str, std::true_type) { - if (_alloc == str._alloc) { - _alloc = str._alloc; + if (alloc_ == str.alloc_) { + alloc_ = str.alloc_; } else { if (!str.is_long()) { reset_internal_buffer(); - _alloc = str._alloc; + alloc_ = str.alloc_; } else { annotate_delete(); [[maybe_unused]] auto guard = make_scope_guard(annotate_new_size(*this)); - auto alloc = str._alloc; + auto alloc = str.alloc_; replace_internal_buffer(allocate_long_buffer(alloc, str.size())); - _alloc = std::move(alloc); + alloc_ = std::move(alloc); } } } @@ -2307,7 +2307,7 @@ namespace plg { basic_string& c, std::true_type ) noexcept(std::is_nothrow_move_assignable_v) { - _alloc = std::move(c._alloc); + alloc_ = std::move(c.alloc_); } constexpr void move_assign_alloc(basic_string&, std::false_type) noexcept { @@ -2433,7 +2433,7 @@ namespace plg { template constexpr void basic_string::init_with_sentinel(InputIterator first, Sentinel last) { - _rep = rep(); + rep_ = rep(); annotate_new(0); #if PLUGIFY_HAS_EXCEPTIONS @@ -2500,23 +2500,23 @@ namespace plg { : ms; annotate_delete(); [[maybe_unused]] auto guard = make_scope_guard(annotate_new_size(*this)); - long_ buffer = allocate_long_buffer(_alloc, cap); + long_ buffer = allocate_long_buffer(alloc_, cap); if (n_copy != 0) { - traits_type::copy(std::to_address(buffer._data), std::to_address(old_p), n_copy); + traits_type::copy(std::to_address(buffer.data_), std::to_address(old_p), n_copy); } if (n_add != 0) { - traits_type::copy(std::to_address(buffer._data) + n_copy, p_new_stuff, n_add); + traits_type::copy(std::to_address(buffer.data_) + n_copy, p_new_stuff, n_add); } size_type sec_cp_sz = old_sz - n_del - n_copy; if (sec_cp_sz != 0) { traits_type::copy( - std::to_address(buffer._data) + n_copy + n_add, + std::to_address(buffer.data_) + n_copy + n_add, std::to_address(old_p) + n_copy + n_del, sec_cp_sz ); } - buffer._size = n_copy + n_add + sec_cp_sz; - traits_type::assign(buffer._data[buffer._size], value_type()); + buffer.size_ = n_copy + n_add + sec_cp_sz; + traits_type::assign(buffer.data_[buffer.size_], value_type()); replace_internal_buffer(buffer); } @@ -2539,14 +2539,14 @@ namespace plg { size_type cap = old_cap < ms / 2 - alignment ? recommend(std::max(old_cap + delta_cap, 2 * old_cap)) : ms; - long_ buffer = allocate_long_buffer(_alloc, cap); + long_ buffer = allocate_long_buffer(alloc_, cap); if (n_copy != 0) { - traits_type::copy(std::to_address(buffer._data), std::to_address(old_p), n_copy); + traits_type::copy(std::to_address(buffer.data_), std::to_address(old_p), n_copy); } size_type sec_cp_sz = old_sz - n_del - n_copy; if (sec_cp_sz != 0) { traits_type::copy( - std::to_address(buffer._data) + n_copy + n_add, + std::to_address(buffer.data_) + n_copy + n_add, std::to_address(old_p) + n_copy + n_del, sec_cp_sz ); @@ -2554,7 +2554,7 @@ namespace plg { // This is -1 to make sure the caller sets the size properly, since old versions of this // function didn't set the size at all. - buffer._size = npos; + buffer.size_ = npos; replace_internal_buffer(buffer); set_long_size(old_sz - n_del + n_add); } @@ -2671,7 +2671,7 @@ namespace plg { annotate_delete(); [[maybe_unused]] auto guard = make_scope_guard(annotate_new_size(*this)); - _rep = str._rep; + rep_ = str.rep_; return *this; } @@ -2681,7 +2681,7 @@ namespace plg { basic_string::move_assign(basic_string& str, std::false_type) noexcept( alloc_traits::is_always_equal::value ) { - if (_alloc != str._alloc) { + if (alloc_ != str.alloc_) { assign(str); } else { move_assign(str, std::true_type()); @@ -2699,7 +2699,7 @@ namespace plg { bool str_was_short = !str.is_long(); move_assign_alloc(str); - _rep = str._rep; + rep_ = str.rep_; str.set_short_size(0); traits_type::assign(str.get_short_pointer()[0], value_type()); @@ -2728,7 +2728,7 @@ namespace plg { template constexpr void basic_string::assign_with_sentinel(InputIterator first, Sentinel last) { - const basic_string temp(init_with_sentinel_tag(), std::move(first), std::move(last), _alloc); + const basic_string temp(init_with_sentinel_tag(), std::move(first), std::move(last), alloc_); assign(temp.data(), temp.size()); } @@ -2974,7 +2974,7 @@ namespace plg { if (string_is_trivial_iterator_v && !addr_in_range(*first)) { return insert_from_safe_copy(n, ip, std::move(first), std::move(last)); } else { - const basic_string temp(init_with_sentinel_tag(), std::move(first), std::move(last), _alloc); + const basic_string temp(init_with_sentinel_tag(), std::move(first), std::move(last), alloc_); return insert_from_safe_copy(n, ip, temp.begin(), temp.end()); } } @@ -3228,9 +3228,9 @@ namespace plg { } [[maybe_unused]] annotation_guard g(*this); - long_ buffer = allocate_long_buffer(_alloc, requested_capacity); - buffer._size = size(); - traits_type::copy(std::to_address(buffer._data), data(), buffer._size + 1); + long_ buffer = allocate_long_buffer(alloc_, requested_capacity); + buffer.size_ = size(); + traits_type::copy(std::to_address(buffer.data_), data(), buffer.size_ + 1); replace_internal_buffer(buffer); } @@ -3252,7 +3252,7 @@ namespace plg { [[maybe_unused]] annotation_guard g(*this); set_short_size(size); traits_type::copy(std::to_address(get_short_pointer()), std::to_address(ptr), size + 1); - alloc_traits::deallocate(_alloc, ptr, cap); + alloc_traits::deallocate(alloc_, ptr, cap); return; } @@ -3260,18 +3260,18 @@ namespace plg { try { #endif // PLUGIFY_HAS_EXCEPTIONS [[maybe_unused]] annotation_guard g(*this); - long_ buffer = allocate_long_buffer(_alloc, size); + long_ buffer = allocate_long_buffer(alloc_, size); // The Standard mandates shrink_to_fit() does not increase the capacity. // With equal capacity keep the existing buffer. This avoids extra work // due to swapping the elements. - if (buffer._cap * endian_factor - 1 >= capacity()) { - alloc_traits::deallocate(_alloc, buffer._data, buffer._cap * endian_factor); + if (buffer.cap_ * endian_factor - 1 >= capacity()) { + alloc_traits::deallocate(alloc_, buffer.data_, buffer.cap_ * endian_factor); return; } traits_type::copy( - std::to_address(buffer._data), + std::to_address(buffer.data_), std::to_address(get_long_pointer()), size + 1 ); @@ -3316,7 +3316,7 @@ namespace plg { template inline constexpr void basic_string::swap(basic_string& str) noexcept { PLUGIFY_ASSERT( - alloc_traits::propagate_on_container_swap::value || alloc_traits::is_always_equal::value || _alloc == str._alloc, + alloc_traits::propagate_on_container_swap::value || alloc_traits::is_always_equal::value || alloc_ == str.alloc_, "swapping non-equal allocators" ); if (!is_long()) { @@ -3325,8 +3325,8 @@ namespace plg { if (this != std::addressof(str) && !str.is_long()) { str.annotate_delete(); } - std::swap(_rep, str._rep); - swap_allocator(_alloc, str._alloc); + std::swap(rep_, str.rep_); + swap_allocator(alloc_, str.alloc_); if (!is_long()) { annotate_new(get_short_size()); } diff --git a/include/plg/uninitialized.hpp b/include/plg/uninitialized.hpp index 9cc3400..85c277b 100644 --- a/include/plg/uninitialized.hpp +++ b/include/plg/uninitialized.hpp @@ -51,16 +51,16 @@ namespace plg { class AllocatorDestroyRangeReverse { public: AllocatorDestroyRangeReverse(Alloc& alloc, Iter& first, Iter& last) - : _alloc(alloc), _first(first), _last(last) {} + : alloc_(alloc), first_(first), last_(last) {} void operator()() const { - allocator_destroy(_alloc, std::reverse_iterator(_last), std::reverse_iterator(_first)); + allocator_destroy(alloc_, std::reverse_iterator(last_), std::reverse_iterator(first_)); } private: - Alloc& _alloc; - Iter& _first; - Iter& _last; + Alloc& alloc_; + Iter& first_; + Iter& last_; }; // Copy-construct [first1, last1) in [first2, first2 + N), where N is @@ -123,7 +123,7 @@ namespace plg { // - is_copy_constructible // - is_trivially_relocatable template - void uninitialized_allocator_relocate(Alloc& alloc, T* first, T* last, T* result) { + constexpr void uninitialized_allocator_relocate(Alloc& alloc, T* first, T* last, T* result) { if (std::is_constant_evaluated() || !is_trivially_relocatable::value || !allocator_has_trivial_move_construct::value || diff --git a/include/plg/variant.hpp b/include/plg/variant.hpp index 9e7ada0..4c68ac4 100644 --- a/include/plg/variant.hpp +++ b/include/plg/variant.hpp @@ -26,13 +26,13 @@ namespace plg { #if PLUGIFY_HAS_EXCEPTIONS class bad_variant_access : public std::exception { public: - explicit bad_variant_access(const char* str) noexcept : message{str} {} + explicit bad_variant_access(const char* str) noexcept : message_{str} {} bad_variant_access() noexcept = default; bad_variant_access(const bad_variant_access&) noexcept = default; bad_variant_access& operator=(const bad_variant_access&) noexcept = default; - const char* what() const noexcept override { return message; } + const char* what() const noexcept override { return message_; } private: - const char* message = ""; // llvm test requires a well formed what() on default init + const char* message_ = ""; // llvm test requires a well formed what() on default init }; #endif // PLUGIFY_HAS_EXCEPTIONS @@ -575,7 +575,7 @@ namespace plg { constexpr variant() noexcept(std::is_nothrow_default_constructible_v>) requires std::is_default_constructible_v> - : _storage{in_place_index<0>}, _current{0} + : storage_{in_place_index<0>}, current_{0} {} // copy constructor (trivial) @@ -587,7 +587,7 @@ namespace plg { // copy constructor constexpr variant(const variant& o) requires (has_copy_ctor and not trivial_copy_ctor) - : _storage{detail::dummy_type{}} { + : storage_{detail::dummy_type{}} { construct_from(o); } @@ -600,7 +600,7 @@ namespace plg { constexpr variant(variant&& o) noexcept((std::is_nothrow_move_constructible_v && ...)) requires (has_move_ctor and not trivial_move_ctor) - : _storage{detail::dummy_type{}} { + : storage_{detail::dummy_type{}} { construct_from(static_cast(o)); } @@ -616,7 +616,7 @@ namespace plg { template requires (Index < size && std::is_constructible_v, Args&&...>) explicit constexpr variant(in_place_index_t tag, Args&&... args) - : _storage{tag, static_cast(args)...}, _current(Index) + : storage_{tag, static_cast(args)...}, current_(Index) {} // construct a given type @@ -633,7 +633,7 @@ namespace plg { std::is_constructible_v, std::initializer_list&, Args&&...> ) explicit constexpr variant(in_place_index_t tag, std::initializer_list list, Args&&... args) - : _storage{tag, list, PLG_FWD(args)...}, _current{Index} + : storage_{tag, list, PLG_FWD(args)...}, current_{Index} {} template @@ -642,7 +642,7 @@ namespace plg { && std::is_constructible_v&, Args&&...> ) explicit constexpr variant(in_place_type_t, std::initializer_list list, Args&&... args) - : _storage{in_place_index>, list, PLG_FWD(args)...}, _current{index_of } + : storage_{in_place_index>, list, PLG_FWD(args)...}, current_{index_of } {} // ================================ destructors (20.7.3.3) @@ -714,7 +714,7 @@ namespace plg { using related_type = detail::best_overload_match; constexpr auto new_index = index_of; - if (_current == new_index) + if (current_ == new_index) unsafe_get() = PLG_FWD(t); else { constexpr bool do_simple_emplace = @@ -765,12 +765,12 @@ namespace plg { constexpr bool valueless_by_exception() const noexcept { if constexpr (can_be_valueless) - return _current == npos; + return current_ == npos; else return false; } constexpr index_type index() const noexcept { - return _current; + return current_; } // =================================== swap (20.7.3.7) @@ -785,7 +785,7 @@ namespace plg { constexpr auto impl_one_valueless = [](auto&& full, auto& empty) { detail::visit_with_index(PLG_FWD(full), detail::emplace_no_dtor_from_elem{empty}); full.reset_no_check(); - full._current = npos; + full.current_ = npos; }; switch (static_cast(index() == npos) + static_cast(o.index() == npos) * 2) { @@ -837,29 +837,29 @@ namespace plg { template constexpr auto& unsafe_get() & noexcept { static_assert(Idx < size); - PLUGIFY_ASSERT(_current == Idx, ""); - return _storage.template get(); + PLUGIFY_ASSERT(current_ == Idx, ""); + return storage_.template get(); } template constexpr auto&& unsafe_get() && noexcept { static_assert(Idx < size); - PLUGIFY_ASSERT(_current == Idx, ""); - return PLG_MOV(_storage.template get()); + PLUGIFY_ASSERT(current_ == Idx, ""); + return PLG_MOV(storage_.template get()); } template constexpr const auto& unsafe_get() const & noexcept { static_assert(Idx < size); - PLUGIFY_ASSERT(_current == Idx, ""); - return _storage.template get(); + PLUGIFY_ASSERT(current_ == Idx, ""); + return storage_.template get(); } template constexpr const auto&& unsafe_get() const && noexcept { static_assert(Idx < size); - PLUGIFY_ASSERT(_current == Idx, ""); - return PLG_MOV(_storage.template get()); + PLUGIFY_ASSERT(current_ == Idx, ""); + return PLG_MOV(storage_.template get()); } private: @@ -868,9 +868,9 @@ namespace plg { constexpr void assign_from(Other&& o, Fn&& fn) { if constexpr (can_be_valueless) { if (o.index() == npos) { - if (_current != npos) { + if (current_ != npos) { reset_no_check(); - _current = npos; + current_ = npos; } return; } @@ -906,7 +906,7 @@ namespace plg { { static_assert(can_be_valueless, "Internal error : the possibly valueless branch of emplace was taken despite |can_be_valueless| being false"); - _current = npos; + current_ = npos; do_emplace_no_dtor(PLG_FWD(args)...); } } @@ -916,7 +916,7 @@ namespace plg { template constexpr void do_emplace_no_dtor(Args&&... args) { - _current = static_cast(Idx); + current_ = static_cast(Idx); auto* ptr = detail::addressof(unsafe_get()); @@ -950,7 +950,7 @@ namespace plg { constexpr void construct_from(Other&& o) { if constexpr (can_be_valueless) if (o.valueless_by_exception()) { - _current = npos; + current_ = npos; return; } @@ -960,11 +960,11 @@ namespace plg { template friend struct detail::emplace_no_dtor_from_elem; - storage _storage; + storage storage_; #if INTPTR_MAX == INT32_MAX - volatile char pad[8]; + volatile char padding_[8]; #endif - index_type _current; + index_type current_; }; // ================================= value access (20.7.5) diff --git a/include/plg/vector.hpp b/include/plg/vector.hpp index 8041c26..56884fc 100644 --- a/include/plg/vector.hpp +++ b/include/plg/vector.hpp @@ -27,7 +27,7 @@ # pragma GCC system_header #endif -// from https://github.com/masahisa/rtw/ +// from https://github.com/llvm/llvm-project/blob/main/libcxx/include/vector namespace plg { namespace detail { template @@ -94,7 +94,7 @@ namespace plg { constexpr vector() noexcept(std::is_nothrow_default_constructible_v) = default; constexpr explicit vector(const allocator_type& a) noexcept - : _alloc(a) { + : alloc_(a) { } constexpr explicit vector(size_type n) { @@ -108,7 +108,7 @@ namespace plg { constexpr explicit vector(size_type n, const allocator_type& a) - : _alloc(a) { + : alloc_(a) { auto guard = make_exception_guard(destroy_vector(*this)); if (n > 0) { vallocate(n); @@ -128,7 +128,7 @@ namespace plg { constexpr vector(size_type n, const value_type& x, const allocator_type& a) - : _alloc(a) { + : alloc_(a) { auto guard = make_exception_guard(destroy_vector(*this)); if (n > 0) { vallocate(n); @@ -146,7 +146,7 @@ namespace plg { template constexpr vector(InputIterator first, InputIterator last, const allocator_type& a) - : _alloc(a) { + : alloc_(a) { init_with_sentinel(first, last); } @@ -160,7 +160,7 @@ namespace plg { template constexpr vector(ForwardIterator first, ForwardIterator last, const allocator_type& a) - : _alloc(a) { + : alloc_(a) { size_type n = static_cast(std::distance(first, last)); init_with_size(first, last, n); } @@ -171,7 +171,7 @@ namespace plg { std::from_range_t, Range&& range, const allocator_type& alloc = allocator_type() - ) : _alloc(alloc) { + ) : alloc_(alloc) { if constexpr (std::ranges::forward_range || std::ranges::sized_range) { auto n = static_cast(std::ranges::distance(range)); init_with_size(std::ranges::begin(range), std::ranges::end(range), n); @@ -190,10 +190,10 @@ namespace plg { } constexpr void operator()() { - if (vec_._begin != nullptr) { + if (vec_.begin_ != nullptr) { vec_.clear(); vec_.annotate_delete(); - alloc_traits::deallocate(vec_._alloc, vec_._begin, vec_.capacity()); + alloc_traits::deallocate(vec_.alloc_, vec_.begin_, vec_.capacity()); } } @@ -207,14 +207,14 @@ namespace plg { } constexpr vector(const vector& x) - : _alloc(alloc_traits::select_on_container_copy_construction(x._alloc)) { - init_with_size(x._begin, x._end, x.size()); + : alloc_(alloc_traits::select_on_container_copy_construction(x.alloc_)) { + init_with_size(x.begin_, x.end_, x.size()); } constexpr vector(const vector& x, const std::type_identity_t& a) - : _alloc(a) { - init_with_size(x._begin, x._end, x.size()); + : alloc_(a) { + init_with_size(x.begin_, x.end_, x.size()); } constexpr vector& operator=(const vector& x); @@ -225,7 +225,7 @@ namespace plg { constexpr vector(std::initializer_list il, const allocator_type& a) - : _alloc(a) { + : alloc_(a) { init_with_size(il.begin(), il.end(), il.size()); } @@ -286,28 +286,28 @@ namespace plg { [[nodiscard]] constexpr allocator_type get_allocator() const noexcept { - return this->_alloc; + return this->alloc_; } // // Iterators // [[nodiscard]] constexpr iterator begin() noexcept { - return make_iter(add_alignment_assumption(this->_begin)); + return make_iter(add_alignment_assumption(this->begin_)); } [[nodiscard]] constexpr const_iterator begin() const noexcept { - return make_iter(add_alignment_assumption(this->_begin)); + return make_iter(add_alignment_assumption(this->begin_)); } [[nodiscard]] constexpr iterator end() noexcept { - return make_iter(add_alignment_assumption(this->_end)); + return make_iter(add_alignment_assumption(this->end_)); } [[nodiscard]] constexpr const_iterator end() const noexcept { - return make_iter(add_alignment_assumption(this->_end)); + return make_iter(add_alignment_assumption(this->end_)); } [[nodiscard]] constexpr reverse_iterator @@ -354,23 +354,23 @@ namespace plg { // [vector.capacity], capacity // [[nodiscard]] constexpr size_type size() const noexcept { - return static_cast(this->_end - this->_begin); + return static_cast(this->end_ - this->begin_); } [[nodiscard]] constexpr size_type capacity() const noexcept { - return static_cast(this->_cap - this->_begin); + return static_cast(this->cap_ - this->begin_); } [[nodiscard]] constexpr bool empty() const noexcept { - return this->_begin == this->_end; + return this->begin_ == this->end_; } [[nodiscard]] constexpr size_type max_size() const noexcept { return std::min( - alloc_traits::max_size(this->_alloc), + alloc_traits::max_size(this->alloc_), std::numeric_limits::max() ); } @@ -384,20 +384,20 @@ namespace plg { [[nodiscard]] constexpr reference operator[](size_type n) noexcept { PLUGIFY_ASSERT(n < size(), "vector[] index out of bounds"); - return this->_begin[n]; + return this->begin_[n]; } [[nodiscard]] constexpr const_reference operator[](size_type n) const noexcept { PLUGIFY_ASSERT(n < size(), "vector[] index out of bounds"); - return this->_begin[n]; + return this->begin_[n]; } [[nodiscard]] constexpr reference at(size_type n) { if (n >= size()) { this->throw_out_of_range(); } - return this->_begin[n]; + return this->begin_[n]; } [[nodiscard]] constexpr const_reference @@ -405,29 +405,29 @@ namespace plg { if (n >= size()) { this->throw_out_of_range(); } - return this->_begin[n]; + return this->begin_[n]; } [[nodiscard]] constexpr reference front() noexcept { PLUGIFY_ASSERT(!empty(), "front() called on an empty vector"); - return *this->_begin; + return *this->begin_; } [[nodiscard]] constexpr const_reference front() const noexcept { PLUGIFY_ASSERT(!empty(), "front() called on an empty vector"); - return *this->_begin; + return *this->begin_; } [[nodiscard]] constexpr reference back() noexcept { PLUGIFY_ASSERT(!empty(), "back() called on an empty vector"); - return *(this->_end - 1); + return *(this->end_ - 1); } [[nodiscard]] constexpr const_reference back() const noexcept { PLUGIFY_ASSERT(!empty(), "back() called on an empty vector"); - return *(this->_end - 1); + return *(this->end_ - 1); } // @@ -435,12 +435,12 @@ namespace plg { // [[nodiscard]] constexpr value_type* data() noexcept { - return std::to_address(this->_begin); + return std::to_address(this->begin_); } [[nodiscard]] constexpr const value_type* data() const noexcept { - return std::to_address(this->_begin); + return std::to_address(this->begin_); } // @@ -467,7 +467,7 @@ namespace plg { "We assume that we have enough space to insert an element at the end of the vector" ); ConstructTransaction tx(*this, 1); - alloc_traits::construct(this->_alloc, std::to_address(tx.pos_), std::forward(args)...); + alloc_traits::construct(this->alloc_, std::to_address(tx.pos_), std::forward(args)...); ++tx.pos_; } @@ -480,7 +480,7 @@ namespace plg { constexpr void pop_back() { PLUGIFY_ASSERT(!empty(), "vector::pop_back called on an empty vector"); - this->destruct_at_end(this->_end - 1); + this->destruct_at_end(this->end_ - 1); } constexpr iterator @@ -532,7 +532,7 @@ namespace plg { constexpr void clear() noexcept { size_type old_size = size(); - base_destruct_at_end(this->_begin); + base_destruct_at_end(this->begin_); annotate_shrink(old_size); } @@ -545,16 +545,16 @@ namespace plg { constexpr bool invariants() const; private: - pointer _begin = nullptr; - pointer _end = nullptr; - pointer _cap = nullptr; + pointer begin_ = nullptr; + pointer end_ = nullptr; + pointer cap_ = nullptr; PLUGIFY_NO_UNIQUE_ADDRESS - allocator_type _alloc; + allocator_type alloc_; // Allocate space for n objects // throws length_error if n > max_size() // throws (probably bad_alloc) if memory run out - // Precondition: _begin == _end == _cap == nullptr + // Precondition: begin_ == end_ == cap_ == nullptr // Precondition: n > 0 // Postcondition: capacity() >= n // Postcondition: size() == 0 @@ -562,10 +562,10 @@ namespace plg { if (n > max_size()) { this->throw_length_error(); } - auto allocation = allocate_at_least(this->_alloc, n); - _begin = allocation.ptr; - _end = allocation.ptr; - _cap = _begin + allocation.count; + auto allocation = allocate_at_least(this->alloc_, n); + begin_ = allocation.ptr; + end_ = allocation.ptr; + cap_ = begin_ + allocation.count; annotate_new(0); } @@ -617,7 +617,7 @@ namespace plg { insert_assign_n_unchecked(Iterator first, difference_type n, pointer position) { for (pointer end_position = position + n; position != end_position; ++position, (void) ++first) { - detail::temp_value tmp(this->_alloc, *first); + detail::temp_value tmp(this->alloc_, *first); *position = std::move(tmp.get()); } } @@ -722,15 +722,15 @@ namespace plg { constexpr explicit ConstructTransaction(vector& v, size_type n) : v_(v) - , pos_(v._end) - , new_end_(v._end + n) { + , pos_(v.end_) + , new_end_(v.end_ + n) { v.annotate_increase(n); } constexpr ~ConstructTransaction() { - v_._end = pos_; + v_.end_ = pos_; if (pos_ != new_end_) { - v_.annotate_shrink(new_end_ - v_._begin); + v_.annotate_shrink(new_end_ - v_.begin_); } } @@ -744,11 +744,11 @@ namespace plg { constexpr void base_destruct_at_end(pointer new_last) noexcept { - pointer soon_to_be_end = this->_end; + pointer soon_to_be_end = this->end_; while (new_last != soon_to_be_end) { - alloc_traits::destroy(this->_alloc, std::to_address(--soon_to_be_end)); + alloc_traits::destroy(this->alloc_, std::to_address(--soon_to_be_end)); } - this->_end = new_last; + this->end_ = new_last; } constexpr void copy_assign_alloc(const vector& c) { @@ -779,13 +779,13 @@ namespace plg { constexpr void copy_assign_alloc(const vector& c, std::true_type) { - if (this->_alloc != c._alloc) { + if (this->alloc_ != c.alloc_) { clear(); annotate_delete(); - alloc_traits::deallocate(this->_alloc, this->_begin, capacity()); - this->_begin = this->_end = this->_cap = nullptr; + alloc_traits::deallocate(this->alloc_, this->begin_, capacity()); + this->begin_ = this->end_ = this->cap_ = nullptr; } - this->_alloc = c._alloc; + this->alloc_ = c.alloc_; } constexpr void @@ -796,7 +796,7 @@ namespace plg { move_assign_alloc(vector& c, std::true_type) noexcept( std::is_nothrow_move_assignable_v ) { - this->_alloc = std::move(c._alloc); + this->alloc_ = std::move(c.alloc_); } constexpr void @@ -820,18 +820,18 @@ namespace plg { constexpr void swap_layouts(split_buffer& sb) { - auto vector_begin = _begin; - auto vector_sentinel = _end; - auto vector_cap = _cap; + auto vector_begin = begin_; + auto vector_sentinel = end_; + auto vector_cap = cap_; auto sb_begin = sb.begin(); auto sb_sentinel = sb.raw_sentinel(); auto sb_cap = sb.raw_capacity(); // TODO: replace with set_valid_range and set_capacity when vector supports it. - _begin = sb_begin; - _end = sb_sentinel; - _cap = sb_cap; + begin_ = sb_begin; + end_ = sb_sentinel; + cap_ = sb_cap; sb.set_valid_range(vector_begin, vector_sentinel); sb.set_capacity(vector_cap); @@ -852,33 +852,33 @@ namespace plg { -> vector, Alloc>; #endif - // swap_out_circular_buffer relocates the objects in [_begin, _end) into the front of v and - // swaps the buffers of *this and v. It is assumed that v provides space for exactly (_end - - // _begin) objects in the front. This function has a strong exception guarantee. + // swap_out_circular_buffer relocates the objects in [begin_, end_) into the front of v and + // swaps the buffers of *this and v. It is assumed that v provides space for exactly (end_ - + // begin_) objects in the front. This function has a strong exception guarantee. template constexpr void vector::swap_out_circular_buffer(split_buffer& v) { annotate_delete(); auto new_begin = v.begin() - size(); uninitialized_allocator_relocate( - this->_alloc, - std::to_address(_begin), - std::to_address(_end), + this->alloc_, + std::to_address(begin_), + std::to_address(end_), std::to_address(new_begin) ); v.set_valid_range(new_begin, v.end()); - _end = _begin; // All the objects have been destroyed by relocating them. + end_ = begin_; // All the objects have been destroyed by relocating them. swap_layouts(v); v.set_data(v.begin()); annotate_new(size()); } - // swap_out_circular_buffer relocates the objects in [_begin, p) into the front of v, the - // objects in [p, _end) into the back of v and swaps the buffers of *this and v. It is assumed - // that v provides space for exactly (p - _begin) objects in the front and space for at least - // (_end - p) objects in the back. This function has a strong exception guarantee if _begin == p - // || _end == p. + // swap_out_circular_buffer relocates the objects in [begin_, p) into the front of v, the + // objects in [p, end_) into the back of v and swaps the buffers of *this and v. It is assumed + // that v provides space for exactly (p - begin_) objects in the front and space for at least + // (end_ - p) objects in the back. This function has a strong exception guarantee if begin_ == p + // || end_ == p. template constexpr typename vector::pointer vector::swap_out_circular_buffer( @@ -888,27 +888,27 @@ namespace plg { annotate_delete(); pointer ret = v.begin(); - // Relocate [p, _end) first to avoid having a hole in [_begin, _end) - // in case something in [_begin, p) throws. + // Relocate [p, end_) first to avoid having a hole in [begin_, end_) + // in case something in [begin_, p) throws. uninitialized_allocator_relocate( - this->_alloc, + this->alloc_, std::to_address(p), - std::to_address(_end), + std::to_address(end_), std::to_address(v.end()) ); - auto relocated_so_far = _end - p; + auto relocated_so_far = end_ - p; v.set_sentinel(v.end() + relocated_so_far); - _end = p; // The objects in [p, _end) have been destroyed by relocating them. - auto new_begin = v.begin() - (p - _begin); + end_ = p; // The objects in [p, end_) have been destroyed by relocating them. + auto new_begin = v.begin() - (p - begin_); uninitialized_allocator_relocate( - this->_alloc, - std::to_address(_begin), + this->alloc_, + std::to_address(begin_), std::to_address(p), std::to_address(new_begin) ); v.set_valid_range(new_begin, v.end()); - _end = _begin; // All the objects have been destroyed by relocating them. + end_ = begin_; // All the objects have been destroyed by relocating them. swap_layouts(v); v.set_data(v.begin()); annotate_new(size()); @@ -917,11 +917,11 @@ namespace plg { template constexpr void vector::vdeallocate() noexcept { - if (this->_begin != nullptr) { + if (this->begin_ != nullptr) { clear(); annotate_delete(); - alloc_traits::deallocate(this->_alloc, this->_begin, capacity()); - this->_begin = this->_end = this->_cap = nullptr; + alloc_traits::deallocate(this->alloc_, this->begin_, capacity()); + this->begin_ = this->end_ = this->cap_ = nullptr; } } @@ -941,7 +941,7 @@ namespace plg { return std::max(2 * cap, new_size); } - // Default constructs n objects starting at _end + // Default constructs n objects starting at end_ // throws if construction throws // Precondition: n > 0 // Precondition: size() + n <= capacity() @@ -951,11 +951,11 @@ namespace plg { ConstructTransaction tx(*this, n); const_pointer new_end = tx.new_end_; for (pointer pos = tx.pos_; pos != new_end; tx.pos_ = ++pos) { - alloc_traits::construct(this->_alloc, std::to_address(pos)); + alloc_traits::construct(this->alloc_, std::to_address(pos)); } } - // Copy constructs n objects starting at _end from x + // Copy constructs n objects starting at end_ from x // throws if construction throws // Precondition: n > 0 // Precondition: size() + n <= capacity() @@ -967,7 +967,7 @@ namespace plg { ConstructTransaction tx(*this, n); const_pointer new_end = tx.new_end_; for (pointer pos = tx.pos_; pos != new_end; tx.pos_ = ++pos) { - alloc_traits::construct(this->_alloc, std::to_address(pos), x); + alloc_traits::construct(this->alloc_, std::to_address(pos), x); } } @@ -977,39 +977,39 @@ namespace plg { vector::construct_at_end(InputIterator first, Sentinel last, size_type n) { ConstructTransaction tx(*this, n); tx.pos_ = uninitialized_allocator_copy( - this->_alloc, + this->alloc_, std::move(first), std::move(last), tx.pos_ ); } - // Default constructs n objects starting at _end + // Default constructs n objects starting at end_ // throws if construction throws // Postcondition: size() == size() + n // Exception safety: strong. template constexpr void vector::append(size_type n) { - if (static_cast(this->_cap - this->_end) >= n) { + if (static_cast(this->cap_ - this->end_) >= n) { this->construct_at_end(n); } else { - split_buffer v(recommend(size() + n), size(), this->_alloc); + split_buffer v(recommend(size() + n), size(), this->alloc_); v.construct_at_end(n); swap_out_circular_buffer(v); } } - // Default constructs n objects starting at _end + // Default constructs n objects starting at end_ // throws if construction throws // Postcondition: size() == size() + n // Exception safety: strong. template constexpr void vector::append(size_type n, const_reference x) { - if (static_cast(this->_cap - this->_end) >= n) { + if (static_cast(this->cap_ - this->end_) >= n) { this->construct_at_end(n, x); } else { - split_buffer v(recommend(size() + n), size(), this->_alloc); + split_buffer v(recommend(size() + n), size(), this->alloc_); v.construct_at_end(n, x); swap_out_circular_buffer(v); } @@ -1018,22 +1018,22 @@ namespace plg { template constexpr inline vector::vector(vector&& x) noexcept - : _alloc(std::move(x._alloc)) { - this->_begin = x._begin; - this->_end = x._end; - this->_cap = x._cap; - x._begin = x._end = x._cap = nullptr; + : alloc_(std::move(x.alloc_)) { + this->begin_ = x.begin_; + this->end_ = x.end_; + this->cap_ = x.cap_; + x.begin_ = x.end_ = x.cap_ = nullptr; } template constexpr inline vector::vector(vector&& x, const std::type_identity_t& a) - : _alloc(a) { - if (a == x._alloc) { - this->_begin = x._begin; - this->_end = x._end; - this->_cap = x._cap; - x._begin = x._end = x._cap = nullptr; + : alloc_(a) { + if (a == x.alloc_) { + this->begin_ = x.begin_; + this->end_ = x.end_; + this->cap_ = x.cap_; + x.begin_ = x.end_ = x.cap_ = nullptr; } else { using Ip = std::move_iterator; init_with_size(Ip(x.begin()), Ip(x.end()), x.size()); @@ -1045,7 +1045,7 @@ namespace plg { vector::move_assign(vector& c, std::false_type) noexcept( alloc_traits::is_always_equal::value ) { - if (this->_alloc != c._alloc) { + if (this->alloc_ != c.alloc_) { using Ip = std::move_iterator; assign(Ip(c.begin()), Ip(c.end())); } else { @@ -1060,10 +1060,10 @@ namespace plg { ) { vdeallocate(); move_assign_alloc(c); // this can throw - this->_begin = c._begin; - this->_end = c._end; - this->_cap = c._cap; - c._begin = c._end = c._cap = nullptr; + this->begin_ = c.begin_; + this->end_ = c.end_; + this->cap_ = c.cap_; + c.begin_ = c.end_ = c.cap_ = nullptr; } template @@ -1071,7 +1071,7 @@ namespace plg { vector::operator=(const vector& x) { if (this != std::addressof(x)) { copy_assign_alloc(x); - assign(x._begin, x._end); + assign(x.begin_, x.end_); } return *this; } @@ -1080,11 +1080,11 @@ namespace plg { template constexpr void vector::assign_with_sentinel(Iterator first, Sentinel last) { - pointer cur = _begin; - for (; first != last && cur != _end; ++first, (void) ++cur) { + pointer cur = begin_; + for (; first != last && cur != end_; ++first, (void) ++cur) { *cur = *first; } - if (cur != _end) { + if (cur != end_) { destruct_at_end(cur); } else { for (; first != last; ++first) { @@ -1101,15 +1101,15 @@ namespace plg { if (new_size <= capacity()) { if (new_size > size()) { #if PLUGIFY_HAS_CXX23 - auto mid = std::ranges::copy_n(std::move(first), size(), this->_begin).in; + auto mid = std::ranges::copy_n(std::move(first), size(), this->begin_).in; construct_at_end(std::move(mid), std::move(last), new_size - size()); #else Iterator mid = std::next(first, size()); - std::copy(first, mid, this->_begin); + std::copy(first, mid, this->begin_); construct_at_end(mid, last, new_size - size()); #endif } else { - pointer m = std::copy(std::move(first), last, this->_begin); + pointer m = std::copy(std::move(first), last, this->begin_); this->destruct_at_end(m); } } else { @@ -1124,11 +1124,11 @@ namespace plg { vector::assign(size_type n, const_reference u) { if (n <= capacity()) { size_type s = size(); - std::fill_n(this->_begin, std::min(n, s), u); + std::fill_n(this->begin_, std::min(n, s), u); if (n > s) { construct_at_end(n - s, u); } else { - this->destruct_at_end(this->_begin + n); + this->destruct_at_end(this->begin_ + n); } } else { vdeallocate(); @@ -1143,7 +1143,7 @@ namespace plg { if (n > max_size()) { this->throw_length_error(); } - split_buffer v(n, size(), this->_alloc); + split_buffer v(n, size(), this->alloc_); swap_out_circular_buffer(v); } } @@ -1154,7 +1154,7 @@ namespace plg { #if PLUGIFY_HAS_EXCEPTIONS try { #endif // PLUGIFY_HAS_EXCEPTIONS - split_buffer v(size(), size(), this->_alloc); + split_buffer v(size(), size(), this->alloc_); // The Standard mandates shrink_to_fit() does not increase the capacity. // With equal capacity keep the existing buffer. This avoids extra work // due to swapping the elements. @@ -1172,13 +1172,13 @@ namespace plg { template constexpr typename vector::pointer vector::emplace_back_slow_path(Args&&... args) { - split_buffer v(recommend(size() + 1), size(), this->_alloc); + split_buffer v(recommend(size() + 1), size(), this->alloc_); // v.emplace_back(std::forward(args)...); pointer end = v.end(); - alloc_traits::construct(this->_alloc, std::to_address(end), std::forward(args)...); + alloc_traits::construct(this->alloc_, std::to_address(end), std::forward(args)...); v.set_sentinel(++end); swap_out_circular_buffer(v); - return this->_end; + return this->end_; } // This makes the compiler inline `else()` if `cond` is known to be false. Currently LLVM @@ -1207,9 +1207,9 @@ namespace plg { constexpr inline typename vector::reference vector::emplace_back(Args&&... args) { - pointer end = this->_end; + pointer end = this->end_; if_likely_else( - end < this->_cap, + end < this->cap_, [&] { emplace_back_assume_capacity(std::forward(args)...); ++end; @@ -1217,7 +1217,7 @@ namespace plg { [&] { end = emplace_back_slow_path(std::forward(args)...); } ); - this->_end = end; + this->end_ = end; return *(end - 1); } @@ -1230,8 +1230,8 @@ namespace plg { "vector::erase(iterator) called with a non-dereferenceable iterator" ); difference_type ps = position - cbegin(); - pointer p = this->_begin + ps; - this->destruct_at_end(std::move(p + 1, this->_end, p)); + pointer p = this->begin_ + ps; + this->destruct_at_end(std::move(p + 1, this->end_, p)); return make_iter(p); } @@ -1242,9 +1242,9 @@ namespace plg { first <= last, "vector::erase(first, last) called with invalid range" ); - pointer p = this->_begin + (first - begin()); + pointer p = this->begin_ + (first - begin()); if (first != last) { - this->destruct_at_end(std::move(p + (last - first), this->_end, p)); + this->destruct_at_end(std::move(p + (last - first), this->end_, p)); } return make_iter(p); } @@ -1252,13 +1252,13 @@ namespace plg { template constexpr void vector::move_range(pointer from_s, pointer from_e, pointer to) { - pointer old_last = this->_end; + pointer old_last = this->end_; difference_type n = old_last - to; { pointer i = from_s + n; ConstructTransaction tx(*this, from_e - i); for (pointer pos = tx.pos_; i < from_e; ++i, (void) ++pos, tx.pos_ = pos) { - alloc_traits::construct(this->_alloc, std::to_address(pos), std::move(*i)); + alloc_traits::construct(this->alloc_, std::to_address(pos), std::move(*i)); } } std::move_backward(from_s, from_s + n, old_last); @@ -1267,16 +1267,16 @@ namespace plg { template constexpr typename vector::iterator vector::insert(const_iterator position, const_reference x) { - pointer p = this->_begin + (position - begin()); - if (this->_end < this->_cap) { - if (p == this->_end) { + pointer p = this->begin_ + (position - begin()); + if (this->end_ < this->cap_) { + if (p == this->end_) { emplace_back_assume_capacity(x); } else { - move_range(p, this->_end, p + 1); + move_range(p, this->end_, p + 1); const_pointer xr = std::pointer_traits::pointer_to(x); if (is_pointer_in_range( std::to_address(p), - std::to_address(_end), + std::to_address(end_), std::addressof(x) )) { ++xr; @@ -1286,8 +1286,8 @@ namespace plg { } else { split_buffer v( recommend(size() + 1), - p - this->_begin, - this->_alloc + p - this->begin_, + this->alloc_ ); v.emplace_back(x); p = swap_out_circular_buffer(v, p); @@ -1298,19 +1298,19 @@ namespace plg { template constexpr typename vector::iterator vector::insert(const_iterator position, value_type&& x) { - pointer p = this->_begin + (position - begin()); - if (this->_end < this->_cap) { - if (p == this->_end) { + pointer p = this->begin_ + (position - begin()); + if (this->end_ < this->cap_) { + if (p == this->end_) { emplace_back_assume_capacity(std::move(x)); } else { - move_range(p, this->_end, p + 1); + move_range(p, this->end_, p + 1); *p = std::move(x); } } else { split_buffer v( recommend(size() + 1), - p - this->_begin, - this->_alloc + p - this->begin_, + this->alloc_ ); v.emplace_back(std::move(x)); p = swap_out_circular_buffer(v, p); @@ -1322,20 +1322,20 @@ namespace plg { template constexpr typename vector::iterator vector::emplace(const_iterator position, Args&&... args) { - pointer p = this->_begin + (position - begin()); - if (this->_end < this->_cap) { - if (p == this->_end) { + pointer p = this->begin_ + (position - begin()); + if (this->end_ < this->cap_) { + if (p == this->end_) { emplace_back_assume_capacity(std::forward(args)...); } else { - detail::temp_value tmp(this->_alloc, std::forward(args)...); - move_range(p, this->_end, p + 1); + detail::temp_value tmp(this->alloc_, std::forward(args)...); + move_range(p, this->end_, p + 1); *p = std::move(tmp.get()); } } else { split_buffer v( recommend(size() + 1), - p - this->_begin, - this->_alloc + p - this->begin_, + this->alloc_ ); v.emplace_back(std::forward(args)...); p = swap_out_circular_buffer(v, p); @@ -1346,13 +1346,13 @@ namespace plg { template constexpr typename vector::iterator vector::insert(const_iterator position, size_type n, const_reference x) { - pointer p = this->_begin + (position - begin()); + pointer p = this->begin_ + (position - begin()); if (n > 0) { - if (n <= static_cast(this->_cap - this->_end)) { + if (n <= static_cast(this->cap_ - this->end_)) { size_type old_n = n; - pointer old_last = this->_end; - if (n > static_cast(this->_end - p)) { - size_type cx = n - (this->_end - p); + pointer old_last = this->end_; + if (n > static_cast(this->end_ - p)) { + size_type cx = n - (this->end_ - p); construct_at_end(cx, x); n -= cx; } @@ -1361,7 +1361,7 @@ namespace plg { const_pointer xr = std::pointer_traits::pointer_to(x); if (is_pointer_in_range( std::to_address(p), - std::to_address(_end), + std::to_address(end_), std::addressof(x) )) { xr += old_n; @@ -1371,8 +1371,8 @@ namespace plg { } else { split_buffer v( recommend(size() + n), - p - this->_begin, - this->_alloc + p - this->begin_, + this->alloc_ ); v.construct_at_end(n, x); p = swap_out_circular_buffer(v, p); @@ -1390,37 +1390,37 @@ namespace plg { Sentinel last ) { difference_type off = position - begin(); - pointer p = this->_begin + off; - pointer old_last = this->_end; - for (; this->_end != this->_cap && first != last; ++first) { + pointer p = this->begin_ + off; + pointer old_last = this->end_; + for (; this->end_ != this->cap_ && first != last; ++first) { emplace_back_assume_capacity(*first); } if (first == last) { - (void) std::rotate(p, old_last, this->_end); + (void) std::rotate(p, old_last, this->end_); } else { - split_buffer v(_alloc); + split_buffer v(alloc_); auto guard = make_exception_guard( - AllocatorDestroyRangeReverse(_alloc, old_last, this->_end) + AllocatorDestroyRangeReverse(alloc_, old_last, this->end_) ); v.construct_at_end_with_sentinel(std::move(first), std::move(last)); split_buffer merged( recommend(size() + v.size()), off, - _alloc + alloc_ ); // has `off` positions available at the front uninitialized_allocator_relocate( - _alloc, + alloc_, std::to_address(old_last), - std::to_address(this->_end), + std::to_address(this->end_), std::to_address(merged.end()) ); - guard.complete(); // Release the guard once objects in [old_last_, _end) have been + guard.complete(); // Release the guard once objects in [old_last_, end_) have been // successfully relocated. - merged.set_sentinel(merged.end() + (this->_end - old_last)); - this->_end = old_last; + merged.set_sentinel(merged.end() + (this->end_ - old_last)); + this->end_ = old_last; uninitialized_allocator_relocate( - _alloc, + alloc_, std::to_address(v.begin()), std::to_address(v.end()), std::to_address(merged.end()) @@ -1441,16 +1441,16 @@ namespace plg { Sentinel last, difference_type n ) { - pointer p = this->_begin + (position - begin()); + pointer p = this->begin_ + (position - begin()); if (n > 0) { - if (n <= this->_cap - this->_end) { - pointer old_last = this->_end; - difference_type dx = this->_end - p; + if (n <= this->cap_ - this->end_) { + pointer old_last = this->end_; + difference_type dx = this->end_ - p; if (n > dx) { #if PLUGIFY_HAS_CXX23 if constexpr (!std::forward_iterator) { construct_at_end(std::move(first), std::move(last), n); - std::rotate(p, old_last, this->_end); + std::rotate(p, old_last, this->end_); } else #endif { @@ -1468,8 +1468,8 @@ namespace plg { } else { split_buffer v( recommend(size() + n), - p - this->_begin, - this->_alloc + p - this->begin_, + this->alloc_ ); v.construct_at_end_with_size(std::move(first), n); p = swap_out_circular_buffer(v, p); @@ -1484,7 +1484,7 @@ namespace plg { if (cs < sz) { this->append(sz - cs); } else if (cs > sz) { - this->destruct_at_end(this->_begin + sz); + this->destruct_at_end(this->begin_ + sz); } } @@ -1495,7 +1495,7 @@ namespace plg { if (cs < sz) { this->append(sz - cs, x); } else if (cs > sz) { - this->destruct_at_end(this->_begin + sz); + this->destruct_at_end(this->begin_ + sz); } } @@ -1504,30 +1504,30 @@ namespace plg { noexcept { PLUGIFY_ASSERT( - alloc_traits::propagate_on_container_swap::value || this->_alloc == x._alloc, + alloc_traits::propagate_on_container_swap::value || this->alloc_ == x.alloc_, "vector::swap: Either propagate_on_container_swap must be true" " or the allocators must compare equal" ); - std::swap(this->_begin, x._begin); - std::swap(this->_end, x._end); - std::swap(this->_cap, x._cap); - swap_allocator(this->_alloc, x._alloc); + std::swap(this->begin_, x.begin_); + std::swap(this->end_, x.end_); + std::swap(this->cap_, x.cap_); + swap_allocator(this->alloc_, x.alloc_); } template constexpr bool vector::invariants() const { - if (this->_begin == nullptr) { - if (this->_end != nullptr || this->_cap != nullptr) { + if (this->begin_ == nullptr) { + if (this->end_ != nullptr || this->cap_ != nullptr) { return false; } } else { - if (this->_begin > this->_end) { + if (this->begin_ > this->end_) { return false; } - if (this->_begin == this->_cap) { + if (this->begin_ == this->cap_) { return false; } - if (this->_end > this->_cap) { + if (this->end_ > this->cap_) { return false; } } diff --git a/include/plg/version.hpp b/include/plg/version.hpp index b8e8c00..f3bf16d 100644 --- a/include/plg/version.hpp +++ b/include/plg/version.hpp @@ -91,38 +91,38 @@ namespace plg { constexpr version& operator=(const version&) = default; constexpr version& operator=(version&&) = default; - constexpr I1 major() const noexcept { return _major; } - constexpr I2 minor() const noexcept { return _minor; } - constexpr I3 patch() const noexcept { return _patch; } + constexpr I1 major() const noexcept { return major_; } + constexpr I2 minor() const noexcept { return minor_; } + constexpr I3 patch() const noexcept { return patch_; } - constexpr const string& prerelease_tag() const { return _prerelease_tag; } - constexpr const string& build_metadata() const { return _build_metadata; } + constexpr const string& prerelease_tag() const { return prerelease_tag_; } + constexpr const string& build_metadata() const { return build_metadata_; } constexpr string to_string() const; private: - I1 _major = 0; - I2 _minor = 1; - I3 _patch = 0; - string _prerelease_tag; - string _build_metadata; + I1 major_ = 0; + I2 minor_ = 1; + I3 patch_ = 0; + string prerelease_tag_; + string build_metadata_; - vector _prerelease_identifiers; + vector prerelease_identifiers_; constexpr std::size_t length() const noexcept { - return detail::length(_major) + detail::length(_minor) + detail::length(_patch) + 2 - + (_prerelease_tag.empty() ? 0 : _prerelease_tag.length() + 1) - + (_build_metadata.empty() ? 0 : _build_metadata.length() + 1); + return detail::length(major_) + detail::length(minor_) + detail::length(patch_) + 2 + + (prerelease_tag_.empty() ? 0 : prerelease_tag_.length() + 1) + + (build_metadata_.empty() ? 0 : build_metadata_.length() + 1); } constexpr void clear() noexcept { - _major = 0; - _minor = 1; - _patch = 0; + major_ = 0; + minor_ = 1; + patch_ = 0; - _prerelease_tag.clear(); - _prerelease_identifiers.clear(); - _build_metadata.clear(); + prerelease_tag_.clear(); + prerelease_identifiers_.clear(); + build_metadata_.clear(); } }; @@ -132,23 +132,23 @@ namespace plg { detail::resize_uninitialized{}.resize(result, length()); auto* it = result.end(); - if (!_build_metadata.empty()) { - it = std::copy_backward(_build_metadata.begin(), _build_metadata.end(), it); + if (!build_metadata_.empty()) { + it = std::copy_backward(build_metadata_.begin(), build_metadata_.end(), it); *(--it) = '+'; } - if (!_prerelease_tag.empty()) { - it = std::copy_backward(_prerelease_tag.begin(), _prerelease_tag.end(), it); + if (!prerelease_tag_.empty()) { + it = std::copy_backward(prerelease_tag_.begin(), prerelease_tag_.end(), it); *(--it) = '-'; } - it = detail::to_chars(it, _patch); + it = detail::to_chars(it, patch_); *(--it) = '.'; - it = detail::to_chars(it, _minor); + it = detail::to_chars(it, minor_); *(--it) = '.'; - it = detail::to_chars(it, _major); + it = detail::to_chars(it, major_); return result; } @@ -273,28 +273,28 @@ namespace plg { class token_stream { public: constexpr token_stream() = default; - constexpr explicit token_stream(vector tokens) noexcept : _tokens(std::move(tokens)) {} + constexpr explicit token_stream(vector tokens) noexcept : tokens_(std::move(tokens)) {} constexpr void push(const token& token) noexcept { - _tokens.push_back(token); + tokens_.push_back(token); } constexpr token advance() noexcept { - const token token = get(_current); - ++_current; + const token token = get(current_); + ++current_; return token; } constexpr token peek(std::size_t k = 0) const noexcept { - return get(_current + k); + return get(current_ + k); } constexpr token previous() const noexcept { - return get(_current - 1); + return get(current_ - 1); } constexpr bool advance_if_match(token& token, token_type type) noexcept { - if (get(_current).type != type) { + if (get(current_).type != type) { return false; } @@ -316,20 +316,20 @@ namespace plg { } private: - std::size_t _current = 0; - vector _tokens; + std::size_t current_ = 0; + vector tokens_; constexpr token get(std::size_t i) const noexcept { - return _tokens[i]; + return tokens_[i]; } }; class lexer { public: - explicit constexpr lexer(std::string_view text) noexcept : _text{text}, _current_pos{0} {} + explicit constexpr lexer(std::string_view text) noexcept : text_{text}, current_pos_{0} {} constexpr from_chars_result scan_tokens(token_stream& token_stream) noexcept { - from_chars_result result{ _text.data(), std::errc{} }; + from_chars_result result{ text_.data(), std::errc{} }; while (!is_eol()) { result = scan_token(token_stream); @@ -338,14 +338,14 @@ namespace plg { } } - token_stream.push({ token_type::eol, {}, _text.data() + _text.size() }); + token_stream.push({ token_type::eol, {}, text_.data() + text_.size() }); return result; } private: - std::string_view _text; - std::size_t _current_pos; + std::string_view text_; + std::size_t current_pos_; constexpr from_chars_result scan_token(token_stream& stream) noexcept { const char c = advance(); @@ -399,8 +399,8 @@ namespace plg { } constexpr char advance() noexcept { - char c = _text[_current_pos]; - _current_pos += 1; + char c = text_[current_pos_]; + current_pos_ += 1; return c; } @@ -409,40 +409,40 @@ namespace plg { return false; } - if (_text[_current_pos] != c) { + if (text_[current_pos_] != c) { return false; } - _current_pos += 1; + current_pos_ += 1; return true; } constexpr const char* get_prev_symbol() const noexcept { - return _text.data() + _current_pos - 1; + return text_.data() + current_pos_ - 1; } - constexpr bool is_eol() const noexcept { return _current_pos >= _text.size(); } + constexpr bool is_eol() const noexcept { return current_pos_ >= text_.size(); } }; class prerelease_comparator { public: template [[nodiscard]] constexpr int compare(const version& lhs, const version& rhs) const noexcept { - if (lhs._prerelease_identifiers.empty() != rhs._prerelease_identifiers.empty()) { - return static_cast(rhs._prerelease_identifiers.size()) - static_cast(lhs._prerelease_identifiers.size()); + if (lhs.prerelease_identifiers_.empty() != rhs.prerelease_identifiers_.empty()) { + return static_cast(rhs.prerelease_identifiers_.size()) - static_cast(lhs.prerelease_identifiers_.size()); } - const std::size_t count = std::min(lhs._prerelease_identifiers.size(), rhs._prerelease_identifiers.size()); + const std::size_t count = std::min(lhs.prerelease_identifiers_.size(), rhs.prerelease_identifiers_.size()); for (std::size_t i = 0; i < count; ++i) { - const int compare_result = compare_identifier(lhs._prerelease_identifiers[i], rhs._prerelease_identifiers[i]); + const int compare_result = compare_identifier(lhs.prerelease_identifiers_[i], rhs.prerelease_identifiers_[i]); if (compare_result != 0) { return compare_result; } } - return static_cast(lhs._prerelease_identifiers.size()) - static_cast(rhs._prerelease_identifiers.size()); + return static_cast(lhs.prerelease_identifiers_.size()) - static_cast(rhs.prerelease_identifiers_.size()); } private: @@ -459,45 +459,45 @@ namespace plg { class version_parser { public: - constexpr explicit version_parser(token_stream& stream) : _stream{stream} { + constexpr explicit version_parser(token_stream& stream) : stream_{stream} { } template constexpr from_chars_result parse(version& out) noexcept { out.clear(); - from_chars_result result = parse_number(out._major); + from_chars_result result = parse_number(out.major_); if (!result) { return result; } - if (!_stream.consume(token_type::dot)) { - return failure(_stream.previous().lexeme); + if (!stream_.consume(token_type::dot)) { + return failure(stream_.previous().lexeme); } - result = parse_number(out._minor); + result = parse_number(out.minor_); if (!result) { return result; } - if (!_stream.consume(token_type::dot)) { - return failure(_stream.previous().lexeme); + if (!stream_.consume(token_type::dot)) { + return failure(stream_.previous().lexeme); } - result = parse_number(out._patch); + result = parse_number(out.patch_); if (!result) { return result; } - if (_stream.advance_if_match(token_type::hyphen)) { - result = parse_prerelease_tag(out._prerelease_tag, out._prerelease_identifiers); + if (stream_.advance_if_match(token_type::hyphen)) { + result = parse_prerelease_tag(out.prerelease_tag_, out.prerelease_identifiers_); if (!result) { return result; } } - if (_stream.advance_if_match(token_type::plus)) { - result = parse_build_metadata(out._build_metadata); + if (stream_.advance_if_match(token_type::plus)) { + result = parse_build_metadata(out.build_metadata_); if (!result) { return result; } @@ -508,11 +508,11 @@ namespace plg { private: - token_stream& _stream; + token_stream& stream_; template constexpr from_chars_result parse_number(Int& out) { - token token = _stream.advance(); + token token = stream_.advance(); if (!is_digit(token)) { return failure(token.lexeme); @@ -523,16 +523,16 @@ namespace plg { if (first_digit == 0) { out = static_cast(result); - return success(_stream.peek().lexeme); + return success(stream_.peek().lexeme); } - while (_stream.advance_if_match(token, token_type::digit)) { + while (stream_.advance_if_match(token, token_type::digit)) { result = result * 10 + std::get(token.value); } if (detail::number_in_range(result)) { out = static_cast(result); - return success(_stream.peek().lexeme); + return success(stream_.peek().lexeme); } return failure(token.lexeme, std::errc::result_out_of_range); @@ -554,10 +554,10 @@ namespace plg { result.append(identifier); out_identifiers.push_back(make_prerelease_identifier(identifier)); - } while (_stream.advance_if_match(token_type::dot)); + } while (stream_.advance_if_match(token_type::dot)); out = result; - return success(_stream.peek().lexeme); + return success(stream_.peek().lexeme); } constexpr from_chars_result parse_build_metadata(string& out) { @@ -574,15 +574,15 @@ namespace plg { } result.append(identifier); - } while (_stream.advance_if_match(token_type::dot)); + } while (stream_.advance_if_match(token_type::dot)); out = result; - return success(_stream.peek().lexeme); + return success(stream_.peek().lexeme); } constexpr from_chars_result parse_prerelease_identifier(string& out) { string result; - token token = _stream.advance(); + token token = stream_.advance(); do { switch (token.type) { @@ -613,10 +613,10 @@ namespace plg { default: return failure(token.lexeme); } - } while (_stream.advance_if_match(token, token_type::hyphen) || _stream.advance_if_match(token, token_type::letter) || _stream.advance_if_match(token, token_type::digit)); + } while (stream_.advance_if_match(token, token_type::hyphen) || stream_.advance_if_match(token, token_type::letter) || stream_.advance_if_match(token, token_type::digit)); out = result; - return success(_stream.peek().lexeme); + return success(stream_.peek().lexeme); } constexpr detail::prerelease_identifier make_prerelease_identifier(const string& identifier) { @@ -632,7 +632,7 @@ namespace plg { constexpr from_chars_result parse_build_identifier(string& out) { string result; - token token = _stream.advance(); + token token = stream_.advance(); do { switch (token.type) { @@ -651,10 +651,10 @@ namespace plg { default: return failure(token.lexeme); } - } while (_stream.advance_if_match(token, token_type::hyphen) || _stream.advance_if_match(token, token_type::letter) || _stream.advance_if_match(token, token_type::digit)); + } while (stream_.advance_if_match(token, token_type::hyphen) || stream_.advance_if_match(token, token_type::letter) || stream_.advance_if_match(token, token_type::digit)); out = result; - return success(_stream.peek().lexeme); + return success(stream_.peek().lexeme); } constexpr bool is_leading_zero(int digit) noexcept { @@ -667,7 +667,7 @@ namespace plg { int digits = 0; while (true) { - const token token = _stream.peek(k); + const token token = stream_.peek(k); if (!is_alphanumeric(token)) { break; @@ -803,44 +803,44 @@ namespace plg { template class range_comparator { public: - constexpr range_comparator(const version& v, range_operator op) noexcept : _v(v), _op(op) {} + constexpr range_comparator(const version& v, range_operator op) noexcept : v_(v), op_(op) {} constexpr bool contains(const version& other) const noexcept { - switch (_op) { + switch (op_) { case range_operator::less: - return detail::compare_parsed(other, _v, version_compare_option::include_prerelease) < 0; + return detail::compare_parsed(other, v_, version_compare_option::include_prerelease) < 0; case range_operator::less_or_equal: - return detail::compare_parsed(other, _v, version_compare_option::include_prerelease) <= 0; + return detail::compare_parsed(other, v_, version_compare_option::include_prerelease) <= 0; case range_operator::greater: - return detail::compare_parsed(other, _v, version_compare_option::include_prerelease) > 0; + return detail::compare_parsed(other, v_, version_compare_option::include_prerelease) > 0; case range_operator::greater_or_equal: - return detail::compare_parsed(other, _v, version_compare_option::include_prerelease) >= 0; + return detail::compare_parsed(other, v_, version_compare_option::include_prerelease) >= 0; case range_operator::equal: - return detail::compare_parsed(other, _v, version_compare_option::include_prerelease) == 0; + return detail::compare_parsed(other, v_, version_compare_option::include_prerelease) == 0; } return false; } - constexpr const version& get_version() const noexcept { return _v; } + constexpr const version& get_version() const noexcept { return v_; } - constexpr range_operator get_operator() const noexcept { return _op; } + constexpr range_operator get_operator() const noexcept { return op_; } constexpr string to_string() const { string result; - switch (_op) { + switch (op_) { case range_operator::less: result += "<"; break; case range_operator::less_or_equal: result += "<="; break; case range_operator::greater: result += ">"; break; case range_operator::greater_or_equal: result += ">="; break; case range_operator::equal: result += "="; break; } - result += _v.to_string(); + result += v_.to_string(); return result; } private: - version _v; - range_operator _op; + version v_; + range_operator op_; }; class range_parser; @@ -857,40 +857,40 @@ namespace plg { } } - return std::all_of(_ranges_comparators.begin(), _ranges_comparators.end(), [&](const auto& ranges_comparator) { + return std::all_of(ranges_comparators_.begin(), ranges_comparators_.end(), [&](const auto& ranges_comparator) { return ranges_comparator.contains(v); }); } constexpr auto begin() const noexcept { - return _ranges_comparators.begin(); + return ranges_comparators_.begin(); } constexpr auto end() const noexcept { - return _ranges_comparators.end(); + return ranges_comparators_.end(); } constexpr std::size_t size() const noexcept { - return _ranges_comparators.size(); + return ranges_comparators_.size(); } constexpr bool empty() const noexcept { - return _ranges_comparators.empty(); + return ranges_comparators_.empty(); } constexpr string to_string() const { - return join(_ranges_comparators, " "); + return join(ranges_comparators_, " "); } private: - vector> _ranges_comparators; + vector> ranges_comparators_; constexpr bool match_at_least_one_comparator_with_prerelease(const version& v) const noexcept { if (v.prerelease_tag().empty()) { return true; } - return std::any_of(_ranges_comparators.begin(), _ranges_comparators.end(), [&](const auto& ranges_comparator) { + return std::any_of(ranges_comparators_.begin(), ranges_comparators_.end(), [&](const auto& ranges_comparator) { const bool has_prerelease = !ranges_comparator.get_version().prerelease_tag().empty(); const bool equal_without_prerelease = detail::compare_parsed(v, ranges_comparator.get_version(), version_compare_option::exclude_prerelease) == 0; return has_prerelease && equal_without_prerelease; @@ -905,39 +905,39 @@ namespace plg { friend class detail::range_parser; constexpr bool contains(const version& v, version_compare_option option = version_compare_option::exclude_prerelease) const noexcept { - return std::any_of(_ranges.begin(), _ranges.end(), [&](const auto& range) { + return std::any_of(ranges_.begin(), ranges_.end(), [&](const auto& range) { return range.contains(v, option); }); } constexpr auto begin() const noexcept { - return _ranges.begin(); + return ranges_.begin(); } constexpr auto end() const noexcept { - return _ranges.end(); + return ranges_.end(); } constexpr std::size_t size() const noexcept { - return _ranges.size(); + return ranges_.size(); } constexpr bool empty() const noexcept { - return _ranges.empty(); + return ranges_.empty(); } constexpr string to_string() const { - return join(_ranges, " "); + return join(ranges_, " "); } private: - vector> _ranges; + vector> ranges_; }; namespace detail { class range_parser { public: - constexpr explicit range_parser(token_stream stream) noexcept : _stream(std::move(stream)) {} + constexpr explicit range_parser(token_stream stream) noexcept : stream_(std::move(stream)) {} template constexpr from_chars_result parse(range_set& out) noexcept { @@ -953,54 +953,54 @@ namespace plg { ranges.push_back(range); skip_whitespaces(); - } while (_stream.advance_if_match(token_type::logical_or)); + } while (stream_.advance_if_match(token_type::logical_or)); - out._ranges = std::move(ranges); + out.ranges_ = std::move(ranges); - return success(_stream.peek().lexeme); + return success(stream_.peek().lexeme); } private: - token_stream _stream; + token_stream stream_; template constexpr from_chars_result parse_range(detail::range& out) noexcept { do { skip_whitespaces(); - if (const auto res = parse_range_comparator(out._ranges_comparators); !res) { + if (const auto res = parse_range_comparator(out.ranges_comparators_); !res) { return res; } skip_whitespaces(); - } while (_stream.check(token_type::range_operator) || _stream.check(token_type::digit)); + } while (stream_.check(token_type::range_operator) || stream_.check(token_type::digit)); - return success(_stream.peek().lexeme); + return success(stream_.peek().lexeme); } template constexpr from_chars_result parse_range_comparator(vector>& out) noexcept { range_operator op = range_operator::equal; token token; - if (_stream.advance_if_match(token, token_type::range_operator)) { + if (stream_.advance_if_match(token, token_type::range_operator)) { op = std::get(token.value); } skip_whitespaces(); version ver; - version_parser parser{ _stream }; + version_parser parser{ stream_ }; if (const auto res = parser.parse(ver); !res) { return res; } out.emplace_back(ver, op); - return success(_stream.peek().lexeme); + return success(stream_.peek().lexeme); } constexpr void skip_whitespaces() noexcept { - while (_stream.advance_if_match(token_type::space)) { + while (stream_.advance_if_match(token_type::space)) { ; } } diff --git a/test/cross_call_master/external/plugify/include/plg/allocator.hpp b/test/cross_call_master/external/plugify/include/plg/allocator.hpp index 3cc57b2..3bb603d 100644 --- a/test/cross_call_master/external/plugify/include/plg/allocator.hpp +++ b/test/cross_call_master/external/plugify/include/plg/allocator.hpp @@ -153,7 +153,7 @@ namespace plg { // __old_last_contained is the previously last allowed (unpoisoned) element, and // __new_last_contained is the new last allowed (unpoisoned) element. template - void annotate_contiguous_container( + constexpr void annotate_contiguous_container( [[maybe_unused]] const void* first_storage, [[maybe_unused]] const void* last_storage, [[maybe_unused]] const void* old_last_contained, diff --git a/test/cross_call_master/external/plugify/include/plg/config.hpp b/test/cross_call_master/external/plugify/include/plg/config.hpp index 8ba7006..a0e43c3 100644 --- a/test/cross_call_master/external/plugify/include/plg/config.hpp +++ b/test/cross_call_master/external/plugify/include/plg/config.hpp @@ -16,7 +16,7 @@ # define __has_builtin(x) 0 #endif -#ifndef __builtin_constant_p +#if !__has_builtin(__builtin_constant_p) # define __builtin_constant_p(x) std::is_constant_evaluated() #endif diff --git a/test/cross_call_master/external/plugify/include/plg/enum.hpp b/test/cross_call_master/external/plugify/include/plg/enum.hpp index 802b7c1..0692a31 100644 --- a/test/cross_call_master/external/plugify/include/plg/enum.hpp +++ b/test/cross_call_master/external/plugify/include/plg/enum.hpp @@ -17,15 +17,15 @@ namespace plg { template struct static_string { constexpr static_string(std::string_view sv) noexcept { - std::copy(sv.begin(), sv.end(), _content.begin()); + std::copy(sv.begin(), sv.end(), content_.begin()); } constexpr operator std::string_view() const noexcept { - return { _content.data(), N }; + return { content_.data(), N }; } private: - std::array _content{}; + std::array content_{}; }; constexpr auto is_pretty(char ch) noexcept { diff --git a/test/cross_call_master/external/plugify/include/plg/guards.hpp b/test/cross_call_master/external/plugify/include/plg/guards.hpp index 4691341..a45e221 100644 --- a/test/cross_call_master/external/plugify/include/plg/guards.hpp +++ b/test/cross_call_master/external/plugify/include/plg/guards.hpp @@ -9,16 +9,16 @@ namespace plg { exception_guard_exceptions() = delete; constexpr explicit exception_guard_exceptions(Rollback rollback) - : _rollback(std::move(rollback)) - , _completed(false) { + : rollback_(std::move(rollback)) + , completed_(false) { } constexpr exception_guard_exceptions( exception_guard_exceptions&& other ) noexcept(std::is_nothrow_move_constructible_v) - : _rollback(std::move(other._rollback)) - , _completed(other._completed) { - other._completed = true; + : rollback_(std::move(other.rollback_)) + , completed_(other.completed_) { + other.completed_ = true; } exception_guard_exceptions(const exception_guard_exceptions&) = delete; @@ -26,18 +26,18 @@ namespace plg { exception_guard_exceptions& operator=(exception_guard_exceptions&&) = delete; constexpr void complete() noexcept { - _completed = true; + completed_ = true; } constexpr ~exception_guard_exceptions() { - if (!_completed) { - _rollback(); + if (!completed_) { + rollback_(); } } private: - PLUGIFY_NO_UNIQUE_ADDRESS Rollback _rollback; - bool _completed; + PLUGIFY_NO_UNIQUE_ADDRESS Rollback rollback_; + bool completed_; }; template @@ -53,8 +53,8 @@ namespace plg { constexpr exception_guard_noexceptions( exception_guard_noexceptions&& other ) noexcept(std::is_nothrow_move_constructible_v) - : _completed(other._completed) { - other._completed = true; + : completed_(other.completed_) { + other.completed_ = true; } exception_guard_noexceptions(const exception_guard_noexceptions&) = delete; @@ -62,15 +62,15 @@ namespace plg { exception_guard_noexceptions& operator=(exception_guard_noexceptions&&) = delete; constexpr void complete() noexcept { - _completed = true; + completed_ = true; } constexpr ~exception_guard_noexceptions() { - PLUGIFY_ASSERT(_completed, "exception_guard not completed with exceptions disabled"); + PLUGIFY_ASSERT(completed_, "exception_guard not completed with exceptions disabled"); } private: - bool _completed = false; + bool completed_ = false; }; template @@ -84,15 +84,15 @@ namespace plg { template class scope_guard { - PLUGIFY_NO_UNIQUE_ADDRESS Func _func; + PLUGIFY_NO_UNIQUE_ADDRESS Func func_; public: constexpr explicit scope_guard(Func func) - : _func(std::move(func)) { + : func_(std::move(func)) { } constexpr ~scope_guard() { - _func(); + func_(); } scope_guard(const scope_guard&) = delete; diff --git a/test/cross_call_master/external/plugify/include/plg/hash.hpp b/test/cross_call_master/external/plugify/include/plg/hash.hpp index 4028e57..982f796 100644 --- a/test/cross_call_master/external/plugify/include/plg/hash.hpp +++ b/test/cross_call_master/external/plugify/include/plg/hash.hpp @@ -3,6 +3,8 @@ #include #include #include +#include +#include #include "plg/string.hpp" @@ -58,11 +60,10 @@ namespace plg { using is_transparent = void; // Enables heterogeneous lookup template - auto operator()(const T& str_like) const noexcept { - std::string_view str = str_like; + std::size_t operator()(const T& str) const noexcept { std::size_t hash = active_hash_traits::fnv_basis; // FNV-1a - for (const char& c : str) { - hash ^= static_cast(std::tolower(static_cast(c))); + for (const auto& c : str) { + hash ^= static_cast(std::tolower(c)); hash *= active_hash_traits::fnv_prime; } return hash; @@ -73,21 +74,14 @@ namespace plg { using is_transparent = void; // Enables heterogeneous lookup template - bool operator()(const T1& lhs_like, const T2& rhs_like) const noexcept { - std::string_view lhs = lhs_like; - std::string_view rhs = rhs_like; - - if (lhs.size() != rhs.size()) { - return false; - } - - for (size_t i = 0; i < lhs.size(); ++i) { - if (std::tolower(static_cast(lhs[i])) - != std::tolower(static_cast(rhs[i]))) { - return false; + bool operator()(const T1& lhs, const T2& rhs) const noexcept { + return std::lexicographical_compare( + lhs.begin(), lhs.end(), + rhs.begin(), rhs.end(), + [](const auto& ac, const auto& bc) { + return std::tolower(ac) < std::tolower(bc); } - } - return true; + ); } }; diff --git a/test/cross_call_master/external/plugify/include/plg/inplace_vector.hpp b/test/cross_call_master/external/plugify/include/plg/inplace_vector.hpp index 71292c8..db59904 100644 --- a/test/cross_call_master/external/plugify/include/plg/inplace_vector.hpp +++ b/test/cross_call_master/external/plugify/include/plg/inplace_vector.hpp @@ -68,15 +68,15 @@ namespace plg { template struct PLUGIFY_INPLACE_VECTOR_TRIVIALLY_RELOCATABLE_IF(std::is_trivially_relocatable_v) ipvbase { - size_t _size = 0; + size_t size_ = 0; union { - [[maybe_unused]] char _dummy; - T _data[N]; + [[maybe_unused]] char dummy_; + T data_[N]; }; - constexpr T *base_data() { return _data; } - constexpr const T *base_data() const { return _data; } - constexpr void set_size(size_t n) { _size = n; } + constexpr T *base_data() { return data_; } + constexpr const T *base_data() const { return data_; } + constexpr void set_size(size_t n) { size_ = n; } constexpr explicit ipvbase() noexcept {} ipvbase(const ipvbase& rhs) @@ -85,8 +85,8 @@ namespace plg { if constexpr (std::is_trivially_copy_constructible_v) { std::memmove((void*)this, (const void*)std::addressof(rhs), sizeof(ipvbase)); } else { - std::uninitialized_copy_n(rhs._data, rhs._size, _data); - _size = rhs._size; + std::uninitialized_copy_n(rhs.data_, rhs.size_, data_); + size_ = rhs.size_; } } ipvbase(ipvbase&& rhs) @@ -100,13 +100,13 @@ namespace plg { std::memmove((void*)this, (const void*)std::addressof(rhs), sizeof(ipvbase)); #if defined(__cpp_lib_trivially_relocatable) } else if constexpr (std::is_trivially_relocatable_v) { - std::uninitialized_relocate_n(rhs._data, rhs._size, _data); - _size = rhs._size; - rhs._size = 0; + std::uninitialized_relocate_n(rhs.data_, rhs.size_, data_); + size_ = rhs.size_; + rhs.size_ = 0; #endif // __cpp_lib_trivially_relocatable } else { - std::uninitialized_move_n(rhs._data, rhs._size, _data); - _size = rhs._size; + std::uninitialized_move_n(rhs.data_, rhs.size_, data_); + size_ = rhs.size_; } } void operator=(const ipvbase& rhs) @@ -116,14 +116,14 @@ namespace plg { std::memmove((void*)this, (const void*)std::addressof(rhs), sizeof(ipvbase)); } else if (this == std::addressof(rhs)) { // do nothing - } else if (rhs._size <= _size) { - std::copy(rhs._data, rhs._data + rhs._size, _data); - std::destroy(_data + rhs._size, _data + _size); - _size = rhs._size; + } else if (rhs.size_ <= size_) { + std::copy(rhs.data_, rhs.data_ + rhs.size_, data_); + std::destroy(data_ + rhs.size_, data_ + size_); + size_ = rhs.size_; } else { - std::copy(rhs._data, rhs._data + _size, _data); - std::uninitialized_copy(rhs._data + _size, rhs._data + rhs._size, _data + _size); - _size = rhs._size; + std::copy(rhs.data_, rhs.data_ + size_, data_); + std::uninitialized_copy(rhs.data_ + size_, rhs.data_ + rhs.size_, data_ + size_); + size_ = rhs.size_; } } void operator=(ipvbase&& rhs) @@ -133,21 +133,21 @@ namespace plg { std::memmove((void*)this, (const void*)std::addressof(rhs), sizeof(ipvbase)); } else if (this == std::addressof(rhs)) { // do nothing - } else if (rhs._size <= _size) { - std::move(rhs._data, rhs._data + rhs._size, _data); - std::destroy(_data + rhs._size, _data + _size); - _size = rhs._size; + } else if (rhs.size_ <= size_) { + std::move(rhs.data_, rhs.data_ + rhs.size_, data_); + std::destroy(data_ + rhs.size_, data_ + size_); + size_ = rhs.size_; } else { - std::move(rhs._data, rhs._data + _size, _data); + std::move(rhs.data_, rhs.data_ + size_, data_); #if defined(__cpp_lib_trivially_relocatable) if constexpr (std::is_trivially_relocatable_v) { - std::uninitialized_relocate(rhs._data + _size, rhs._data + rhs._size, _data + _size); - std::swap(rhs._size, _size); + std::uninitialized_relocate(rhs.data_ + size_, rhs.data_ + rhs.size_, data_ + size_); + std::swap(rhs.size_, size_); return; } #endif // __cpp_lib_trivially_relocatable - std::uninitialized_move(rhs._data + _size, rhs._data + rhs._size, _data + _size); - _size = rhs._size; + std::uninitialized_move(rhs.data_ + size_, rhs.data_ + rhs.size_, data_ + size_); + size_ = rhs.size_; } } @@ -163,13 +163,13 @@ namespace plg { constexpr #endif // PLUGIFY_CPP_VERSION >= 202002L ~ipvbase() { - std::destroy(_data, _data + _size); + std::destroy(data_, data_ + size_); } }; template struct ipvbase_zero { - static constexpr size_t _size = 0; + static constexpr size_t size_ = 0; constexpr T *base_data() { return nullptr; } constexpr const T *base_data() const { return nullptr; } constexpr void set_size(size_t) { } @@ -177,15 +177,15 @@ namespace plg { template struct ipvbase_trivial { - size_t _size = 0; + size_t size_ = 0; union { - [[maybe_unused]] char _dummy; - T _data[N]; + [[maybe_unused]] char dummy_; + T data_[N]; }; constexpr explicit ipvbase_trivial() {} - constexpr T *base_data() { return _data; } - constexpr const T *base_data() const { return _data; } - constexpr void set_size(size_t n) { _size = n; } + constexpr T *base_data() { return data_; } + constexpr const T *base_data() const { return data_; } + constexpr void set_size(size_t n) { size_ = n; } }; template @@ -202,7 +202,7 @@ namespace plg { template class inplace_vector : detail::ipvbase_assignable, detail::ipvbase_t { - using detail::ipvbase_t::_size; + using detail::ipvbase_t::size_; using detail::ipvbase_t::set_size; public: using value_type = T; @@ -277,12 +277,12 @@ namespace plg { { if (n > N) { throw_bad_alloc(); - } else if (_size >= n) { + } else if (size_ >= n) { std::fill_n(data(), n, value); - std::destroy(data() + n, data() + _size); + std::destroy(data() + n, data() + size_); } else { - std::fill_n(data(), _size, value); - std::uninitialized_fill_n(data() + _size, n - _size, value); + std::fill_n(data(), size_, value); + std::uninitialized_fill_n(data() + size_, n - size_, value); } set_size(n); } @@ -293,12 +293,12 @@ namespace plg { const size_type n = static_cast(std::distance(first, last)); if (n > N) { throw_bad_alloc(); - } else if (_size >= n) { + } else if (size_ >= n) { std::copy(first, last, data()); - std::destroy(data() + n, data() + _size); + std::destroy(data() + n, data() + size_); } else { - std::copy(first, first + _size, data()); - std::uninitialized_copy(first + _size, last, data() + _size); + std::copy(first, first + size_, data()); + std::uninitialized_copy(first + size_, last, data() + size_); } set_size(n); } @@ -329,13 +329,13 @@ namespace plg { size_t n = std::ranges::size(rg); if (n > N) { throw_bad_alloc(); - } else if (_size >= n) { + } else if (size_ >= n) { std::ranges::copy(first, last, data()); - std::destroy(data() + n, data() + _size); + std::destroy(data() + n, data() + size_); } else { - auto mid = std::ranges::next(first, _size, last); + auto mid = std::ranges::next(first, size_, last); std::ranges::copy(first, mid, data()); - std::ranges::uninitialized_copy(mid, last, data() + _size); + std::ranges::uninitialized_copy(mid, last, data() + size_); } set_size(n); } @@ -344,15 +344,15 @@ namespace plg { // iterators constexpr iterator begin() noexcept { return data(); } - constexpr iterator end() noexcept { return data() + _size; } + constexpr iterator end() noexcept { return data() + size_; } constexpr const_iterator begin() const noexcept { return data(); } - constexpr const_iterator end() const noexcept { return data() + _size; } + constexpr const_iterator end() const noexcept { return data() + size_; } constexpr reverse_iterator rbegin() noexcept { return reverse_iterator(end()); } constexpr reverse_iterator rend() noexcept { return reverse_iterator(begin()); } constexpr const_reverse_iterator rbegin() const noexcept { return const_reverse_iterator(end()); } constexpr const_reverse_iterator rend() const noexcept { return const_reverse_iterator(begin()); } constexpr const_iterator cbegin() const noexcept { return data(); } - constexpr const_iterator cend() const noexcept { return data() + _size; } + constexpr const_iterator cend() const noexcept { return data() + size_; } constexpr const_reverse_iterator crbegin() const noexcept { return const_reverse_iterator(end()); } constexpr const_reverse_iterator crend() const noexcept { return const_reverse_iterator(begin()); } @@ -361,12 +361,12 @@ namespace plg { { if (n > N) { throw_bad_alloc(); - } else if (n < _size) { - std::destroy(data() + n, data() + _size); + } else if (n < size_) { + std::destroy(data() + n, data() + size_); set_size(n); } else { - std::uninitialized_value_construct(data() + _size, data() + n); - set_size(_size + n); + std::uninitialized_value_construct(data() + size_, data() + n); + set_size(size_ + n); } } @@ -375,12 +375,12 @@ namespace plg { { if (n > N) { throw_bad_alloc(); - } else if (n < _size) { - std::destroy(data() + n, data() + _size); + } else if (n < size_) { + std::destroy(data() + n, data() + size_); set_size(n); } else { - std::uninitialized_fill(data() + _size, data() + n, value); - set_size(_size + n); + std::uninitialized_fill(data() + size_, data() + n, value); + set_size(size_ + n); } } @@ -403,7 +403,7 @@ namespace plg { } constexpr reference back() { PLUGIFY_ASSERT(!empty(), "called on an empty vector"); - return data()[_size - 1]; + return data()[size_ - 1]; } constexpr const_reference operator[](size_type pos) const { @@ -416,17 +416,17 @@ namespace plg { } constexpr const_reference back() const { PLUGIFY_ASSERT(!empty(), "called on an empty vector"); - return data()[_size - 1]; + return data()[size_ - 1]; } constexpr reference at(size_type i) { - if (i >= _size) { + if (i >= size_) { throw_out_of_range(); } return data()[i]; } constexpr const_reference at(size_type i) const { - if (i >= _size) { + if (i >= size_) { throw_out_of_range(); } return data()[i]; @@ -436,20 +436,20 @@ namespace plg { constexpr T* data() noexcept { return this->base_data(); } constexpr const T* data() const noexcept { return this->base_data(); } - constexpr size_type size() const noexcept { return _size; } + constexpr size_type size() const noexcept { return size_; } static constexpr size_type max_size() noexcept { return N; } static constexpr size_type capacity() noexcept { return N; } - [[nodiscard]] constexpr bool empty() const noexcept { return _size == 0; }; + [[nodiscard]] constexpr bool empty() const noexcept { return size_ == 0; }; // [inplace.vector.modifiers] template requires std::is_constructible_v value_type& unchecked_emplace_back(Args&&... args) { - // Precondition: (_size < N) - value_type* p = data() + _size; + // Precondition: (size_ < N) + value_type* p = data() + size_; p = std::construct_at(p, std::forward(args)...); - set_size(_size + 1); + set_size(size_ + 1); return *p; } value_type& unchecked_push_back(const value_type& value) @@ -466,7 +466,7 @@ namespace plg { template requires std::is_constructible_v constexpr value_type* try_emplace_back(Args&&... args) { - if (_size == N) { + if (size_ == N) { return nullptr; } return std::addressof(unchecked_emplace_back(static_cast(args)...)); @@ -485,7 +485,7 @@ namespace plg { template requires std::is_constructible_v value_type& emplace_back(Args&&... args) { - if (_size == N) { + if (size_ == N) { throw_bad_alloc(); } return unchecked_emplace_back(static_cast(args)...); @@ -512,8 +512,8 @@ namespace plg { #endif // __cpp_lib_ranges >= 201911L && __cpp_lib_ranges_to_container >= 202202L void pop_back() { - std::destroy_at(data() + _size - 1); - set_size(_size - 1); + std::destroy_at(data() + size_ - 1); + set_size(size_ - 1); } template @@ -538,7 +538,7 @@ namespace plg { iterator insert(const_iterator pos, size_type n, const value_type& value) requires std::is_copy_constructible_v { - if (N - _size < n) { + if (N - size_ < n) { throw_bad_alloc(); } auto it = iterator(pos); @@ -549,7 +549,7 @@ namespace plg { std::uninitialized_relocate_backward(it, oldend, oldend + n); try { std::uninitialized_fill_n(it, n, value); - set_size(_size + n); + set_size(size_ + n); } catch (...) { std::uninitialized_relocate(it + n, oldend + n, it); throw; @@ -559,7 +559,7 @@ namespace plg { #endif // Fill at the end of the vector, then rotate into place. std::uninitialized_fill_n(oldend, n, value); - set_size(_size + n); + set_size(size_ + n); std::rotate(it, oldend, oldend + n); return it; } @@ -571,7 +571,7 @@ namespace plg { auto oldend = end(); if constexpr (std::random_access_iterator) { size_type n = static_cast(std::distance(first, last)); - if (N - _size < n) { + if (N - size_ < n) { throw_bad_alloc(); } #if defined(__cpp_lib_trivially_relocatable) @@ -580,7 +580,7 @@ namespace plg { std::uninitialized_relocate_backward(it, oldend, oldend + n); try { std::uninitialized_copy_n(first, n, it); - set_size(_size + n); + set_size(size_ + n); } catch (...) { std::uninitialized_relocate(it + n, oldend + n, it); throw; @@ -590,7 +590,7 @@ namespace plg { #endif // Fill at the end of the vector, then rotate into place. std::uninitialized_copy_n(first, n, oldend); - set_size(_size + n); + set_size(size_ + n); std::rotate(it, oldend, oldend + n); } else { for (; first != last; ++first) { @@ -609,7 +609,7 @@ namespace plg { auto oldend = end(); if constexpr (std::ranges::sized_range) { size_type n = std::ranges::size(rg); - if (N - _size < n) { + if (N - size_ < n) { throw_bad_alloc(); } #if defined(__cpp_lib_trivially_relocatable) @@ -618,7 +618,7 @@ namespace plg { std::uninitialized_relocate_backward(it, oldend, oldend + n); try { std::ranges::uninitialized_copy_n(std::ranges::begin(rg), n, it, std::unreachable_sentinel); - set_size(_size + n); + set_size(size_ + n); } catch (...) { std::uninitialized_relocate(it + n, oldend + n, it); throw; @@ -628,7 +628,7 @@ namespace plg { #endif // Fill at the end of the vector, then rotate into place. std::ranges::uninitialized_copy_n(std::ranges::begin(rg), n, oldend, std::unreachable_sentinel); - set_size(_size + n); + set_size(size_ + n); std::rotate(it, oldend, oldend + n); } else { auto [rgend, newend] = std::ranges::uninitialized_copy(rg, std::ranges::subrange(oldend, data() + N)); @@ -659,13 +659,13 @@ namespace plg { if constexpr (std::is_trivially_relocatable_v) { std::destroy_at(it); std::uninitialized_relocate(it + 1, oldend, it); - set_size(_size - 1); + set_size(size_ - 1); return it; } #endif std::move(it + 1, oldend, it); std::destroy_at(oldend - 1); - set_size(_size - 1); + set_size(size_ - 1); return it; } @@ -681,18 +681,18 @@ namespace plg { if constexpr (std::is_trivially_relocatable_v) { std::destroy(ifirst, ilast); std::uninitialized_relocate(ilast, oldend, ifirst); - set_size(_size - n); + set_size(size_ - n); return ifirst; } #endif // __cpp_lib_trivially_relocatable std::destroy(std::move(ilast, oldend, ifirst), oldend); - set_size(_size - n); + set_size(size_ - n); } return ifirst; } constexpr void clear() noexcept { - std::destroy(data(), data() + _size); + std::destroy(data(), data() + size_); set_size(0); } @@ -701,20 +701,20 @@ namespace plg { requires (!std::is_const_v) { auto& a = *this; - if (a._size < b._size) { + if (a.size_ < b.size_) { b.swap(a); } else { - std::swap_ranges(a.data(), a.data() + b._size, b.data()); + std::swap_ranges(a.data(), a.data() + b.size_, b.data()); #if defined(__cpp_lib_trivially_relocatable) - size_t n = a._size; - a.set_size(b._size); - std::uninitialized_relocate(a.data() + b._size, a.data() + n, b.data() + b._size); + size_t n = a.size_; + a.set_size(b.size_); + std::uninitialized_relocate(a.data() + b.size_, a.data() + n, b.data() + b.size_); b.set_size(n); #else - std::uninitialized_move(a.data() + b._size, a.data() + a._size, b.data() + b._size); - std::destroy(a.data() + b._size, a.data() + a._size); + std::uninitialized_move(a.data() + b.size_, a.data() + a.size_, b.data() + b.size_); + std::destroy(a.data() + b.size_, a.data() + a.size_); if constexpr (N != 0) { - std::swap(a._size, b._size); + std::swap(a.size_, b.size_); } #endif } @@ -737,7 +737,7 @@ namespace plg { constexpr friend bool operator<(const inplace_vector& a, const inplace_vector& b) { const T* adata = a.data(); const T* bdata = b.data(); - size_t n = (a._size < b._size) ? a._size : b._size; + size_t n = (a.size_ < b.size_) ? a.size_ : b.size_; for (size_t i = 0; i < n; ++i) { if (adata[i] < bdata[i]) { return true; @@ -745,7 +745,7 @@ namespace plg { return false; } } - return (a._size < b._size); + return (a.size_ < b.size_); } constexpr friend bool operator>(const inplace_vector& a, const inplace_vector& b) { return (b < a); } constexpr friend bool operator<=(const inplace_vector& a, const inplace_vector& b) { return !(b < a); } diff --git a/test/cross_call_master/external/plugify/include/plg/split_buffer.hpp b/test/cross_call_master/external/plugify/include/plg/split_buffer.hpp index 0568d15..ddae84f 100644 --- a/test/cross_call_master/external/plugify/include/plg/split_buffer.hpp +++ b/test/cross_call_master/external/plugify/include/plg/split_buffer.hpp @@ -26,115 +26,115 @@ namespace plg { public: constexpr split_buffer_pointer_layout() - : _back_cap(nullptr) { + : back_cap_(nullptr) { } constexpr explicit split_buffer_pointer_layout(const allocator_type& alloc) - : _back_cap(nullptr) - , _alloc(alloc) { + : back_cap_(nullptr) + , alloc_(alloc) { } constexpr pointer front_cap() noexcept { - return _front_cap; + return front_cap_; } constexpr const_pointer front_cap() const noexcept { - return _front_cap; + return front_cap_; } constexpr pointer begin() noexcept { - return _begin; + return begin_; } constexpr const_pointer begin() const noexcept { - return _begin; + return begin_; } constexpr pointer end() noexcept { - return _end; + return end_; } constexpr pointer end() const noexcept { - return _end; + return end_; } constexpr size_type size() const noexcept { - return static_cast(_end - _begin); + return static_cast(end_ - begin_); } constexpr bool empty() const noexcept { - return _begin == _end; + return begin_ == end_; } constexpr size_type capacity() const noexcept { - return static_cast(_back_cap - _front_cap); + return static_cast(back_cap_ - front_cap_); } constexpr allocator_type& get_allocator() noexcept { - return _alloc; + return alloc_; } constexpr const allocator_type& get_allocator() const noexcept { - return _alloc; + return alloc_; } // Returns the sentinel object directly. Should be used in conjunction with automatic type // deduction, not explicit types. constexpr sentinel_type raw_sentinel() const noexcept { - return _end; + return end_; } constexpr sentinel_type raw_capacity() const noexcept { - return _back_cap; + return back_cap_; } constexpr void set_data(pointer new_first) noexcept { - _front_cap = new_first; + front_cap_ = new_first; } constexpr void set_valid_range(pointer new_begin, pointer new_end) noexcept { - _begin = new_begin; - _end = new_end; + begin_ = new_begin; + end_ = new_end; } constexpr void set_valid_range(pointer new_begin, size_type new_size) noexcept { - _begin = new_begin; - _end = _begin + new_size; + begin_ = new_begin; + end_ = begin_ + new_size; } constexpr void set_sentinel(pointer new_end) noexcept { - PLUGIFY_ASSERT(_front_cap <= new_end, "new_end cannot precede _front_cap"); - _end = new_end; + PLUGIFY_ASSERT(front_cap_ <= new_end, "new_end cannot precede front_cap_"); + end_ = new_end; } constexpr void set_sentinel(size_type new_size) noexcept { - _end = _begin + new_size; + end_ = begin_ + new_size; } constexpr void set_capacity(size_type new_capacity) noexcept { - _back_cap = _front_cap + new_capacity; + back_cap_ = front_cap_ + new_capacity; } constexpr void set_capacity(pointer new_capacity) noexcept { - _back_cap = new_capacity; + back_cap_ = new_capacity; } constexpr size_type front_spare() const noexcept { - return static_cast(_begin - _front_cap); + return static_cast(begin_ - front_cap_); } constexpr size_type back_spare() const noexcept { - return static_cast(_back_cap - _end); + return static_cast(back_cap_ - end_); } constexpr reference back() noexcept { - return *(_end - 1); + return *(end_ - 1); } constexpr const_reference back() const noexcept { - return *(_end - 1); + return *(end_ - 1); } constexpr void swap_without_allocator( @@ -143,42 +143,42 @@ namespace plg { value_type, alloc_rr&>& other ) noexcept { - std::swap(_front_cap, other._front_cap); - std::swap(_begin, other._begin); - std::swap(_back_cap, other._back_cap); - std::swap(_end, other._end); + std::swap(front_cap_, other.front_cap_); + std::swap(begin_, other.begin_); + std::swap(back_cap_, other.back_cap_); + std::swap(end_, other.end_); } constexpr void swap(split_buffer_pointer_layout& other) noexcept { - std::swap(_front_cap, other._front_cap); - std::swap(_begin, other._begin); - std::swap(_back_cap, other._back_cap); - std::swap(_end, other._end); - swap_allocator(_alloc, other._alloc); + std::swap(front_cap_, other.front_cap_); + std::swap(begin_, other.begin_); + std::swap(back_cap_, other.back_cap_); + std::swap(end_, other.end_); + swap_allocator(alloc_, other.alloc_); } constexpr void reset() noexcept { - _front_cap = nullptr; - _begin = nullptr; - _end = nullptr; - _back_cap = nullptr; + front_cap_ = nullptr; + begin_ = nullptr; + end_ = nullptr; + back_cap_ = nullptr; } constexpr void copy_without_alloc( const split_buffer_pointer_layout& other ) noexcept(std::is_nothrow_copy_assignable::value) { - _front_cap = other._front_cap; - _begin = other._begin; - _end = other._end; - _back_cap = other._back_cap; + front_cap_ = other.front_cap_; + begin_ = other.begin_; + end_ = other.end_; + back_cap_ = other.back_cap_; } private: - pointer _front_cap = nullptr; - pointer _begin = nullptr; - pointer _end = nullptr; - pointer _back_cap = nullptr; - PLUGIFY_NO_UNIQUE_ADDRESS allocator_type _alloc; + pointer front_cap_ = nullptr; + pointer begin_ = nullptr; + pointer end_ = nullptr; + pointer back_cap_ = nullptr; + PLUGIFY_NO_UNIQUE_ADDRESS allocator_type alloc_; template friend class split_buffer_pointer_layout; @@ -205,73 +205,73 @@ namespace plg { constexpr split_buffer_size_layout() = default; constexpr explicit split_buffer_size_layout(const allocator_type& alloc) - : _alloc(alloc) { + : alloc_(alloc) { } constexpr pointer front_cap() noexcept { - return _front_cap; + return front_cap_; } constexpr const_pointer front_cap() const noexcept { - return _front_cap; + return front_cap_; } constexpr pointer begin() noexcept { - return _begin; + return begin_; } constexpr const_pointer begin() const noexcept { - return _begin; + return begin_; } constexpr pointer end() noexcept { - return _begin + _size; + return begin_ + size_; } constexpr pointer end() const noexcept { - return _begin + _size; + return begin_ + size_; } constexpr size_type size() const noexcept { - return _size; + return size_; } constexpr bool empty() const noexcept { - return _size == 0; + return size_ == 0; } constexpr size_type capacity() const noexcept { - return _cap; + return cap_; } constexpr allocator_type& get_allocator() noexcept { - return _alloc; + return alloc_; } constexpr const allocator_type& get_allocator() const noexcept { - return _alloc; + return alloc_; } // Returns the sentinel object directly. Should be used in conjunction with automatic type // deduction, not explicit types. constexpr sentinel_type raw_sentinel() const noexcept { - return _size; + return size_; } constexpr sentinel_type raw_capacity() const noexcept { - return _cap; + return cap_; } constexpr void set_data(pointer new_first) noexcept { - _front_cap = new_first; + front_cap_ = new_first; } constexpr void set_valid_range(pointer new_begin, pointer new_end) noexcept { // Size-based split_buffers track their size directly: we need to explicitly update the size // when the front is adjusted. - _size -= new_begin - _begin; - _begin = new_begin; + size_ -= new_begin - begin_; + begin_ = new_begin; set_sentinel(new_end); } @@ -279,44 +279,44 @@ namespace plg { set_valid_range(pointer new_begin, size_type new_size) noexcept { // Size-based split_buffers track their size directly: we need to explicitly update the size // when the front is adjusted. - _size -= new_begin - _begin; - _begin = new_begin; + size_ -= new_begin - begin_; + begin_ = new_begin; set_sentinel(new_size); } constexpr void set_sentinel(pointer new_end) noexcept { - _LIBCPP_ASSERT_INTERNAL(_front_cap <= new_end, "new_end cannot precede _front_cap"); - _size += new_end - end(); + _LIBCPP_ASSERT_INTERNAL(front_cap_ <= new_end, "new_end cannot precede front_cap_"); + size_ += new_end - end(); } constexpr void set_sentinel(size_type new_size) noexcept { - _size = new_size; + size_ = new_size; } constexpr void set_capacity(size_type new_capacity) noexcept { - _cap = new_capacity; + cap_ = new_capacity; } constexpr void set_capacity(pointer new_capacity) noexcept { - _cap = new_capacity - _begin; + cap_ = new_capacity - begin_; } constexpr size_type front_spare() const noexcept { - return static_cast(_begin - _front_cap); + return static_cast(begin_ - front_cap_); } constexpr size_type back_spare() const noexcept { - // `_cap - _end` tells us the total number of spares when in size-mode. We need to remove + // `cap_ - end_` tells us the total number of spares when in size-mode. We need to remove // the front_spare from the count. - return _cap - _size - front_spare(); + return cap_ - size_ - front_spare(); } constexpr reference back() noexcept { - return _begin[_size - 1]; + return begin_[size_ - 1]; } constexpr const_reference back() const noexcept { - return _begin[_size - 1]; + return begin_[size_ - 1]; } constexpr void swap_without_allocator( @@ -325,42 +325,42 @@ namespace plg { value_type, alloc_rr&>& other ) noexcept { - std::swap(_front_cap, other._front_cap); - std::swap(_begin, other._begin); - std::swap(_cap, other._cap); - std::swap(_size, other._size); + std::swap(front_cap_, other.front_cap_); + std::swap(begin_, other.begin_); + std::swap(cap_, other.cap_); + std::swap(size_, other.size_); } constexpr void swap(split_buffer_size_layout& other) noexcept { - std::swap(_front_cap, other._front_cap); - std::swap(_begin, other._begin); - std::swap(_cap, other._cap); - std::swap(_size, other._size); - swap_allocator(_alloc, other._alloc); + std::swap(front_cap_, other.front_cap_); + std::swap(begin_, other.begin_); + std::swap(cap_, other.cap_); + std::swap(size_, other.size_); + swap_allocator(alloc_, other.alloc_); } constexpr void reset() noexcept { - _front_cap = nullptr; - _begin = nullptr; - _size = 0; - _cap = 0; + front_cap_ = nullptr; + begin_ = nullptr; + size_ = 0; + cap_ = 0; } constexpr void copy_without_alloc( const split_buffer_size_layout& other ) noexcept(std::is_nothrow_copy_assignable::value) { - _front_cap = other._front_cap; - _begin = other._begin; - _cap = other._cap; - _size = other._size; + front_cap_ = other.front_cap_; + begin_ = other.begin_; + cap_ = other.cap_; + size_ = other.size_; } private: - pointer _front_cap = nullptr; - pointer _begin = nullptr; - size_type _size = 0; - size_type _cap = 0; - PLUGIFY_NO_UNIQUE_ADDRESS allocator_type _alloc; + pointer front_cap_ = nullptr; + pointer begin_ = nullptr; + size_type size_ = 0; + size_type cap_ = 0; + PLUGIFY_NO_UNIQUE_ADDRESS allocator_type alloc_; template friend class split_buffer_size_layout; @@ -377,11 +377,11 @@ namespace plg { // // |oooooooooooooooooooxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxoooooooooooooooooooooooo| // ^ ^ ^ ^ - // _front_cap _begin _end _back_cap + // front_cap_ begin_ end_ back_cap_ // - // The range [_front_cap, _begin) contains uninitialized memory. It is referred to as the "front - // spare capacity". The range [_begin, _end) contains valid objects. It is referred to as the "valid - // range". The range [_end, _back_cap) contains uninitialized memory. It is referred to as the "back + // The range [front_cap_, begin_) contains uninitialized memory. It is referred to as the "front + // spare capacity". The range [begin_, end_) contains valid objects. It is referred to as the "valid + // range". The range [end_, back_cap_) contains uninitialized memory. It is referred to as the "back // spare capacity". // // The layout of `split_buffer` is determined by the `Layout` template template parameter. This @@ -641,20 +641,20 @@ namespace plg { pointer p, size_type n ) noexcept - : _pos(p) - , _end(p + n) - , _parent(parent) { + : pos_(p) + , end_(p + n) + , parent_(parent) { } constexpr ~ConstructTransaction() { - _parent->set_sentinel(_pos); + parent_->set_sentinel(pos_); } - pointer _pos; - const pointer _end; + pointer pos_; + const pointer end_; private: - split_buffer* _parent; + split_buffer* parent_; }; template class L2> @@ -669,8 +669,8 @@ namespace plg { template class Layout> constexpr void split_buffer::construct_at_end(size_type n) { ConstructTransaction tx(this, end(), n); - for (; tx._pos != tx._end; ++tx._pos) { - alloc_traits::construct(get_allocator(), std::to_address(tx._pos)); + for (; tx.pos_ != tx.end_; ++tx.pos_) { + alloc_traits::construct(get_allocator(), std::to_address(tx.pos_)); } } @@ -684,8 +684,8 @@ namespace plg { constexpr void split_buffer::construct_at_end(size_type n, const_reference x) { ConstructTransaction tx(this, end(), n); - for (; tx._pos != tx._end; ++tx._pos) { - alloc_traits::construct(get_allocator(), std::to_address(tx._pos), x); + for (; tx.pos_ != tx.end_; ++tx.pos_) { + alloc_traits::construct(get_allocator(), std::to_address(tx.pos_), x); } } @@ -725,8 +725,8 @@ namespace plg { constexpr void split_buffer::construct_at_end_with_size(ForwardIterator first, size_type n) { ConstructTransaction tx(this, end(), n); - for (; tx._pos != tx._end; ++tx._pos, (void) ++first) { - alloc_traits::construct(get_allocator(), std::to_address(tx._pos), *first); + for (; tx.pos_ != tx.end_; ++tx.pos_, (void) ++first) { + alloc_traits::construct(get_allocator(), std::to_address(tx.pos_), *first); } } diff --git a/test/cross_call_master/external/plugify/include/plg/string.hpp b/test/cross_call_master/external/plugify/include/plg/string.hpp index 3613b95..aaaf3c1 100644 --- a/test/cross_call_master/external/plugify/include/plg/string.hpp +++ b/test/cross_call_master/external/plugify/include/plg/string.hpp @@ -650,7 +650,7 @@ namespace plg { template struct padding { - char _pad[N]; + char padding[N]; }; template <> @@ -781,32 +781,32 @@ namespace plg { constexpr long_() = default; constexpr long_(alloc_result alloc, size_type size) - : _data(alloc.ptr) - , _size(size) - , _cap(alloc.count / endian_factor) - , _is_long(true) { + : data_(alloc.ptr) + , size_(size) + , cap_(alloc.count / endian_factor) + , is_long_(true) { PLUGIFY_ASSERT(!fits_in_sso(alloc.count), "Long capacity should always be larger than the SSO"); } - pointer _data; - size_type _size; - size_type _cap : sizeof(size_type) * char_bit - 1; - size_type _is_long : 1; + pointer data_; + size_type size_; + size_type cap_ : sizeof(size_type) * char_bit - 1; + size_type is_long_ : 1; }; static constexpr size_type min_cap = ((sizeof(long_) - 1) / sizeof(value_type) > 2 ? (sizeof(long_) - 1) / sizeof(value_type) : 2) + 1; struct short_ { constexpr short_() - : _data{} - , _spare_size(min_cap - 1) - , _is_long(false) { + : data_{} + , spare_size_(min_cap - 1) + , is_long_(false) { } - value_type _data[min_cap - 1]; - PLUGIFY_NO_UNIQUE_ADDRESS padding _padding; - uint8_t _spare_size : 7; - uint8_t _is_long : 1; + value_type data_[min_cap - 1]; + PLUGIFY_NO_UNIQUE_ADDRESS padding padding_; + uint8_t spare_size_ : 7; + uint8_t is_long_ : 1; }; // The endian_factor is required because the field we use to store the size @@ -836,21 +836,21 @@ namespace plg { union rep { short_ s{}; long_ l; - } _rep; + } rep_; PLUGIFY_NO_UNIQUE_ADDRESS - allocator_type _alloc; + allocator_type alloc_; // annotate the string with its size() at scope exit. The string has to be in a valid state // at that point. struct annotate_new_size { - basic_string& _str; + basic_string& str_; constexpr explicit annotate_new_size(basic_string& str) - : _str(str) { + : str_(str) { } constexpr void operator()() { - _str.annotate_new(_str.size()); + str_.annotate_new(str_.size()); } }; @@ -858,13 +858,13 @@ namespace plg { // but don't initialize the characters. The contents of the string, including the null // terminator, must be initialized separately. constexpr /*explicit*/ basic_string(uninitialized_size_tag, size_type size, const allocator_type& a) - : _alloc(a) { + : alloc_(a) { init_internal_buffer(size); } template constexpr basic_string(init_with_sentinel_tag, Iter first, Sent last, const allocator_type& a) - : _alloc(a) { + : alloc_(a) { init_with_sentinel(std::move(first), std::move(last)); } @@ -880,20 +880,20 @@ namespace plg { static const size_type npos = static_cast(-1); constexpr basic_string() noexcept(std::is_nothrow_default_constructible_v) - : _rep(short_()) { + : rep_(short_()) { annotate_new(0); } constexpr /*explicit*/ basic_string(const allocator_type& a) noexcept - : _rep(short_()) - , _alloc(a) { + : rep_(short_()) + , alloc_(a) { annotate_new(0); } constexpr PLUGIFY_INTERNAL_MEMORY_ACCESS basic_string(const basic_string& str) - : _alloc(alloc_traits::select_on_container_copy_construction(str._alloc)) { + : alloc_(alloc_traits::select_on_container_copy_construction(str.alloc_)) { if (!str.is_long()) { - _rep = str._rep; + rep_ = str.rep_; annotate_new(get_short_size()); } else { init_copy_ctor_external(std::to_address(str.get_long_pointer()), str.get_long_size()); @@ -902,9 +902,9 @@ namespace plg { constexpr PLUGIFY_INTERNAL_MEMORY_ACCESS basic_string(const basic_string& str, const allocator_type& a) - : _alloc(a) { + : alloc_(a) { if (!str.is_long()) { - _rep = str._rep; + rep_ = str.rep_; annotate_new(get_short_size()); } else { init_copy_ctor_external(std::to_address(str.get_long_pointer()), str.get_long_size()); @@ -916,14 +916,14 @@ namespace plg { // PLUGIFY_INTERNAL_MEMORY_ACCESS does not work consistently during // initialization of r_, so we instead unpoison str's memory manually first. str's // memory needs to be unpoisoned only in the case where it's a short string. - : _rep([](basic_string& s) -> decltype(s._rep)&& { + : rep_([](basic_string& s) -> decltype(s.rep_)&& { if (!s.is_long()) { s.annotate_delete(); } - return std::move(s._rep); + return std::move(s.rep_); }(str)) - , _alloc(std::move(str._alloc)) { - str._rep = rep(); + , alloc_(std::move(str.alloc_)) { + str.rep_ = rep(); str.annotate_new(0); if (!is_long()) { annotate_new(size()); @@ -931,18 +931,18 @@ namespace plg { } constexpr basic_string(basic_string&& str, const allocator_type& a) - : _alloc(a) { - if (str.is_long() && a != str._alloc) { // copy, not move + : alloc_(a) { + if (str.is_long() && a != str.alloc_) { // copy, not move init(std::to_address(str.get_long_pointer()), str.get_long_size()); } else { if (std::is_constant_evaluated()) { - _rep = rep(); + rep_ = rep(); } if (!str.is_long()) { str.annotate_delete(); } - _rep = str._rep; - str._rep = rep(); + rep_ = str.rep_; + str.rep_ = rep(); str.annotate_new(0); if (!is_long() && this != std::addressof(str)) { annotate_new(size()); @@ -959,7 +959,7 @@ namespace plg { constexpr basic_string(const CharT* PLUGIFY_NO_NULL s, const Allocator& a) requires(is_allocator) - : _alloc(a) { + : alloc_(a) { PLUGIFY_ASSERT(s != nullptr, "basic_string(const char*, allocator) detected nullptr"); init(s, traits_type::length(s)); } @@ -972,7 +972,7 @@ namespace plg { } constexpr basic_string(const CharT* s, size_type n, const Allocator& a) - : _alloc(a) { + : alloc_(a) { PLUGIFY_ASSERT( n == 0 || s != nullptr, "basic_string(const char*, n, allocator) detected nullptr" @@ -994,13 +994,13 @@ namespace plg { size_type n, const Allocator& alloc = Allocator() ) - : _alloc(alloc) { + : alloc_(alloc) { if (pos > str.size()) { this->throw_out_of_range(); } auto len = std::min(n, str.size() - pos); - if (alloc_traits::is_always_equal::value || alloc == str._alloc) { + if (alloc_traits::is_always_equal::value || alloc == str.alloc_) { move_assign(std::move(str), pos, len); } else { // Perform a copy because the allocators are not compatible. @@ -1010,7 +1010,7 @@ namespace plg { constexpr basic_string(size_type n, CharT c, const Allocator& a) requires(is_allocator) - : _alloc(a) { + : alloc_(a) { init(n, c); } @@ -1020,7 +1020,7 @@ namespace plg { size_type n, const Allocator& a = Allocator() ) - : _alloc(a) { + : alloc_(a) { size_type str_sz = str.size(); if (pos > str_sz) { this->throw_out_of_range(); @@ -1029,7 +1029,7 @@ namespace plg { } constexpr basic_string(const basic_string& str, size_type pos, const Allocator& a = Allocator()) - : _alloc(a) { + : alloc_(a) { size_type str_sz = str.size(); if (pos > str_sz) { this->throw_out_of_range(); @@ -1044,7 +1044,7 @@ namespace plg { size_type n, const allocator_type& a = allocator_type() ) - : _alloc(a) { + : alloc_(a) { self_view sv0 = t; self_view sv = sv0.substr(pos, n); init(sv.data(), sv.size()); @@ -1058,7 +1058,7 @@ namespace plg { template T> constexpr /*explicit*/ basic_string(const T& t, const allocator_type& a) - : _alloc(a) { + : alloc_(a) { self_view sv = t; init(sv.data(), sv.size()); } @@ -1070,14 +1070,14 @@ namespace plg { template constexpr basic_string(InputIterator first, InputIterator last, const allocator_type& a) - : _alloc(a) { + : alloc_(a) { init(first, last); } #if PLUGIFY_HAS_CXX23 template Range> constexpr basic_string(std::from_range_t, Range&& range, const allocator_type& a = allocator_type()) - : _alloc(a) { + : alloc_(a) { if constexpr (std::ranges::forward_range || std::ranges::sized_range) { init_with_size( std::ranges::begin(range), @@ -1095,7 +1095,7 @@ namespace plg { } constexpr basic_string(std::initializer_list il, const Allocator& a) - : _alloc(a) { + : alloc_(a) { init(il.begin(), il.end()); } @@ -1194,7 +1194,7 @@ namespace plg { constexpr size_type max_size() const noexcept { constexpr bool uses_lsb = endian_factor == 2; - if (size_type m = alloc_traits::max_size(_alloc); + if (size_type m = alloc_traits::max_size(alloc_); m <= std::numeric_limits::max() / 2) { size_type res = m - alignment; @@ -1317,7 +1317,7 @@ namespace plg { template constexpr basic_string& append(InputIterator first, InputIterator last) { - const basic_string temp(first, last, _alloc); + const basic_string temp(first, last, alloc_); append(temp.data(), temp.size()); return *this; } @@ -1341,7 +1341,7 @@ namespace plg { set_size(sz + n); return *this; } else { - const basic_string temp(first, last, _alloc); + const basic_string temp(first, last, alloc_); return append(temp.data(), temp.size()); } } @@ -1389,13 +1389,13 @@ namespace plg { constexpr void move_assign(basic_string&& str, size_type pos, size_type len) { // Pilfer the allocation from str. - PLUGIFY_ASSERT(_alloc == str._alloc, "move_assign called with wrong allocator"); + PLUGIFY_ASSERT(alloc_ == str.alloc_, "move_assign called with wrong allocator"); size_type old_sz = str.size(); if (!str.is_long()) { str.annotate_delete(); } - _rep = str._rep; - str._rep = rep(); + rep_ = str.rep_; + str.rep_ = rep(); str.annotate_new(0); Traits::move(data(), data() + pos, len); @@ -1510,7 +1510,7 @@ namespace plg { return insert_with_size(position, std::ranges::begin(range), std::ranges::end(range), n); } else { - basic_string temp(std::from_range, std::forward(range), _alloc); + basic_string temp(std::from_range, std::forward(range), alloc_); return insert(position, temp.data(), temp.data() + temp.size()); } } @@ -1524,7 +1524,7 @@ namespace plg { template constexpr iterator insert(const_iterator pos, InputIterator first, InputIterator last) { - const basic_string temp(first, last, _alloc); + const basic_string temp(first, last, alloc_); return insert(pos, temp.data(), temp.data() + temp.size()); } @@ -1605,7 +1605,7 @@ namespace plg { template constexpr basic_string& replace(const_iterator i1, const_iterator i2, InputIterator j1, InputIterator j2) { - const basic_string temp(j1, j2, _alloc); + const basic_string temp(j1, j2, alloc_); return replace(i1, i2, temp); } @@ -1613,7 +1613,7 @@ namespace plg { template Range> constexpr basic_string& replace_with_range(const_iterator i1, const_iterator i2, Range&& range) { - basic_string temp(std::from_range, std::forward(range), _alloc); + basic_string temp(std::from_range, std::forward(range), alloc_); return replace(i1, i2, temp); } #endif @@ -1651,7 +1651,7 @@ namespace plg { } constexpr allocator_type get_allocator() const noexcept { - return _alloc; + return alloc_; } // find @@ -1890,7 +1890,7 @@ namespace plg { // starts_with constexpr bool starts_with(self_view sv) const noexcept { - return self_view(typename self_view::assume_valid(), data(), size()).starts_with(sv); + return self_view(data(), size()).starts_with(sv); } constexpr bool starts_with(value_type c) const noexcept { @@ -1904,7 +1904,7 @@ namespace plg { // ends_with constexpr bool ends_with(self_view sv) const noexcept { - return self_view(typename self_view::assume_valid(), data(), size()).ends_with(sv); + return self_view(data(), size()).ends_with(sv); } constexpr bool ends_with(value_type c) const noexcept { @@ -1918,25 +1918,25 @@ namespace plg { // contains constexpr bool contains(self_view sv) const noexcept { - return self_view(typename self_view::assume_valid(), data(), size()).contains(sv); + return self_view(data(), size()).contains(sv); } constexpr bool contains(value_type c) const noexcept { - return self_view(typename self_view::assume_valid(), data(), size()).contains(c); + return self_view(data(), size()).contains(c); } constexpr bool contains(const value_type* PLUGIFY_NO_NULL s) const { - return self_view(typename self_view::assume_valid(), data(), size()).contains(s); + return self_view(data(), size()).contains(s); } [[nodiscard]] constexpr bool invariants() const; private: [[nodiscard]] constexpr PLUGIFY_INTERNAL_MEMORY_ACCESS bool is_long() const noexcept { - if (std::is_constant_evaluated() && __builtin_constant_p(_rep.l._is_long)) { - return _rep.l._is_long; + if (std::is_constant_evaluated() && __builtin_constant_p(rep_.l.is_long_)) { + return rep_.l.is_long_; } - return _rep.s._is_long; + return rep_.s.is_long_; } static constexpr bool fits_in_sso(size_type sz) { @@ -2008,22 +2008,22 @@ namespace plg { s < min_cap, "s should never be greater than or equal to the short string capacity" ); - _rep.s._spare_size = (min_cap - 1) - s; - _rep.s._is_long = false; + rep_.s.spare_size_ = (min_cap - 1) - s; + rep_.s.is_long_ = false; } constexpr PLUGIFY_INTERNAL_MEMORY_ACCESS size_type get_short_size() const noexcept { - PLUGIFY_ASSERT(!_rep.s._is_long, "String has to be short when trying to get the short size"); - return (min_cap - 1) - _rep.s._spare_size; + PLUGIFY_ASSERT(!rep_.s.is_long_, "String has to be short when trying to get the short size"); + return (min_cap - 1) - rep_.s.spare_size_; } constexpr void set_long_size(size_type s) noexcept { - _rep.l._size = s; + rep_.l.size_ = s; } constexpr size_type get_long_size() const noexcept { - PLUGIFY_ASSERT(_rep.l._is_long, "String has to be long when trying to get the long size"); - return _rep.l._size; + PLUGIFY_ASSERT(rep_.l.is_long_, "String has to be long when trying to get the long size"); + return rep_.l.size_; } constexpr void set_size(size_type s) noexcept { @@ -2035,29 +2035,29 @@ namespace plg { } constexpr size_type get_long_cap() const noexcept { - PLUGIFY_ASSERT(_rep.l._is_long, "String has to be long when trying to get the long capacity"); - return _rep.l._cap * endian_factor; + PLUGIFY_ASSERT(rep_.l.is_long_, "String has to be long when trying to get the long capacity"); + return rep_.l.cap_ * endian_factor; } constexpr pointer get_long_pointer() noexcept { - PLUGIFY_ASSERT(_rep.l._is_long, "String has to be long when trying to get the long pointer"); - return PLUGIFY_ASAN_VOLATILE_WRAPPER(_rep.l._data); + PLUGIFY_ASSERT(rep_.l.is_long_, "String has to be long when trying to get the long pointer"); + return PLUGIFY_ASAN_VOLATILE_WRAPPER(rep_.l.data_); } constexpr const_pointer get_long_pointer() const noexcept { - PLUGIFY_ASSERT(_rep.l._is_long, "String has to be long when trying to get the long pointer"); - return PLUGIFY_ASAN_VOLATILE_WRAPPER(_rep.l._data); + PLUGIFY_ASSERT(rep_.l.is_long_, "String has to be long when trying to get the long pointer"); + return PLUGIFY_ASAN_VOLATILE_WRAPPER(rep_.l.data_); } constexpr PLUGIFY_INTERNAL_MEMORY_ACCESS pointer get_short_pointer() noexcept { return PLUGIFY_ASAN_VOLATILE_WRAPPER( - std::pointer_traits::pointer_to(_rep.s._data[0]) + std::pointer_traits::pointer_to(rep_.s.data_[0]) ); } constexpr PLUGIFY_INTERNAL_MEMORY_ACCESS const_pointer get_short_pointer() const noexcept { return PLUGIFY_ASAN_VOLATILE_WRAPPER( - std::pointer_traits::pointer_to(_rep.s._data[0]) + std::pointer_traits::pointer_to(rep_.s.data_[0]) ); } @@ -2094,22 +2094,22 @@ namespace plg { constexpr void reset_internal_buffer() { annotate_delete(); if (is_long()) { - alloc_traits::deallocate(_alloc, get_long_pointer(), get_long_cap()); + alloc_traits::deallocate(alloc_, get_long_pointer(), get_long_cap()); } - _rep.s = short_(); + rep_.s = short_(); } // Replace the current buffer with alloc; the first size elements constitute a string constexpr void replace_internal_buffer(long_ alloc) { reset_internal_buffer(); - _rep.l = alloc; + rep_.l = alloc; } // Initialize the internal buffer to hold size elements // The elements and null terminator have to be set by the caller constexpr pointer init_internal_buffer(size_type size) { if (std::is_constant_evaluated()) { - _rep = rep(); + rep_ = rep(); } if (size > max_size()) { @@ -2121,7 +2121,7 @@ namespace plg { annotate_new(size); return get_short_pointer(); } else { - _rep.l = allocate_long_buffer(_alloc, size); + rep_.l = allocate_long_buffer(alloc_, size); annotate_new(size); return get_long_pointer(); } @@ -2270,18 +2270,18 @@ namespace plg { } constexpr void copy_assign_alloc(const basic_string& str, std::true_type) { - if (_alloc == str._alloc) { - _alloc = str._alloc; + if (alloc_ == str.alloc_) { + alloc_ = str.alloc_; } else { if (!str.is_long()) { reset_internal_buffer(); - _alloc = str._alloc; + alloc_ = str.alloc_; } else { annotate_delete(); [[maybe_unused]] auto guard = make_scope_guard(annotate_new_size(*this)); - auto alloc = str._alloc; + auto alloc = str.alloc_; replace_internal_buffer(allocate_long_buffer(alloc, str.size())); - _alloc = std::move(alloc); + alloc_ = std::move(alloc); } } } @@ -2307,7 +2307,7 @@ namespace plg { basic_string& c, std::true_type ) noexcept(std::is_nothrow_move_assignable_v) { - _alloc = std::move(c._alloc); + alloc_ = std::move(c.alloc_); } constexpr void move_assign_alloc(basic_string&, std::false_type) noexcept { @@ -2433,7 +2433,7 @@ namespace plg { template constexpr void basic_string::init_with_sentinel(InputIterator first, Sentinel last) { - _rep = rep(); + rep_ = rep(); annotate_new(0); #if PLUGIFY_HAS_EXCEPTIONS @@ -2500,23 +2500,23 @@ namespace plg { : ms; annotate_delete(); [[maybe_unused]] auto guard = make_scope_guard(annotate_new_size(*this)); - long_ buffer = allocate_long_buffer(_alloc, cap); + long_ buffer = allocate_long_buffer(alloc_, cap); if (n_copy != 0) { - traits_type::copy(std::to_address(buffer._data), std::to_address(old_p), n_copy); + traits_type::copy(std::to_address(buffer.data_), std::to_address(old_p), n_copy); } if (n_add != 0) { - traits_type::copy(std::to_address(buffer._data) + n_copy, p_new_stuff, n_add); + traits_type::copy(std::to_address(buffer.data_) + n_copy, p_new_stuff, n_add); } size_type sec_cp_sz = old_sz - n_del - n_copy; if (sec_cp_sz != 0) { traits_type::copy( - std::to_address(buffer._data) + n_copy + n_add, + std::to_address(buffer.data_) + n_copy + n_add, std::to_address(old_p) + n_copy + n_del, sec_cp_sz ); } - buffer._size = n_copy + n_add + sec_cp_sz; - traits_type::assign(buffer._data[buffer._size], value_type()); + buffer.size_ = n_copy + n_add + sec_cp_sz; + traits_type::assign(buffer.data_[buffer.size_], value_type()); replace_internal_buffer(buffer); } @@ -2539,14 +2539,14 @@ namespace plg { size_type cap = old_cap < ms / 2 - alignment ? recommend(std::max(old_cap + delta_cap, 2 * old_cap)) : ms; - long_ buffer = allocate_long_buffer(_alloc, cap); + long_ buffer = allocate_long_buffer(alloc_, cap); if (n_copy != 0) { - traits_type::copy(std::to_address(buffer._data), std::to_address(old_p), n_copy); + traits_type::copy(std::to_address(buffer.data_), std::to_address(old_p), n_copy); } size_type sec_cp_sz = old_sz - n_del - n_copy; if (sec_cp_sz != 0) { traits_type::copy( - std::to_address(buffer._data) + n_copy + n_add, + std::to_address(buffer.data_) + n_copy + n_add, std::to_address(old_p) + n_copy + n_del, sec_cp_sz ); @@ -2554,7 +2554,7 @@ namespace plg { // This is -1 to make sure the caller sets the size properly, since old versions of this // function didn't set the size at all. - buffer._size = npos; + buffer.size_ = npos; replace_internal_buffer(buffer); set_long_size(old_sz - n_del + n_add); } @@ -2671,7 +2671,7 @@ namespace plg { annotate_delete(); [[maybe_unused]] auto guard = make_scope_guard(annotate_new_size(*this)); - _rep = str._rep; + rep_ = str.rep_; return *this; } @@ -2681,7 +2681,7 @@ namespace plg { basic_string::move_assign(basic_string& str, std::false_type) noexcept( alloc_traits::is_always_equal::value ) { - if (_alloc != str._alloc) { + if (alloc_ != str.alloc_) { assign(str); } else { move_assign(str, std::true_type()); @@ -2699,7 +2699,7 @@ namespace plg { bool str_was_short = !str.is_long(); move_assign_alloc(str); - _rep = str._rep; + rep_ = str.rep_; str.set_short_size(0); traits_type::assign(str.get_short_pointer()[0], value_type()); @@ -2728,7 +2728,7 @@ namespace plg { template constexpr void basic_string::assign_with_sentinel(InputIterator first, Sentinel last) { - const basic_string temp(init_with_sentinel_tag(), std::move(first), std::move(last), _alloc); + const basic_string temp(init_with_sentinel_tag(), std::move(first), std::move(last), alloc_); assign(temp.data(), temp.size()); } @@ -2974,7 +2974,7 @@ namespace plg { if (string_is_trivial_iterator_v && !addr_in_range(*first)) { return insert_from_safe_copy(n, ip, std::move(first), std::move(last)); } else { - const basic_string temp(init_with_sentinel_tag(), std::move(first), std::move(last), _alloc); + const basic_string temp(init_with_sentinel_tag(), std::move(first), std::move(last), alloc_); return insert_from_safe_copy(n, ip, temp.begin(), temp.end()); } } @@ -3228,9 +3228,9 @@ namespace plg { } [[maybe_unused]] annotation_guard g(*this); - long_ buffer = allocate_long_buffer(_alloc, requested_capacity); - buffer._size = size(); - traits_type::copy(std::to_address(buffer._data), data(), buffer._size + 1); + long_ buffer = allocate_long_buffer(alloc_, requested_capacity); + buffer.size_ = size(); + traits_type::copy(std::to_address(buffer.data_), data(), buffer.size_ + 1); replace_internal_buffer(buffer); } @@ -3252,7 +3252,7 @@ namespace plg { [[maybe_unused]] annotation_guard g(*this); set_short_size(size); traits_type::copy(std::to_address(get_short_pointer()), std::to_address(ptr), size + 1); - alloc_traits::deallocate(_alloc, ptr, cap); + alloc_traits::deallocate(alloc_, ptr, cap); return; } @@ -3260,18 +3260,18 @@ namespace plg { try { #endif // PLUGIFY_HAS_EXCEPTIONS [[maybe_unused]] annotation_guard g(*this); - long_ buffer = allocate_long_buffer(_alloc, size); + long_ buffer = allocate_long_buffer(alloc_, size); // The Standard mandates shrink_to_fit() does not increase the capacity. // With equal capacity keep the existing buffer. This avoids extra work // due to swapping the elements. - if (buffer._cap * endian_factor - 1 >= capacity()) { - alloc_traits::deallocate(_alloc, buffer._data, buffer._cap * endian_factor); + if (buffer.cap_ * endian_factor - 1 >= capacity()) { + alloc_traits::deallocate(alloc_, buffer.data_, buffer.cap_ * endian_factor); return; } traits_type::copy( - std::to_address(buffer._data), + std::to_address(buffer.data_), std::to_address(get_long_pointer()), size + 1 ); @@ -3316,7 +3316,7 @@ namespace plg { template inline constexpr void basic_string::swap(basic_string& str) noexcept { PLUGIFY_ASSERT( - alloc_traits::propagate_on_container_swap::value || alloc_traits::is_always_equal::value || _alloc == str._alloc, + alloc_traits::propagate_on_container_swap::value || alloc_traits::is_always_equal::value || alloc_ == str.alloc_, "swapping non-equal allocators" ); if (!is_long()) { @@ -3325,8 +3325,8 @@ namespace plg { if (this != std::addressof(str) && !str.is_long()) { str.annotate_delete(); } - std::swap(_rep, str._rep); - swap_allocator(_alloc, str._alloc); + std::swap(rep_, str.rep_); + swap_allocator(alloc_, str.alloc_); if (!is_long()) { annotate_new(get_short_size()); } diff --git a/test/cross_call_master/external/plugify/include/plg/uninitialized.hpp b/test/cross_call_master/external/plugify/include/plg/uninitialized.hpp index 9cc3400..85c277b 100644 --- a/test/cross_call_master/external/plugify/include/plg/uninitialized.hpp +++ b/test/cross_call_master/external/plugify/include/plg/uninitialized.hpp @@ -51,16 +51,16 @@ namespace plg { class AllocatorDestroyRangeReverse { public: AllocatorDestroyRangeReverse(Alloc& alloc, Iter& first, Iter& last) - : _alloc(alloc), _first(first), _last(last) {} + : alloc_(alloc), first_(first), last_(last) {} void operator()() const { - allocator_destroy(_alloc, std::reverse_iterator(_last), std::reverse_iterator(_first)); + allocator_destroy(alloc_, std::reverse_iterator(last_), std::reverse_iterator(first_)); } private: - Alloc& _alloc; - Iter& _first; - Iter& _last; + Alloc& alloc_; + Iter& first_; + Iter& last_; }; // Copy-construct [first1, last1) in [first2, first2 + N), where N is @@ -123,7 +123,7 @@ namespace plg { // - is_copy_constructible // - is_trivially_relocatable template - void uninitialized_allocator_relocate(Alloc& alloc, T* first, T* last, T* result) { + constexpr void uninitialized_allocator_relocate(Alloc& alloc, T* first, T* last, T* result) { if (std::is_constant_evaluated() || !is_trivially_relocatable::value || !allocator_has_trivial_move_construct::value || diff --git a/test/cross_call_master/external/plugify/include/plg/variant.hpp b/test/cross_call_master/external/plugify/include/plg/variant.hpp index 9e7ada0..4c68ac4 100644 --- a/test/cross_call_master/external/plugify/include/plg/variant.hpp +++ b/test/cross_call_master/external/plugify/include/plg/variant.hpp @@ -26,13 +26,13 @@ namespace plg { #if PLUGIFY_HAS_EXCEPTIONS class bad_variant_access : public std::exception { public: - explicit bad_variant_access(const char* str) noexcept : message{str} {} + explicit bad_variant_access(const char* str) noexcept : message_{str} {} bad_variant_access() noexcept = default; bad_variant_access(const bad_variant_access&) noexcept = default; bad_variant_access& operator=(const bad_variant_access&) noexcept = default; - const char* what() const noexcept override { return message; } + const char* what() const noexcept override { return message_; } private: - const char* message = ""; // llvm test requires a well formed what() on default init + const char* message_ = ""; // llvm test requires a well formed what() on default init }; #endif // PLUGIFY_HAS_EXCEPTIONS @@ -575,7 +575,7 @@ namespace plg { constexpr variant() noexcept(std::is_nothrow_default_constructible_v>) requires std::is_default_constructible_v> - : _storage{in_place_index<0>}, _current{0} + : storage_{in_place_index<0>}, current_{0} {} // copy constructor (trivial) @@ -587,7 +587,7 @@ namespace plg { // copy constructor constexpr variant(const variant& o) requires (has_copy_ctor and not trivial_copy_ctor) - : _storage{detail::dummy_type{}} { + : storage_{detail::dummy_type{}} { construct_from(o); } @@ -600,7 +600,7 @@ namespace plg { constexpr variant(variant&& o) noexcept((std::is_nothrow_move_constructible_v && ...)) requires (has_move_ctor and not trivial_move_ctor) - : _storage{detail::dummy_type{}} { + : storage_{detail::dummy_type{}} { construct_from(static_cast(o)); } @@ -616,7 +616,7 @@ namespace plg { template requires (Index < size && std::is_constructible_v, Args&&...>) explicit constexpr variant(in_place_index_t tag, Args&&... args) - : _storage{tag, static_cast(args)...}, _current(Index) + : storage_{tag, static_cast(args)...}, current_(Index) {} // construct a given type @@ -633,7 +633,7 @@ namespace plg { std::is_constructible_v, std::initializer_list&, Args&&...> ) explicit constexpr variant(in_place_index_t tag, std::initializer_list list, Args&&... args) - : _storage{tag, list, PLG_FWD(args)...}, _current{Index} + : storage_{tag, list, PLG_FWD(args)...}, current_{Index} {} template @@ -642,7 +642,7 @@ namespace plg { && std::is_constructible_v&, Args&&...> ) explicit constexpr variant(in_place_type_t, std::initializer_list list, Args&&... args) - : _storage{in_place_index>, list, PLG_FWD(args)...}, _current{index_of } + : storage_{in_place_index>, list, PLG_FWD(args)...}, current_{index_of } {} // ================================ destructors (20.7.3.3) @@ -714,7 +714,7 @@ namespace plg { using related_type = detail::best_overload_match; constexpr auto new_index = index_of; - if (_current == new_index) + if (current_ == new_index) unsafe_get() = PLG_FWD(t); else { constexpr bool do_simple_emplace = @@ -765,12 +765,12 @@ namespace plg { constexpr bool valueless_by_exception() const noexcept { if constexpr (can_be_valueless) - return _current == npos; + return current_ == npos; else return false; } constexpr index_type index() const noexcept { - return _current; + return current_; } // =================================== swap (20.7.3.7) @@ -785,7 +785,7 @@ namespace plg { constexpr auto impl_one_valueless = [](auto&& full, auto& empty) { detail::visit_with_index(PLG_FWD(full), detail::emplace_no_dtor_from_elem{empty}); full.reset_no_check(); - full._current = npos; + full.current_ = npos; }; switch (static_cast(index() == npos) + static_cast(o.index() == npos) * 2) { @@ -837,29 +837,29 @@ namespace plg { template constexpr auto& unsafe_get() & noexcept { static_assert(Idx < size); - PLUGIFY_ASSERT(_current == Idx, ""); - return _storage.template get(); + PLUGIFY_ASSERT(current_ == Idx, ""); + return storage_.template get(); } template constexpr auto&& unsafe_get() && noexcept { static_assert(Idx < size); - PLUGIFY_ASSERT(_current == Idx, ""); - return PLG_MOV(_storage.template get()); + PLUGIFY_ASSERT(current_ == Idx, ""); + return PLG_MOV(storage_.template get()); } template constexpr const auto& unsafe_get() const & noexcept { static_assert(Idx < size); - PLUGIFY_ASSERT(_current == Idx, ""); - return _storage.template get(); + PLUGIFY_ASSERT(current_ == Idx, ""); + return storage_.template get(); } template constexpr const auto&& unsafe_get() const && noexcept { static_assert(Idx < size); - PLUGIFY_ASSERT(_current == Idx, ""); - return PLG_MOV(_storage.template get()); + PLUGIFY_ASSERT(current_ == Idx, ""); + return PLG_MOV(storage_.template get()); } private: @@ -868,9 +868,9 @@ namespace plg { constexpr void assign_from(Other&& o, Fn&& fn) { if constexpr (can_be_valueless) { if (o.index() == npos) { - if (_current != npos) { + if (current_ != npos) { reset_no_check(); - _current = npos; + current_ = npos; } return; } @@ -906,7 +906,7 @@ namespace plg { { static_assert(can_be_valueless, "Internal error : the possibly valueless branch of emplace was taken despite |can_be_valueless| being false"); - _current = npos; + current_ = npos; do_emplace_no_dtor(PLG_FWD(args)...); } } @@ -916,7 +916,7 @@ namespace plg { template constexpr void do_emplace_no_dtor(Args&&... args) { - _current = static_cast(Idx); + current_ = static_cast(Idx); auto* ptr = detail::addressof(unsafe_get()); @@ -950,7 +950,7 @@ namespace plg { constexpr void construct_from(Other&& o) { if constexpr (can_be_valueless) if (o.valueless_by_exception()) { - _current = npos; + current_ = npos; return; } @@ -960,11 +960,11 @@ namespace plg { template friend struct detail::emplace_no_dtor_from_elem; - storage _storage; + storage storage_; #if INTPTR_MAX == INT32_MAX - volatile char pad[8]; + volatile char padding_[8]; #endif - index_type _current; + index_type current_; }; // ================================= value access (20.7.5) diff --git a/test/cross_call_master/external/plugify/include/plg/vector.hpp b/test/cross_call_master/external/plugify/include/plg/vector.hpp index cd26021..56884fc 100644 --- a/test/cross_call_master/external/plugify/include/plg/vector.hpp +++ b/test/cross_call_master/external/plugify/include/plg/vector.hpp @@ -94,7 +94,7 @@ namespace plg { constexpr vector() noexcept(std::is_nothrow_default_constructible_v) = default; constexpr explicit vector(const allocator_type& a) noexcept - : _alloc(a) { + : alloc_(a) { } constexpr explicit vector(size_type n) { @@ -108,7 +108,7 @@ namespace plg { constexpr explicit vector(size_type n, const allocator_type& a) - : _alloc(a) { + : alloc_(a) { auto guard = make_exception_guard(destroy_vector(*this)); if (n > 0) { vallocate(n); @@ -128,7 +128,7 @@ namespace plg { constexpr vector(size_type n, const value_type& x, const allocator_type& a) - : _alloc(a) { + : alloc_(a) { auto guard = make_exception_guard(destroy_vector(*this)); if (n > 0) { vallocate(n); @@ -146,7 +146,7 @@ namespace plg { template constexpr vector(InputIterator first, InputIterator last, const allocator_type& a) - : _alloc(a) { + : alloc_(a) { init_with_sentinel(first, last); } @@ -160,7 +160,7 @@ namespace plg { template constexpr vector(ForwardIterator first, ForwardIterator last, const allocator_type& a) - : _alloc(a) { + : alloc_(a) { size_type n = static_cast(std::distance(first, last)); init_with_size(first, last, n); } @@ -171,7 +171,7 @@ namespace plg { std::from_range_t, Range&& range, const allocator_type& alloc = allocator_type() - ) : _alloc(alloc) { + ) : alloc_(alloc) { if constexpr (std::ranges::forward_range || std::ranges::sized_range) { auto n = static_cast(std::ranges::distance(range)); init_with_size(std::ranges::begin(range), std::ranges::end(range), n); @@ -190,10 +190,10 @@ namespace plg { } constexpr void operator()() { - if (vec_._begin != nullptr) { + if (vec_.begin_ != nullptr) { vec_.clear(); vec_.annotate_delete(); - alloc_traits::deallocate(vec_._alloc, vec_._begin, vec_.capacity()); + alloc_traits::deallocate(vec_.alloc_, vec_.begin_, vec_.capacity()); } } @@ -207,14 +207,14 @@ namespace plg { } constexpr vector(const vector& x) - : _alloc(alloc_traits::select_on_container_copy_construction(x._alloc)) { - init_with_size(x._begin, x._end, x.size()); + : alloc_(alloc_traits::select_on_container_copy_construction(x.alloc_)) { + init_with_size(x.begin_, x.end_, x.size()); } constexpr vector(const vector& x, const std::type_identity_t& a) - : _alloc(a) { - init_with_size(x._begin, x._end, x.size()); + : alloc_(a) { + init_with_size(x.begin_, x.end_, x.size()); } constexpr vector& operator=(const vector& x); @@ -225,7 +225,7 @@ namespace plg { constexpr vector(std::initializer_list il, const allocator_type& a) - : _alloc(a) { + : alloc_(a) { init_with_size(il.begin(), il.end(), il.size()); } @@ -286,28 +286,28 @@ namespace plg { [[nodiscard]] constexpr allocator_type get_allocator() const noexcept { - return this->_alloc; + return this->alloc_; } // // Iterators // [[nodiscard]] constexpr iterator begin() noexcept { - return make_iter(add_alignment_assumption(this->_begin)); + return make_iter(add_alignment_assumption(this->begin_)); } [[nodiscard]] constexpr const_iterator begin() const noexcept { - return make_iter(add_alignment_assumption(this->_begin)); + return make_iter(add_alignment_assumption(this->begin_)); } [[nodiscard]] constexpr iterator end() noexcept { - return make_iter(add_alignment_assumption(this->_end)); + return make_iter(add_alignment_assumption(this->end_)); } [[nodiscard]] constexpr const_iterator end() const noexcept { - return make_iter(add_alignment_assumption(this->_end)); + return make_iter(add_alignment_assumption(this->end_)); } [[nodiscard]] constexpr reverse_iterator @@ -354,23 +354,23 @@ namespace plg { // [vector.capacity], capacity // [[nodiscard]] constexpr size_type size() const noexcept { - return static_cast(this->_end - this->_begin); + return static_cast(this->end_ - this->begin_); } [[nodiscard]] constexpr size_type capacity() const noexcept { - return static_cast(this->_cap - this->_begin); + return static_cast(this->cap_ - this->begin_); } [[nodiscard]] constexpr bool empty() const noexcept { - return this->_begin == this->_end; + return this->begin_ == this->end_; } [[nodiscard]] constexpr size_type max_size() const noexcept { return std::min( - alloc_traits::max_size(this->_alloc), + alloc_traits::max_size(this->alloc_), std::numeric_limits::max() ); } @@ -384,20 +384,20 @@ namespace plg { [[nodiscard]] constexpr reference operator[](size_type n) noexcept { PLUGIFY_ASSERT(n < size(), "vector[] index out of bounds"); - return this->_begin[n]; + return this->begin_[n]; } [[nodiscard]] constexpr const_reference operator[](size_type n) const noexcept { PLUGIFY_ASSERT(n < size(), "vector[] index out of bounds"); - return this->_begin[n]; + return this->begin_[n]; } [[nodiscard]] constexpr reference at(size_type n) { if (n >= size()) { this->throw_out_of_range(); } - return this->_begin[n]; + return this->begin_[n]; } [[nodiscard]] constexpr const_reference @@ -405,29 +405,29 @@ namespace plg { if (n >= size()) { this->throw_out_of_range(); } - return this->_begin[n]; + return this->begin_[n]; } [[nodiscard]] constexpr reference front() noexcept { PLUGIFY_ASSERT(!empty(), "front() called on an empty vector"); - return *this->_begin; + return *this->begin_; } [[nodiscard]] constexpr const_reference front() const noexcept { PLUGIFY_ASSERT(!empty(), "front() called on an empty vector"); - return *this->_begin; + return *this->begin_; } [[nodiscard]] constexpr reference back() noexcept { PLUGIFY_ASSERT(!empty(), "back() called on an empty vector"); - return *(this->_end - 1); + return *(this->end_ - 1); } [[nodiscard]] constexpr const_reference back() const noexcept { PLUGIFY_ASSERT(!empty(), "back() called on an empty vector"); - return *(this->_end - 1); + return *(this->end_ - 1); } // @@ -435,12 +435,12 @@ namespace plg { // [[nodiscard]] constexpr value_type* data() noexcept { - return std::to_address(this->_begin); + return std::to_address(this->begin_); } [[nodiscard]] constexpr const value_type* data() const noexcept { - return std::to_address(this->_begin); + return std::to_address(this->begin_); } // @@ -467,7 +467,7 @@ namespace plg { "We assume that we have enough space to insert an element at the end of the vector" ); ConstructTransaction tx(*this, 1); - alloc_traits::construct(this->_alloc, std::to_address(tx.pos_), std::forward(args)...); + alloc_traits::construct(this->alloc_, std::to_address(tx.pos_), std::forward(args)...); ++tx.pos_; } @@ -480,7 +480,7 @@ namespace plg { constexpr void pop_back() { PLUGIFY_ASSERT(!empty(), "vector::pop_back called on an empty vector"); - this->destruct_at_end(this->_end - 1); + this->destruct_at_end(this->end_ - 1); } constexpr iterator @@ -532,7 +532,7 @@ namespace plg { constexpr void clear() noexcept { size_type old_size = size(); - base_destruct_at_end(this->_begin); + base_destruct_at_end(this->begin_); annotate_shrink(old_size); } @@ -545,16 +545,16 @@ namespace plg { constexpr bool invariants() const; private: - pointer _begin = nullptr; - pointer _end = nullptr; - pointer _cap = nullptr; + pointer begin_ = nullptr; + pointer end_ = nullptr; + pointer cap_ = nullptr; PLUGIFY_NO_UNIQUE_ADDRESS - allocator_type _alloc; + allocator_type alloc_; // Allocate space for n objects // throws length_error if n > max_size() // throws (probably bad_alloc) if memory run out - // Precondition: _begin == _end == _cap == nullptr + // Precondition: begin_ == end_ == cap_ == nullptr // Precondition: n > 0 // Postcondition: capacity() >= n // Postcondition: size() == 0 @@ -562,10 +562,10 @@ namespace plg { if (n > max_size()) { this->throw_length_error(); } - auto allocation = allocate_at_least(this->_alloc, n); - _begin = allocation.ptr; - _end = allocation.ptr; - _cap = _begin + allocation.count; + auto allocation = allocate_at_least(this->alloc_, n); + begin_ = allocation.ptr; + end_ = allocation.ptr; + cap_ = begin_ + allocation.count; annotate_new(0); } @@ -617,7 +617,7 @@ namespace plg { insert_assign_n_unchecked(Iterator first, difference_type n, pointer position) { for (pointer end_position = position + n; position != end_position; ++position, (void) ++first) { - detail::temp_value tmp(this->_alloc, *first); + detail::temp_value tmp(this->alloc_, *first); *position = std::move(tmp.get()); } } @@ -722,15 +722,15 @@ namespace plg { constexpr explicit ConstructTransaction(vector& v, size_type n) : v_(v) - , pos_(v._end) - , new_end_(v._end + n) { + , pos_(v.end_) + , new_end_(v.end_ + n) { v.annotate_increase(n); } constexpr ~ConstructTransaction() { - v_._end = pos_; + v_.end_ = pos_; if (pos_ != new_end_) { - v_.annotate_shrink(new_end_ - v_._begin); + v_.annotate_shrink(new_end_ - v_.begin_); } } @@ -744,11 +744,11 @@ namespace plg { constexpr void base_destruct_at_end(pointer new_last) noexcept { - pointer soon_to_be_end = this->_end; + pointer soon_to_be_end = this->end_; while (new_last != soon_to_be_end) { - alloc_traits::destroy(this->_alloc, std::to_address(--soon_to_be_end)); + alloc_traits::destroy(this->alloc_, std::to_address(--soon_to_be_end)); } - this->_end = new_last; + this->end_ = new_last; } constexpr void copy_assign_alloc(const vector& c) { @@ -779,13 +779,13 @@ namespace plg { constexpr void copy_assign_alloc(const vector& c, std::true_type) { - if (this->_alloc != c._alloc) { + if (this->alloc_ != c.alloc_) { clear(); annotate_delete(); - alloc_traits::deallocate(this->_alloc, this->_begin, capacity()); - this->_begin = this->_end = this->_cap = nullptr; + alloc_traits::deallocate(this->alloc_, this->begin_, capacity()); + this->begin_ = this->end_ = this->cap_ = nullptr; } - this->_alloc = c._alloc; + this->alloc_ = c.alloc_; } constexpr void @@ -796,7 +796,7 @@ namespace plg { move_assign_alloc(vector& c, std::true_type) noexcept( std::is_nothrow_move_assignable_v ) { - this->_alloc = std::move(c._alloc); + this->alloc_ = std::move(c.alloc_); } constexpr void @@ -820,18 +820,18 @@ namespace plg { constexpr void swap_layouts(split_buffer& sb) { - auto vector_begin = _begin; - auto vector_sentinel = _end; - auto vector_cap = _cap; + auto vector_begin = begin_; + auto vector_sentinel = end_; + auto vector_cap = cap_; auto sb_begin = sb.begin(); auto sb_sentinel = sb.raw_sentinel(); auto sb_cap = sb.raw_capacity(); // TODO: replace with set_valid_range and set_capacity when vector supports it. - _begin = sb_begin; - _end = sb_sentinel; - _cap = sb_cap; + begin_ = sb_begin; + end_ = sb_sentinel; + cap_ = sb_cap; sb.set_valid_range(vector_begin, vector_sentinel); sb.set_capacity(vector_cap); @@ -852,33 +852,33 @@ namespace plg { -> vector, Alloc>; #endif - // swap_out_circular_buffer relocates the objects in [_begin, _end) into the front of v and - // swaps the buffers of *this and v. It is assumed that v provides space for exactly (_end - - // _begin) objects in the front. This function has a strong exception guarantee. + // swap_out_circular_buffer relocates the objects in [begin_, end_) into the front of v and + // swaps the buffers of *this and v. It is assumed that v provides space for exactly (end_ - + // begin_) objects in the front. This function has a strong exception guarantee. template constexpr void vector::swap_out_circular_buffer(split_buffer& v) { annotate_delete(); auto new_begin = v.begin() - size(); uninitialized_allocator_relocate( - this->_alloc, - std::to_address(_begin), - std::to_address(_end), + this->alloc_, + std::to_address(begin_), + std::to_address(end_), std::to_address(new_begin) ); v.set_valid_range(new_begin, v.end()); - _end = _begin; // All the objects have been destroyed by relocating them. + end_ = begin_; // All the objects have been destroyed by relocating them. swap_layouts(v); v.set_data(v.begin()); annotate_new(size()); } - // swap_out_circular_buffer relocates the objects in [_begin, p) into the front of v, the - // objects in [p, _end) into the back of v and swaps the buffers of *this and v. It is assumed - // that v provides space for exactly (p - _begin) objects in the front and space for at least - // (_end - p) objects in the back. This function has a strong exception guarantee if _begin == p - // || _end == p. + // swap_out_circular_buffer relocates the objects in [begin_, p) into the front of v, the + // objects in [p, end_) into the back of v and swaps the buffers of *this and v. It is assumed + // that v provides space for exactly (p - begin_) objects in the front and space for at least + // (end_ - p) objects in the back. This function has a strong exception guarantee if begin_ == p + // || end_ == p. template constexpr typename vector::pointer vector::swap_out_circular_buffer( @@ -888,27 +888,27 @@ namespace plg { annotate_delete(); pointer ret = v.begin(); - // Relocate [p, _end) first to avoid having a hole in [_begin, _end) - // in case something in [_begin, p) throws. + // Relocate [p, end_) first to avoid having a hole in [begin_, end_) + // in case something in [begin_, p) throws. uninitialized_allocator_relocate( - this->_alloc, + this->alloc_, std::to_address(p), - std::to_address(_end), + std::to_address(end_), std::to_address(v.end()) ); - auto relocated_so_far = _end - p; + auto relocated_so_far = end_ - p; v.set_sentinel(v.end() + relocated_so_far); - _end = p; // The objects in [p, _end) have been destroyed by relocating them. - auto new_begin = v.begin() - (p - _begin); + end_ = p; // The objects in [p, end_) have been destroyed by relocating them. + auto new_begin = v.begin() - (p - begin_); uninitialized_allocator_relocate( - this->_alloc, - std::to_address(_begin), + this->alloc_, + std::to_address(begin_), std::to_address(p), std::to_address(new_begin) ); v.set_valid_range(new_begin, v.end()); - _end = _begin; // All the objects have been destroyed by relocating them. + end_ = begin_; // All the objects have been destroyed by relocating them. swap_layouts(v); v.set_data(v.begin()); annotate_new(size()); @@ -917,11 +917,11 @@ namespace plg { template constexpr void vector::vdeallocate() noexcept { - if (this->_begin != nullptr) { + if (this->begin_ != nullptr) { clear(); annotate_delete(); - alloc_traits::deallocate(this->_alloc, this->_begin, capacity()); - this->_begin = this->_end = this->_cap = nullptr; + alloc_traits::deallocate(this->alloc_, this->begin_, capacity()); + this->begin_ = this->end_ = this->cap_ = nullptr; } } @@ -941,7 +941,7 @@ namespace plg { return std::max(2 * cap, new_size); } - // Default constructs n objects starting at _end + // Default constructs n objects starting at end_ // throws if construction throws // Precondition: n > 0 // Precondition: size() + n <= capacity() @@ -951,11 +951,11 @@ namespace plg { ConstructTransaction tx(*this, n); const_pointer new_end = tx.new_end_; for (pointer pos = tx.pos_; pos != new_end; tx.pos_ = ++pos) { - alloc_traits::construct(this->_alloc, std::to_address(pos)); + alloc_traits::construct(this->alloc_, std::to_address(pos)); } } - // Copy constructs n objects starting at _end from x + // Copy constructs n objects starting at end_ from x // throws if construction throws // Precondition: n > 0 // Precondition: size() + n <= capacity() @@ -967,7 +967,7 @@ namespace plg { ConstructTransaction tx(*this, n); const_pointer new_end = tx.new_end_; for (pointer pos = tx.pos_; pos != new_end; tx.pos_ = ++pos) { - alloc_traits::construct(this->_alloc, std::to_address(pos), x); + alloc_traits::construct(this->alloc_, std::to_address(pos), x); } } @@ -977,39 +977,39 @@ namespace plg { vector::construct_at_end(InputIterator first, Sentinel last, size_type n) { ConstructTransaction tx(*this, n); tx.pos_ = uninitialized_allocator_copy( - this->_alloc, + this->alloc_, std::move(first), std::move(last), tx.pos_ ); } - // Default constructs n objects starting at _end + // Default constructs n objects starting at end_ // throws if construction throws // Postcondition: size() == size() + n // Exception safety: strong. template constexpr void vector::append(size_type n) { - if (static_cast(this->_cap - this->_end) >= n) { + if (static_cast(this->cap_ - this->end_) >= n) { this->construct_at_end(n); } else { - split_buffer v(recommend(size() + n), size(), this->_alloc); + split_buffer v(recommend(size() + n), size(), this->alloc_); v.construct_at_end(n); swap_out_circular_buffer(v); } } - // Default constructs n objects starting at _end + // Default constructs n objects starting at end_ // throws if construction throws // Postcondition: size() == size() + n // Exception safety: strong. template constexpr void vector::append(size_type n, const_reference x) { - if (static_cast(this->_cap - this->_end) >= n) { + if (static_cast(this->cap_ - this->end_) >= n) { this->construct_at_end(n, x); } else { - split_buffer v(recommend(size() + n), size(), this->_alloc); + split_buffer v(recommend(size() + n), size(), this->alloc_); v.construct_at_end(n, x); swap_out_circular_buffer(v); } @@ -1018,22 +1018,22 @@ namespace plg { template constexpr inline vector::vector(vector&& x) noexcept - : _alloc(std::move(x._alloc)) { - this->_begin = x._begin; - this->_end = x._end; - this->_cap = x._cap; - x._begin = x._end = x._cap = nullptr; + : alloc_(std::move(x.alloc_)) { + this->begin_ = x.begin_; + this->end_ = x.end_; + this->cap_ = x.cap_; + x.begin_ = x.end_ = x.cap_ = nullptr; } template constexpr inline vector::vector(vector&& x, const std::type_identity_t& a) - : _alloc(a) { - if (a == x._alloc) { - this->_begin = x._begin; - this->_end = x._end; - this->_cap = x._cap; - x._begin = x._end = x._cap = nullptr; + : alloc_(a) { + if (a == x.alloc_) { + this->begin_ = x.begin_; + this->end_ = x.end_; + this->cap_ = x.cap_; + x.begin_ = x.end_ = x.cap_ = nullptr; } else { using Ip = std::move_iterator; init_with_size(Ip(x.begin()), Ip(x.end()), x.size()); @@ -1045,7 +1045,7 @@ namespace plg { vector::move_assign(vector& c, std::false_type) noexcept( alloc_traits::is_always_equal::value ) { - if (this->_alloc != c._alloc) { + if (this->alloc_ != c.alloc_) { using Ip = std::move_iterator; assign(Ip(c.begin()), Ip(c.end())); } else { @@ -1060,10 +1060,10 @@ namespace plg { ) { vdeallocate(); move_assign_alloc(c); // this can throw - this->_begin = c._begin; - this->_end = c._end; - this->_cap = c._cap; - c._begin = c._end = c._cap = nullptr; + this->begin_ = c.begin_; + this->end_ = c.end_; + this->cap_ = c.cap_; + c.begin_ = c.end_ = c.cap_ = nullptr; } template @@ -1071,7 +1071,7 @@ namespace plg { vector::operator=(const vector& x) { if (this != std::addressof(x)) { copy_assign_alloc(x); - assign(x._begin, x._end); + assign(x.begin_, x.end_); } return *this; } @@ -1080,11 +1080,11 @@ namespace plg { template constexpr void vector::assign_with_sentinel(Iterator first, Sentinel last) { - pointer cur = _begin; - for (; first != last && cur != _end; ++first, (void) ++cur) { + pointer cur = begin_; + for (; first != last && cur != end_; ++first, (void) ++cur) { *cur = *first; } - if (cur != _end) { + if (cur != end_) { destruct_at_end(cur); } else { for (; first != last; ++first) { @@ -1101,15 +1101,15 @@ namespace plg { if (new_size <= capacity()) { if (new_size > size()) { #if PLUGIFY_HAS_CXX23 - auto mid = std::ranges::copy_n(std::move(first), size(), this->_begin).in; + auto mid = std::ranges::copy_n(std::move(first), size(), this->begin_).in; construct_at_end(std::move(mid), std::move(last), new_size - size()); #else Iterator mid = std::next(first, size()); - std::copy(first, mid, this->_begin); + std::copy(first, mid, this->begin_); construct_at_end(mid, last, new_size - size()); #endif } else { - pointer m = std::copy(std::move(first), last, this->_begin); + pointer m = std::copy(std::move(first), last, this->begin_); this->destruct_at_end(m); } } else { @@ -1124,11 +1124,11 @@ namespace plg { vector::assign(size_type n, const_reference u) { if (n <= capacity()) { size_type s = size(); - std::fill_n(this->_begin, std::min(n, s), u); + std::fill_n(this->begin_, std::min(n, s), u); if (n > s) { construct_at_end(n - s, u); } else { - this->destruct_at_end(this->_begin + n); + this->destruct_at_end(this->begin_ + n); } } else { vdeallocate(); @@ -1143,7 +1143,7 @@ namespace plg { if (n > max_size()) { this->throw_length_error(); } - split_buffer v(n, size(), this->_alloc); + split_buffer v(n, size(), this->alloc_); swap_out_circular_buffer(v); } } @@ -1154,7 +1154,7 @@ namespace plg { #if PLUGIFY_HAS_EXCEPTIONS try { #endif // PLUGIFY_HAS_EXCEPTIONS - split_buffer v(size(), size(), this->_alloc); + split_buffer v(size(), size(), this->alloc_); // The Standard mandates shrink_to_fit() does not increase the capacity. // With equal capacity keep the existing buffer. This avoids extra work // due to swapping the elements. @@ -1172,13 +1172,13 @@ namespace plg { template constexpr typename vector::pointer vector::emplace_back_slow_path(Args&&... args) { - split_buffer v(recommend(size() + 1), size(), this->_alloc); + split_buffer v(recommend(size() + 1), size(), this->alloc_); // v.emplace_back(std::forward(args)...); pointer end = v.end(); - alloc_traits::construct(this->_alloc, std::to_address(end), std::forward(args)...); + alloc_traits::construct(this->alloc_, std::to_address(end), std::forward(args)...); v.set_sentinel(++end); swap_out_circular_buffer(v); - return this->_end; + return this->end_; } // This makes the compiler inline `else()` if `cond` is known to be false. Currently LLVM @@ -1207,9 +1207,9 @@ namespace plg { constexpr inline typename vector::reference vector::emplace_back(Args&&... args) { - pointer end = this->_end; + pointer end = this->end_; if_likely_else( - end < this->_cap, + end < this->cap_, [&] { emplace_back_assume_capacity(std::forward(args)...); ++end; @@ -1217,7 +1217,7 @@ namespace plg { [&] { end = emplace_back_slow_path(std::forward(args)...); } ); - this->_end = end; + this->end_ = end; return *(end - 1); } @@ -1230,8 +1230,8 @@ namespace plg { "vector::erase(iterator) called with a non-dereferenceable iterator" ); difference_type ps = position - cbegin(); - pointer p = this->_begin + ps; - this->destruct_at_end(std::move(p + 1, this->_end, p)); + pointer p = this->begin_ + ps; + this->destruct_at_end(std::move(p + 1, this->end_, p)); return make_iter(p); } @@ -1242,9 +1242,9 @@ namespace plg { first <= last, "vector::erase(first, last) called with invalid range" ); - pointer p = this->_begin + (first - begin()); + pointer p = this->begin_ + (first - begin()); if (first != last) { - this->destruct_at_end(std::move(p + (last - first), this->_end, p)); + this->destruct_at_end(std::move(p + (last - first), this->end_, p)); } return make_iter(p); } @@ -1252,13 +1252,13 @@ namespace plg { template constexpr void vector::move_range(pointer from_s, pointer from_e, pointer to) { - pointer old_last = this->_end; + pointer old_last = this->end_; difference_type n = old_last - to; { pointer i = from_s + n; ConstructTransaction tx(*this, from_e - i); for (pointer pos = tx.pos_; i < from_e; ++i, (void) ++pos, tx.pos_ = pos) { - alloc_traits::construct(this->_alloc, std::to_address(pos), std::move(*i)); + alloc_traits::construct(this->alloc_, std::to_address(pos), std::move(*i)); } } std::move_backward(from_s, from_s + n, old_last); @@ -1267,16 +1267,16 @@ namespace plg { template constexpr typename vector::iterator vector::insert(const_iterator position, const_reference x) { - pointer p = this->_begin + (position - begin()); - if (this->_end < this->_cap) { - if (p == this->_end) { + pointer p = this->begin_ + (position - begin()); + if (this->end_ < this->cap_) { + if (p == this->end_) { emplace_back_assume_capacity(x); } else { - move_range(p, this->_end, p + 1); + move_range(p, this->end_, p + 1); const_pointer xr = std::pointer_traits::pointer_to(x); if (is_pointer_in_range( std::to_address(p), - std::to_address(_end), + std::to_address(end_), std::addressof(x) )) { ++xr; @@ -1286,8 +1286,8 @@ namespace plg { } else { split_buffer v( recommend(size() + 1), - p - this->_begin, - this->_alloc + p - this->begin_, + this->alloc_ ); v.emplace_back(x); p = swap_out_circular_buffer(v, p); @@ -1298,19 +1298,19 @@ namespace plg { template constexpr typename vector::iterator vector::insert(const_iterator position, value_type&& x) { - pointer p = this->_begin + (position - begin()); - if (this->_end < this->_cap) { - if (p == this->_end) { + pointer p = this->begin_ + (position - begin()); + if (this->end_ < this->cap_) { + if (p == this->end_) { emplace_back_assume_capacity(std::move(x)); } else { - move_range(p, this->_end, p + 1); + move_range(p, this->end_, p + 1); *p = std::move(x); } } else { split_buffer v( recommend(size() + 1), - p - this->_begin, - this->_alloc + p - this->begin_, + this->alloc_ ); v.emplace_back(std::move(x)); p = swap_out_circular_buffer(v, p); @@ -1322,20 +1322,20 @@ namespace plg { template constexpr typename vector::iterator vector::emplace(const_iterator position, Args&&... args) { - pointer p = this->_begin + (position - begin()); - if (this->_end < this->_cap) { - if (p == this->_end) { + pointer p = this->begin_ + (position - begin()); + if (this->end_ < this->cap_) { + if (p == this->end_) { emplace_back_assume_capacity(std::forward(args)...); } else { - detail::temp_value tmp(this->_alloc, std::forward(args)...); - move_range(p, this->_end, p + 1); + detail::temp_value tmp(this->alloc_, std::forward(args)...); + move_range(p, this->end_, p + 1); *p = std::move(tmp.get()); } } else { split_buffer v( recommend(size() + 1), - p - this->_begin, - this->_alloc + p - this->begin_, + this->alloc_ ); v.emplace_back(std::forward(args)...); p = swap_out_circular_buffer(v, p); @@ -1346,13 +1346,13 @@ namespace plg { template constexpr typename vector::iterator vector::insert(const_iterator position, size_type n, const_reference x) { - pointer p = this->_begin + (position - begin()); + pointer p = this->begin_ + (position - begin()); if (n > 0) { - if (n <= static_cast(this->_cap - this->_end)) { + if (n <= static_cast(this->cap_ - this->end_)) { size_type old_n = n; - pointer old_last = this->_end; - if (n > static_cast(this->_end - p)) { - size_type cx = n - (this->_end - p); + pointer old_last = this->end_; + if (n > static_cast(this->end_ - p)) { + size_type cx = n - (this->end_ - p); construct_at_end(cx, x); n -= cx; } @@ -1361,7 +1361,7 @@ namespace plg { const_pointer xr = std::pointer_traits::pointer_to(x); if (is_pointer_in_range( std::to_address(p), - std::to_address(_end), + std::to_address(end_), std::addressof(x) )) { xr += old_n; @@ -1371,8 +1371,8 @@ namespace plg { } else { split_buffer v( recommend(size() + n), - p - this->_begin, - this->_alloc + p - this->begin_, + this->alloc_ ); v.construct_at_end(n, x); p = swap_out_circular_buffer(v, p); @@ -1390,37 +1390,37 @@ namespace plg { Sentinel last ) { difference_type off = position - begin(); - pointer p = this->_begin + off; - pointer old_last = this->_end; - for (; this->_end != this->_cap && first != last; ++first) { + pointer p = this->begin_ + off; + pointer old_last = this->end_; + for (; this->end_ != this->cap_ && first != last; ++first) { emplace_back_assume_capacity(*first); } if (first == last) { - (void) std::rotate(p, old_last, this->_end); + (void) std::rotate(p, old_last, this->end_); } else { - split_buffer v(_alloc); + split_buffer v(alloc_); auto guard = make_exception_guard( - AllocatorDestroyRangeReverse(_alloc, old_last, this->_end) + AllocatorDestroyRangeReverse(alloc_, old_last, this->end_) ); v.construct_at_end_with_sentinel(std::move(first), std::move(last)); split_buffer merged( recommend(size() + v.size()), off, - _alloc + alloc_ ); // has `off` positions available at the front uninitialized_allocator_relocate( - _alloc, + alloc_, std::to_address(old_last), - std::to_address(this->_end), + std::to_address(this->end_), std::to_address(merged.end()) ); - guard.complete(); // Release the guard once objects in [old_last_, _end) have been + guard.complete(); // Release the guard once objects in [old_last_, end_) have been // successfully relocated. - merged.set_sentinel(merged.end() + (this->_end - old_last)); - this->_end = old_last; + merged.set_sentinel(merged.end() + (this->end_ - old_last)); + this->end_ = old_last; uninitialized_allocator_relocate( - _alloc, + alloc_, std::to_address(v.begin()), std::to_address(v.end()), std::to_address(merged.end()) @@ -1441,16 +1441,16 @@ namespace plg { Sentinel last, difference_type n ) { - pointer p = this->_begin + (position - begin()); + pointer p = this->begin_ + (position - begin()); if (n > 0) { - if (n <= this->_cap - this->_end) { - pointer old_last = this->_end; - difference_type dx = this->_end - p; + if (n <= this->cap_ - this->end_) { + pointer old_last = this->end_; + difference_type dx = this->end_ - p; if (n > dx) { #if PLUGIFY_HAS_CXX23 if constexpr (!std::forward_iterator) { construct_at_end(std::move(first), std::move(last), n); - std::rotate(p, old_last, this->_end); + std::rotate(p, old_last, this->end_); } else #endif { @@ -1468,8 +1468,8 @@ namespace plg { } else { split_buffer v( recommend(size() + n), - p - this->_begin, - this->_alloc + p - this->begin_, + this->alloc_ ); v.construct_at_end_with_size(std::move(first), n); p = swap_out_circular_buffer(v, p); @@ -1484,7 +1484,7 @@ namespace plg { if (cs < sz) { this->append(sz - cs); } else if (cs > sz) { - this->destruct_at_end(this->_begin + sz); + this->destruct_at_end(this->begin_ + sz); } } @@ -1495,7 +1495,7 @@ namespace plg { if (cs < sz) { this->append(sz - cs, x); } else if (cs > sz) { - this->destruct_at_end(this->_begin + sz); + this->destruct_at_end(this->begin_ + sz); } } @@ -1504,30 +1504,30 @@ namespace plg { noexcept { PLUGIFY_ASSERT( - alloc_traits::propagate_on_container_swap::value || this->_alloc == x._alloc, + alloc_traits::propagate_on_container_swap::value || this->alloc_ == x.alloc_, "vector::swap: Either propagate_on_container_swap must be true" " or the allocators must compare equal" ); - std::swap(this->_begin, x._begin); - std::swap(this->_end, x._end); - std::swap(this->_cap, x._cap); - swap_allocator(this->_alloc, x._alloc); + std::swap(this->begin_, x.begin_); + std::swap(this->end_, x.end_); + std::swap(this->cap_, x.cap_); + swap_allocator(this->alloc_, x.alloc_); } template constexpr bool vector::invariants() const { - if (this->_begin == nullptr) { - if (this->_end != nullptr || this->_cap != nullptr) { + if (this->begin_ == nullptr) { + if (this->end_ != nullptr || this->cap_ != nullptr) { return false; } } else { - if (this->_begin > this->_end) { + if (this->begin_ > this->end_) { return false; } - if (this->_begin == this->_cap) { + if (this->begin_ == this->cap_) { return false; } - if (this->_end > this->_cap) { + if (this->end_ > this->cap_) { return false; } } diff --git a/test/cross_call_master/external/plugify/include/plg/version.hpp b/test/cross_call_master/external/plugify/include/plg/version.hpp index b8e8c00..f3bf16d 100644 --- a/test/cross_call_master/external/plugify/include/plg/version.hpp +++ b/test/cross_call_master/external/plugify/include/plg/version.hpp @@ -91,38 +91,38 @@ namespace plg { constexpr version& operator=(const version&) = default; constexpr version& operator=(version&&) = default; - constexpr I1 major() const noexcept { return _major; } - constexpr I2 minor() const noexcept { return _minor; } - constexpr I3 patch() const noexcept { return _patch; } + constexpr I1 major() const noexcept { return major_; } + constexpr I2 minor() const noexcept { return minor_; } + constexpr I3 patch() const noexcept { return patch_; } - constexpr const string& prerelease_tag() const { return _prerelease_tag; } - constexpr const string& build_metadata() const { return _build_metadata; } + constexpr const string& prerelease_tag() const { return prerelease_tag_; } + constexpr const string& build_metadata() const { return build_metadata_; } constexpr string to_string() const; private: - I1 _major = 0; - I2 _minor = 1; - I3 _patch = 0; - string _prerelease_tag; - string _build_metadata; + I1 major_ = 0; + I2 minor_ = 1; + I3 patch_ = 0; + string prerelease_tag_; + string build_metadata_; - vector _prerelease_identifiers; + vector prerelease_identifiers_; constexpr std::size_t length() const noexcept { - return detail::length(_major) + detail::length(_minor) + detail::length(_patch) + 2 - + (_prerelease_tag.empty() ? 0 : _prerelease_tag.length() + 1) - + (_build_metadata.empty() ? 0 : _build_metadata.length() + 1); + return detail::length(major_) + detail::length(minor_) + detail::length(patch_) + 2 + + (prerelease_tag_.empty() ? 0 : prerelease_tag_.length() + 1) + + (build_metadata_.empty() ? 0 : build_metadata_.length() + 1); } constexpr void clear() noexcept { - _major = 0; - _minor = 1; - _patch = 0; + major_ = 0; + minor_ = 1; + patch_ = 0; - _prerelease_tag.clear(); - _prerelease_identifiers.clear(); - _build_metadata.clear(); + prerelease_tag_.clear(); + prerelease_identifiers_.clear(); + build_metadata_.clear(); } }; @@ -132,23 +132,23 @@ namespace plg { detail::resize_uninitialized{}.resize(result, length()); auto* it = result.end(); - if (!_build_metadata.empty()) { - it = std::copy_backward(_build_metadata.begin(), _build_metadata.end(), it); + if (!build_metadata_.empty()) { + it = std::copy_backward(build_metadata_.begin(), build_metadata_.end(), it); *(--it) = '+'; } - if (!_prerelease_tag.empty()) { - it = std::copy_backward(_prerelease_tag.begin(), _prerelease_tag.end(), it); + if (!prerelease_tag_.empty()) { + it = std::copy_backward(prerelease_tag_.begin(), prerelease_tag_.end(), it); *(--it) = '-'; } - it = detail::to_chars(it, _patch); + it = detail::to_chars(it, patch_); *(--it) = '.'; - it = detail::to_chars(it, _minor); + it = detail::to_chars(it, minor_); *(--it) = '.'; - it = detail::to_chars(it, _major); + it = detail::to_chars(it, major_); return result; } @@ -273,28 +273,28 @@ namespace plg { class token_stream { public: constexpr token_stream() = default; - constexpr explicit token_stream(vector tokens) noexcept : _tokens(std::move(tokens)) {} + constexpr explicit token_stream(vector tokens) noexcept : tokens_(std::move(tokens)) {} constexpr void push(const token& token) noexcept { - _tokens.push_back(token); + tokens_.push_back(token); } constexpr token advance() noexcept { - const token token = get(_current); - ++_current; + const token token = get(current_); + ++current_; return token; } constexpr token peek(std::size_t k = 0) const noexcept { - return get(_current + k); + return get(current_ + k); } constexpr token previous() const noexcept { - return get(_current - 1); + return get(current_ - 1); } constexpr bool advance_if_match(token& token, token_type type) noexcept { - if (get(_current).type != type) { + if (get(current_).type != type) { return false; } @@ -316,20 +316,20 @@ namespace plg { } private: - std::size_t _current = 0; - vector _tokens; + std::size_t current_ = 0; + vector tokens_; constexpr token get(std::size_t i) const noexcept { - return _tokens[i]; + return tokens_[i]; } }; class lexer { public: - explicit constexpr lexer(std::string_view text) noexcept : _text{text}, _current_pos{0} {} + explicit constexpr lexer(std::string_view text) noexcept : text_{text}, current_pos_{0} {} constexpr from_chars_result scan_tokens(token_stream& token_stream) noexcept { - from_chars_result result{ _text.data(), std::errc{} }; + from_chars_result result{ text_.data(), std::errc{} }; while (!is_eol()) { result = scan_token(token_stream); @@ -338,14 +338,14 @@ namespace plg { } } - token_stream.push({ token_type::eol, {}, _text.data() + _text.size() }); + token_stream.push({ token_type::eol, {}, text_.data() + text_.size() }); return result; } private: - std::string_view _text; - std::size_t _current_pos; + std::string_view text_; + std::size_t current_pos_; constexpr from_chars_result scan_token(token_stream& stream) noexcept { const char c = advance(); @@ -399,8 +399,8 @@ namespace plg { } constexpr char advance() noexcept { - char c = _text[_current_pos]; - _current_pos += 1; + char c = text_[current_pos_]; + current_pos_ += 1; return c; } @@ -409,40 +409,40 @@ namespace plg { return false; } - if (_text[_current_pos] != c) { + if (text_[current_pos_] != c) { return false; } - _current_pos += 1; + current_pos_ += 1; return true; } constexpr const char* get_prev_symbol() const noexcept { - return _text.data() + _current_pos - 1; + return text_.data() + current_pos_ - 1; } - constexpr bool is_eol() const noexcept { return _current_pos >= _text.size(); } + constexpr bool is_eol() const noexcept { return current_pos_ >= text_.size(); } }; class prerelease_comparator { public: template [[nodiscard]] constexpr int compare(const version& lhs, const version& rhs) const noexcept { - if (lhs._prerelease_identifiers.empty() != rhs._prerelease_identifiers.empty()) { - return static_cast(rhs._prerelease_identifiers.size()) - static_cast(lhs._prerelease_identifiers.size()); + if (lhs.prerelease_identifiers_.empty() != rhs.prerelease_identifiers_.empty()) { + return static_cast(rhs.prerelease_identifiers_.size()) - static_cast(lhs.prerelease_identifiers_.size()); } - const std::size_t count = std::min(lhs._prerelease_identifiers.size(), rhs._prerelease_identifiers.size()); + const std::size_t count = std::min(lhs.prerelease_identifiers_.size(), rhs.prerelease_identifiers_.size()); for (std::size_t i = 0; i < count; ++i) { - const int compare_result = compare_identifier(lhs._prerelease_identifiers[i], rhs._prerelease_identifiers[i]); + const int compare_result = compare_identifier(lhs.prerelease_identifiers_[i], rhs.prerelease_identifiers_[i]); if (compare_result != 0) { return compare_result; } } - return static_cast(lhs._prerelease_identifiers.size()) - static_cast(rhs._prerelease_identifiers.size()); + return static_cast(lhs.prerelease_identifiers_.size()) - static_cast(rhs.prerelease_identifiers_.size()); } private: @@ -459,45 +459,45 @@ namespace plg { class version_parser { public: - constexpr explicit version_parser(token_stream& stream) : _stream{stream} { + constexpr explicit version_parser(token_stream& stream) : stream_{stream} { } template constexpr from_chars_result parse(version& out) noexcept { out.clear(); - from_chars_result result = parse_number(out._major); + from_chars_result result = parse_number(out.major_); if (!result) { return result; } - if (!_stream.consume(token_type::dot)) { - return failure(_stream.previous().lexeme); + if (!stream_.consume(token_type::dot)) { + return failure(stream_.previous().lexeme); } - result = parse_number(out._minor); + result = parse_number(out.minor_); if (!result) { return result; } - if (!_stream.consume(token_type::dot)) { - return failure(_stream.previous().lexeme); + if (!stream_.consume(token_type::dot)) { + return failure(stream_.previous().lexeme); } - result = parse_number(out._patch); + result = parse_number(out.patch_); if (!result) { return result; } - if (_stream.advance_if_match(token_type::hyphen)) { - result = parse_prerelease_tag(out._prerelease_tag, out._prerelease_identifiers); + if (stream_.advance_if_match(token_type::hyphen)) { + result = parse_prerelease_tag(out.prerelease_tag_, out.prerelease_identifiers_); if (!result) { return result; } } - if (_stream.advance_if_match(token_type::plus)) { - result = parse_build_metadata(out._build_metadata); + if (stream_.advance_if_match(token_type::plus)) { + result = parse_build_metadata(out.build_metadata_); if (!result) { return result; } @@ -508,11 +508,11 @@ namespace plg { private: - token_stream& _stream; + token_stream& stream_; template constexpr from_chars_result parse_number(Int& out) { - token token = _stream.advance(); + token token = stream_.advance(); if (!is_digit(token)) { return failure(token.lexeme); @@ -523,16 +523,16 @@ namespace plg { if (first_digit == 0) { out = static_cast(result); - return success(_stream.peek().lexeme); + return success(stream_.peek().lexeme); } - while (_stream.advance_if_match(token, token_type::digit)) { + while (stream_.advance_if_match(token, token_type::digit)) { result = result * 10 + std::get(token.value); } if (detail::number_in_range(result)) { out = static_cast(result); - return success(_stream.peek().lexeme); + return success(stream_.peek().lexeme); } return failure(token.lexeme, std::errc::result_out_of_range); @@ -554,10 +554,10 @@ namespace plg { result.append(identifier); out_identifiers.push_back(make_prerelease_identifier(identifier)); - } while (_stream.advance_if_match(token_type::dot)); + } while (stream_.advance_if_match(token_type::dot)); out = result; - return success(_stream.peek().lexeme); + return success(stream_.peek().lexeme); } constexpr from_chars_result parse_build_metadata(string& out) { @@ -574,15 +574,15 @@ namespace plg { } result.append(identifier); - } while (_stream.advance_if_match(token_type::dot)); + } while (stream_.advance_if_match(token_type::dot)); out = result; - return success(_stream.peek().lexeme); + return success(stream_.peek().lexeme); } constexpr from_chars_result parse_prerelease_identifier(string& out) { string result; - token token = _stream.advance(); + token token = stream_.advance(); do { switch (token.type) { @@ -613,10 +613,10 @@ namespace plg { default: return failure(token.lexeme); } - } while (_stream.advance_if_match(token, token_type::hyphen) || _stream.advance_if_match(token, token_type::letter) || _stream.advance_if_match(token, token_type::digit)); + } while (stream_.advance_if_match(token, token_type::hyphen) || stream_.advance_if_match(token, token_type::letter) || stream_.advance_if_match(token, token_type::digit)); out = result; - return success(_stream.peek().lexeme); + return success(stream_.peek().lexeme); } constexpr detail::prerelease_identifier make_prerelease_identifier(const string& identifier) { @@ -632,7 +632,7 @@ namespace plg { constexpr from_chars_result parse_build_identifier(string& out) { string result; - token token = _stream.advance(); + token token = stream_.advance(); do { switch (token.type) { @@ -651,10 +651,10 @@ namespace plg { default: return failure(token.lexeme); } - } while (_stream.advance_if_match(token, token_type::hyphen) || _stream.advance_if_match(token, token_type::letter) || _stream.advance_if_match(token, token_type::digit)); + } while (stream_.advance_if_match(token, token_type::hyphen) || stream_.advance_if_match(token, token_type::letter) || stream_.advance_if_match(token, token_type::digit)); out = result; - return success(_stream.peek().lexeme); + return success(stream_.peek().lexeme); } constexpr bool is_leading_zero(int digit) noexcept { @@ -667,7 +667,7 @@ namespace plg { int digits = 0; while (true) { - const token token = _stream.peek(k); + const token token = stream_.peek(k); if (!is_alphanumeric(token)) { break; @@ -803,44 +803,44 @@ namespace plg { template class range_comparator { public: - constexpr range_comparator(const version& v, range_operator op) noexcept : _v(v), _op(op) {} + constexpr range_comparator(const version& v, range_operator op) noexcept : v_(v), op_(op) {} constexpr bool contains(const version& other) const noexcept { - switch (_op) { + switch (op_) { case range_operator::less: - return detail::compare_parsed(other, _v, version_compare_option::include_prerelease) < 0; + return detail::compare_parsed(other, v_, version_compare_option::include_prerelease) < 0; case range_operator::less_or_equal: - return detail::compare_parsed(other, _v, version_compare_option::include_prerelease) <= 0; + return detail::compare_parsed(other, v_, version_compare_option::include_prerelease) <= 0; case range_operator::greater: - return detail::compare_parsed(other, _v, version_compare_option::include_prerelease) > 0; + return detail::compare_parsed(other, v_, version_compare_option::include_prerelease) > 0; case range_operator::greater_or_equal: - return detail::compare_parsed(other, _v, version_compare_option::include_prerelease) >= 0; + return detail::compare_parsed(other, v_, version_compare_option::include_prerelease) >= 0; case range_operator::equal: - return detail::compare_parsed(other, _v, version_compare_option::include_prerelease) == 0; + return detail::compare_parsed(other, v_, version_compare_option::include_prerelease) == 0; } return false; } - constexpr const version& get_version() const noexcept { return _v; } + constexpr const version& get_version() const noexcept { return v_; } - constexpr range_operator get_operator() const noexcept { return _op; } + constexpr range_operator get_operator() const noexcept { return op_; } constexpr string to_string() const { string result; - switch (_op) { + switch (op_) { case range_operator::less: result += "<"; break; case range_operator::less_or_equal: result += "<="; break; case range_operator::greater: result += ">"; break; case range_operator::greater_or_equal: result += ">="; break; case range_operator::equal: result += "="; break; } - result += _v.to_string(); + result += v_.to_string(); return result; } private: - version _v; - range_operator _op; + version v_; + range_operator op_; }; class range_parser; @@ -857,40 +857,40 @@ namespace plg { } } - return std::all_of(_ranges_comparators.begin(), _ranges_comparators.end(), [&](const auto& ranges_comparator) { + return std::all_of(ranges_comparators_.begin(), ranges_comparators_.end(), [&](const auto& ranges_comparator) { return ranges_comparator.contains(v); }); } constexpr auto begin() const noexcept { - return _ranges_comparators.begin(); + return ranges_comparators_.begin(); } constexpr auto end() const noexcept { - return _ranges_comparators.end(); + return ranges_comparators_.end(); } constexpr std::size_t size() const noexcept { - return _ranges_comparators.size(); + return ranges_comparators_.size(); } constexpr bool empty() const noexcept { - return _ranges_comparators.empty(); + return ranges_comparators_.empty(); } constexpr string to_string() const { - return join(_ranges_comparators, " "); + return join(ranges_comparators_, " "); } private: - vector> _ranges_comparators; + vector> ranges_comparators_; constexpr bool match_at_least_one_comparator_with_prerelease(const version& v) const noexcept { if (v.prerelease_tag().empty()) { return true; } - return std::any_of(_ranges_comparators.begin(), _ranges_comparators.end(), [&](const auto& ranges_comparator) { + return std::any_of(ranges_comparators_.begin(), ranges_comparators_.end(), [&](const auto& ranges_comparator) { const bool has_prerelease = !ranges_comparator.get_version().prerelease_tag().empty(); const bool equal_without_prerelease = detail::compare_parsed(v, ranges_comparator.get_version(), version_compare_option::exclude_prerelease) == 0; return has_prerelease && equal_without_prerelease; @@ -905,39 +905,39 @@ namespace plg { friend class detail::range_parser; constexpr bool contains(const version& v, version_compare_option option = version_compare_option::exclude_prerelease) const noexcept { - return std::any_of(_ranges.begin(), _ranges.end(), [&](const auto& range) { + return std::any_of(ranges_.begin(), ranges_.end(), [&](const auto& range) { return range.contains(v, option); }); } constexpr auto begin() const noexcept { - return _ranges.begin(); + return ranges_.begin(); } constexpr auto end() const noexcept { - return _ranges.end(); + return ranges_.end(); } constexpr std::size_t size() const noexcept { - return _ranges.size(); + return ranges_.size(); } constexpr bool empty() const noexcept { - return _ranges.empty(); + return ranges_.empty(); } constexpr string to_string() const { - return join(_ranges, " "); + return join(ranges_, " "); } private: - vector> _ranges; + vector> ranges_; }; namespace detail { class range_parser { public: - constexpr explicit range_parser(token_stream stream) noexcept : _stream(std::move(stream)) {} + constexpr explicit range_parser(token_stream stream) noexcept : stream_(std::move(stream)) {} template constexpr from_chars_result parse(range_set& out) noexcept { @@ -953,54 +953,54 @@ namespace plg { ranges.push_back(range); skip_whitespaces(); - } while (_stream.advance_if_match(token_type::logical_or)); + } while (stream_.advance_if_match(token_type::logical_or)); - out._ranges = std::move(ranges); + out.ranges_ = std::move(ranges); - return success(_stream.peek().lexeme); + return success(stream_.peek().lexeme); } private: - token_stream _stream; + token_stream stream_; template constexpr from_chars_result parse_range(detail::range& out) noexcept { do { skip_whitespaces(); - if (const auto res = parse_range_comparator(out._ranges_comparators); !res) { + if (const auto res = parse_range_comparator(out.ranges_comparators_); !res) { return res; } skip_whitespaces(); - } while (_stream.check(token_type::range_operator) || _stream.check(token_type::digit)); + } while (stream_.check(token_type::range_operator) || stream_.check(token_type::digit)); - return success(_stream.peek().lexeme); + return success(stream_.peek().lexeme); } template constexpr from_chars_result parse_range_comparator(vector>& out) noexcept { range_operator op = range_operator::equal; token token; - if (_stream.advance_if_match(token, token_type::range_operator)) { + if (stream_.advance_if_match(token, token_type::range_operator)) { op = std::get(token.value); } skip_whitespaces(); version ver; - version_parser parser{ _stream }; + version_parser parser{ stream_ }; if (const auto res = parser.parse(ver); !res) { return res; } out.emplace_back(ver, op); - return success(_stream.peek().lexeme); + return success(stream_.peek().lexeme); } constexpr void skip_whitespaces() noexcept { - while (_stream.advance_if_match(token_type::space)) { + while (stream_.advance_if_match(token_type::space)) { ; } } diff --git a/test/cross_call_worker/external/plugify/include/plg/allocator.hpp b/test/cross_call_worker/external/plugify/include/plg/allocator.hpp index 3cc57b2..3bb603d 100644 --- a/test/cross_call_worker/external/plugify/include/plg/allocator.hpp +++ b/test/cross_call_worker/external/plugify/include/plg/allocator.hpp @@ -153,7 +153,7 @@ namespace plg { // __old_last_contained is the previously last allowed (unpoisoned) element, and // __new_last_contained is the new last allowed (unpoisoned) element. template - void annotate_contiguous_container( + constexpr void annotate_contiguous_container( [[maybe_unused]] const void* first_storage, [[maybe_unused]] const void* last_storage, [[maybe_unused]] const void* old_last_contained, diff --git a/test/cross_call_worker/external/plugify/include/plg/config.hpp b/test/cross_call_worker/external/plugify/include/plg/config.hpp index 8ba7006..a0e43c3 100644 --- a/test/cross_call_worker/external/plugify/include/plg/config.hpp +++ b/test/cross_call_worker/external/plugify/include/plg/config.hpp @@ -16,7 +16,7 @@ # define __has_builtin(x) 0 #endif -#ifndef __builtin_constant_p +#if !__has_builtin(__builtin_constant_p) # define __builtin_constant_p(x) std::is_constant_evaluated() #endif diff --git a/test/cross_call_worker/external/plugify/include/plg/enum.hpp b/test/cross_call_worker/external/plugify/include/plg/enum.hpp index 802b7c1..0692a31 100644 --- a/test/cross_call_worker/external/plugify/include/plg/enum.hpp +++ b/test/cross_call_worker/external/plugify/include/plg/enum.hpp @@ -17,15 +17,15 @@ namespace plg { template struct static_string { constexpr static_string(std::string_view sv) noexcept { - std::copy(sv.begin(), sv.end(), _content.begin()); + std::copy(sv.begin(), sv.end(), content_.begin()); } constexpr operator std::string_view() const noexcept { - return { _content.data(), N }; + return { content_.data(), N }; } private: - std::array _content{}; + std::array content_{}; }; constexpr auto is_pretty(char ch) noexcept { diff --git a/test/cross_call_worker/external/plugify/include/plg/guards.hpp b/test/cross_call_worker/external/plugify/include/plg/guards.hpp index 4691341..a45e221 100644 --- a/test/cross_call_worker/external/plugify/include/plg/guards.hpp +++ b/test/cross_call_worker/external/plugify/include/plg/guards.hpp @@ -9,16 +9,16 @@ namespace plg { exception_guard_exceptions() = delete; constexpr explicit exception_guard_exceptions(Rollback rollback) - : _rollback(std::move(rollback)) - , _completed(false) { + : rollback_(std::move(rollback)) + , completed_(false) { } constexpr exception_guard_exceptions( exception_guard_exceptions&& other ) noexcept(std::is_nothrow_move_constructible_v) - : _rollback(std::move(other._rollback)) - , _completed(other._completed) { - other._completed = true; + : rollback_(std::move(other.rollback_)) + , completed_(other.completed_) { + other.completed_ = true; } exception_guard_exceptions(const exception_guard_exceptions&) = delete; @@ -26,18 +26,18 @@ namespace plg { exception_guard_exceptions& operator=(exception_guard_exceptions&&) = delete; constexpr void complete() noexcept { - _completed = true; + completed_ = true; } constexpr ~exception_guard_exceptions() { - if (!_completed) { - _rollback(); + if (!completed_) { + rollback_(); } } private: - PLUGIFY_NO_UNIQUE_ADDRESS Rollback _rollback; - bool _completed; + PLUGIFY_NO_UNIQUE_ADDRESS Rollback rollback_; + bool completed_; }; template @@ -53,8 +53,8 @@ namespace plg { constexpr exception_guard_noexceptions( exception_guard_noexceptions&& other ) noexcept(std::is_nothrow_move_constructible_v) - : _completed(other._completed) { - other._completed = true; + : completed_(other.completed_) { + other.completed_ = true; } exception_guard_noexceptions(const exception_guard_noexceptions&) = delete; @@ -62,15 +62,15 @@ namespace plg { exception_guard_noexceptions& operator=(exception_guard_noexceptions&&) = delete; constexpr void complete() noexcept { - _completed = true; + completed_ = true; } constexpr ~exception_guard_noexceptions() { - PLUGIFY_ASSERT(_completed, "exception_guard not completed with exceptions disabled"); + PLUGIFY_ASSERT(completed_, "exception_guard not completed with exceptions disabled"); } private: - bool _completed = false; + bool completed_ = false; }; template @@ -84,15 +84,15 @@ namespace plg { template class scope_guard { - PLUGIFY_NO_UNIQUE_ADDRESS Func _func; + PLUGIFY_NO_UNIQUE_ADDRESS Func func_; public: constexpr explicit scope_guard(Func func) - : _func(std::move(func)) { + : func_(std::move(func)) { } constexpr ~scope_guard() { - _func(); + func_(); } scope_guard(const scope_guard&) = delete; diff --git a/test/cross_call_worker/external/plugify/include/plg/hash.hpp b/test/cross_call_worker/external/plugify/include/plg/hash.hpp index 4028e57..982f796 100644 --- a/test/cross_call_worker/external/plugify/include/plg/hash.hpp +++ b/test/cross_call_worker/external/plugify/include/plg/hash.hpp @@ -3,6 +3,8 @@ #include #include #include +#include +#include #include "plg/string.hpp" @@ -58,11 +60,10 @@ namespace plg { using is_transparent = void; // Enables heterogeneous lookup template - auto operator()(const T& str_like) const noexcept { - std::string_view str = str_like; + std::size_t operator()(const T& str) const noexcept { std::size_t hash = active_hash_traits::fnv_basis; // FNV-1a - for (const char& c : str) { - hash ^= static_cast(std::tolower(static_cast(c))); + for (const auto& c : str) { + hash ^= static_cast(std::tolower(c)); hash *= active_hash_traits::fnv_prime; } return hash; @@ -73,21 +74,14 @@ namespace plg { using is_transparent = void; // Enables heterogeneous lookup template - bool operator()(const T1& lhs_like, const T2& rhs_like) const noexcept { - std::string_view lhs = lhs_like; - std::string_view rhs = rhs_like; - - if (lhs.size() != rhs.size()) { - return false; - } - - for (size_t i = 0; i < lhs.size(); ++i) { - if (std::tolower(static_cast(lhs[i])) - != std::tolower(static_cast(rhs[i]))) { - return false; + bool operator()(const T1& lhs, const T2& rhs) const noexcept { + return std::lexicographical_compare( + lhs.begin(), lhs.end(), + rhs.begin(), rhs.end(), + [](const auto& ac, const auto& bc) { + return std::tolower(ac) < std::tolower(bc); } - } - return true; + ); } }; diff --git a/test/cross_call_worker/external/plugify/include/plg/inplace_vector.hpp b/test/cross_call_worker/external/plugify/include/plg/inplace_vector.hpp index 71292c8..db59904 100644 --- a/test/cross_call_worker/external/plugify/include/plg/inplace_vector.hpp +++ b/test/cross_call_worker/external/plugify/include/plg/inplace_vector.hpp @@ -68,15 +68,15 @@ namespace plg { template struct PLUGIFY_INPLACE_VECTOR_TRIVIALLY_RELOCATABLE_IF(std::is_trivially_relocatable_v) ipvbase { - size_t _size = 0; + size_t size_ = 0; union { - [[maybe_unused]] char _dummy; - T _data[N]; + [[maybe_unused]] char dummy_; + T data_[N]; }; - constexpr T *base_data() { return _data; } - constexpr const T *base_data() const { return _data; } - constexpr void set_size(size_t n) { _size = n; } + constexpr T *base_data() { return data_; } + constexpr const T *base_data() const { return data_; } + constexpr void set_size(size_t n) { size_ = n; } constexpr explicit ipvbase() noexcept {} ipvbase(const ipvbase& rhs) @@ -85,8 +85,8 @@ namespace plg { if constexpr (std::is_trivially_copy_constructible_v) { std::memmove((void*)this, (const void*)std::addressof(rhs), sizeof(ipvbase)); } else { - std::uninitialized_copy_n(rhs._data, rhs._size, _data); - _size = rhs._size; + std::uninitialized_copy_n(rhs.data_, rhs.size_, data_); + size_ = rhs.size_; } } ipvbase(ipvbase&& rhs) @@ -100,13 +100,13 @@ namespace plg { std::memmove((void*)this, (const void*)std::addressof(rhs), sizeof(ipvbase)); #if defined(__cpp_lib_trivially_relocatable) } else if constexpr (std::is_trivially_relocatable_v) { - std::uninitialized_relocate_n(rhs._data, rhs._size, _data); - _size = rhs._size; - rhs._size = 0; + std::uninitialized_relocate_n(rhs.data_, rhs.size_, data_); + size_ = rhs.size_; + rhs.size_ = 0; #endif // __cpp_lib_trivially_relocatable } else { - std::uninitialized_move_n(rhs._data, rhs._size, _data); - _size = rhs._size; + std::uninitialized_move_n(rhs.data_, rhs.size_, data_); + size_ = rhs.size_; } } void operator=(const ipvbase& rhs) @@ -116,14 +116,14 @@ namespace plg { std::memmove((void*)this, (const void*)std::addressof(rhs), sizeof(ipvbase)); } else if (this == std::addressof(rhs)) { // do nothing - } else if (rhs._size <= _size) { - std::copy(rhs._data, rhs._data + rhs._size, _data); - std::destroy(_data + rhs._size, _data + _size); - _size = rhs._size; + } else if (rhs.size_ <= size_) { + std::copy(rhs.data_, rhs.data_ + rhs.size_, data_); + std::destroy(data_ + rhs.size_, data_ + size_); + size_ = rhs.size_; } else { - std::copy(rhs._data, rhs._data + _size, _data); - std::uninitialized_copy(rhs._data + _size, rhs._data + rhs._size, _data + _size); - _size = rhs._size; + std::copy(rhs.data_, rhs.data_ + size_, data_); + std::uninitialized_copy(rhs.data_ + size_, rhs.data_ + rhs.size_, data_ + size_); + size_ = rhs.size_; } } void operator=(ipvbase&& rhs) @@ -133,21 +133,21 @@ namespace plg { std::memmove((void*)this, (const void*)std::addressof(rhs), sizeof(ipvbase)); } else if (this == std::addressof(rhs)) { // do nothing - } else if (rhs._size <= _size) { - std::move(rhs._data, rhs._data + rhs._size, _data); - std::destroy(_data + rhs._size, _data + _size); - _size = rhs._size; + } else if (rhs.size_ <= size_) { + std::move(rhs.data_, rhs.data_ + rhs.size_, data_); + std::destroy(data_ + rhs.size_, data_ + size_); + size_ = rhs.size_; } else { - std::move(rhs._data, rhs._data + _size, _data); + std::move(rhs.data_, rhs.data_ + size_, data_); #if defined(__cpp_lib_trivially_relocatable) if constexpr (std::is_trivially_relocatable_v) { - std::uninitialized_relocate(rhs._data + _size, rhs._data + rhs._size, _data + _size); - std::swap(rhs._size, _size); + std::uninitialized_relocate(rhs.data_ + size_, rhs.data_ + rhs.size_, data_ + size_); + std::swap(rhs.size_, size_); return; } #endif // __cpp_lib_trivially_relocatable - std::uninitialized_move(rhs._data + _size, rhs._data + rhs._size, _data + _size); - _size = rhs._size; + std::uninitialized_move(rhs.data_ + size_, rhs.data_ + rhs.size_, data_ + size_); + size_ = rhs.size_; } } @@ -163,13 +163,13 @@ namespace plg { constexpr #endif // PLUGIFY_CPP_VERSION >= 202002L ~ipvbase() { - std::destroy(_data, _data + _size); + std::destroy(data_, data_ + size_); } }; template struct ipvbase_zero { - static constexpr size_t _size = 0; + static constexpr size_t size_ = 0; constexpr T *base_data() { return nullptr; } constexpr const T *base_data() const { return nullptr; } constexpr void set_size(size_t) { } @@ -177,15 +177,15 @@ namespace plg { template struct ipvbase_trivial { - size_t _size = 0; + size_t size_ = 0; union { - [[maybe_unused]] char _dummy; - T _data[N]; + [[maybe_unused]] char dummy_; + T data_[N]; }; constexpr explicit ipvbase_trivial() {} - constexpr T *base_data() { return _data; } - constexpr const T *base_data() const { return _data; } - constexpr void set_size(size_t n) { _size = n; } + constexpr T *base_data() { return data_; } + constexpr const T *base_data() const { return data_; } + constexpr void set_size(size_t n) { size_ = n; } }; template @@ -202,7 +202,7 @@ namespace plg { template class inplace_vector : detail::ipvbase_assignable, detail::ipvbase_t { - using detail::ipvbase_t::_size; + using detail::ipvbase_t::size_; using detail::ipvbase_t::set_size; public: using value_type = T; @@ -277,12 +277,12 @@ namespace plg { { if (n > N) { throw_bad_alloc(); - } else if (_size >= n) { + } else if (size_ >= n) { std::fill_n(data(), n, value); - std::destroy(data() + n, data() + _size); + std::destroy(data() + n, data() + size_); } else { - std::fill_n(data(), _size, value); - std::uninitialized_fill_n(data() + _size, n - _size, value); + std::fill_n(data(), size_, value); + std::uninitialized_fill_n(data() + size_, n - size_, value); } set_size(n); } @@ -293,12 +293,12 @@ namespace plg { const size_type n = static_cast(std::distance(first, last)); if (n > N) { throw_bad_alloc(); - } else if (_size >= n) { + } else if (size_ >= n) { std::copy(first, last, data()); - std::destroy(data() + n, data() + _size); + std::destroy(data() + n, data() + size_); } else { - std::copy(first, first + _size, data()); - std::uninitialized_copy(first + _size, last, data() + _size); + std::copy(first, first + size_, data()); + std::uninitialized_copy(first + size_, last, data() + size_); } set_size(n); } @@ -329,13 +329,13 @@ namespace plg { size_t n = std::ranges::size(rg); if (n > N) { throw_bad_alloc(); - } else if (_size >= n) { + } else if (size_ >= n) { std::ranges::copy(first, last, data()); - std::destroy(data() + n, data() + _size); + std::destroy(data() + n, data() + size_); } else { - auto mid = std::ranges::next(first, _size, last); + auto mid = std::ranges::next(first, size_, last); std::ranges::copy(first, mid, data()); - std::ranges::uninitialized_copy(mid, last, data() + _size); + std::ranges::uninitialized_copy(mid, last, data() + size_); } set_size(n); } @@ -344,15 +344,15 @@ namespace plg { // iterators constexpr iterator begin() noexcept { return data(); } - constexpr iterator end() noexcept { return data() + _size; } + constexpr iterator end() noexcept { return data() + size_; } constexpr const_iterator begin() const noexcept { return data(); } - constexpr const_iterator end() const noexcept { return data() + _size; } + constexpr const_iterator end() const noexcept { return data() + size_; } constexpr reverse_iterator rbegin() noexcept { return reverse_iterator(end()); } constexpr reverse_iterator rend() noexcept { return reverse_iterator(begin()); } constexpr const_reverse_iterator rbegin() const noexcept { return const_reverse_iterator(end()); } constexpr const_reverse_iterator rend() const noexcept { return const_reverse_iterator(begin()); } constexpr const_iterator cbegin() const noexcept { return data(); } - constexpr const_iterator cend() const noexcept { return data() + _size; } + constexpr const_iterator cend() const noexcept { return data() + size_; } constexpr const_reverse_iterator crbegin() const noexcept { return const_reverse_iterator(end()); } constexpr const_reverse_iterator crend() const noexcept { return const_reverse_iterator(begin()); } @@ -361,12 +361,12 @@ namespace plg { { if (n > N) { throw_bad_alloc(); - } else if (n < _size) { - std::destroy(data() + n, data() + _size); + } else if (n < size_) { + std::destroy(data() + n, data() + size_); set_size(n); } else { - std::uninitialized_value_construct(data() + _size, data() + n); - set_size(_size + n); + std::uninitialized_value_construct(data() + size_, data() + n); + set_size(size_ + n); } } @@ -375,12 +375,12 @@ namespace plg { { if (n > N) { throw_bad_alloc(); - } else if (n < _size) { - std::destroy(data() + n, data() + _size); + } else if (n < size_) { + std::destroy(data() + n, data() + size_); set_size(n); } else { - std::uninitialized_fill(data() + _size, data() + n, value); - set_size(_size + n); + std::uninitialized_fill(data() + size_, data() + n, value); + set_size(size_ + n); } } @@ -403,7 +403,7 @@ namespace plg { } constexpr reference back() { PLUGIFY_ASSERT(!empty(), "called on an empty vector"); - return data()[_size - 1]; + return data()[size_ - 1]; } constexpr const_reference operator[](size_type pos) const { @@ -416,17 +416,17 @@ namespace plg { } constexpr const_reference back() const { PLUGIFY_ASSERT(!empty(), "called on an empty vector"); - return data()[_size - 1]; + return data()[size_ - 1]; } constexpr reference at(size_type i) { - if (i >= _size) { + if (i >= size_) { throw_out_of_range(); } return data()[i]; } constexpr const_reference at(size_type i) const { - if (i >= _size) { + if (i >= size_) { throw_out_of_range(); } return data()[i]; @@ -436,20 +436,20 @@ namespace plg { constexpr T* data() noexcept { return this->base_data(); } constexpr const T* data() const noexcept { return this->base_data(); } - constexpr size_type size() const noexcept { return _size; } + constexpr size_type size() const noexcept { return size_; } static constexpr size_type max_size() noexcept { return N; } static constexpr size_type capacity() noexcept { return N; } - [[nodiscard]] constexpr bool empty() const noexcept { return _size == 0; }; + [[nodiscard]] constexpr bool empty() const noexcept { return size_ == 0; }; // [inplace.vector.modifiers] template requires std::is_constructible_v value_type& unchecked_emplace_back(Args&&... args) { - // Precondition: (_size < N) - value_type* p = data() + _size; + // Precondition: (size_ < N) + value_type* p = data() + size_; p = std::construct_at(p, std::forward(args)...); - set_size(_size + 1); + set_size(size_ + 1); return *p; } value_type& unchecked_push_back(const value_type& value) @@ -466,7 +466,7 @@ namespace plg { template requires std::is_constructible_v constexpr value_type* try_emplace_back(Args&&... args) { - if (_size == N) { + if (size_ == N) { return nullptr; } return std::addressof(unchecked_emplace_back(static_cast(args)...)); @@ -485,7 +485,7 @@ namespace plg { template requires std::is_constructible_v value_type& emplace_back(Args&&... args) { - if (_size == N) { + if (size_ == N) { throw_bad_alloc(); } return unchecked_emplace_back(static_cast(args)...); @@ -512,8 +512,8 @@ namespace plg { #endif // __cpp_lib_ranges >= 201911L && __cpp_lib_ranges_to_container >= 202202L void pop_back() { - std::destroy_at(data() + _size - 1); - set_size(_size - 1); + std::destroy_at(data() + size_ - 1); + set_size(size_ - 1); } template @@ -538,7 +538,7 @@ namespace plg { iterator insert(const_iterator pos, size_type n, const value_type& value) requires std::is_copy_constructible_v { - if (N - _size < n) { + if (N - size_ < n) { throw_bad_alloc(); } auto it = iterator(pos); @@ -549,7 +549,7 @@ namespace plg { std::uninitialized_relocate_backward(it, oldend, oldend + n); try { std::uninitialized_fill_n(it, n, value); - set_size(_size + n); + set_size(size_ + n); } catch (...) { std::uninitialized_relocate(it + n, oldend + n, it); throw; @@ -559,7 +559,7 @@ namespace plg { #endif // Fill at the end of the vector, then rotate into place. std::uninitialized_fill_n(oldend, n, value); - set_size(_size + n); + set_size(size_ + n); std::rotate(it, oldend, oldend + n); return it; } @@ -571,7 +571,7 @@ namespace plg { auto oldend = end(); if constexpr (std::random_access_iterator) { size_type n = static_cast(std::distance(first, last)); - if (N - _size < n) { + if (N - size_ < n) { throw_bad_alloc(); } #if defined(__cpp_lib_trivially_relocatable) @@ -580,7 +580,7 @@ namespace plg { std::uninitialized_relocate_backward(it, oldend, oldend + n); try { std::uninitialized_copy_n(first, n, it); - set_size(_size + n); + set_size(size_ + n); } catch (...) { std::uninitialized_relocate(it + n, oldend + n, it); throw; @@ -590,7 +590,7 @@ namespace plg { #endif // Fill at the end of the vector, then rotate into place. std::uninitialized_copy_n(first, n, oldend); - set_size(_size + n); + set_size(size_ + n); std::rotate(it, oldend, oldend + n); } else { for (; first != last; ++first) { @@ -609,7 +609,7 @@ namespace plg { auto oldend = end(); if constexpr (std::ranges::sized_range) { size_type n = std::ranges::size(rg); - if (N - _size < n) { + if (N - size_ < n) { throw_bad_alloc(); } #if defined(__cpp_lib_trivially_relocatable) @@ -618,7 +618,7 @@ namespace plg { std::uninitialized_relocate_backward(it, oldend, oldend + n); try { std::ranges::uninitialized_copy_n(std::ranges::begin(rg), n, it, std::unreachable_sentinel); - set_size(_size + n); + set_size(size_ + n); } catch (...) { std::uninitialized_relocate(it + n, oldend + n, it); throw; @@ -628,7 +628,7 @@ namespace plg { #endif // Fill at the end of the vector, then rotate into place. std::ranges::uninitialized_copy_n(std::ranges::begin(rg), n, oldend, std::unreachable_sentinel); - set_size(_size + n); + set_size(size_ + n); std::rotate(it, oldend, oldend + n); } else { auto [rgend, newend] = std::ranges::uninitialized_copy(rg, std::ranges::subrange(oldend, data() + N)); @@ -659,13 +659,13 @@ namespace plg { if constexpr (std::is_trivially_relocatable_v) { std::destroy_at(it); std::uninitialized_relocate(it + 1, oldend, it); - set_size(_size - 1); + set_size(size_ - 1); return it; } #endif std::move(it + 1, oldend, it); std::destroy_at(oldend - 1); - set_size(_size - 1); + set_size(size_ - 1); return it; } @@ -681,18 +681,18 @@ namespace plg { if constexpr (std::is_trivially_relocatable_v) { std::destroy(ifirst, ilast); std::uninitialized_relocate(ilast, oldend, ifirst); - set_size(_size - n); + set_size(size_ - n); return ifirst; } #endif // __cpp_lib_trivially_relocatable std::destroy(std::move(ilast, oldend, ifirst), oldend); - set_size(_size - n); + set_size(size_ - n); } return ifirst; } constexpr void clear() noexcept { - std::destroy(data(), data() + _size); + std::destroy(data(), data() + size_); set_size(0); } @@ -701,20 +701,20 @@ namespace plg { requires (!std::is_const_v) { auto& a = *this; - if (a._size < b._size) { + if (a.size_ < b.size_) { b.swap(a); } else { - std::swap_ranges(a.data(), a.data() + b._size, b.data()); + std::swap_ranges(a.data(), a.data() + b.size_, b.data()); #if defined(__cpp_lib_trivially_relocatable) - size_t n = a._size; - a.set_size(b._size); - std::uninitialized_relocate(a.data() + b._size, a.data() + n, b.data() + b._size); + size_t n = a.size_; + a.set_size(b.size_); + std::uninitialized_relocate(a.data() + b.size_, a.data() + n, b.data() + b.size_); b.set_size(n); #else - std::uninitialized_move(a.data() + b._size, a.data() + a._size, b.data() + b._size); - std::destroy(a.data() + b._size, a.data() + a._size); + std::uninitialized_move(a.data() + b.size_, a.data() + a.size_, b.data() + b.size_); + std::destroy(a.data() + b.size_, a.data() + a.size_); if constexpr (N != 0) { - std::swap(a._size, b._size); + std::swap(a.size_, b.size_); } #endif } @@ -737,7 +737,7 @@ namespace plg { constexpr friend bool operator<(const inplace_vector& a, const inplace_vector& b) { const T* adata = a.data(); const T* bdata = b.data(); - size_t n = (a._size < b._size) ? a._size : b._size; + size_t n = (a.size_ < b.size_) ? a.size_ : b.size_; for (size_t i = 0; i < n; ++i) { if (adata[i] < bdata[i]) { return true; @@ -745,7 +745,7 @@ namespace plg { return false; } } - return (a._size < b._size); + return (a.size_ < b.size_); } constexpr friend bool operator>(const inplace_vector& a, const inplace_vector& b) { return (b < a); } constexpr friend bool operator<=(const inplace_vector& a, const inplace_vector& b) { return !(b < a); } diff --git a/test/cross_call_worker/external/plugify/include/plg/split_buffer.hpp b/test/cross_call_worker/external/plugify/include/plg/split_buffer.hpp index 0568d15..ddae84f 100644 --- a/test/cross_call_worker/external/plugify/include/plg/split_buffer.hpp +++ b/test/cross_call_worker/external/plugify/include/plg/split_buffer.hpp @@ -26,115 +26,115 @@ namespace plg { public: constexpr split_buffer_pointer_layout() - : _back_cap(nullptr) { + : back_cap_(nullptr) { } constexpr explicit split_buffer_pointer_layout(const allocator_type& alloc) - : _back_cap(nullptr) - , _alloc(alloc) { + : back_cap_(nullptr) + , alloc_(alloc) { } constexpr pointer front_cap() noexcept { - return _front_cap; + return front_cap_; } constexpr const_pointer front_cap() const noexcept { - return _front_cap; + return front_cap_; } constexpr pointer begin() noexcept { - return _begin; + return begin_; } constexpr const_pointer begin() const noexcept { - return _begin; + return begin_; } constexpr pointer end() noexcept { - return _end; + return end_; } constexpr pointer end() const noexcept { - return _end; + return end_; } constexpr size_type size() const noexcept { - return static_cast(_end - _begin); + return static_cast(end_ - begin_); } constexpr bool empty() const noexcept { - return _begin == _end; + return begin_ == end_; } constexpr size_type capacity() const noexcept { - return static_cast(_back_cap - _front_cap); + return static_cast(back_cap_ - front_cap_); } constexpr allocator_type& get_allocator() noexcept { - return _alloc; + return alloc_; } constexpr const allocator_type& get_allocator() const noexcept { - return _alloc; + return alloc_; } // Returns the sentinel object directly. Should be used in conjunction with automatic type // deduction, not explicit types. constexpr sentinel_type raw_sentinel() const noexcept { - return _end; + return end_; } constexpr sentinel_type raw_capacity() const noexcept { - return _back_cap; + return back_cap_; } constexpr void set_data(pointer new_first) noexcept { - _front_cap = new_first; + front_cap_ = new_first; } constexpr void set_valid_range(pointer new_begin, pointer new_end) noexcept { - _begin = new_begin; - _end = new_end; + begin_ = new_begin; + end_ = new_end; } constexpr void set_valid_range(pointer new_begin, size_type new_size) noexcept { - _begin = new_begin; - _end = _begin + new_size; + begin_ = new_begin; + end_ = begin_ + new_size; } constexpr void set_sentinel(pointer new_end) noexcept { - PLUGIFY_ASSERT(_front_cap <= new_end, "new_end cannot precede _front_cap"); - _end = new_end; + PLUGIFY_ASSERT(front_cap_ <= new_end, "new_end cannot precede front_cap_"); + end_ = new_end; } constexpr void set_sentinel(size_type new_size) noexcept { - _end = _begin + new_size; + end_ = begin_ + new_size; } constexpr void set_capacity(size_type new_capacity) noexcept { - _back_cap = _front_cap + new_capacity; + back_cap_ = front_cap_ + new_capacity; } constexpr void set_capacity(pointer new_capacity) noexcept { - _back_cap = new_capacity; + back_cap_ = new_capacity; } constexpr size_type front_spare() const noexcept { - return static_cast(_begin - _front_cap); + return static_cast(begin_ - front_cap_); } constexpr size_type back_spare() const noexcept { - return static_cast(_back_cap - _end); + return static_cast(back_cap_ - end_); } constexpr reference back() noexcept { - return *(_end - 1); + return *(end_ - 1); } constexpr const_reference back() const noexcept { - return *(_end - 1); + return *(end_ - 1); } constexpr void swap_without_allocator( @@ -143,42 +143,42 @@ namespace plg { value_type, alloc_rr&>& other ) noexcept { - std::swap(_front_cap, other._front_cap); - std::swap(_begin, other._begin); - std::swap(_back_cap, other._back_cap); - std::swap(_end, other._end); + std::swap(front_cap_, other.front_cap_); + std::swap(begin_, other.begin_); + std::swap(back_cap_, other.back_cap_); + std::swap(end_, other.end_); } constexpr void swap(split_buffer_pointer_layout& other) noexcept { - std::swap(_front_cap, other._front_cap); - std::swap(_begin, other._begin); - std::swap(_back_cap, other._back_cap); - std::swap(_end, other._end); - swap_allocator(_alloc, other._alloc); + std::swap(front_cap_, other.front_cap_); + std::swap(begin_, other.begin_); + std::swap(back_cap_, other.back_cap_); + std::swap(end_, other.end_); + swap_allocator(alloc_, other.alloc_); } constexpr void reset() noexcept { - _front_cap = nullptr; - _begin = nullptr; - _end = nullptr; - _back_cap = nullptr; + front_cap_ = nullptr; + begin_ = nullptr; + end_ = nullptr; + back_cap_ = nullptr; } constexpr void copy_without_alloc( const split_buffer_pointer_layout& other ) noexcept(std::is_nothrow_copy_assignable::value) { - _front_cap = other._front_cap; - _begin = other._begin; - _end = other._end; - _back_cap = other._back_cap; + front_cap_ = other.front_cap_; + begin_ = other.begin_; + end_ = other.end_; + back_cap_ = other.back_cap_; } private: - pointer _front_cap = nullptr; - pointer _begin = nullptr; - pointer _end = nullptr; - pointer _back_cap = nullptr; - PLUGIFY_NO_UNIQUE_ADDRESS allocator_type _alloc; + pointer front_cap_ = nullptr; + pointer begin_ = nullptr; + pointer end_ = nullptr; + pointer back_cap_ = nullptr; + PLUGIFY_NO_UNIQUE_ADDRESS allocator_type alloc_; template friend class split_buffer_pointer_layout; @@ -205,73 +205,73 @@ namespace plg { constexpr split_buffer_size_layout() = default; constexpr explicit split_buffer_size_layout(const allocator_type& alloc) - : _alloc(alloc) { + : alloc_(alloc) { } constexpr pointer front_cap() noexcept { - return _front_cap; + return front_cap_; } constexpr const_pointer front_cap() const noexcept { - return _front_cap; + return front_cap_; } constexpr pointer begin() noexcept { - return _begin; + return begin_; } constexpr const_pointer begin() const noexcept { - return _begin; + return begin_; } constexpr pointer end() noexcept { - return _begin + _size; + return begin_ + size_; } constexpr pointer end() const noexcept { - return _begin + _size; + return begin_ + size_; } constexpr size_type size() const noexcept { - return _size; + return size_; } constexpr bool empty() const noexcept { - return _size == 0; + return size_ == 0; } constexpr size_type capacity() const noexcept { - return _cap; + return cap_; } constexpr allocator_type& get_allocator() noexcept { - return _alloc; + return alloc_; } constexpr const allocator_type& get_allocator() const noexcept { - return _alloc; + return alloc_; } // Returns the sentinel object directly. Should be used in conjunction with automatic type // deduction, not explicit types. constexpr sentinel_type raw_sentinel() const noexcept { - return _size; + return size_; } constexpr sentinel_type raw_capacity() const noexcept { - return _cap; + return cap_; } constexpr void set_data(pointer new_first) noexcept { - _front_cap = new_first; + front_cap_ = new_first; } constexpr void set_valid_range(pointer new_begin, pointer new_end) noexcept { // Size-based split_buffers track their size directly: we need to explicitly update the size // when the front is adjusted. - _size -= new_begin - _begin; - _begin = new_begin; + size_ -= new_begin - begin_; + begin_ = new_begin; set_sentinel(new_end); } @@ -279,44 +279,44 @@ namespace plg { set_valid_range(pointer new_begin, size_type new_size) noexcept { // Size-based split_buffers track their size directly: we need to explicitly update the size // when the front is adjusted. - _size -= new_begin - _begin; - _begin = new_begin; + size_ -= new_begin - begin_; + begin_ = new_begin; set_sentinel(new_size); } constexpr void set_sentinel(pointer new_end) noexcept { - _LIBCPP_ASSERT_INTERNAL(_front_cap <= new_end, "new_end cannot precede _front_cap"); - _size += new_end - end(); + _LIBCPP_ASSERT_INTERNAL(front_cap_ <= new_end, "new_end cannot precede front_cap_"); + size_ += new_end - end(); } constexpr void set_sentinel(size_type new_size) noexcept { - _size = new_size; + size_ = new_size; } constexpr void set_capacity(size_type new_capacity) noexcept { - _cap = new_capacity; + cap_ = new_capacity; } constexpr void set_capacity(pointer new_capacity) noexcept { - _cap = new_capacity - _begin; + cap_ = new_capacity - begin_; } constexpr size_type front_spare() const noexcept { - return static_cast(_begin - _front_cap); + return static_cast(begin_ - front_cap_); } constexpr size_type back_spare() const noexcept { - // `_cap - _end` tells us the total number of spares when in size-mode. We need to remove + // `cap_ - end_` tells us the total number of spares when in size-mode. We need to remove // the front_spare from the count. - return _cap - _size - front_spare(); + return cap_ - size_ - front_spare(); } constexpr reference back() noexcept { - return _begin[_size - 1]; + return begin_[size_ - 1]; } constexpr const_reference back() const noexcept { - return _begin[_size - 1]; + return begin_[size_ - 1]; } constexpr void swap_without_allocator( @@ -325,42 +325,42 @@ namespace plg { value_type, alloc_rr&>& other ) noexcept { - std::swap(_front_cap, other._front_cap); - std::swap(_begin, other._begin); - std::swap(_cap, other._cap); - std::swap(_size, other._size); + std::swap(front_cap_, other.front_cap_); + std::swap(begin_, other.begin_); + std::swap(cap_, other.cap_); + std::swap(size_, other.size_); } constexpr void swap(split_buffer_size_layout& other) noexcept { - std::swap(_front_cap, other._front_cap); - std::swap(_begin, other._begin); - std::swap(_cap, other._cap); - std::swap(_size, other._size); - swap_allocator(_alloc, other._alloc); + std::swap(front_cap_, other.front_cap_); + std::swap(begin_, other.begin_); + std::swap(cap_, other.cap_); + std::swap(size_, other.size_); + swap_allocator(alloc_, other.alloc_); } constexpr void reset() noexcept { - _front_cap = nullptr; - _begin = nullptr; - _size = 0; - _cap = 0; + front_cap_ = nullptr; + begin_ = nullptr; + size_ = 0; + cap_ = 0; } constexpr void copy_without_alloc( const split_buffer_size_layout& other ) noexcept(std::is_nothrow_copy_assignable::value) { - _front_cap = other._front_cap; - _begin = other._begin; - _cap = other._cap; - _size = other._size; + front_cap_ = other.front_cap_; + begin_ = other.begin_; + cap_ = other.cap_; + size_ = other.size_; } private: - pointer _front_cap = nullptr; - pointer _begin = nullptr; - size_type _size = 0; - size_type _cap = 0; - PLUGIFY_NO_UNIQUE_ADDRESS allocator_type _alloc; + pointer front_cap_ = nullptr; + pointer begin_ = nullptr; + size_type size_ = 0; + size_type cap_ = 0; + PLUGIFY_NO_UNIQUE_ADDRESS allocator_type alloc_; template friend class split_buffer_size_layout; @@ -377,11 +377,11 @@ namespace plg { // // |oooooooooooooooooooxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxoooooooooooooooooooooooo| // ^ ^ ^ ^ - // _front_cap _begin _end _back_cap + // front_cap_ begin_ end_ back_cap_ // - // The range [_front_cap, _begin) contains uninitialized memory. It is referred to as the "front - // spare capacity". The range [_begin, _end) contains valid objects. It is referred to as the "valid - // range". The range [_end, _back_cap) contains uninitialized memory. It is referred to as the "back + // The range [front_cap_, begin_) contains uninitialized memory. It is referred to as the "front + // spare capacity". The range [begin_, end_) contains valid objects. It is referred to as the "valid + // range". The range [end_, back_cap_) contains uninitialized memory. It is referred to as the "back // spare capacity". // // The layout of `split_buffer` is determined by the `Layout` template template parameter. This @@ -641,20 +641,20 @@ namespace plg { pointer p, size_type n ) noexcept - : _pos(p) - , _end(p + n) - , _parent(parent) { + : pos_(p) + , end_(p + n) + , parent_(parent) { } constexpr ~ConstructTransaction() { - _parent->set_sentinel(_pos); + parent_->set_sentinel(pos_); } - pointer _pos; - const pointer _end; + pointer pos_; + const pointer end_; private: - split_buffer* _parent; + split_buffer* parent_; }; template class L2> @@ -669,8 +669,8 @@ namespace plg { template class Layout> constexpr void split_buffer::construct_at_end(size_type n) { ConstructTransaction tx(this, end(), n); - for (; tx._pos != tx._end; ++tx._pos) { - alloc_traits::construct(get_allocator(), std::to_address(tx._pos)); + for (; tx.pos_ != tx.end_; ++tx.pos_) { + alloc_traits::construct(get_allocator(), std::to_address(tx.pos_)); } } @@ -684,8 +684,8 @@ namespace plg { constexpr void split_buffer::construct_at_end(size_type n, const_reference x) { ConstructTransaction tx(this, end(), n); - for (; tx._pos != tx._end; ++tx._pos) { - alloc_traits::construct(get_allocator(), std::to_address(tx._pos), x); + for (; tx.pos_ != tx.end_; ++tx.pos_) { + alloc_traits::construct(get_allocator(), std::to_address(tx.pos_), x); } } @@ -725,8 +725,8 @@ namespace plg { constexpr void split_buffer::construct_at_end_with_size(ForwardIterator first, size_type n) { ConstructTransaction tx(this, end(), n); - for (; tx._pos != tx._end; ++tx._pos, (void) ++first) { - alloc_traits::construct(get_allocator(), std::to_address(tx._pos), *first); + for (; tx.pos_ != tx.end_; ++tx.pos_, (void) ++first) { + alloc_traits::construct(get_allocator(), std::to_address(tx.pos_), *first); } } diff --git a/test/cross_call_worker/external/plugify/include/plg/string.hpp b/test/cross_call_worker/external/plugify/include/plg/string.hpp index 3613b95..aaaf3c1 100644 --- a/test/cross_call_worker/external/plugify/include/plg/string.hpp +++ b/test/cross_call_worker/external/plugify/include/plg/string.hpp @@ -650,7 +650,7 @@ namespace plg { template struct padding { - char _pad[N]; + char padding[N]; }; template <> @@ -781,32 +781,32 @@ namespace plg { constexpr long_() = default; constexpr long_(alloc_result alloc, size_type size) - : _data(alloc.ptr) - , _size(size) - , _cap(alloc.count / endian_factor) - , _is_long(true) { + : data_(alloc.ptr) + , size_(size) + , cap_(alloc.count / endian_factor) + , is_long_(true) { PLUGIFY_ASSERT(!fits_in_sso(alloc.count), "Long capacity should always be larger than the SSO"); } - pointer _data; - size_type _size; - size_type _cap : sizeof(size_type) * char_bit - 1; - size_type _is_long : 1; + pointer data_; + size_type size_; + size_type cap_ : sizeof(size_type) * char_bit - 1; + size_type is_long_ : 1; }; static constexpr size_type min_cap = ((sizeof(long_) - 1) / sizeof(value_type) > 2 ? (sizeof(long_) - 1) / sizeof(value_type) : 2) + 1; struct short_ { constexpr short_() - : _data{} - , _spare_size(min_cap - 1) - , _is_long(false) { + : data_{} + , spare_size_(min_cap - 1) + , is_long_(false) { } - value_type _data[min_cap - 1]; - PLUGIFY_NO_UNIQUE_ADDRESS padding _padding; - uint8_t _spare_size : 7; - uint8_t _is_long : 1; + value_type data_[min_cap - 1]; + PLUGIFY_NO_UNIQUE_ADDRESS padding padding_; + uint8_t spare_size_ : 7; + uint8_t is_long_ : 1; }; // The endian_factor is required because the field we use to store the size @@ -836,21 +836,21 @@ namespace plg { union rep { short_ s{}; long_ l; - } _rep; + } rep_; PLUGIFY_NO_UNIQUE_ADDRESS - allocator_type _alloc; + allocator_type alloc_; // annotate the string with its size() at scope exit. The string has to be in a valid state // at that point. struct annotate_new_size { - basic_string& _str; + basic_string& str_; constexpr explicit annotate_new_size(basic_string& str) - : _str(str) { + : str_(str) { } constexpr void operator()() { - _str.annotate_new(_str.size()); + str_.annotate_new(str_.size()); } }; @@ -858,13 +858,13 @@ namespace plg { // but don't initialize the characters. The contents of the string, including the null // terminator, must be initialized separately. constexpr /*explicit*/ basic_string(uninitialized_size_tag, size_type size, const allocator_type& a) - : _alloc(a) { + : alloc_(a) { init_internal_buffer(size); } template constexpr basic_string(init_with_sentinel_tag, Iter first, Sent last, const allocator_type& a) - : _alloc(a) { + : alloc_(a) { init_with_sentinel(std::move(first), std::move(last)); } @@ -880,20 +880,20 @@ namespace plg { static const size_type npos = static_cast(-1); constexpr basic_string() noexcept(std::is_nothrow_default_constructible_v) - : _rep(short_()) { + : rep_(short_()) { annotate_new(0); } constexpr /*explicit*/ basic_string(const allocator_type& a) noexcept - : _rep(short_()) - , _alloc(a) { + : rep_(short_()) + , alloc_(a) { annotate_new(0); } constexpr PLUGIFY_INTERNAL_MEMORY_ACCESS basic_string(const basic_string& str) - : _alloc(alloc_traits::select_on_container_copy_construction(str._alloc)) { + : alloc_(alloc_traits::select_on_container_copy_construction(str.alloc_)) { if (!str.is_long()) { - _rep = str._rep; + rep_ = str.rep_; annotate_new(get_short_size()); } else { init_copy_ctor_external(std::to_address(str.get_long_pointer()), str.get_long_size()); @@ -902,9 +902,9 @@ namespace plg { constexpr PLUGIFY_INTERNAL_MEMORY_ACCESS basic_string(const basic_string& str, const allocator_type& a) - : _alloc(a) { + : alloc_(a) { if (!str.is_long()) { - _rep = str._rep; + rep_ = str.rep_; annotate_new(get_short_size()); } else { init_copy_ctor_external(std::to_address(str.get_long_pointer()), str.get_long_size()); @@ -916,14 +916,14 @@ namespace plg { // PLUGIFY_INTERNAL_MEMORY_ACCESS does not work consistently during // initialization of r_, so we instead unpoison str's memory manually first. str's // memory needs to be unpoisoned only in the case where it's a short string. - : _rep([](basic_string& s) -> decltype(s._rep)&& { + : rep_([](basic_string& s) -> decltype(s.rep_)&& { if (!s.is_long()) { s.annotate_delete(); } - return std::move(s._rep); + return std::move(s.rep_); }(str)) - , _alloc(std::move(str._alloc)) { - str._rep = rep(); + , alloc_(std::move(str.alloc_)) { + str.rep_ = rep(); str.annotate_new(0); if (!is_long()) { annotate_new(size()); @@ -931,18 +931,18 @@ namespace plg { } constexpr basic_string(basic_string&& str, const allocator_type& a) - : _alloc(a) { - if (str.is_long() && a != str._alloc) { // copy, not move + : alloc_(a) { + if (str.is_long() && a != str.alloc_) { // copy, not move init(std::to_address(str.get_long_pointer()), str.get_long_size()); } else { if (std::is_constant_evaluated()) { - _rep = rep(); + rep_ = rep(); } if (!str.is_long()) { str.annotate_delete(); } - _rep = str._rep; - str._rep = rep(); + rep_ = str.rep_; + str.rep_ = rep(); str.annotate_new(0); if (!is_long() && this != std::addressof(str)) { annotate_new(size()); @@ -959,7 +959,7 @@ namespace plg { constexpr basic_string(const CharT* PLUGIFY_NO_NULL s, const Allocator& a) requires(is_allocator) - : _alloc(a) { + : alloc_(a) { PLUGIFY_ASSERT(s != nullptr, "basic_string(const char*, allocator) detected nullptr"); init(s, traits_type::length(s)); } @@ -972,7 +972,7 @@ namespace plg { } constexpr basic_string(const CharT* s, size_type n, const Allocator& a) - : _alloc(a) { + : alloc_(a) { PLUGIFY_ASSERT( n == 0 || s != nullptr, "basic_string(const char*, n, allocator) detected nullptr" @@ -994,13 +994,13 @@ namespace plg { size_type n, const Allocator& alloc = Allocator() ) - : _alloc(alloc) { + : alloc_(alloc) { if (pos > str.size()) { this->throw_out_of_range(); } auto len = std::min(n, str.size() - pos); - if (alloc_traits::is_always_equal::value || alloc == str._alloc) { + if (alloc_traits::is_always_equal::value || alloc == str.alloc_) { move_assign(std::move(str), pos, len); } else { // Perform a copy because the allocators are not compatible. @@ -1010,7 +1010,7 @@ namespace plg { constexpr basic_string(size_type n, CharT c, const Allocator& a) requires(is_allocator) - : _alloc(a) { + : alloc_(a) { init(n, c); } @@ -1020,7 +1020,7 @@ namespace plg { size_type n, const Allocator& a = Allocator() ) - : _alloc(a) { + : alloc_(a) { size_type str_sz = str.size(); if (pos > str_sz) { this->throw_out_of_range(); @@ -1029,7 +1029,7 @@ namespace plg { } constexpr basic_string(const basic_string& str, size_type pos, const Allocator& a = Allocator()) - : _alloc(a) { + : alloc_(a) { size_type str_sz = str.size(); if (pos > str_sz) { this->throw_out_of_range(); @@ -1044,7 +1044,7 @@ namespace plg { size_type n, const allocator_type& a = allocator_type() ) - : _alloc(a) { + : alloc_(a) { self_view sv0 = t; self_view sv = sv0.substr(pos, n); init(sv.data(), sv.size()); @@ -1058,7 +1058,7 @@ namespace plg { template T> constexpr /*explicit*/ basic_string(const T& t, const allocator_type& a) - : _alloc(a) { + : alloc_(a) { self_view sv = t; init(sv.data(), sv.size()); } @@ -1070,14 +1070,14 @@ namespace plg { template constexpr basic_string(InputIterator first, InputIterator last, const allocator_type& a) - : _alloc(a) { + : alloc_(a) { init(first, last); } #if PLUGIFY_HAS_CXX23 template Range> constexpr basic_string(std::from_range_t, Range&& range, const allocator_type& a = allocator_type()) - : _alloc(a) { + : alloc_(a) { if constexpr (std::ranges::forward_range || std::ranges::sized_range) { init_with_size( std::ranges::begin(range), @@ -1095,7 +1095,7 @@ namespace plg { } constexpr basic_string(std::initializer_list il, const Allocator& a) - : _alloc(a) { + : alloc_(a) { init(il.begin(), il.end()); } @@ -1194,7 +1194,7 @@ namespace plg { constexpr size_type max_size() const noexcept { constexpr bool uses_lsb = endian_factor == 2; - if (size_type m = alloc_traits::max_size(_alloc); + if (size_type m = alloc_traits::max_size(alloc_); m <= std::numeric_limits::max() / 2) { size_type res = m - alignment; @@ -1317,7 +1317,7 @@ namespace plg { template constexpr basic_string& append(InputIterator first, InputIterator last) { - const basic_string temp(first, last, _alloc); + const basic_string temp(first, last, alloc_); append(temp.data(), temp.size()); return *this; } @@ -1341,7 +1341,7 @@ namespace plg { set_size(sz + n); return *this; } else { - const basic_string temp(first, last, _alloc); + const basic_string temp(first, last, alloc_); return append(temp.data(), temp.size()); } } @@ -1389,13 +1389,13 @@ namespace plg { constexpr void move_assign(basic_string&& str, size_type pos, size_type len) { // Pilfer the allocation from str. - PLUGIFY_ASSERT(_alloc == str._alloc, "move_assign called with wrong allocator"); + PLUGIFY_ASSERT(alloc_ == str.alloc_, "move_assign called with wrong allocator"); size_type old_sz = str.size(); if (!str.is_long()) { str.annotate_delete(); } - _rep = str._rep; - str._rep = rep(); + rep_ = str.rep_; + str.rep_ = rep(); str.annotate_new(0); Traits::move(data(), data() + pos, len); @@ -1510,7 +1510,7 @@ namespace plg { return insert_with_size(position, std::ranges::begin(range), std::ranges::end(range), n); } else { - basic_string temp(std::from_range, std::forward(range), _alloc); + basic_string temp(std::from_range, std::forward(range), alloc_); return insert(position, temp.data(), temp.data() + temp.size()); } } @@ -1524,7 +1524,7 @@ namespace plg { template constexpr iterator insert(const_iterator pos, InputIterator first, InputIterator last) { - const basic_string temp(first, last, _alloc); + const basic_string temp(first, last, alloc_); return insert(pos, temp.data(), temp.data() + temp.size()); } @@ -1605,7 +1605,7 @@ namespace plg { template constexpr basic_string& replace(const_iterator i1, const_iterator i2, InputIterator j1, InputIterator j2) { - const basic_string temp(j1, j2, _alloc); + const basic_string temp(j1, j2, alloc_); return replace(i1, i2, temp); } @@ -1613,7 +1613,7 @@ namespace plg { template Range> constexpr basic_string& replace_with_range(const_iterator i1, const_iterator i2, Range&& range) { - basic_string temp(std::from_range, std::forward(range), _alloc); + basic_string temp(std::from_range, std::forward(range), alloc_); return replace(i1, i2, temp); } #endif @@ -1651,7 +1651,7 @@ namespace plg { } constexpr allocator_type get_allocator() const noexcept { - return _alloc; + return alloc_; } // find @@ -1890,7 +1890,7 @@ namespace plg { // starts_with constexpr bool starts_with(self_view sv) const noexcept { - return self_view(typename self_view::assume_valid(), data(), size()).starts_with(sv); + return self_view(data(), size()).starts_with(sv); } constexpr bool starts_with(value_type c) const noexcept { @@ -1904,7 +1904,7 @@ namespace plg { // ends_with constexpr bool ends_with(self_view sv) const noexcept { - return self_view(typename self_view::assume_valid(), data(), size()).ends_with(sv); + return self_view(data(), size()).ends_with(sv); } constexpr bool ends_with(value_type c) const noexcept { @@ -1918,25 +1918,25 @@ namespace plg { // contains constexpr bool contains(self_view sv) const noexcept { - return self_view(typename self_view::assume_valid(), data(), size()).contains(sv); + return self_view(data(), size()).contains(sv); } constexpr bool contains(value_type c) const noexcept { - return self_view(typename self_view::assume_valid(), data(), size()).contains(c); + return self_view(data(), size()).contains(c); } constexpr bool contains(const value_type* PLUGIFY_NO_NULL s) const { - return self_view(typename self_view::assume_valid(), data(), size()).contains(s); + return self_view(data(), size()).contains(s); } [[nodiscard]] constexpr bool invariants() const; private: [[nodiscard]] constexpr PLUGIFY_INTERNAL_MEMORY_ACCESS bool is_long() const noexcept { - if (std::is_constant_evaluated() && __builtin_constant_p(_rep.l._is_long)) { - return _rep.l._is_long; + if (std::is_constant_evaluated() && __builtin_constant_p(rep_.l.is_long_)) { + return rep_.l.is_long_; } - return _rep.s._is_long; + return rep_.s.is_long_; } static constexpr bool fits_in_sso(size_type sz) { @@ -2008,22 +2008,22 @@ namespace plg { s < min_cap, "s should never be greater than or equal to the short string capacity" ); - _rep.s._spare_size = (min_cap - 1) - s; - _rep.s._is_long = false; + rep_.s.spare_size_ = (min_cap - 1) - s; + rep_.s.is_long_ = false; } constexpr PLUGIFY_INTERNAL_MEMORY_ACCESS size_type get_short_size() const noexcept { - PLUGIFY_ASSERT(!_rep.s._is_long, "String has to be short when trying to get the short size"); - return (min_cap - 1) - _rep.s._spare_size; + PLUGIFY_ASSERT(!rep_.s.is_long_, "String has to be short when trying to get the short size"); + return (min_cap - 1) - rep_.s.spare_size_; } constexpr void set_long_size(size_type s) noexcept { - _rep.l._size = s; + rep_.l.size_ = s; } constexpr size_type get_long_size() const noexcept { - PLUGIFY_ASSERT(_rep.l._is_long, "String has to be long when trying to get the long size"); - return _rep.l._size; + PLUGIFY_ASSERT(rep_.l.is_long_, "String has to be long when trying to get the long size"); + return rep_.l.size_; } constexpr void set_size(size_type s) noexcept { @@ -2035,29 +2035,29 @@ namespace plg { } constexpr size_type get_long_cap() const noexcept { - PLUGIFY_ASSERT(_rep.l._is_long, "String has to be long when trying to get the long capacity"); - return _rep.l._cap * endian_factor; + PLUGIFY_ASSERT(rep_.l.is_long_, "String has to be long when trying to get the long capacity"); + return rep_.l.cap_ * endian_factor; } constexpr pointer get_long_pointer() noexcept { - PLUGIFY_ASSERT(_rep.l._is_long, "String has to be long when trying to get the long pointer"); - return PLUGIFY_ASAN_VOLATILE_WRAPPER(_rep.l._data); + PLUGIFY_ASSERT(rep_.l.is_long_, "String has to be long when trying to get the long pointer"); + return PLUGIFY_ASAN_VOLATILE_WRAPPER(rep_.l.data_); } constexpr const_pointer get_long_pointer() const noexcept { - PLUGIFY_ASSERT(_rep.l._is_long, "String has to be long when trying to get the long pointer"); - return PLUGIFY_ASAN_VOLATILE_WRAPPER(_rep.l._data); + PLUGIFY_ASSERT(rep_.l.is_long_, "String has to be long when trying to get the long pointer"); + return PLUGIFY_ASAN_VOLATILE_WRAPPER(rep_.l.data_); } constexpr PLUGIFY_INTERNAL_MEMORY_ACCESS pointer get_short_pointer() noexcept { return PLUGIFY_ASAN_VOLATILE_WRAPPER( - std::pointer_traits::pointer_to(_rep.s._data[0]) + std::pointer_traits::pointer_to(rep_.s.data_[0]) ); } constexpr PLUGIFY_INTERNAL_MEMORY_ACCESS const_pointer get_short_pointer() const noexcept { return PLUGIFY_ASAN_VOLATILE_WRAPPER( - std::pointer_traits::pointer_to(_rep.s._data[0]) + std::pointer_traits::pointer_to(rep_.s.data_[0]) ); } @@ -2094,22 +2094,22 @@ namespace plg { constexpr void reset_internal_buffer() { annotate_delete(); if (is_long()) { - alloc_traits::deallocate(_alloc, get_long_pointer(), get_long_cap()); + alloc_traits::deallocate(alloc_, get_long_pointer(), get_long_cap()); } - _rep.s = short_(); + rep_.s = short_(); } // Replace the current buffer with alloc; the first size elements constitute a string constexpr void replace_internal_buffer(long_ alloc) { reset_internal_buffer(); - _rep.l = alloc; + rep_.l = alloc; } // Initialize the internal buffer to hold size elements // The elements and null terminator have to be set by the caller constexpr pointer init_internal_buffer(size_type size) { if (std::is_constant_evaluated()) { - _rep = rep(); + rep_ = rep(); } if (size > max_size()) { @@ -2121,7 +2121,7 @@ namespace plg { annotate_new(size); return get_short_pointer(); } else { - _rep.l = allocate_long_buffer(_alloc, size); + rep_.l = allocate_long_buffer(alloc_, size); annotate_new(size); return get_long_pointer(); } @@ -2270,18 +2270,18 @@ namespace plg { } constexpr void copy_assign_alloc(const basic_string& str, std::true_type) { - if (_alloc == str._alloc) { - _alloc = str._alloc; + if (alloc_ == str.alloc_) { + alloc_ = str.alloc_; } else { if (!str.is_long()) { reset_internal_buffer(); - _alloc = str._alloc; + alloc_ = str.alloc_; } else { annotate_delete(); [[maybe_unused]] auto guard = make_scope_guard(annotate_new_size(*this)); - auto alloc = str._alloc; + auto alloc = str.alloc_; replace_internal_buffer(allocate_long_buffer(alloc, str.size())); - _alloc = std::move(alloc); + alloc_ = std::move(alloc); } } } @@ -2307,7 +2307,7 @@ namespace plg { basic_string& c, std::true_type ) noexcept(std::is_nothrow_move_assignable_v) { - _alloc = std::move(c._alloc); + alloc_ = std::move(c.alloc_); } constexpr void move_assign_alloc(basic_string&, std::false_type) noexcept { @@ -2433,7 +2433,7 @@ namespace plg { template constexpr void basic_string::init_with_sentinel(InputIterator first, Sentinel last) { - _rep = rep(); + rep_ = rep(); annotate_new(0); #if PLUGIFY_HAS_EXCEPTIONS @@ -2500,23 +2500,23 @@ namespace plg { : ms; annotate_delete(); [[maybe_unused]] auto guard = make_scope_guard(annotate_new_size(*this)); - long_ buffer = allocate_long_buffer(_alloc, cap); + long_ buffer = allocate_long_buffer(alloc_, cap); if (n_copy != 0) { - traits_type::copy(std::to_address(buffer._data), std::to_address(old_p), n_copy); + traits_type::copy(std::to_address(buffer.data_), std::to_address(old_p), n_copy); } if (n_add != 0) { - traits_type::copy(std::to_address(buffer._data) + n_copy, p_new_stuff, n_add); + traits_type::copy(std::to_address(buffer.data_) + n_copy, p_new_stuff, n_add); } size_type sec_cp_sz = old_sz - n_del - n_copy; if (sec_cp_sz != 0) { traits_type::copy( - std::to_address(buffer._data) + n_copy + n_add, + std::to_address(buffer.data_) + n_copy + n_add, std::to_address(old_p) + n_copy + n_del, sec_cp_sz ); } - buffer._size = n_copy + n_add + sec_cp_sz; - traits_type::assign(buffer._data[buffer._size], value_type()); + buffer.size_ = n_copy + n_add + sec_cp_sz; + traits_type::assign(buffer.data_[buffer.size_], value_type()); replace_internal_buffer(buffer); } @@ -2539,14 +2539,14 @@ namespace plg { size_type cap = old_cap < ms / 2 - alignment ? recommend(std::max(old_cap + delta_cap, 2 * old_cap)) : ms; - long_ buffer = allocate_long_buffer(_alloc, cap); + long_ buffer = allocate_long_buffer(alloc_, cap); if (n_copy != 0) { - traits_type::copy(std::to_address(buffer._data), std::to_address(old_p), n_copy); + traits_type::copy(std::to_address(buffer.data_), std::to_address(old_p), n_copy); } size_type sec_cp_sz = old_sz - n_del - n_copy; if (sec_cp_sz != 0) { traits_type::copy( - std::to_address(buffer._data) + n_copy + n_add, + std::to_address(buffer.data_) + n_copy + n_add, std::to_address(old_p) + n_copy + n_del, sec_cp_sz ); @@ -2554,7 +2554,7 @@ namespace plg { // This is -1 to make sure the caller sets the size properly, since old versions of this // function didn't set the size at all. - buffer._size = npos; + buffer.size_ = npos; replace_internal_buffer(buffer); set_long_size(old_sz - n_del + n_add); } @@ -2671,7 +2671,7 @@ namespace plg { annotate_delete(); [[maybe_unused]] auto guard = make_scope_guard(annotate_new_size(*this)); - _rep = str._rep; + rep_ = str.rep_; return *this; } @@ -2681,7 +2681,7 @@ namespace plg { basic_string::move_assign(basic_string& str, std::false_type) noexcept( alloc_traits::is_always_equal::value ) { - if (_alloc != str._alloc) { + if (alloc_ != str.alloc_) { assign(str); } else { move_assign(str, std::true_type()); @@ -2699,7 +2699,7 @@ namespace plg { bool str_was_short = !str.is_long(); move_assign_alloc(str); - _rep = str._rep; + rep_ = str.rep_; str.set_short_size(0); traits_type::assign(str.get_short_pointer()[0], value_type()); @@ -2728,7 +2728,7 @@ namespace plg { template constexpr void basic_string::assign_with_sentinel(InputIterator first, Sentinel last) { - const basic_string temp(init_with_sentinel_tag(), std::move(first), std::move(last), _alloc); + const basic_string temp(init_with_sentinel_tag(), std::move(first), std::move(last), alloc_); assign(temp.data(), temp.size()); } @@ -2974,7 +2974,7 @@ namespace plg { if (string_is_trivial_iterator_v && !addr_in_range(*first)) { return insert_from_safe_copy(n, ip, std::move(first), std::move(last)); } else { - const basic_string temp(init_with_sentinel_tag(), std::move(first), std::move(last), _alloc); + const basic_string temp(init_with_sentinel_tag(), std::move(first), std::move(last), alloc_); return insert_from_safe_copy(n, ip, temp.begin(), temp.end()); } } @@ -3228,9 +3228,9 @@ namespace plg { } [[maybe_unused]] annotation_guard g(*this); - long_ buffer = allocate_long_buffer(_alloc, requested_capacity); - buffer._size = size(); - traits_type::copy(std::to_address(buffer._data), data(), buffer._size + 1); + long_ buffer = allocate_long_buffer(alloc_, requested_capacity); + buffer.size_ = size(); + traits_type::copy(std::to_address(buffer.data_), data(), buffer.size_ + 1); replace_internal_buffer(buffer); } @@ -3252,7 +3252,7 @@ namespace plg { [[maybe_unused]] annotation_guard g(*this); set_short_size(size); traits_type::copy(std::to_address(get_short_pointer()), std::to_address(ptr), size + 1); - alloc_traits::deallocate(_alloc, ptr, cap); + alloc_traits::deallocate(alloc_, ptr, cap); return; } @@ -3260,18 +3260,18 @@ namespace plg { try { #endif // PLUGIFY_HAS_EXCEPTIONS [[maybe_unused]] annotation_guard g(*this); - long_ buffer = allocate_long_buffer(_alloc, size); + long_ buffer = allocate_long_buffer(alloc_, size); // The Standard mandates shrink_to_fit() does not increase the capacity. // With equal capacity keep the existing buffer. This avoids extra work // due to swapping the elements. - if (buffer._cap * endian_factor - 1 >= capacity()) { - alloc_traits::deallocate(_alloc, buffer._data, buffer._cap * endian_factor); + if (buffer.cap_ * endian_factor - 1 >= capacity()) { + alloc_traits::deallocate(alloc_, buffer.data_, buffer.cap_ * endian_factor); return; } traits_type::copy( - std::to_address(buffer._data), + std::to_address(buffer.data_), std::to_address(get_long_pointer()), size + 1 ); @@ -3316,7 +3316,7 @@ namespace plg { template inline constexpr void basic_string::swap(basic_string& str) noexcept { PLUGIFY_ASSERT( - alloc_traits::propagate_on_container_swap::value || alloc_traits::is_always_equal::value || _alloc == str._alloc, + alloc_traits::propagate_on_container_swap::value || alloc_traits::is_always_equal::value || alloc_ == str.alloc_, "swapping non-equal allocators" ); if (!is_long()) { @@ -3325,8 +3325,8 @@ namespace plg { if (this != std::addressof(str) && !str.is_long()) { str.annotate_delete(); } - std::swap(_rep, str._rep); - swap_allocator(_alloc, str._alloc); + std::swap(rep_, str.rep_); + swap_allocator(alloc_, str.alloc_); if (!is_long()) { annotate_new(get_short_size()); } diff --git a/test/cross_call_worker/external/plugify/include/plg/uninitialized.hpp b/test/cross_call_worker/external/plugify/include/plg/uninitialized.hpp index 9cc3400..85c277b 100644 --- a/test/cross_call_worker/external/plugify/include/plg/uninitialized.hpp +++ b/test/cross_call_worker/external/plugify/include/plg/uninitialized.hpp @@ -51,16 +51,16 @@ namespace plg { class AllocatorDestroyRangeReverse { public: AllocatorDestroyRangeReverse(Alloc& alloc, Iter& first, Iter& last) - : _alloc(alloc), _first(first), _last(last) {} + : alloc_(alloc), first_(first), last_(last) {} void operator()() const { - allocator_destroy(_alloc, std::reverse_iterator(_last), std::reverse_iterator(_first)); + allocator_destroy(alloc_, std::reverse_iterator(last_), std::reverse_iterator(first_)); } private: - Alloc& _alloc; - Iter& _first; - Iter& _last; + Alloc& alloc_; + Iter& first_; + Iter& last_; }; // Copy-construct [first1, last1) in [first2, first2 + N), where N is @@ -123,7 +123,7 @@ namespace plg { // - is_copy_constructible // - is_trivially_relocatable template - void uninitialized_allocator_relocate(Alloc& alloc, T* first, T* last, T* result) { + constexpr void uninitialized_allocator_relocate(Alloc& alloc, T* first, T* last, T* result) { if (std::is_constant_evaluated() || !is_trivially_relocatable::value || !allocator_has_trivial_move_construct::value || diff --git a/test/cross_call_worker/external/plugify/include/plg/variant.hpp b/test/cross_call_worker/external/plugify/include/plg/variant.hpp index 9e7ada0..4c68ac4 100644 --- a/test/cross_call_worker/external/plugify/include/plg/variant.hpp +++ b/test/cross_call_worker/external/plugify/include/plg/variant.hpp @@ -26,13 +26,13 @@ namespace plg { #if PLUGIFY_HAS_EXCEPTIONS class bad_variant_access : public std::exception { public: - explicit bad_variant_access(const char* str) noexcept : message{str} {} + explicit bad_variant_access(const char* str) noexcept : message_{str} {} bad_variant_access() noexcept = default; bad_variant_access(const bad_variant_access&) noexcept = default; bad_variant_access& operator=(const bad_variant_access&) noexcept = default; - const char* what() const noexcept override { return message; } + const char* what() const noexcept override { return message_; } private: - const char* message = ""; // llvm test requires a well formed what() on default init + const char* message_ = ""; // llvm test requires a well formed what() on default init }; #endif // PLUGIFY_HAS_EXCEPTIONS @@ -575,7 +575,7 @@ namespace plg { constexpr variant() noexcept(std::is_nothrow_default_constructible_v>) requires std::is_default_constructible_v> - : _storage{in_place_index<0>}, _current{0} + : storage_{in_place_index<0>}, current_{0} {} // copy constructor (trivial) @@ -587,7 +587,7 @@ namespace plg { // copy constructor constexpr variant(const variant& o) requires (has_copy_ctor and not trivial_copy_ctor) - : _storage{detail::dummy_type{}} { + : storage_{detail::dummy_type{}} { construct_from(o); } @@ -600,7 +600,7 @@ namespace plg { constexpr variant(variant&& o) noexcept((std::is_nothrow_move_constructible_v && ...)) requires (has_move_ctor and not trivial_move_ctor) - : _storage{detail::dummy_type{}} { + : storage_{detail::dummy_type{}} { construct_from(static_cast(o)); } @@ -616,7 +616,7 @@ namespace plg { template requires (Index < size && std::is_constructible_v, Args&&...>) explicit constexpr variant(in_place_index_t tag, Args&&... args) - : _storage{tag, static_cast(args)...}, _current(Index) + : storage_{tag, static_cast(args)...}, current_(Index) {} // construct a given type @@ -633,7 +633,7 @@ namespace plg { std::is_constructible_v, std::initializer_list&, Args&&...> ) explicit constexpr variant(in_place_index_t tag, std::initializer_list list, Args&&... args) - : _storage{tag, list, PLG_FWD(args)...}, _current{Index} + : storage_{tag, list, PLG_FWD(args)...}, current_{Index} {} template @@ -642,7 +642,7 @@ namespace plg { && std::is_constructible_v&, Args&&...> ) explicit constexpr variant(in_place_type_t, std::initializer_list list, Args&&... args) - : _storage{in_place_index>, list, PLG_FWD(args)...}, _current{index_of } + : storage_{in_place_index>, list, PLG_FWD(args)...}, current_{index_of } {} // ================================ destructors (20.7.3.3) @@ -714,7 +714,7 @@ namespace plg { using related_type = detail::best_overload_match; constexpr auto new_index = index_of; - if (_current == new_index) + if (current_ == new_index) unsafe_get() = PLG_FWD(t); else { constexpr bool do_simple_emplace = @@ -765,12 +765,12 @@ namespace plg { constexpr bool valueless_by_exception() const noexcept { if constexpr (can_be_valueless) - return _current == npos; + return current_ == npos; else return false; } constexpr index_type index() const noexcept { - return _current; + return current_; } // =================================== swap (20.7.3.7) @@ -785,7 +785,7 @@ namespace plg { constexpr auto impl_one_valueless = [](auto&& full, auto& empty) { detail::visit_with_index(PLG_FWD(full), detail::emplace_no_dtor_from_elem{empty}); full.reset_no_check(); - full._current = npos; + full.current_ = npos; }; switch (static_cast(index() == npos) + static_cast(o.index() == npos) * 2) { @@ -837,29 +837,29 @@ namespace plg { template constexpr auto& unsafe_get() & noexcept { static_assert(Idx < size); - PLUGIFY_ASSERT(_current == Idx, ""); - return _storage.template get(); + PLUGIFY_ASSERT(current_ == Idx, ""); + return storage_.template get(); } template constexpr auto&& unsafe_get() && noexcept { static_assert(Idx < size); - PLUGIFY_ASSERT(_current == Idx, ""); - return PLG_MOV(_storage.template get()); + PLUGIFY_ASSERT(current_ == Idx, ""); + return PLG_MOV(storage_.template get()); } template constexpr const auto& unsafe_get() const & noexcept { static_assert(Idx < size); - PLUGIFY_ASSERT(_current == Idx, ""); - return _storage.template get(); + PLUGIFY_ASSERT(current_ == Idx, ""); + return storage_.template get(); } template constexpr const auto&& unsafe_get() const && noexcept { static_assert(Idx < size); - PLUGIFY_ASSERT(_current == Idx, ""); - return PLG_MOV(_storage.template get()); + PLUGIFY_ASSERT(current_ == Idx, ""); + return PLG_MOV(storage_.template get()); } private: @@ -868,9 +868,9 @@ namespace plg { constexpr void assign_from(Other&& o, Fn&& fn) { if constexpr (can_be_valueless) { if (o.index() == npos) { - if (_current != npos) { + if (current_ != npos) { reset_no_check(); - _current = npos; + current_ = npos; } return; } @@ -906,7 +906,7 @@ namespace plg { { static_assert(can_be_valueless, "Internal error : the possibly valueless branch of emplace was taken despite |can_be_valueless| being false"); - _current = npos; + current_ = npos; do_emplace_no_dtor(PLG_FWD(args)...); } } @@ -916,7 +916,7 @@ namespace plg { template constexpr void do_emplace_no_dtor(Args&&... args) { - _current = static_cast(Idx); + current_ = static_cast(Idx); auto* ptr = detail::addressof(unsafe_get()); @@ -950,7 +950,7 @@ namespace plg { constexpr void construct_from(Other&& o) { if constexpr (can_be_valueless) if (o.valueless_by_exception()) { - _current = npos; + current_ = npos; return; } @@ -960,11 +960,11 @@ namespace plg { template friend struct detail::emplace_no_dtor_from_elem; - storage _storage; + storage storage_; #if INTPTR_MAX == INT32_MAX - volatile char pad[8]; + volatile char padding_[8]; #endif - index_type _current; + index_type current_; }; // ================================= value access (20.7.5) diff --git a/test/cross_call_worker/external/plugify/include/plg/vector.hpp b/test/cross_call_worker/external/plugify/include/plg/vector.hpp index cd26021..56884fc 100644 --- a/test/cross_call_worker/external/plugify/include/plg/vector.hpp +++ b/test/cross_call_worker/external/plugify/include/plg/vector.hpp @@ -94,7 +94,7 @@ namespace plg { constexpr vector() noexcept(std::is_nothrow_default_constructible_v) = default; constexpr explicit vector(const allocator_type& a) noexcept - : _alloc(a) { + : alloc_(a) { } constexpr explicit vector(size_type n) { @@ -108,7 +108,7 @@ namespace plg { constexpr explicit vector(size_type n, const allocator_type& a) - : _alloc(a) { + : alloc_(a) { auto guard = make_exception_guard(destroy_vector(*this)); if (n > 0) { vallocate(n); @@ -128,7 +128,7 @@ namespace plg { constexpr vector(size_type n, const value_type& x, const allocator_type& a) - : _alloc(a) { + : alloc_(a) { auto guard = make_exception_guard(destroy_vector(*this)); if (n > 0) { vallocate(n); @@ -146,7 +146,7 @@ namespace plg { template constexpr vector(InputIterator first, InputIterator last, const allocator_type& a) - : _alloc(a) { + : alloc_(a) { init_with_sentinel(first, last); } @@ -160,7 +160,7 @@ namespace plg { template constexpr vector(ForwardIterator first, ForwardIterator last, const allocator_type& a) - : _alloc(a) { + : alloc_(a) { size_type n = static_cast(std::distance(first, last)); init_with_size(first, last, n); } @@ -171,7 +171,7 @@ namespace plg { std::from_range_t, Range&& range, const allocator_type& alloc = allocator_type() - ) : _alloc(alloc) { + ) : alloc_(alloc) { if constexpr (std::ranges::forward_range || std::ranges::sized_range) { auto n = static_cast(std::ranges::distance(range)); init_with_size(std::ranges::begin(range), std::ranges::end(range), n); @@ -190,10 +190,10 @@ namespace plg { } constexpr void operator()() { - if (vec_._begin != nullptr) { + if (vec_.begin_ != nullptr) { vec_.clear(); vec_.annotate_delete(); - alloc_traits::deallocate(vec_._alloc, vec_._begin, vec_.capacity()); + alloc_traits::deallocate(vec_.alloc_, vec_.begin_, vec_.capacity()); } } @@ -207,14 +207,14 @@ namespace plg { } constexpr vector(const vector& x) - : _alloc(alloc_traits::select_on_container_copy_construction(x._alloc)) { - init_with_size(x._begin, x._end, x.size()); + : alloc_(alloc_traits::select_on_container_copy_construction(x.alloc_)) { + init_with_size(x.begin_, x.end_, x.size()); } constexpr vector(const vector& x, const std::type_identity_t& a) - : _alloc(a) { - init_with_size(x._begin, x._end, x.size()); + : alloc_(a) { + init_with_size(x.begin_, x.end_, x.size()); } constexpr vector& operator=(const vector& x); @@ -225,7 +225,7 @@ namespace plg { constexpr vector(std::initializer_list il, const allocator_type& a) - : _alloc(a) { + : alloc_(a) { init_with_size(il.begin(), il.end(), il.size()); } @@ -286,28 +286,28 @@ namespace plg { [[nodiscard]] constexpr allocator_type get_allocator() const noexcept { - return this->_alloc; + return this->alloc_; } // // Iterators // [[nodiscard]] constexpr iterator begin() noexcept { - return make_iter(add_alignment_assumption(this->_begin)); + return make_iter(add_alignment_assumption(this->begin_)); } [[nodiscard]] constexpr const_iterator begin() const noexcept { - return make_iter(add_alignment_assumption(this->_begin)); + return make_iter(add_alignment_assumption(this->begin_)); } [[nodiscard]] constexpr iterator end() noexcept { - return make_iter(add_alignment_assumption(this->_end)); + return make_iter(add_alignment_assumption(this->end_)); } [[nodiscard]] constexpr const_iterator end() const noexcept { - return make_iter(add_alignment_assumption(this->_end)); + return make_iter(add_alignment_assumption(this->end_)); } [[nodiscard]] constexpr reverse_iterator @@ -354,23 +354,23 @@ namespace plg { // [vector.capacity], capacity // [[nodiscard]] constexpr size_type size() const noexcept { - return static_cast(this->_end - this->_begin); + return static_cast(this->end_ - this->begin_); } [[nodiscard]] constexpr size_type capacity() const noexcept { - return static_cast(this->_cap - this->_begin); + return static_cast(this->cap_ - this->begin_); } [[nodiscard]] constexpr bool empty() const noexcept { - return this->_begin == this->_end; + return this->begin_ == this->end_; } [[nodiscard]] constexpr size_type max_size() const noexcept { return std::min( - alloc_traits::max_size(this->_alloc), + alloc_traits::max_size(this->alloc_), std::numeric_limits::max() ); } @@ -384,20 +384,20 @@ namespace plg { [[nodiscard]] constexpr reference operator[](size_type n) noexcept { PLUGIFY_ASSERT(n < size(), "vector[] index out of bounds"); - return this->_begin[n]; + return this->begin_[n]; } [[nodiscard]] constexpr const_reference operator[](size_type n) const noexcept { PLUGIFY_ASSERT(n < size(), "vector[] index out of bounds"); - return this->_begin[n]; + return this->begin_[n]; } [[nodiscard]] constexpr reference at(size_type n) { if (n >= size()) { this->throw_out_of_range(); } - return this->_begin[n]; + return this->begin_[n]; } [[nodiscard]] constexpr const_reference @@ -405,29 +405,29 @@ namespace plg { if (n >= size()) { this->throw_out_of_range(); } - return this->_begin[n]; + return this->begin_[n]; } [[nodiscard]] constexpr reference front() noexcept { PLUGIFY_ASSERT(!empty(), "front() called on an empty vector"); - return *this->_begin; + return *this->begin_; } [[nodiscard]] constexpr const_reference front() const noexcept { PLUGIFY_ASSERT(!empty(), "front() called on an empty vector"); - return *this->_begin; + return *this->begin_; } [[nodiscard]] constexpr reference back() noexcept { PLUGIFY_ASSERT(!empty(), "back() called on an empty vector"); - return *(this->_end - 1); + return *(this->end_ - 1); } [[nodiscard]] constexpr const_reference back() const noexcept { PLUGIFY_ASSERT(!empty(), "back() called on an empty vector"); - return *(this->_end - 1); + return *(this->end_ - 1); } // @@ -435,12 +435,12 @@ namespace plg { // [[nodiscard]] constexpr value_type* data() noexcept { - return std::to_address(this->_begin); + return std::to_address(this->begin_); } [[nodiscard]] constexpr const value_type* data() const noexcept { - return std::to_address(this->_begin); + return std::to_address(this->begin_); } // @@ -467,7 +467,7 @@ namespace plg { "We assume that we have enough space to insert an element at the end of the vector" ); ConstructTransaction tx(*this, 1); - alloc_traits::construct(this->_alloc, std::to_address(tx.pos_), std::forward(args)...); + alloc_traits::construct(this->alloc_, std::to_address(tx.pos_), std::forward(args)...); ++tx.pos_; } @@ -480,7 +480,7 @@ namespace plg { constexpr void pop_back() { PLUGIFY_ASSERT(!empty(), "vector::pop_back called on an empty vector"); - this->destruct_at_end(this->_end - 1); + this->destruct_at_end(this->end_ - 1); } constexpr iterator @@ -532,7 +532,7 @@ namespace plg { constexpr void clear() noexcept { size_type old_size = size(); - base_destruct_at_end(this->_begin); + base_destruct_at_end(this->begin_); annotate_shrink(old_size); } @@ -545,16 +545,16 @@ namespace plg { constexpr bool invariants() const; private: - pointer _begin = nullptr; - pointer _end = nullptr; - pointer _cap = nullptr; + pointer begin_ = nullptr; + pointer end_ = nullptr; + pointer cap_ = nullptr; PLUGIFY_NO_UNIQUE_ADDRESS - allocator_type _alloc; + allocator_type alloc_; // Allocate space for n objects // throws length_error if n > max_size() // throws (probably bad_alloc) if memory run out - // Precondition: _begin == _end == _cap == nullptr + // Precondition: begin_ == end_ == cap_ == nullptr // Precondition: n > 0 // Postcondition: capacity() >= n // Postcondition: size() == 0 @@ -562,10 +562,10 @@ namespace plg { if (n > max_size()) { this->throw_length_error(); } - auto allocation = allocate_at_least(this->_alloc, n); - _begin = allocation.ptr; - _end = allocation.ptr; - _cap = _begin + allocation.count; + auto allocation = allocate_at_least(this->alloc_, n); + begin_ = allocation.ptr; + end_ = allocation.ptr; + cap_ = begin_ + allocation.count; annotate_new(0); } @@ -617,7 +617,7 @@ namespace plg { insert_assign_n_unchecked(Iterator first, difference_type n, pointer position) { for (pointer end_position = position + n; position != end_position; ++position, (void) ++first) { - detail::temp_value tmp(this->_alloc, *first); + detail::temp_value tmp(this->alloc_, *first); *position = std::move(tmp.get()); } } @@ -722,15 +722,15 @@ namespace plg { constexpr explicit ConstructTransaction(vector& v, size_type n) : v_(v) - , pos_(v._end) - , new_end_(v._end + n) { + , pos_(v.end_) + , new_end_(v.end_ + n) { v.annotate_increase(n); } constexpr ~ConstructTransaction() { - v_._end = pos_; + v_.end_ = pos_; if (pos_ != new_end_) { - v_.annotate_shrink(new_end_ - v_._begin); + v_.annotate_shrink(new_end_ - v_.begin_); } } @@ -744,11 +744,11 @@ namespace plg { constexpr void base_destruct_at_end(pointer new_last) noexcept { - pointer soon_to_be_end = this->_end; + pointer soon_to_be_end = this->end_; while (new_last != soon_to_be_end) { - alloc_traits::destroy(this->_alloc, std::to_address(--soon_to_be_end)); + alloc_traits::destroy(this->alloc_, std::to_address(--soon_to_be_end)); } - this->_end = new_last; + this->end_ = new_last; } constexpr void copy_assign_alloc(const vector& c) { @@ -779,13 +779,13 @@ namespace plg { constexpr void copy_assign_alloc(const vector& c, std::true_type) { - if (this->_alloc != c._alloc) { + if (this->alloc_ != c.alloc_) { clear(); annotate_delete(); - alloc_traits::deallocate(this->_alloc, this->_begin, capacity()); - this->_begin = this->_end = this->_cap = nullptr; + alloc_traits::deallocate(this->alloc_, this->begin_, capacity()); + this->begin_ = this->end_ = this->cap_ = nullptr; } - this->_alloc = c._alloc; + this->alloc_ = c.alloc_; } constexpr void @@ -796,7 +796,7 @@ namespace plg { move_assign_alloc(vector& c, std::true_type) noexcept( std::is_nothrow_move_assignable_v ) { - this->_alloc = std::move(c._alloc); + this->alloc_ = std::move(c.alloc_); } constexpr void @@ -820,18 +820,18 @@ namespace plg { constexpr void swap_layouts(split_buffer& sb) { - auto vector_begin = _begin; - auto vector_sentinel = _end; - auto vector_cap = _cap; + auto vector_begin = begin_; + auto vector_sentinel = end_; + auto vector_cap = cap_; auto sb_begin = sb.begin(); auto sb_sentinel = sb.raw_sentinel(); auto sb_cap = sb.raw_capacity(); // TODO: replace with set_valid_range and set_capacity when vector supports it. - _begin = sb_begin; - _end = sb_sentinel; - _cap = sb_cap; + begin_ = sb_begin; + end_ = sb_sentinel; + cap_ = sb_cap; sb.set_valid_range(vector_begin, vector_sentinel); sb.set_capacity(vector_cap); @@ -852,33 +852,33 @@ namespace plg { -> vector, Alloc>; #endif - // swap_out_circular_buffer relocates the objects in [_begin, _end) into the front of v and - // swaps the buffers of *this and v. It is assumed that v provides space for exactly (_end - - // _begin) objects in the front. This function has a strong exception guarantee. + // swap_out_circular_buffer relocates the objects in [begin_, end_) into the front of v and + // swaps the buffers of *this and v. It is assumed that v provides space for exactly (end_ - + // begin_) objects in the front. This function has a strong exception guarantee. template constexpr void vector::swap_out_circular_buffer(split_buffer& v) { annotate_delete(); auto new_begin = v.begin() - size(); uninitialized_allocator_relocate( - this->_alloc, - std::to_address(_begin), - std::to_address(_end), + this->alloc_, + std::to_address(begin_), + std::to_address(end_), std::to_address(new_begin) ); v.set_valid_range(new_begin, v.end()); - _end = _begin; // All the objects have been destroyed by relocating them. + end_ = begin_; // All the objects have been destroyed by relocating them. swap_layouts(v); v.set_data(v.begin()); annotate_new(size()); } - // swap_out_circular_buffer relocates the objects in [_begin, p) into the front of v, the - // objects in [p, _end) into the back of v and swaps the buffers of *this and v. It is assumed - // that v provides space for exactly (p - _begin) objects in the front and space for at least - // (_end - p) objects in the back. This function has a strong exception guarantee if _begin == p - // || _end == p. + // swap_out_circular_buffer relocates the objects in [begin_, p) into the front of v, the + // objects in [p, end_) into the back of v and swaps the buffers of *this and v. It is assumed + // that v provides space for exactly (p - begin_) objects in the front and space for at least + // (end_ - p) objects in the back. This function has a strong exception guarantee if begin_ == p + // || end_ == p. template constexpr typename vector::pointer vector::swap_out_circular_buffer( @@ -888,27 +888,27 @@ namespace plg { annotate_delete(); pointer ret = v.begin(); - // Relocate [p, _end) first to avoid having a hole in [_begin, _end) - // in case something in [_begin, p) throws. + // Relocate [p, end_) first to avoid having a hole in [begin_, end_) + // in case something in [begin_, p) throws. uninitialized_allocator_relocate( - this->_alloc, + this->alloc_, std::to_address(p), - std::to_address(_end), + std::to_address(end_), std::to_address(v.end()) ); - auto relocated_so_far = _end - p; + auto relocated_so_far = end_ - p; v.set_sentinel(v.end() + relocated_so_far); - _end = p; // The objects in [p, _end) have been destroyed by relocating them. - auto new_begin = v.begin() - (p - _begin); + end_ = p; // The objects in [p, end_) have been destroyed by relocating them. + auto new_begin = v.begin() - (p - begin_); uninitialized_allocator_relocate( - this->_alloc, - std::to_address(_begin), + this->alloc_, + std::to_address(begin_), std::to_address(p), std::to_address(new_begin) ); v.set_valid_range(new_begin, v.end()); - _end = _begin; // All the objects have been destroyed by relocating them. + end_ = begin_; // All the objects have been destroyed by relocating them. swap_layouts(v); v.set_data(v.begin()); annotate_new(size()); @@ -917,11 +917,11 @@ namespace plg { template constexpr void vector::vdeallocate() noexcept { - if (this->_begin != nullptr) { + if (this->begin_ != nullptr) { clear(); annotate_delete(); - alloc_traits::deallocate(this->_alloc, this->_begin, capacity()); - this->_begin = this->_end = this->_cap = nullptr; + alloc_traits::deallocate(this->alloc_, this->begin_, capacity()); + this->begin_ = this->end_ = this->cap_ = nullptr; } } @@ -941,7 +941,7 @@ namespace plg { return std::max(2 * cap, new_size); } - // Default constructs n objects starting at _end + // Default constructs n objects starting at end_ // throws if construction throws // Precondition: n > 0 // Precondition: size() + n <= capacity() @@ -951,11 +951,11 @@ namespace plg { ConstructTransaction tx(*this, n); const_pointer new_end = tx.new_end_; for (pointer pos = tx.pos_; pos != new_end; tx.pos_ = ++pos) { - alloc_traits::construct(this->_alloc, std::to_address(pos)); + alloc_traits::construct(this->alloc_, std::to_address(pos)); } } - // Copy constructs n objects starting at _end from x + // Copy constructs n objects starting at end_ from x // throws if construction throws // Precondition: n > 0 // Precondition: size() + n <= capacity() @@ -967,7 +967,7 @@ namespace plg { ConstructTransaction tx(*this, n); const_pointer new_end = tx.new_end_; for (pointer pos = tx.pos_; pos != new_end; tx.pos_ = ++pos) { - alloc_traits::construct(this->_alloc, std::to_address(pos), x); + alloc_traits::construct(this->alloc_, std::to_address(pos), x); } } @@ -977,39 +977,39 @@ namespace plg { vector::construct_at_end(InputIterator first, Sentinel last, size_type n) { ConstructTransaction tx(*this, n); tx.pos_ = uninitialized_allocator_copy( - this->_alloc, + this->alloc_, std::move(first), std::move(last), tx.pos_ ); } - // Default constructs n objects starting at _end + // Default constructs n objects starting at end_ // throws if construction throws // Postcondition: size() == size() + n // Exception safety: strong. template constexpr void vector::append(size_type n) { - if (static_cast(this->_cap - this->_end) >= n) { + if (static_cast(this->cap_ - this->end_) >= n) { this->construct_at_end(n); } else { - split_buffer v(recommend(size() + n), size(), this->_alloc); + split_buffer v(recommend(size() + n), size(), this->alloc_); v.construct_at_end(n); swap_out_circular_buffer(v); } } - // Default constructs n objects starting at _end + // Default constructs n objects starting at end_ // throws if construction throws // Postcondition: size() == size() + n // Exception safety: strong. template constexpr void vector::append(size_type n, const_reference x) { - if (static_cast(this->_cap - this->_end) >= n) { + if (static_cast(this->cap_ - this->end_) >= n) { this->construct_at_end(n, x); } else { - split_buffer v(recommend(size() + n), size(), this->_alloc); + split_buffer v(recommend(size() + n), size(), this->alloc_); v.construct_at_end(n, x); swap_out_circular_buffer(v); } @@ -1018,22 +1018,22 @@ namespace plg { template constexpr inline vector::vector(vector&& x) noexcept - : _alloc(std::move(x._alloc)) { - this->_begin = x._begin; - this->_end = x._end; - this->_cap = x._cap; - x._begin = x._end = x._cap = nullptr; + : alloc_(std::move(x.alloc_)) { + this->begin_ = x.begin_; + this->end_ = x.end_; + this->cap_ = x.cap_; + x.begin_ = x.end_ = x.cap_ = nullptr; } template constexpr inline vector::vector(vector&& x, const std::type_identity_t& a) - : _alloc(a) { - if (a == x._alloc) { - this->_begin = x._begin; - this->_end = x._end; - this->_cap = x._cap; - x._begin = x._end = x._cap = nullptr; + : alloc_(a) { + if (a == x.alloc_) { + this->begin_ = x.begin_; + this->end_ = x.end_; + this->cap_ = x.cap_; + x.begin_ = x.end_ = x.cap_ = nullptr; } else { using Ip = std::move_iterator; init_with_size(Ip(x.begin()), Ip(x.end()), x.size()); @@ -1045,7 +1045,7 @@ namespace plg { vector::move_assign(vector& c, std::false_type) noexcept( alloc_traits::is_always_equal::value ) { - if (this->_alloc != c._alloc) { + if (this->alloc_ != c.alloc_) { using Ip = std::move_iterator; assign(Ip(c.begin()), Ip(c.end())); } else { @@ -1060,10 +1060,10 @@ namespace plg { ) { vdeallocate(); move_assign_alloc(c); // this can throw - this->_begin = c._begin; - this->_end = c._end; - this->_cap = c._cap; - c._begin = c._end = c._cap = nullptr; + this->begin_ = c.begin_; + this->end_ = c.end_; + this->cap_ = c.cap_; + c.begin_ = c.end_ = c.cap_ = nullptr; } template @@ -1071,7 +1071,7 @@ namespace plg { vector::operator=(const vector& x) { if (this != std::addressof(x)) { copy_assign_alloc(x); - assign(x._begin, x._end); + assign(x.begin_, x.end_); } return *this; } @@ -1080,11 +1080,11 @@ namespace plg { template constexpr void vector::assign_with_sentinel(Iterator first, Sentinel last) { - pointer cur = _begin; - for (; first != last && cur != _end; ++first, (void) ++cur) { + pointer cur = begin_; + for (; first != last && cur != end_; ++first, (void) ++cur) { *cur = *first; } - if (cur != _end) { + if (cur != end_) { destruct_at_end(cur); } else { for (; first != last; ++first) { @@ -1101,15 +1101,15 @@ namespace plg { if (new_size <= capacity()) { if (new_size > size()) { #if PLUGIFY_HAS_CXX23 - auto mid = std::ranges::copy_n(std::move(first), size(), this->_begin).in; + auto mid = std::ranges::copy_n(std::move(first), size(), this->begin_).in; construct_at_end(std::move(mid), std::move(last), new_size - size()); #else Iterator mid = std::next(first, size()); - std::copy(first, mid, this->_begin); + std::copy(first, mid, this->begin_); construct_at_end(mid, last, new_size - size()); #endif } else { - pointer m = std::copy(std::move(first), last, this->_begin); + pointer m = std::copy(std::move(first), last, this->begin_); this->destruct_at_end(m); } } else { @@ -1124,11 +1124,11 @@ namespace plg { vector::assign(size_type n, const_reference u) { if (n <= capacity()) { size_type s = size(); - std::fill_n(this->_begin, std::min(n, s), u); + std::fill_n(this->begin_, std::min(n, s), u); if (n > s) { construct_at_end(n - s, u); } else { - this->destruct_at_end(this->_begin + n); + this->destruct_at_end(this->begin_ + n); } } else { vdeallocate(); @@ -1143,7 +1143,7 @@ namespace plg { if (n > max_size()) { this->throw_length_error(); } - split_buffer v(n, size(), this->_alloc); + split_buffer v(n, size(), this->alloc_); swap_out_circular_buffer(v); } } @@ -1154,7 +1154,7 @@ namespace plg { #if PLUGIFY_HAS_EXCEPTIONS try { #endif // PLUGIFY_HAS_EXCEPTIONS - split_buffer v(size(), size(), this->_alloc); + split_buffer v(size(), size(), this->alloc_); // The Standard mandates shrink_to_fit() does not increase the capacity. // With equal capacity keep the existing buffer. This avoids extra work // due to swapping the elements. @@ -1172,13 +1172,13 @@ namespace plg { template constexpr typename vector::pointer vector::emplace_back_slow_path(Args&&... args) { - split_buffer v(recommend(size() + 1), size(), this->_alloc); + split_buffer v(recommend(size() + 1), size(), this->alloc_); // v.emplace_back(std::forward(args)...); pointer end = v.end(); - alloc_traits::construct(this->_alloc, std::to_address(end), std::forward(args)...); + alloc_traits::construct(this->alloc_, std::to_address(end), std::forward(args)...); v.set_sentinel(++end); swap_out_circular_buffer(v); - return this->_end; + return this->end_; } // This makes the compiler inline `else()` if `cond` is known to be false. Currently LLVM @@ -1207,9 +1207,9 @@ namespace plg { constexpr inline typename vector::reference vector::emplace_back(Args&&... args) { - pointer end = this->_end; + pointer end = this->end_; if_likely_else( - end < this->_cap, + end < this->cap_, [&] { emplace_back_assume_capacity(std::forward(args)...); ++end; @@ -1217,7 +1217,7 @@ namespace plg { [&] { end = emplace_back_slow_path(std::forward(args)...); } ); - this->_end = end; + this->end_ = end; return *(end - 1); } @@ -1230,8 +1230,8 @@ namespace plg { "vector::erase(iterator) called with a non-dereferenceable iterator" ); difference_type ps = position - cbegin(); - pointer p = this->_begin + ps; - this->destruct_at_end(std::move(p + 1, this->_end, p)); + pointer p = this->begin_ + ps; + this->destruct_at_end(std::move(p + 1, this->end_, p)); return make_iter(p); } @@ -1242,9 +1242,9 @@ namespace plg { first <= last, "vector::erase(first, last) called with invalid range" ); - pointer p = this->_begin + (first - begin()); + pointer p = this->begin_ + (first - begin()); if (first != last) { - this->destruct_at_end(std::move(p + (last - first), this->_end, p)); + this->destruct_at_end(std::move(p + (last - first), this->end_, p)); } return make_iter(p); } @@ -1252,13 +1252,13 @@ namespace plg { template constexpr void vector::move_range(pointer from_s, pointer from_e, pointer to) { - pointer old_last = this->_end; + pointer old_last = this->end_; difference_type n = old_last - to; { pointer i = from_s + n; ConstructTransaction tx(*this, from_e - i); for (pointer pos = tx.pos_; i < from_e; ++i, (void) ++pos, tx.pos_ = pos) { - alloc_traits::construct(this->_alloc, std::to_address(pos), std::move(*i)); + alloc_traits::construct(this->alloc_, std::to_address(pos), std::move(*i)); } } std::move_backward(from_s, from_s + n, old_last); @@ -1267,16 +1267,16 @@ namespace plg { template constexpr typename vector::iterator vector::insert(const_iterator position, const_reference x) { - pointer p = this->_begin + (position - begin()); - if (this->_end < this->_cap) { - if (p == this->_end) { + pointer p = this->begin_ + (position - begin()); + if (this->end_ < this->cap_) { + if (p == this->end_) { emplace_back_assume_capacity(x); } else { - move_range(p, this->_end, p + 1); + move_range(p, this->end_, p + 1); const_pointer xr = std::pointer_traits::pointer_to(x); if (is_pointer_in_range( std::to_address(p), - std::to_address(_end), + std::to_address(end_), std::addressof(x) )) { ++xr; @@ -1286,8 +1286,8 @@ namespace plg { } else { split_buffer v( recommend(size() + 1), - p - this->_begin, - this->_alloc + p - this->begin_, + this->alloc_ ); v.emplace_back(x); p = swap_out_circular_buffer(v, p); @@ -1298,19 +1298,19 @@ namespace plg { template constexpr typename vector::iterator vector::insert(const_iterator position, value_type&& x) { - pointer p = this->_begin + (position - begin()); - if (this->_end < this->_cap) { - if (p == this->_end) { + pointer p = this->begin_ + (position - begin()); + if (this->end_ < this->cap_) { + if (p == this->end_) { emplace_back_assume_capacity(std::move(x)); } else { - move_range(p, this->_end, p + 1); + move_range(p, this->end_, p + 1); *p = std::move(x); } } else { split_buffer v( recommend(size() + 1), - p - this->_begin, - this->_alloc + p - this->begin_, + this->alloc_ ); v.emplace_back(std::move(x)); p = swap_out_circular_buffer(v, p); @@ -1322,20 +1322,20 @@ namespace plg { template constexpr typename vector::iterator vector::emplace(const_iterator position, Args&&... args) { - pointer p = this->_begin + (position - begin()); - if (this->_end < this->_cap) { - if (p == this->_end) { + pointer p = this->begin_ + (position - begin()); + if (this->end_ < this->cap_) { + if (p == this->end_) { emplace_back_assume_capacity(std::forward(args)...); } else { - detail::temp_value tmp(this->_alloc, std::forward(args)...); - move_range(p, this->_end, p + 1); + detail::temp_value tmp(this->alloc_, std::forward(args)...); + move_range(p, this->end_, p + 1); *p = std::move(tmp.get()); } } else { split_buffer v( recommend(size() + 1), - p - this->_begin, - this->_alloc + p - this->begin_, + this->alloc_ ); v.emplace_back(std::forward(args)...); p = swap_out_circular_buffer(v, p); @@ -1346,13 +1346,13 @@ namespace plg { template constexpr typename vector::iterator vector::insert(const_iterator position, size_type n, const_reference x) { - pointer p = this->_begin + (position - begin()); + pointer p = this->begin_ + (position - begin()); if (n > 0) { - if (n <= static_cast(this->_cap - this->_end)) { + if (n <= static_cast(this->cap_ - this->end_)) { size_type old_n = n; - pointer old_last = this->_end; - if (n > static_cast(this->_end - p)) { - size_type cx = n - (this->_end - p); + pointer old_last = this->end_; + if (n > static_cast(this->end_ - p)) { + size_type cx = n - (this->end_ - p); construct_at_end(cx, x); n -= cx; } @@ -1361,7 +1361,7 @@ namespace plg { const_pointer xr = std::pointer_traits::pointer_to(x); if (is_pointer_in_range( std::to_address(p), - std::to_address(_end), + std::to_address(end_), std::addressof(x) )) { xr += old_n; @@ -1371,8 +1371,8 @@ namespace plg { } else { split_buffer v( recommend(size() + n), - p - this->_begin, - this->_alloc + p - this->begin_, + this->alloc_ ); v.construct_at_end(n, x); p = swap_out_circular_buffer(v, p); @@ -1390,37 +1390,37 @@ namespace plg { Sentinel last ) { difference_type off = position - begin(); - pointer p = this->_begin + off; - pointer old_last = this->_end; - for (; this->_end != this->_cap && first != last; ++first) { + pointer p = this->begin_ + off; + pointer old_last = this->end_; + for (; this->end_ != this->cap_ && first != last; ++first) { emplace_back_assume_capacity(*first); } if (first == last) { - (void) std::rotate(p, old_last, this->_end); + (void) std::rotate(p, old_last, this->end_); } else { - split_buffer v(_alloc); + split_buffer v(alloc_); auto guard = make_exception_guard( - AllocatorDestroyRangeReverse(_alloc, old_last, this->_end) + AllocatorDestroyRangeReverse(alloc_, old_last, this->end_) ); v.construct_at_end_with_sentinel(std::move(first), std::move(last)); split_buffer merged( recommend(size() + v.size()), off, - _alloc + alloc_ ); // has `off` positions available at the front uninitialized_allocator_relocate( - _alloc, + alloc_, std::to_address(old_last), - std::to_address(this->_end), + std::to_address(this->end_), std::to_address(merged.end()) ); - guard.complete(); // Release the guard once objects in [old_last_, _end) have been + guard.complete(); // Release the guard once objects in [old_last_, end_) have been // successfully relocated. - merged.set_sentinel(merged.end() + (this->_end - old_last)); - this->_end = old_last; + merged.set_sentinel(merged.end() + (this->end_ - old_last)); + this->end_ = old_last; uninitialized_allocator_relocate( - _alloc, + alloc_, std::to_address(v.begin()), std::to_address(v.end()), std::to_address(merged.end()) @@ -1441,16 +1441,16 @@ namespace plg { Sentinel last, difference_type n ) { - pointer p = this->_begin + (position - begin()); + pointer p = this->begin_ + (position - begin()); if (n > 0) { - if (n <= this->_cap - this->_end) { - pointer old_last = this->_end; - difference_type dx = this->_end - p; + if (n <= this->cap_ - this->end_) { + pointer old_last = this->end_; + difference_type dx = this->end_ - p; if (n > dx) { #if PLUGIFY_HAS_CXX23 if constexpr (!std::forward_iterator) { construct_at_end(std::move(first), std::move(last), n); - std::rotate(p, old_last, this->_end); + std::rotate(p, old_last, this->end_); } else #endif { @@ -1468,8 +1468,8 @@ namespace plg { } else { split_buffer v( recommend(size() + n), - p - this->_begin, - this->_alloc + p - this->begin_, + this->alloc_ ); v.construct_at_end_with_size(std::move(first), n); p = swap_out_circular_buffer(v, p); @@ -1484,7 +1484,7 @@ namespace plg { if (cs < sz) { this->append(sz - cs); } else if (cs > sz) { - this->destruct_at_end(this->_begin + sz); + this->destruct_at_end(this->begin_ + sz); } } @@ -1495,7 +1495,7 @@ namespace plg { if (cs < sz) { this->append(sz - cs, x); } else if (cs > sz) { - this->destruct_at_end(this->_begin + sz); + this->destruct_at_end(this->begin_ + sz); } } @@ -1504,30 +1504,30 @@ namespace plg { noexcept { PLUGIFY_ASSERT( - alloc_traits::propagate_on_container_swap::value || this->_alloc == x._alloc, + alloc_traits::propagate_on_container_swap::value || this->alloc_ == x.alloc_, "vector::swap: Either propagate_on_container_swap must be true" " or the allocators must compare equal" ); - std::swap(this->_begin, x._begin); - std::swap(this->_end, x._end); - std::swap(this->_cap, x._cap); - swap_allocator(this->_alloc, x._alloc); + std::swap(this->begin_, x.begin_); + std::swap(this->end_, x.end_); + std::swap(this->cap_, x.cap_); + swap_allocator(this->alloc_, x.alloc_); } template constexpr bool vector::invariants() const { - if (this->_begin == nullptr) { - if (this->_end != nullptr || this->_cap != nullptr) { + if (this->begin_ == nullptr) { + if (this->end_ != nullptr || this->cap_ != nullptr) { return false; } } else { - if (this->_begin > this->_end) { + if (this->begin_ > this->end_) { return false; } - if (this->_begin == this->_cap) { + if (this->begin_ == this->cap_) { return false; } - if (this->_end > this->_cap) { + if (this->end_ > this->cap_) { return false; } } diff --git a/test/cross_call_worker/external/plugify/include/plg/version.hpp b/test/cross_call_worker/external/plugify/include/plg/version.hpp index b8e8c00..f3bf16d 100644 --- a/test/cross_call_worker/external/plugify/include/plg/version.hpp +++ b/test/cross_call_worker/external/plugify/include/plg/version.hpp @@ -91,38 +91,38 @@ namespace plg { constexpr version& operator=(const version&) = default; constexpr version& operator=(version&&) = default; - constexpr I1 major() const noexcept { return _major; } - constexpr I2 minor() const noexcept { return _minor; } - constexpr I3 patch() const noexcept { return _patch; } + constexpr I1 major() const noexcept { return major_; } + constexpr I2 minor() const noexcept { return minor_; } + constexpr I3 patch() const noexcept { return patch_; } - constexpr const string& prerelease_tag() const { return _prerelease_tag; } - constexpr const string& build_metadata() const { return _build_metadata; } + constexpr const string& prerelease_tag() const { return prerelease_tag_; } + constexpr const string& build_metadata() const { return build_metadata_; } constexpr string to_string() const; private: - I1 _major = 0; - I2 _minor = 1; - I3 _patch = 0; - string _prerelease_tag; - string _build_metadata; + I1 major_ = 0; + I2 minor_ = 1; + I3 patch_ = 0; + string prerelease_tag_; + string build_metadata_; - vector _prerelease_identifiers; + vector prerelease_identifiers_; constexpr std::size_t length() const noexcept { - return detail::length(_major) + detail::length(_minor) + detail::length(_patch) + 2 - + (_prerelease_tag.empty() ? 0 : _prerelease_tag.length() + 1) - + (_build_metadata.empty() ? 0 : _build_metadata.length() + 1); + return detail::length(major_) + detail::length(minor_) + detail::length(patch_) + 2 + + (prerelease_tag_.empty() ? 0 : prerelease_tag_.length() + 1) + + (build_metadata_.empty() ? 0 : build_metadata_.length() + 1); } constexpr void clear() noexcept { - _major = 0; - _minor = 1; - _patch = 0; + major_ = 0; + minor_ = 1; + patch_ = 0; - _prerelease_tag.clear(); - _prerelease_identifiers.clear(); - _build_metadata.clear(); + prerelease_tag_.clear(); + prerelease_identifiers_.clear(); + build_metadata_.clear(); } }; @@ -132,23 +132,23 @@ namespace plg { detail::resize_uninitialized{}.resize(result, length()); auto* it = result.end(); - if (!_build_metadata.empty()) { - it = std::copy_backward(_build_metadata.begin(), _build_metadata.end(), it); + if (!build_metadata_.empty()) { + it = std::copy_backward(build_metadata_.begin(), build_metadata_.end(), it); *(--it) = '+'; } - if (!_prerelease_tag.empty()) { - it = std::copy_backward(_prerelease_tag.begin(), _prerelease_tag.end(), it); + if (!prerelease_tag_.empty()) { + it = std::copy_backward(prerelease_tag_.begin(), prerelease_tag_.end(), it); *(--it) = '-'; } - it = detail::to_chars(it, _patch); + it = detail::to_chars(it, patch_); *(--it) = '.'; - it = detail::to_chars(it, _minor); + it = detail::to_chars(it, minor_); *(--it) = '.'; - it = detail::to_chars(it, _major); + it = detail::to_chars(it, major_); return result; } @@ -273,28 +273,28 @@ namespace plg { class token_stream { public: constexpr token_stream() = default; - constexpr explicit token_stream(vector tokens) noexcept : _tokens(std::move(tokens)) {} + constexpr explicit token_stream(vector tokens) noexcept : tokens_(std::move(tokens)) {} constexpr void push(const token& token) noexcept { - _tokens.push_back(token); + tokens_.push_back(token); } constexpr token advance() noexcept { - const token token = get(_current); - ++_current; + const token token = get(current_); + ++current_; return token; } constexpr token peek(std::size_t k = 0) const noexcept { - return get(_current + k); + return get(current_ + k); } constexpr token previous() const noexcept { - return get(_current - 1); + return get(current_ - 1); } constexpr bool advance_if_match(token& token, token_type type) noexcept { - if (get(_current).type != type) { + if (get(current_).type != type) { return false; } @@ -316,20 +316,20 @@ namespace plg { } private: - std::size_t _current = 0; - vector _tokens; + std::size_t current_ = 0; + vector tokens_; constexpr token get(std::size_t i) const noexcept { - return _tokens[i]; + return tokens_[i]; } }; class lexer { public: - explicit constexpr lexer(std::string_view text) noexcept : _text{text}, _current_pos{0} {} + explicit constexpr lexer(std::string_view text) noexcept : text_{text}, current_pos_{0} {} constexpr from_chars_result scan_tokens(token_stream& token_stream) noexcept { - from_chars_result result{ _text.data(), std::errc{} }; + from_chars_result result{ text_.data(), std::errc{} }; while (!is_eol()) { result = scan_token(token_stream); @@ -338,14 +338,14 @@ namespace plg { } } - token_stream.push({ token_type::eol, {}, _text.data() + _text.size() }); + token_stream.push({ token_type::eol, {}, text_.data() + text_.size() }); return result; } private: - std::string_view _text; - std::size_t _current_pos; + std::string_view text_; + std::size_t current_pos_; constexpr from_chars_result scan_token(token_stream& stream) noexcept { const char c = advance(); @@ -399,8 +399,8 @@ namespace plg { } constexpr char advance() noexcept { - char c = _text[_current_pos]; - _current_pos += 1; + char c = text_[current_pos_]; + current_pos_ += 1; return c; } @@ -409,40 +409,40 @@ namespace plg { return false; } - if (_text[_current_pos] != c) { + if (text_[current_pos_] != c) { return false; } - _current_pos += 1; + current_pos_ += 1; return true; } constexpr const char* get_prev_symbol() const noexcept { - return _text.data() + _current_pos - 1; + return text_.data() + current_pos_ - 1; } - constexpr bool is_eol() const noexcept { return _current_pos >= _text.size(); } + constexpr bool is_eol() const noexcept { return current_pos_ >= text_.size(); } }; class prerelease_comparator { public: template [[nodiscard]] constexpr int compare(const version& lhs, const version& rhs) const noexcept { - if (lhs._prerelease_identifiers.empty() != rhs._prerelease_identifiers.empty()) { - return static_cast(rhs._prerelease_identifiers.size()) - static_cast(lhs._prerelease_identifiers.size()); + if (lhs.prerelease_identifiers_.empty() != rhs.prerelease_identifiers_.empty()) { + return static_cast(rhs.prerelease_identifiers_.size()) - static_cast(lhs.prerelease_identifiers_.size()); } - const std::size_t count = std::min(lhs._prerelease_identifiers.size(), rhs._prerelease_identifiers.size()); + const std::size_t count = std::min(lhs.prerelease_identifiers_.size(), rhs.prerelease_identifiers_.size()); for (std::size_t i = 0; i < count; ++i) { - const int compare_result = compare_identifier(lhs._prerelease_identifiers[i], rhs._prerelease_identifiers[i]); + const int compare_result = compare_identifier(lhs.prerelease_identifiers_[i], rhs.prerelease_identifiers_[i]); if (compare_result != 0) { return compare_result; } } - return static_cast(lhs._prerelease_identifiers.size()) - static_cast(rhs._prerelease_identifiers.size()); + return static_cast(lhs.prerelease_identifiers_.size()) - static_cast(rhs.prerelease_identifiers_.size()); } private: @@ -459,45 +459,45 @@ namespace plg { class version_parser { public: - constexpr explicit version_parser(token_stream& stream) : _stream{stream} { + constexpr explicit version_parser(token_stream& stream) : stream_{stream} { } template constexpr from_chars_result parse(version& out) noexcept { out.clear(); - from_chars_result result = parse_number(out._major); + from_chars_result result = parse_number(out.major_); if (!result) { return result; } - if (!_stream.consume(token_type::dot)) { - return failure(_stream.previous().lexeme); + if (!stream_.consume(token_type::dot)) { + return failure(stream_.previous().lexeme); } - result = parse_number(out._minor); + result = parse_number(out.minor_); if (!result) { return result; } - if (!_stream.consume(token_type::dot)) { - return failure(_stream.previous().lexeme); + if (!stream_.consume(token_type::dot)) { + return failure(stream_.previous().lexeme); } - result = parse_number(out._patch); + result = parse_number(out.patch_); if (!result) { return result; } - if (_stream.advance_if_match(token_type::hyphen)) { - result = parse_prerelease_tag(out._prerelease_tag, out._prerelease_identifiers); + if (stream_.advance_if_match(token_type::hyphen)) { + result = parse_prerelease_tag(out.prerelease_tag_, out.prerelease_identifiers_); if (!result) { return result; } } - if (_stream.advance_if_match(token_type::plus)) { - result = parse_build_metadata(out._build_metadata); + if (stream_.advance_if_match(token_type::plus)) { + result = parse_build_metadata(out.build_metadata_); if (!result) { return result; } @@ -508,11 +508,11 @@ namespace plg { private: - token_stream& _stream; + token_stream& stream_; template constexpr from_chars_result parse_number(Int& out) { - token token = _stream.advance(); + token token = stream_.advance(); if (!is_digit(token)) { return failure(token.lexeme); @@ -523,16 +523,16 @@ namespace plg { if (first_digit == 0) { out = static_cast(result); - return success(_stream.peek().lexeme); + return success(stream_.peek().lexeme); } - while (_stream.advance_if_match(token, token_type::digit)) { + while (stream_.advance_if_match(token, token_type::digit)) { result = result * 10 + std::get(token.value); } if (detail::number_in_range(result)) { out = static_cast(result); - return success(_stream.peek().lexeme); + return success(stream_.peek().lexeme); } return failure(token.lexeme, std::errc::result_out_of_range); @@ -554,10 +554,10 @@ namespace plg { result.append(identifier); out_identifiers.push_back(make_prerelease_identifier(identifier)); - } while (_stream.advance_if_match(token_type::dot)); + } while (stream_.advance_if_match(token_type::dot)); out = result; - return success(_stream.peek().lexeme); + return success(stream_.peek().lexeme); } constexpr from_chars_result parse_build_metadata(string& out) { @@ -574,15 +574,15 @@ namespace plg { } result.append(identifier); - } while (_stream.advance_if_match(token_type::dot)); + } while (stream_.advance_if_match(token_type::dot)); out = result; - return success(_stream.peek().lexeme); + return success(stream_.peek().lexeme); } constexpr from_chars_result parse_prerelease_identifier(string& out) { string result; - token token = _stream.advance(); + token token = stream_.advance(); do { switch (token.type) { @@ -613,10 +613,10 @@ namespace plg { default: return failure(token.lexeme); } - } while (_stream.advance_if_match(token, token_type::hyphen) || _stream.advance_if_match(token, token_type::letter) || _stream.advance_if_match(token, token_type::digit)); + } while (stream_.advance_if_match(token, token_type::hyphen) || stream_.advance_if_match(token, token_type::letter) || stream_.advance_if_match(token, token_type::digit)); out = result; - return success(_stream.peek().lexeme); + return success(stream_.peek().lexeme); } constexpr detail::prerelease_identifier make_prerelease_identifier(const string& identifier) { @@ -632,7 +632,7 @@ namespace plg { constexpr from_chars_result parse_build_identifier(string& out) { string result; - token token = _stream.advance(); + token token = stream_.advance(); do { switch (token.type) { @@ -651,10 +651,10 @@ namespace plg { default: return failure(token.lexeme); } - } while (_stream.advance_if_match(token, token_type::hyphen) || _stream.advance_if_match(token, token_type::letter) || _stream.advance_if_match(token, token_type::digit)); + } while (stream_.advance_if_match(token, token_type::hyphen) || stream_.advance_if_match(token, token_type::letter) || stream_.advance_if_match(token, token_type::digit)); out = result; - return success(_stream.peek().lexeme); + return success(stream_.peek().lexeme); } constexpr bool is_leading_zero(int digit) noexcept { @@ -667,7 +667,7 @@ namespace plg { int digits = 0; while (true) { - const token token = _stream.peek(k); + const token token = stream_.peek(k); if (!is_alphanumeric(token)) { break; @@ -803,44 +803,44 @@ namespace plg { template class range_comparator { public: - constexpr range_comparator(const version& v, range_operator op) noexcept : _v(v), _op(op) {} + constexpr range_comparator(const version& v, range_operator op) noexcept : v_(v), op_(op) {} constexpr bool contains(const version& other) const noexcept { - switch (_op) { + switch (op_) { case range_operator::less: - return detail::compare_parsed(other, _v, version_compare_option::include_prerelease) < 0; + return detail::compare_parsed(other, v_, version_compare_option::include_prerelease) < 0; case range_operator::less_or_equal: - return detail::compare_parsed(other, _v, version_compare_option::include_prerelease) <= 0; + return detail::compare_parsed(other, v_, version_compare_option::include_prerelease) <= 0; case range_operator::greater: - return detail::compare_parsed(other, _v, version_compare_option::include_prerelease) > 0; + return detail::compare_parsed(other, v_, version_compare_option::include_prerelease) > 0; case range_operator::greater_or_equal: - return detail::compare_parsed(other, _v, version_compare_option::include_prerelease) >= 0; + return detail::compare_parsed(other, v_, version_compare_option::include_prerelease) >= 0; case range_operator::equal: - return detail::compare_parsed(other, _v, version_compare_option::include_prerelease) == 0; + return detail::compare_parsed(other, v_, version_compare_option::include_prerelease) == 0; } return false; } - constexpr const version& get_version() const noexcept { return _v; } + constexpr const version& get_version() const noexcept { return v_; } - constexpr range_operator get_operator() const noexcept { return _op; } + constexpr range_operator get_operator() const noexcept { return op_; } constexpr string to_string() const { string result; - switch (_op) { + switch (op_) { case range_operator::less: result += "<"; break; case range_operator::less_or_equal: result += "<="; break; case range_operator::greater: result += ">"; break; case range_operator::greater_or_equal: result += ">="; break; case range_operator::equal: result += "="; break; } - result += _v.to_string(); + result += v_.to_string(); return result; } private: - version _v; - range_operator _op; + version v_; + range_operator op_; }; class range_parser; @@ -857,40 +857,40 @@ namespace plg { } } - return std::all_of(_ranges_comparators.begin(), _ranges_comparators.end(), [&](const auto& ranges_comparator) { + return std::all_of(ranges_comparators_.begin(), ranges_comparators_.end(), [&](const auto& ranges_comparator) { return ranges_comparator.contains(v); }); } constexpr auto begin() const noexcept { - return _ranges_comparators.begin(); + return ranges_comparators_.begin(); } constexpr auto end() const noexcept { - return _ranges_comparators.end(); + return ranges_comparators_.end(); } constexpr std::size_t size() const noexcept { - return _ranges_comparators.size(); + return ranges_comparators_.size(); } constexpr bool empty() const noexcept { - return _ranges_comparators.empty(); + return ranges_comparators_.empty(); } constexpr string to_string() const { - return join(_ranges_comparators, " "); + return join(ranges_comparators_, " "); } private: - vector> _ranges_comparators; + vector> ranges_comparators_; constexpr bool match_at_least_one_comparator_with_prerelease(const version& v) const noexcept { if (v.prerelease_tag().empty()) { return true; } - return std::any_of(_ranges_comparators.begin(), _ranges_comparators.end(), [&](const auto& ranges_comparator) { + return std::any_of(ranges_comparators_.begin(), ranges_comparators_.end(), [&](const auto& ranges_comparator) { const bool has_prerelease = !ranges_comparator.get_version().prerelease_tag().empty(); const bool equal_without_prerelease = detail::compare_parsed(v, ranges_comparator.get_version(), version_compare_option::exclude_prerelease) == 0; return has_prerelease && equal_without_prerelease; @@ -905,39 +905,39 @@ namespace plg { friend class detail::range_parser; constexpr bool contains(const version& v, version_compare_option option = version_compare_option::exclude_prerelease) const noexcept { - return std::any_of(_ranges.begin(), _ranges.end(), [&](const auto& range) { + return std::any_of(ranges_.begin(), ranges_.end(), [&](const auto& range) { return range.contains(v, option); }); } constexpr auto begin() const noexcept { - return _ranges.begin(); + return ranges_.begin(); } constexpr auto end() const noexcept { - return _ranges.end(); + return ranges_.end(); } constexpr std::size_t size() const noexcept { - return _ranges.size(); + return ranges_.size(); } constexpr bool empty() const noexcept { - return _ranges.empty(); + return ranges_.empty(); } constexpr string to_string() const { - return join(_ranges, " "); + return join(ranges_, " "); } private: - vector> _ranges; + vector> ranges_; }; namespace detail { class range_parser { public: - constexpr explicit range_parser(token_stream stream) noexcept : _stream(std::move(stream)) {} + constexpr explicit range_parser(token_stream stream) noexcept : stream_(std::move(stream)) {} template constexpr from_chars_result parse(range_set& out) noexcept { @@ -953,54 +953,54 @@ namespace plg { ranges.push_back(range); skip_whitespaces(); - } while (_stream.advance_if_match(token_type::logical_or)); + } while (stream_.advance_if_match(token_type::logical_or)); - out._ranges = std::move(ranges); + out.ranges_ = std::move(ranges); - return success(_stream.peek().lexeme); + return success(stream_.peek().lexeme); } private: - token_stream _stream; + token_stream stream_; template constexpr from_chars_result parse_range(detail::range& out) noexcept { do { skip_whitespaces(); - if (const auto res = parse_range_comparator(out._ranges_comparators); !res) { + if (const auto res = parse_range_comparator(out.ranges_comparators_); !res) { return res; } skip_whitespaces(); - } while (_stream.check(token_type::range_operator) || _stream.check(token_type::digit)); + } while (stream_.check(token_type::range_operator) || stream_.check(token_type::digit)); - return success(_stream.peek().lexeme); + return success(stream_.peek().lexeme); } template constexpr from_chars_result parse_range_comparator(vector>& out) noexcept { range_operator op = range_operator::equal; token token; - if (_stream.advance_if_match(token, token_type::range_operator)) { + if (stream_.advance_if_match(token, token_type::range_operator)) { op = std::get(token.value); } skip_whitespaces(); version ver; - version_parser parser{ _stream }; + version_parser parser{ stream_ }; if (const auto res = parser.parse(ver); !res) { return res; } out.emplace_back(ver, op); - return success(_stream.peek().lexeme); + return success(stream_.peek().lexeme); } constexpr void skip_whitespaces() noexcept { - while (_stream.advance_if_match(token_type::space)) { + while (stream_.advance_if_match(token_type::space)) { ; } } diff --git a/test/example_plugin/external/plugify/include/plg/allocator.hpp b/test/example_plugin/external/plugify/include/plg/allocator.hpp index 3cc57b2..3bb603d 100644 --- a/test/example_plugin/external/plugify/include/plg/allocator.hpp +++ b/test/example_plugin/external/plugify/include/plg/allocator.hpp @@ -153,7 +153,7 @@ namespace plg { // __old_last_contained is the previously last allowed (unpoisoned) element, and // __new_last_contained is the new last allowed (unpoisoned) element. template - void annotate_contiguous_container( + constexpr void annotate_contiguous_container( [[maybe_unused]] const void* first_storage, [[maybe_unused]] const void* last_storage, [[maybe_unused]] const void* old_last_contained, diff --git a/test/example_plugin/external/plugify/include/plg/config.hpp b/test/example_plugin/external/plugify/include/plg/config.hpp index 8ba7006..a0e43c3 100644 --- a/test/example_plugin/external/plugify/include/plg/config.hpp +++ b/test/example_plugin/external/plugify/include/plg/config.hpp @@ -16,7 +16,7 @@ # define __has_builtin(x) 0 #endif -#ifndef __builtin_constant_p +#if !__has_builtin(__builtin_constant_p) # define __builtin_constant_p(x) std::is_constant_evaluated() #endif diff --git a/test/example_plugin/external/plugify/include/plg/enum.hpp b/test/example_plugin/external/plugify/include/plg/enum.hpp index 802b7c1..0692a31 100644 --- a/test/example_plugin/external/plugify/include/plg/enum.hpp +++ b/test/example_plugin/external/plugify/include/plg/enum.hpp @@ -17,15 +17,15 @@ namespace plg { template struct static_string { constexpr static_string(std::string_view sv) noexcept { - std::copy(sv.begin(), sv.end(), _content.begin()); + std::copy(sv.begin(), sv.end(), content_.begin()); } constexpr operator std::string_view() const noexcept { - return { _content.data(), N }; + return { content_.data(), N }; } private: - std::array _content{}; + std::array content_{}; }; constexpr auto is_pretty(char ch) noexcept { diff --git a/test/example_plugin/external/plugify/include/plg/guards.hpp b/test/example_plugin/external/plugify/include/plg/guards.hpp index 4691341..a45e221 100644 --- a/test/example_plugin/external/plugify/include/plg/guards.hpp +++ b/test/example_plugin/external/plugify/include/plg/guards.hpp @@ -9,16 +9,16 @@ namespace plg { exception_guard_exceptions() = delete; constexpr explicit exception_guard_exceptions(Rollback rollback) - : _rollback(std::move(rollback)) - , _completed(false) { + : rollback_(std::move(rollback)) + , completed_(false) { } constexpr exception_guard_exceptions( exception_guard_exceptions&& other ) noexcept(std::is_nothrow_move_constructible_v) - : _rollback(std::move(other._rollback)) - , _completed(other._completed) { - other._completed = true; + : rollback_(std::move(other.rollback_)) + , completed_(other.completed_) { + other.completed_ = true; } exception_guard_exceptions(const exception_guard_exceptions&) = delete; @@ -26,18 +26,18 @@ namespace plg { exception_guard_exceptions& operator=(exception_guard_exceptions&&) = delete; constexpr void complete() noexcept { - _completed = true; + completed_ = true; } constexpr ~exception_guard_exceptions() { - if (!_completed) { - _rollback(); + if (!completed_) { + rollback_(); } } private: - PLUGIFY_NO_UNIQUE_ADDRESS Rollback _rollback; - bool _completed; + PLUGIFY_NO_UNIQUE_ADDRESS Rollback rollback_; + bool completed_; }; template @@ -53,8 +53,8 @@ namespace plg { constexpr exception_guard_noexceptions( exception_guard_noexceptions&& other ) noexcept(std::is_nothrow_move_constructible_v) - : _completed(other._completed) { - other._completed = true; + : completed_(other.completed_) { + other.completed_ = true; } exception_guard_noexceptions(const exception_guard_noexceptions&) = delete; @@ -62,15 +62,15 @@ namespace plg { exception_guard_noexceptions& operator=(exception_guard_noexceptions&&) = delete; constexpr void complete() noexcept { - _completed = true; + completed_ = true; } constexpr ~exception_guard_noexceptions() { - PLUGIFY_ASSERT(_completed, "exception_guard not completed with exceptions disabled"); + PLUGIFY_ASSERT(completed_, "exception_guard not completed with exceptions disabled"); } private: - bool _completed = false; + bool completed_ = false; }; template @@ -84,15 +84,15 @@ namespace plg { template class scope_guard { - PLUGIFY_NO_UNIQUE_ADDRESS Func _func; + PLUGIFY_NO_UNIQUE_ADDRESS Func func_; public: constexpr explicit scope_guard(Func func) - : _func(std::move(func)) { + : func_(std::move(func)) { } constexpr ~scope_guard() { - _func(); + func_(); } scope_guard(const scope_guard&) = delete; diff --git a/test/example_plugin/external/plugify/include/plg/hash.hpp b/test/example_plugin/external/plugify/include/plg/hash.hpp index 4028e57..982f796 100644 --- a/test/example_plugin/external/plugify/include/plg/hash.hpp +++ b/test/example_plugin/external/plugify/include/plg/hash.hpp @@ -3,6 +3,8 @@ #include #include #include +#include +#include #include "plg/string.hpp" @@ -58,11 +60,10 @@ namespace plg { using is_transparent = void; // Enables heterogeneous lookup template - auto operator()(const T& str_like) const noexcept { - std::string_view str = str_like; + std::size_t operator()(const T& str) const noexcept { std::size_t hash = active_hash_traits::fnv_basis; // FNV-1a - for (const char& c : str) { - hash ^= static_cast(std::tolower(static_cast(c))); + for (const auto& c : str) { + hash ^= static_cast(std::tolower(c)); hash *= active_hash_traits::fnv_prime; } return hash; @@ -73,21 +74,14 @@ namespace plg { using is_transparent = void; // Enables heterogeneous lookup template - bool operator()(const T1& lhs_like, const T2& rhs_like) const noexcept { - std::string_view lhs = lhs_like; - std::string_view rhs = rhs_like; - - if (lhs.size() != rhs.size()) { - return false; - } - - for (size_t i = 0; i < lhs.size(); ++i) { - if (std::tolower(static_cast(lhs[i])) - != std::tolower(static_cast(rhs[i]))) { - return false; + bool operator()(const T1& lhs, const T2& rhs) const noexcept { + return std::lexicographical_compare( + lhs.begin(), lhs.end(), + rhs.begin(), rhs.end(), + [](const auto& ac, const auto& bc) { + return std::tolower(ac) < std::tolower(bc); } - } - return true; + ); } }; diff --git a/test/example_plugin/external/plugify/include/plg/inplace_vector.hpp b/test/example_plugin/external/plugify/include/plg/inplace_vector.hpp index 71292c8..db59904 100644 --- a/test/example_plugin/external/plugify/include/plg/inplace_vector.hpp +++ b/test/example_plugin/external/plugify/include/plg/inplace_vector.hpp @@ -68,15 +68,15 @@ namespace plg { template struct PLUGIFY_INPLACE_VECTOR_TRIVIALLY_RELOCATABLE_IF(std::is_trivially_relocatable_v) ipvbase { - size_t _size = 0; + size_t size_ = 0; union { - [[maybe_unused]] char _dummy; - T _data[N]; + [[maybe_unused]] char dummy_; + T data_[N]; }; - constexpr T *base_data() { return _data; } - constexpr const T *base_data() const { return _data; } - constexpr void set_size(size_t n) { _size = n; } + constexpr T *base_data() { return data_; } + constexpr const T *base_data() const { return data_; } + constexpr void set_size(size_t n) { size_ = n; } constexpr explicit ipvbase() noexcept {} ipvbase(const ipvbase& rhs) @@ -85,8 +85,8 @@ namespace plg { if constexpr (std::is_trivially_copy_constructible_v) { std::memmove((void*)this, (const void*)std::addressof(rhs), sizeof(ipvbase)); } else { - std::uninitialized_copy_n(rhs._data, rhs._size, _data); - _size = rhs._size; + std::uninitialized_copy_n(rhs.data_, rhs.size_, data_); + size_ = rhs.size_; } } ipvbase(ipvbase&& rhs) @@ -100,13 +100,13 @@ namespace plg { std::memmove((void*)this, (const void*)std::addressof(rhs), sizeof(ipvbase)); #if defined(__cpp_lib_trivially_relocatable) } else if constexpr (std::is_trivially_relocatable_v) { - std::uninitialized_relocate_n(rhs._data, rhs._size, _data); - _size = rhs._size; - rhs._size = 0; + std::uninitialized_relocate_n(rhs.data_, rhs.size_, data_); + size_ = rhs.size_; + rhs.size_ = 0; #endif // __cpp_lib_trivially_relocatable } else { - std::uninitialized_move_n(rhs._data, rhs._size, _data); - _size = rhs._size; + std::uninitialized_move_n(rhs.data_, rhs.size_, data_); + size_ = rhs.size_; } } void operator=(const ipvbase& rhs) @@ -116,14 +116,14 @@ namespace plg { std::memmove((void*)this, (const void*)std::addressof(rhs), sizeof(ipvbase)); } else if (this == std::addressof(rhs)) { // do nothing - } else if (rhs._size <= _size) { - std::copy(rhs._data, rhs._data + rhs._size, _data); - std::destroy(_data + rhs._size, _data + _size); - _size = rhs._size; + } else if (rhs.size_ <= size_) { + std::copy(rhs.data_, rhs.data_ + rhs.size_, data_); + std::destroy(data_ + rhs.size_, data_ + size_); + size_ = rhs.size_; } else { - std::copy(rhs._data, rhs._data + _size, _data); - std::uninitialized_copy(rhs._data + _size, rhs._data + rhs._size, _data + _size); - _size = rhs._size; + std::copy(rhs.data_, rhs.data_ + size_, data_); + std::uninitialized_copy(rhs.data_ + size_, rhs.data_ + rhs.size_, data_ + size_); + size_ = rhs.size_; } } void operator=(ipvbase&& rhs) @@ -133,21 +133,21 @@ namespace plg { std::memmove((void*)this, (const void*)std::addressof(rhs), sizeof(ipvbase)); } else if (this == std::addressof(rhs)) { // do nothing - } else if (rhs._size <= _size) { - std::move(rhs._data, rhs._data + rhs._size, _data); - std::destroy(_data + rhs._size, _data + _size); - _size = rhs._size; + } else if (rhs.size_ <= size_) { + std::move(rhs.data_, rhs.data_ + rhs.size_, data_); + std::destroy(data_ + rhs.size_, data_ + size_); + size_ = rhs.size_; } else { - std::move(rhs._data, rhs._data + _size, _data); + std::move(rhs.data_, rhs.data_ + size_, data_); #if defined(__cpp_lib_trivially_relocatable) if constexpr (std::is_trivially_relocatable_v) { - std::uninitialized_relocate(rhs._data + _size, rhs._data + rhs._size, _data + _size); - std::swap(rhs._size, _size); + std::uninitialized_relocate(rhs.data_ + size_, rhs.data_ + rhs.size_, data_ + size_); + std::swap(rhs.size_, size_); return; } #endif // __cpp_lib_trivially_relocatable - std::uninitialized_move(rhs._data + _size, rhs._data + rhs._size, _data + _size); - _size = rhs._size; + std::uninitialized_move(rhs.data_ + size_, rhs.data_ + rhs.size_, data_ + size_); + size_ = rhs.size_; } } @@ -163,13 +163,13 @@ namespace plg { constexpr #endif // PLUGIFY_CPP_VERSION >= 202002L ~ipvbase() { - std::destroy(_data, _data + _size); + std::destroy(data_, data_ + size_); } }; template struct ipvbase_zero { - static constexpr size_t _size = 0; + static constexpr size_t size_ = 0; constexpr T *base_data() { return nullptr; } constexpr const T *base_data() const { return nullptr; } constexpr void set_size(size_t) { } @@ -177,15 +177,15 @@ namespace plg { template struct ipvbase_trivial { - size_t _size = 0; + size_t size_ = 0; union { - [[maybe_unused]] char _dummy; - T _data[N]; + [[maybe_unused]] char dummy_; + T data_[N]; }; constexpr explicit ipvbase_trivial() {} - constexpr T *base_data() { return _data; } - constexpr const T *base_data() const { return _data; } - constexpr void set_size(size_t n) { _size = n; } + constexpr T *base_data() { return data_; } + constexpr const T *base_data() const { return data_; } + constexpr void set_size(size_t n) { size_ = n; } }; template @@ -202,7 +202,7 @@ namespace plg { template class inplace_vector : detail::ipvbase_assignable, detail::ipvbase_t { - using detail::ipvbase_t::_size; + using detail::ipvbase_t::size_; using detail::ipvbase_t::set_size; public: using value_type = T; @@ -277,12 +277,12 @@ namespace plg { { if (n > N) { throw_bad_alloc(); - } else if (_size >= n) { + } else if (size_ >= n) { std::fill_n(data(), n, value); - std::destroy(data() + n, data() + _size); + std::destroy(data() + n, data() + size_); } else { - std::fill_n(data(), _size, value); - std::uninitialized_fill_n(data() + _size, n - _size, value); + std::fill_n(data(), size_, value); + std::uninitialized_fill_n(data() + size_, n - size_, value); } set_size(n); } @@ -293,12 +293,12 @@ namespace plg { const size_type n = static_cast(std::distance(first, last)); if (n > N) { throw_bad_alloc(); - } else if (_size >= n) { + } else if (size_ >= n) { std::copy(first, last, data()); - std::destroy(data() + n, data() + _size); + std::destroy(data() + n, data() + size_); } else { - std::copy(first, first + _size, data()); - std::uninitialized_copy(first + _size, last, data() + _size); + std::copy(first, first + size_, data()); + std::uninitialized_copy(first + size_, last, data() + size_); } set_size(n); } @@ -329,13 +329,13 @@ namespace plg { size_t n = std::ranges::size(rg); if (n > N) { throw_bad_alloc(); - } else if (_size >= n) { + } else if (size_ >= n) { std::ranges::copy(first, last, data()); - std::destroy(data() + n, data() + _size); + std::destroy(data() + n, data() + size_); } else { - auto mid = std::ranges::next(first, _size, last); + auto mid = std::ranges::next(first, size_, last); std::ranges::copy(first, mid, data()); - std::ranges::uninitialized_copy(mid, last, data() + _size); + std::ranges::uninitialized_copy(mid, last, data() + size_); } set_size(n); } @@ -344,15 +344,15 @@ namespace plg { // iterators constexpr iterator begin() noexcept { return data(); } - constexpr iterator end() noexcept { return data() + _size; } + constexpr iterator end() noexcept { return data() + size_; } constexpr const_iterator begin() const noexcept { return data(); } - constexpr const_iterator end() const noexcept { return data() + _size; } + constexpr const_iterator end() const noexcept { return data() + size_; } constexpr reverse_iterator rbegin() noexcept { return reverse_iterator(end()); } constexpr reverse_iterator rend() noexcept { return reverse_iterator(begin()); } constexpr const_reverse_iterator rbegin() const noexcept { return const_reverse_iterator(end()); } constexpr const_reverse_iterator rend() const noexcept { return const_reverse_iterator(begin()); } constexpr const_iterator cbegin() const noexcept { return data(); } - constexpr const_iterator cend() const noexcept { return data() + _size; } + constexpr const_iterator cend() const noexcept { return data() + size_; } constexpr const_reverse_iterator crbegin() const noexcept { return const_reverse_iterator(end()); } constexpr const_reverse_iterator crend() const noexcept { return const_reverse_iterator(begin()); } @@ -361,12 +361,12 @@ namespace plg { { if (n > N) { throw_bad_alloc(); - } else if (n < _size) { - std::destroy(data() + n, data() + _size); + } else if (n < size_) { + std::destroy(data() + n, data() + size_); set_size(n); } else { - std::uninitialized_value_construct(data() + _size, data() + n); - set_size(_size + n); + std::uninitialized_value_construct(data() + size_, data() + n); + set_size(size_ + n); } } @@ -375,12 +375,12 @@ namespace plg { { if (n > N) { throw_bad_alloc(); - } else if (n < _size) { - std::destroy(data() + n, data() + _size); + } else if (n < size_) { + std::destroy(data() + n, data() + size_); set_size(n); } else { - std::uninitialized_fill(data() + _size, data() + n, value); - set_size(_size + n); + std::uninitialized_fill(data() + size_, data() + n, value); + set_size(size_ + n); } } @@ -403,7 +403,7 @@ namespace plg { } constexpr reference back() { PLUGIFY_ASSERT(!empty(), "called on an empty vector"); - return data()[_size - 1]; + return data()[size_ - 1]; } constexpr const_reference operator[](size_type pos) const { @@ -416,17 +416,17 @@ namespace plg { } constexpr const_reference back() const { PLUGIFY_ASSERT(!empty(), "called on an empty vector"); - return data()[_size - 1]; + return data()[size_ - 1]; } constexpr reference at(size_type i) { - if (i >= _size) { + if (i >= size_) { throw_out_of_range(); } return data()[i]; } constexpr const_reference at(size_type i) const { - if (i >= _size) { + if (i >= size_) { throw_out_of_range(); } return data()[i]; @@ -436,20 +436,20 @@ namespace plg { constexpr T* data() noexcept { return this->base_data(); } constexpr const T* data() const noexcept { return this->base_data(); } - constexpr size_type size() const noexcept { return _size; } + constexpr size_type size() const noexcept { return size_; } static constexpr size_type max_size() noexcept { return N; } static constexpr size_type capacity() noexcept { return N; } - [[nodiscard]] constexpr bool empty() const noexcept { return _size == 0; }; + [[nodiscard]] constexpr bool empty() const noexcept { return size_ == 0; }; // [inplace.vector.modifiers] template requires std::is_constructible_v value_type& unchecked_emplace_back(Args&&... args) { - // Precondition: (_size < N) - value_type* p = data() + _size; + // Precondition: (size_ < N) + value_type* p = data() + size_; p = std::construct_at(p, std::forward(args)...); - set_size(_size + 1); + set_size(size_ + 1); return *p; } value_type& unchecked_push_back(const value_type& value) @@ -466,7 +466,7 @@ namespace plg { template requires std::is_constructible_v constexpr value_type* try_emplace_back(Args&&... args) { - if (_size == N) { + if (size_ == N) { return nullptr; } return std::addressof(unchecked_emplace_back(static_cast(args)...)); @@ -485,7 +485,7 @@ namespace plg { template requires std::is_constructible_v value_type& emplace_back(Args&&... args) { - if (_size == N) { + if (size_ == N) { throw_bad_alloc(); } return unchecked_emplace_back(static_cast(args)...); @@ -512,8 +512,8 @@ namespace plg { #endif // __cpp_lib_ranges >= 201911L && __cpp_lib_ranges_to_container >= 202202L void pop_back() { - std::destroy_at(data() + _size - 1); - set_size(_size - 1); + std::destroy_at(data() + size_ - 1); + set_size(size_ - 1); } template @@ -538,7 +538,7 @@ namespace plg { iterator insert(const_iterator pos, size_type n, const value_type& value) requires std::is_copy_constructible_v { - if (N - _size < n) { + if (N - size_ < n) { throw_bad_alloc(); } auto it = iterator(pos); @@ -549,7 +549,7 @@ namespace plg { std::uninitialized_relocate_backward(it, oldend, oldend + n); try { std::uninitialized_fill_n(it, n, value); - set_size(_size + n); + set_size(size_ + n); } catch (...) { std::uninitialized_relocate(it + n, oldend + n, it); throw; @@ -559,7 +559,7 @@ namespace plg { #endif // Fill at the end of the vector, then rotate into place. std::uninitialized_fill_n(oldend, n, value); - set_size(_size + n); + set_size(size_ + n); std::rotate(it, oldend, oldend + n); return it; } @@ -571,7 +571,7 @@ namespace plg { auto oldend = end(); if constexpr (std::random_access_iterator) { size_type n = static_cast(std::distance(first, last)); - if (N - _size < n) { + if (N - size_ < n) { throw_bad_alloc(); } #if defined(__cpp_lib_trivially_relocatable) @@ -580,7 +580,7 @@ namespace plg { std::uninitialized_relocate_backward(it, oldend, oldend + n); try { std::uninitialized_copy_n(first, n, it); - set_size(_size + n); + set_size(size_ + n); } catch (...) { std::uninitialized_relocate(it + n, oldend + n, it); throw; @@ -590,7 +590,7 @@ namespace plg { #endif // Fill at the end of the vector, then rotate into place. std::uninitialized_copy_n(first, n, oldend); - set_size(_size + n); + set_size(size_ + n); std::rotate(it, oldend, oldend + n); } else { for (; first != last; ++first) { @@ -609,7 +609,7 @@ namespace plg { auto oldend = end(); if constexpr (std::ranges::sized_range) { size_type n = std::ranges::size(rg); - if (N - _size < n) { + if (N - size_ < n) { throw_bad_alloc(); } #if defined(__cpp_lib_trivially_relocatable) @@ -618,7 +618,7 @@ namespace plg { std::uninitialized_relocate_backward(it, oldend, oldend + n); try { std::ranges::uninitialized_copy_n(std::ranges::begin(rg), n, it, std::unreachable_sentinel); - set_size(_size + n); + set_size(size_ + n); } catch (...) { std::uninitialized_relocate(it + n, oldend + n, it); throw; @@ -628,7 +628,7 @@ namespace plg { #endif // Fill at the end of the vector, then rotate into place. std::ranges::uninitialized_copy_n(std::ranges::begin(rg), n, oldend, std::unreachable_sentinel); - set_size(_size + n); + set_size(size_ + n); std::rotate(it, oldend, oldend + n); } else { auto [rgend, newend] = std::ranges::uninitialized_copy(rg, std::ranges::subrange(oldend, data() + N)); @@ -659,13 +659,13 @@ namespace plg { if constexpr (std::is_trivially_relocatable_v) { std::destroy_at(it); std::uninitialized_relocate(it + 1, oldend, it); - set_size(_size - 1); + set_size(size_ - 1); return it; } #endif std::move(it + 1, oldend, it); std::destroy_at(oldend - 1); - set_size(_size - 1); + set_size(size_ - 1); return it; } @@ -681,18 +681,18 @@ namespace plg { if constexpr (std::is_trivially_relocatable_v) { std::destroy(ifirst, ilast); std::uninitialized_relocate(ilast, oldend, ifirst); - set_size(_size - n); + set_size(size_ - n); return ifirst; } #endif // __cpp_lib_trivially_relocatable std::destroy(std::move(ilast, oldend, ifirst), oldend); - set_size(_size - n); + set_size(size_ - n); } return ifirst; } constexpr void clear() noexcept { - std::destroy(data(), data() + _size); + std::destroy(data(), data() + size_); set_size(0); } @@ -701,20 +701,20 @@ namespace plg { requires (!std::is_const_v) { auto& a = *this; - if (a._size < b._size) { + if (a.size_ < b.size_) { b.swap(a); } else { - std::swap_ranges(a.data(), a.data() + b._size, b.data()); + std::swap_ranges(a.data(), a.data() + b.size_, b.data()); #if defined(__cpp_lib_trivially_relocatable) - size_t n = a._size; - a.set_size(b._size); - std::uninitialized_relocate(a.data() + b._size, a.data() + n, b.data() + b._size); + size_t n = a.size_; + a.set_size(b.size_); + std::uninitialized_relocate(a.data() + b.size_, a.data() + n, b.data() + b.size_); b.set_size(n); #else - std::uninitialized_move(a.data() + b._size, a.data() + a._size, b.data() + b._size); - std::destroy(a.data() + b._size, a.data() + a._size); + std::uninitialized_move(a.data() + b.size_, a.data() + a.size_, b.data() + b.size_); + std::destroy(a.data() + b.size_, a.data() + a.size_); if constexpr (N != 0) { - std::swap(a._size, b._size); + std::swap(a.size_, b.size_); } #endif } @@ -737,7 +737,7 @@ namespace plg { constexpr friend bool operator<(const inplace_vector& a, const inplace_vector& b) { const T* adata = a.data(); const T* bdata = b.data(); - size_t n = (a._size < b._size) ? a._size : b._size; + size_t n = (a.size_ < b.size_) ? a.size_ : b.size_; for (size_t i = 0; i < n; ++i) { if (adata[i] < bdata[i]) { return true; @@ -745,7 +745,7 @@ namespace plg { return false; } } - return (a._size < b._size); + return (a.size_ < b.size_); } constexpr friend bool operator>(const inplace_vector& a, const inplace_vector& b) { return (b < a); } constexpr friend bool operator<=(const inplace_vector& a, const inplace_vector& b) { return !(b < a); } diff --git a/test/example_plugin/external/plugify/include/plg/split_buffer.hpp b/test/example_plugin/external/plugify/include/plg/split_buffer.hpp index 0568d15..ddae84f 100644 --- a/test/example_plugin/external/plugify/include/plg/split_buffer.hpp +++ b/test/example_plugin/external/plugify/include/plg/split_buffer.hpp @@ -26,115 +26,115 @@ namespace plg { public: constexpr split_buffer_pointer_layout() - : _back_cap(nullptr) { + : back_cap_(nullptr) { } constexpr explicit split_buffer_pointer_layout(const allocator_type& alloc) - : _back_cap(nullptr) - , _alloc(alloc) { + : back_cap_(nullptr) + , alloc_(alloc) { } constexpr pointer front_cap() noexcept { - return _front_cap; + return front_cap_; } constexpr const_pointer front_cap() const noexcept { - return _front_cap; + return front_cap_; } constexpr pointer begin() noexcept { - return _begin; + return begin_; } constexpr const_pointer begin() const noexcept { - return _begin; + return begin_; } constexpr pointer end() noexcept { - return _end; + return end_; } constexpr pointer end() const noexcept { - return _end; + return end_; } constexpr size_type size() const noexcept { - return static_cast(_end - _begin); + return static_cast(end_ - begin_); } constexpr bool empty() const noexcept { - return _begin == _end; + return begin_ == end_; } constexpr size_type capacity() const noexcept { - return static_cast(_back_cap - _front_cap); + return static_cast(back_cap_ - front_cap_); } constexpr allocator_type& get_allocator() noexcept { - return _alloc; + return alloc_; } constexpr const allocator_type& get_allocator() const noexcept { - return _alloc; + return alloc_; } // Returns the sentinel object directly. Should be used in conjunction with automatic type // deduction, not explicit types. constexpr sentinel_type raw_sentinel() const noexcept { - return _end; + return end_; } constexpr sentinel_type raw_capacity() const noexcept { - return _back_cap; + return back_cap_; } constexpr void set_data(pointer new_first) noexcept { - _front_cap = new_first; + front_cap_ = new_first; } constexpr void set_valid_range(pointer new_begin, pointer new_end) noexcept { - _begin = new_begin; - _end = new_end; + begin_ = new_begin; + end_ = new_end; } constexpr void set_valid_range(pointer new_begin, size_type new_size) noexcept { - _begin = new_begin; - _end = _begin + new_size; + begin_ = new_begin; + end_ = begin_ + new_size; } constexpr void set_sentinel(pointer new_end) noexcept { - PLUGIFY_ASSERT(_front_cap <= new_end, "new_end cannot precede _front_cap"); - _end = new_end; + PLUGIFY_ASSERT(front_cap_ <= new_end, "new_end cannot precede front_cap_"); + end_ = new_end; } constexpr void set_sentinel(size_type new_size) noexcept { - _end = _begin + new_size; + end_ = begin_ + new_size; } constexpr void set_capacity(size_type new_capacity) noexcept { - _back_cap = _front_cap + new_capacity; + back_cap_ = front_cap_ + new_capacity; } constexpr void set_capacity(pointer new_capacity) noexcept { - _back_cap = new_capacity; + back_cap_ = new_capacity; } constexpr size_type front_spare() const noexcept { - return static_cast(_begin - _front_cap); + return static_cast(begin_ - front_cap_); } constexpr size_type back_spare() const noexcept { - return static_cast(_back_cap - _end); + return static_cast(back_cap_ - end_); } constexpr reference back() noexcept { - return *(_end - 1); + return *(end_ - 1); } constexpr const_reference back() const noexcept { - return *(_end - 1); + return *(end_ - 1); } constexpr void swap_without_allocator( @@ -143,42 +143,42 @@ namespace plg { value_type, alloc_rr&>& other ) noexcept { - std::swap(_front_cap, other._front_cap); - std::swap(_begin, other._begin); - std::swap(_back_cap, other._back_cap); - std::swap(_end, other._end); + std::swap(front_cap_, other.front_cap_); + std::swap(begin_, other.begin_); + std::swap(back_cap_, other.back_cap_); + std::swap(end_, other.end_); } constexpr void swap(split_buffer_pointer_layout& other) noexcept { - std::swap(_front_cap, other._front_cap); - std::swap(_begin, other._begin); - std::swap(_back_cap, other._back_cap); - std::swap(_end, other._end); - swap_allocator(_alloc, other._alloc); + std::swap(front_cap_, other.front_cap_); + std::swap(begin_, other.begin_); + std::swap(back_cap_, other.back_cap_); + std::swap(end_, other.end_); + swap_allocator(alloc_, other.alloc_); } constexpr void reset() noexcept { - _front_cap = nullptr; - _begin = nullptr; - _end = nullptr; - _back_cap = nullptr; + front_cap_ = nullptr; + begin_ = nullptr; + end_ = nullptr; + back_cap_ = nullptr; } constexpr void copy_without_alloc( const split_buffer_pointer_layout& other ) noexcept(std::is_nothrow_copy_assignable::value) { - _front_cap = other._front_cap; - _begin = other._begin; - _end = other._end; - _back_cap = other._back_cap; + front_cap_ = other.front_cap_; + begin_ = other.begin_; + end_ = other.end_; + back_cap_ = other.back_cap_; } private: - pointer _front_cap = nullptr; - pointer _begin = nullptr; - pointer _end = nullptr; - pointer _back_cap = nullptr; - PLUGIFY_NO_UNIQUE_ADDRESS allocator_type _alloc; + pointer front_cap_ = nullptr; + pointer begin_ = nullptr; + pointer end_ = nullptr; + pointer back_cap_ = nullptr; + PLUGIFY_NO_UNIQUE_ADDRESS allocator_type alloc_; template friend class split_buffer_pointer_layout; @@ -205,73 +205,73 @@ namespace plg { constexpr split_buffer_size_layout() = default; constexpr explicit split_buffer_size_layout(const allocator_type& alloc) - : _alloc(alloc) { + : alloc_(alloc) { } constexpr pointer front_cap() noexcept { - return _front_cap; + return front_cap_; } constexpr const_pointer front_cap() const noexcept { - return _front_cap; + return front_cap_; } constexpr pointer begin() noexcept { - return _begin; + return begin_; } constexpr const_pointer begin() const noexcept { - return _begin; + return begin_; } constexpr pointer end() noexcept { - return _begin + _size; + return begin_ + size_; } constexpr pointer end() const noexcept { - return _begin + _size; + return begin_ + size_; } constexpr size_type size() const noexcept { - return _size; + return size_; } constexpr bool empty() const noexcept { - return _size == 0; + return size_ == 0; } constexpr size_type capacity() const noexcept { - return _cap; + return cap_; } constexpr allocator_type& get_allocator() noexcept { - return _alloc; + return alloc_; } constexpr const allocator_type& get_allocator() const noexcept { - return _alloc; + return alloc_; } // Returns the sentinel object directly. Should be used in conjunction with automatic type // deduction, not explicit types. constexpr sentinel_type raw_sentinel() const noexcept { - return _size; + return size_; } constexpr sentinel_type raw_capacity() const noexcept { - return _cap; + return cap_; } constexpr void set_data(pointer new_first) noexcept { - _front_cap = new_first; + front_cap_ = new_first; } constexpr void set_valid_range(pointer new_begin, pointer new_end) noexcept { // Size-based split_buffers track their size directly: we need to explicitly update the size // when the front is adjusted. - _size -= new_begin - _begin; - _begin = new_begin; + size_ -= new_begin - begin_; + begin_ = new_begin; set_sentinel(new_end); } @@ -279,44 +279,44 @@ namespace plg { set_valid_range(pointer new_begin, size_type new_size) noexcept { // Size-based split_buffers track their size directly: we need to explicitly update the size // when the front is adjusted. - _size -= new_begin - _begin; - _begin = new_begin; + size_ -= new_begin - begin_; + begin_ = new_begin; set_sentinel(new_size); } constexpr void set_sentinel(pointer new_end) noexcept { - _LIBCPP_ASSERT_INTERNAL(_front_cap <= new_end, "new_end cannot precede _front_cap"); - _size += new_end - end(); + _LIBCPP_ASSERT_INTERNAL(front_cap_ <= new_end, "new_end cannot precede front_cap_"); + size_ += new_end - end(); } constexpr void set_sentinel(size_type new_size) noexcept { - _size = new_size; + size_ = new_size; } constexpr void set_capacity(size_type new_capacity) noexcept { - _cap = new_capacity; + cap_ = new_capacity; } constexpr void set_capacity(pointer new_capacity) noexcept { - _cap = new_capacity - _begin; + cap_ = new_capacity - begin_; } constexpr size_type front_spare() const noexcept { - return static_cast(_begin - _front_cap); + return static_cast(begin_ - front_cap_); } constexpr size_type back_spare() const noexcept { - // `_cap - _end` tells us the total number of spares when in size-mode. We need to remove + // `cap_ - end_` tells us the total number of spares when in size-mode. We need to remove // the front_spare from the count. - return _cap - _size - front_spare(); + return cap_ - size_ - front_spare(); } constexpr reference back() noexcept { - return _begin[_size - 1]; + return begin_[size_ - 1]; } constexpr const_reference back() const noexcept { - return _begin[_size - 1]; + return begin_[size_ - 1]; } constexpr void swap_without_allocator( @@ -325,42 +325,42 @@ namespace plg { value_type, alloc_rr&>& other ) noexcept { - std::swap(_front_cap, other._front_cap); - std::swap(_begin, other._begin); - std::swap(_cap, other._cap); - std::swap(_size, other._size); + std::swap(front_cap_, other.front_cap_); + std::swap(begin_, other.begin_); + std::swap(cap_, other.cap_); + std::swap(size_, other.size_); } constexpr void swap(split_buffer_size_layout& other) noexcept { - std::swap(_front_cap, other._front_cap); - std::swap(_begin, other._begin); - std::swap(_cap, other._cap); - std::swap(_size, other._size); - swap_allocator(_alloc, other._alloc); + std::swap(front_cap_, other.front_cap_); + std::swap(begin_, other.begin_); + std::swap(cap_, other.cap_); + std::swap(size_, other.size_); + swap_allocator(alloc_, other.alloc_); } constexpr void reset() noexcept { - _front_cap = nullptr; - _begin = nullptr; - _size = 0; - _cap = 0; + front_cap_ = nullptr; + begin_ = nullptr; + size_ = 0; + cap_ = 0; } constexpr void copy_without_alloc( const split_buffer_size_layout& other ) noexcept(std::is_nothrow_copy_assignable::value) { - _front_cap = other._front_cap; - _begin = other._begin; - _cap = other._cap; - _size = other._size; + front_cap_ = other.front_cap_; + begin_ = other.begin_; + cap_ = other.cap_; + size_ = other.size_; } private: - pointer _front_cap = nullptr; - pointer _begin = nullptr; - size_type _size = 0; - size_type _cap = 0; - PLUGIFY_NO_UNIQUE_ADDRESS allocator_type _alloc; + pointer front_cap_ = nullptr; + pointer begin_ = nullptr; + size_type size_ = 0; + size_type cap_ = 0; + PLUGIFY_NO_UNIQUE_ADDRESS allocator_type alloc_; template friend class split_buffer_size_layout; @@ -377,11 +377,11 @@ namespace plg { // // |oooooooooooooooooooxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxoooooooooooooooooooooooo| // ^ ^ ^ ^ - // _front_cap _begin _end _back_cap + // front_cap_ begin_ end_ back_cap_ // - // The range [_front_cap, _begin) contains uninitialized memory. It is referred to as the "front - // spare capacity". The range [_begin, _end) contains valid objects. It is referred to as the "valid - // range". The range [_end, _back_cap) contains uninitialized memory. It is referred to as the "back + // The range [front_cap_, begin_) contains uninitialized memory. It is referred to as the "front + // spare capacity". The range [begin_, end_) contains valid objects. It is referred to as the "valid + // range". The range [end_, back_cap_) contains uninitialized memory. It is referred to as the "back // spare capacity". // // The layout of `split_buffer` is determined by the `Layout` template template parameter. This @@ -641,20 +641,20 @@ namespace plg { pointer p, size_type n ) noexcept - : _pos(p) - , _end(p + n) - , _parent(parent) { + : pos_(p) + , end_(p + n) + , parent_(parent) { } constexpr ~ConstructTransaction() { - _parent->set_sentinel(_pos); + parent_->set_sentinel(pos_); } - pointer _pos; - const pointer _end; + pointer pos_; + const pointer end_; private: - split_buffer* _parent; + split_buffer* parent_; }; template class L2> @@ -669,8 +669,8 @@ namespace plg { template class Layout> constexpr void split_buffer::construct_at_end(size_type n) { ConstructTransaction tx(this, end(), n); - for (; tx._pos != tx._end; ++tx._pos) { - alloc_traits::construct(get_allocator(), std::to_address(tx._pos)); + for (; tx.pos_ != tx.end_; ++tx.pos_) { + alloc_traits::construct(get_allocator(), std::to_address(tx.pos_)); } } @@ -684,8 +684,8 @@ namespace plg { constexpr void split_buffer::construct_at_end(size_type n, const_reference x) { ConstructTransaction tx(this, end(), n); - for (; tx._pos != tx._end; ++tx._pos) { - alloc_traits::construct(get_allocator(), std::to_address(tx._pos), x); + for (; tx.pos_ != tx.end_; ++tx.pos_) { + alloc_traits::construct(get_allocator(), std::to_address(tx.pos_), x); } } @@ -725,8 +725,8 @@ namespace plg { constexpr void split_buffer::construct_at_end_with_size(ForwardIterator first, size_type n) { ConstructTransaction tx(this, end(), n); - for (; tx._pos != tx._end; ++tx._pos, (void) ++first) { - alloc_traits::construct(get_allocator(), std::to_address(tx._pos), *first); + for (; tx.pos_ != tx.end_; ++tx.pos_, (void) ++first) { + alloc_traits::construct(get_allocator(), std::to_address(tx.pos_), *first); } } diff --git a/test/example_plugin/external/plugify/include/plg/string.hpp b/test/example_plugin/external/plugify/include/plg/string.hpp index 3613b95..aaaf3c1 100644 --- a/test/example_plugin/external/plugify/include/plg/string.hpp +++ b/test/example_plugin/external/plugify/include/plg/string.hpp @@ -650,7 +650,7 @@ namespace plg { template struct padding { - char _pad[N]; + char padding[N]; }; template <> @@ -781,32 +781,32 @@ namespace plg { constexpr long_() = default; constexpr long_(alloc_result alloc, size_type size) - : _data(alloc.ptr) - , _size(size) - , _cap(alloc.count / endian_factor) - , _is_long(true) { + : data_(alloc.ptr) + , size_(size) + , cap_(alloc.count / endian_factor) + , is_long_(true) { PLUGIFY_ASSERT(!fits_in_sso(alloc.count), "Long capacity should always be larger than the SSO"); } - pointer _data; - size_type _size; - size_type _cap : sizeof(size_type) * char_bit - 1; - size_type _is_long : 1; + pointer data_; + size_type size_; + size_type cap_ : sizeof(size_type) * char_bit - 1; + size_type is_long_ : 1; }; static constexpr size_type min_cap = ((sizeof(long_) - 1) / sizeof(value_type) > 2 ? (sizeof(long_) - 1) / sizeof(value_type) : 2) + 1; struct short_ { constexpr short_() - : _data{} - , _spare_size(min_cap - 1) - , _is_long(false) { + : data_{} + , spare_size_(min_cap - 1) + , is_long_(false) { } - value_type _data[min_cap - 1]; - PLUGIFY_NO_UNIQUE_ADDRESS padding _padding; - uint8_t _spare_size : 7; - uint8_t _is_long : 1; + value_type data_[min_cap - 1]; + PLUGIFY_NO_UNIQUE_ADDRESS padding padding_; + uint8_t spare_size_ : 7; + uint8_t is_long_ : 1; }; // The endian_factor is required because the field we use to store the size @@ -836,21 +836,21 @@ namespace plg { union rep { short_ s{}; long_ l; - } _rep; + } rep_; PLUGIFY_NO_UNIQUE_ADDRESS - allocator_type _alloc; + allocator_type alloc_; // annotate the string with its size() at scope exit. The string has to be in a valid state // at that point. struct annotate_new_size { - basic_string& _str; + basic_string& str_; constexpr explicit annotate_new_size(basic_string& str) - : _str(str) { + : str_(str) { } constexpr void operator()() { - _str.annotate_new(_str.size()); + str_.annotate_new(str_.size()); } }; @@ -858,13 +858,13 @@ namespace plg { // but don't initialize the characters. The contents of the string, including the null // terminator, must be initialized separately. constexpr /*explicit*/ basic_string(uninitialized_size_tag, size_type size, const allocator_type& a) - : _alloc(a) { + : alloc_(a) { init_internal_buffer(size); } template constexpr basic_string(init_with_sentinel_tag, Iter first, Sent last, const allocator_type& a) - : _alloc(a) { + : alloc_(a) { init_with_sentinel(std::move(first), std::move(last)); } @@ -880,20 +880,20 @@ namespace plg { static const size_type npos = static_cast(-1); constexpr basic_string() noexcept(std::is_nothrow_default_constructible_v) - : _rep(short_()) { + : rep_(short_()) { annotate_new(0); } constexpr /*explicit*/ basic_string(const allocator_type& a) noexcept - : _rep(short_()) - , _alloc(a) { + : rep_(short_()) + , alloc_(a) { annotate_new(0); } constexpr PLUGIFY_INTERNAL_MEMORY_ACCESS basic_string(const basic_string& str) - : _alloc(alloc_traits::select_on_container_copy_construction(str._alloc)) { + : alloc_(alloc_traits::select_on_container_copy_construction(str.alloc_)) { if (!str.is_long()) { - _rep = str._rep; + rep_ = str.rep_; annotate_new(get_short_size()); } else { init_copy_ctor_external(std::to_address(str.get_long_pointer()), str.get_long_size()); @@ -902,9 +902,9 @@ namespace plg { constexpr PLUGIFY_INTERNAL_MEMORY_ACCESS basic_string(const basic_string& str, const allocator_type& a) - : _alloc(a) { + : alloc_(a) { if (!str.is_long()) { - _rep = str._rep; + rep_ = str.rep_; annotate_new(get_short_size()); } else { init_copy_ctor_external(std::to_address(str.get_long_pointer()), str.get_long_size()); @@ -916,14 +916,14 @@ namespace plg { // PLUGIFY_INTERNAL_MEMORY_ACCESS does not work consistently during // initialization of r_, so we instead unpoison str's memory manually first. str's // memory needs to be unpoisoned only in the case where it's a short string. - : _rep([](basic_string& s) -> decltype(s._rep)&& { + : rep_([](basic_string& s) -> decltype(s.rep_)&& { if (!s.is_long()) { s.annotate_delete(); } - return std::move(s._rep); + return std::move(s.rep_); }(str)) - , _alloc(std::move(str._alloc)) { - str._rep = rep(); + , alloc_(std::move(str.alloc_)) { + str.rep_ = rep(); str.annotate_new(0); if (!is_long()) { annotate_new(size()); @@ -931,18 +931,18 @@ namespace plg { } constexpr basic_string(basic_string&& str, const allocator_type& a) - : _alloc(a) { - if (str.is_long() && a != str._alloc) { // copy, not move + : alloc_(a) { + if (str.is_long() && a != str.alloc_) { // copy, not move init(std::to_address(str.get_long_pointer()), str.get_long_size()); } else { if (std::is_constant_evaluated()) { - _rep = rep(); + rep_ = rep(); } if (!str.is_long()) { str.annotate_delete(); } - _rep = str._rep; - str._rep = rep(); + rep_ = str.rep_; + str.rep_ = rep(); str.annotate_new(0); if (!is_long() && this != std::addressof(str)) { annotate_new(size()); @@ -959,7 +959,7 @@ namespace plg { constexpr basic_string(const CharT* PLUGIFY_NO_NULL s, const Allocator& a) requires(is_allocator) - : _alloc(a) { + : alloc_(a) { PLUGIFY_ASSERT(s != nullptr, "basic_string(const char*, allocator) detected nullptr"); init(s, traits_type::length(s)); } @@ -972,7 +972,7 @@ namespace plg { } constexpr basic_string(const CharT* s, size_type n, const Allocator& a) - : _alloc(a) { + : alloc_(a) { PLUGIFY_ASSERT( n == 0 || s != nullptr, "basic_string(const char*, n, allocator) detected nullptr" @@ -994,13 +994,13 @@ namespace plg { size_type n, const Allocator& alloc = Allocator() ) - : _alloc(alloc) { + : alloc_(alloc) { if (pos > str.size()) { this->throw_out_of_range(); } auto len = std::min(n, str.size() - pos); - if (alloc_traits::is_always_equal::value || alloc == str._alloc) { + if (alloc_traits::is_always_equal::value || alloc == str.alloc_) { move_assign(std::move(str), pos, len); } else { // Perform a copy because the allocators are not compatible. @@ -1010,7 +1010,7 @@ namespace plg { constexpr basic_string(size_type n, CharT c, const Allocator& a) requires(is_allocator) - : _alloc(a) { + : alloc_(a) { init(n, c); } @@ -1020,7 +1020,7 @@ namespace plg { size_type n, const Allocator& a = Allocator() ) - : _alloc(a) { + : alloc_(a) { size_type str_sz = str.size(); if (pos > str_sz) { this->throw_out_of_range(); @@ -1029,7 +1029,7 @@ namespace plg { } constexpr basic_string(const basic_string& str, size_type pos, const Allocator& a = Allocator()) - : _alloc(a) { + : alloc_(a) { size_type str_sz = str.size(); if (pos > str_sz) { this->throw_out_of_range(); @@ -1044,7 +1044,7 @@ namespace plg { size_type n, const allocator_type& a = allocator_type() ) - : _alloc(a) { + : alloc_(a) { self_view sv0 = t; self_view sv = sv0.substr(pos, n); init(sv.data(), sv.size()); @@ -1058,7 +1058,7 @@ namespace plg { template T> constexpr /*explicit*/ basic_string(const T& t, const allocator_type& a) - : _alloc(a) { + : alloc_(a) { self_view sv = t; init(sv.data(), sv.size()); } @@ -1070,14 +1070,14 @@ namespace plg { template constexpr basic_string(InputIterator first, InputIterator last, const allocator_type& a) - : _alloc(a) { + : alloc_(a) { init(first, last); } #if PLUGIFY_HAS_CXX23 template Range> constexpr basic_string(std::from_range_t, Range&& range, const allocator_type& a = allocator_type()) - : _alloc(a) { + : alloc_(a) { if constexpr (std::ranges::forward_range || std::ranges::sized_range) { init_with_size( std::ranges::begin(range), @@ -1095,7 +1095,7 @@ namespace plg { } constexpr basic_string(std::initializer_list il, const Allocator& a) - : _alloc(a) { + : alloc_(a) { init(il.begin(), il.end()); } @@ -1194,7 +1194,7 @@ namespace plg { constexpr size_type max_size() const noexcept { constexpr bool uses_lsb = endian_factor == 2; - if (size_type m = alloc_traits::max_size(_alloc); + if (size_type m = alloc_traits::max_size(alloc_); m <= std::numeric_limits::max() / 2) { size_type res = m - alignment; @@ -1317,7 +1317,7 @@ namespace plg { template constexpr basic_string& append(InputIterator first, InputIterator last) { - const basic_string temp(first, last, _alloc); + const basic_string temp(first, last, alloc_); append(temp.data(), temp.size()); return *this; } @@ -1341,7 +1341,7 @@ namespace plg { set_size(sz + n); return *this; } else { - const basic_string temp(first, last, _alloc); + const basic_string temp(first, last, alloc_); return append(temp.data(), temp.size()); } } @@ -1389,13 +1389,13 @@ namespace plg { constexpr void move_assign(basic_string&& str, size_type pos, size_type len) { // Pilfer the allocation from str. - PLUGIFY_ASSERT(_alloc == str._alloc, "move_assign called with wrong allocator"); + PLUGIFY_ASSERT(alloc_ == str.alloc_, "move_assign called with wrong allocator"); size_type old_sz = str.size(); if (!str.is_long()) { str.annotate_delete(); } - _rep = str._rep; - str._rep = rep(); + rep_ = str.rep_; + str.rep_ = rep(); str.annotate_new(0); Traits::move(data(), data() + pos, len); @@ -1510,7 +1510,7 @@ namespace plg { return insert_with_size(position, std::ranges::begin(range), std::ranges::end(range), n); } else { - basic_string temp(std::from_range, std::forward(range), _alloc); + basic_string temp(std::from_range, std::forward(range), alloc_); return insert(position, temp.data(), temp.data() + temp.size()); } } @@ -1524,7 +1524,7 @@ namespace plg { template constexpr iterator insert(const_iterator pos, InputIterator first, InputIterator last) { - const basic_string temp(first, last, _alloc); + const basic_string temp(first, last, alloc_); return insert(pos, temp.data(), temp.data() + temp.size()); } @@ -1605,7 +1605,7 @@ namespace plg { template constexpr basic_string& replace(const_iterator i1, const_iterator i2, InputIterator j1, InputIterator j2) { - const basic_string temp(j1, j2, _alloc); + const basic_string temp(j1, j2, alloc_); return replace(i1, i2, temp); } @@ -1613,7 +1613,7 @@ namespace plg { template Range> constexpr basic_string& replace_with_range(const_iterator i1, const_iterator i2, Range&& range) { - basic_string temp(std::from_range, std::forward(range), _alloc); + basic_string temp(std::from_range, std::forward(range), alloc_); return replace(i1, i2, temp); } #endif @@ -1651,7 +1651,7 @@ namespace plg { } constexpr allocator_type get_allocator() const noexcept { - return _alloc; + return alloc_; } // find @@ -1890,7 +1890,7 @@ namespace plg { // starts_with constexpr bool starts_with(self_view sv) const noexcept { - return self_view(typename self_view::assume_valid(), data(), size()).starts_with(sv); + return self_view(data(), size()).starts_with(sv); } constexpr bool starts_with(value_type c) const noexcept { @@ -1904,7 +1904,7 @@ namespace plg { // ends_with constexpr bool ends_with(self_view sv) const noexcept { - return self_view(typename self_view::assume_valid(), data(), size()).ends_with(sv); + return self_view(data(), size()).ends_with(sv); } constexpr bool ends_with(value_type c) const noexcept { @@ -1918,25 +1918,25 @@ namespace plg { // contains constexpr bool contains(self_view sv) const noexcept { - return self_view(typename self_view::assume_valid(), data(), size()).contains(sv); + return self_view(data(), size()).contains(sv); } constexpr bool contains(value_type c) const noexcept { - return self_view(typename self_view::assume_valid(), data(), size()).contains(c); + return self_view(data(), size()).contains(c); } constexpr bool contains(const value_type* PLUGIFY_NO_NULL s) const { - return self_view(typename self_view::assume_valid(), data(), size()).contains(s); + return self_view(data(), size()).contains(s); } [[nodiscard]] constexpr bool invariants() const; private: [[nodiscard]] constexpr PLUGIFY_INTERNAL_MEMORY_ACCESS bool is_long() const noexcept { - if (std::is_constant_evaluated() && __builtin_constant_p(_rep.l._is_long)) { - return _rep.l._is_long; + if (std::is_constant_evaluated() && __builtin_constant_p(rep_.l.is_long_)) { + return rep_.l.is_long_; } - return _rep.s._is_long; + return rep_.s.is_long_; } static constexpr bool fits_in_sso(size_type sz) { @@ -2008,22 +2008,22 @@ namespace plg { s < min_cap, "s should never be greater than or equal to the short string capacity" ); - _rep.s._spare_size = (min_cap - 1) - s; - _rep.s._is_long = false; + rep_.s.spare_size_ = (min_cap - 1) - s; + rep_.s.is_long_ = false; } constexpr PLUGIFY_INTERNAL_MEMORY_ACCESS size_type get_short_size() const noexcept { - PLUGIFY_ASSERT(!_rep.s._is_long, "String has to be short when trying to get the short size"); - return (min_cap - 1) - _rep.s._spare_size; + PLUGIFY_ASSERT(!rep_.s.is_long_, "String has to be short when trying to get the short size"); + return (min_cap - 1) - rep_.s.spare_size_; } constexpr void set_long_size(size_type s) noexcept { - _rep.l._size = s; + rep_.l.size_ = s; } constexpr size_type get_long_size() const noexcept { - PLUGIFY_ASSERT(_rep.l._is_long, "String has to be long when trying to get the long size"); - return _rep.l._size; + PLUGIFY_ASSERT(rep_.l.is_long_, "String has to be long when trying to get the long size"); + return rep_.l.size_; } constexpr void set_size(size_type s) noexcept { @@ -2035,29 +2035,29 @@ namespace plg { } constexpr size_type get_long_cap() const noexcept { - PLUGIFY_ASSERT(_rep.l._is_long, "String has to be long when trying to get the long capacity"); - return _rep.l._cap * endian_factor; + PLUGIFY_ASSERT(rep_.l.is_long_, "String has to be long when trying to get the long capacity"); + return rep_.l.cap_ * endian_factor; } constexpr pointer get_long_pointer() noexcept { - PLUGIFY_ASSERT(_rep.l._is_long, "String has to be long when trying to get the long pointer"); - return PLUGIFY_ASAN_VOLATILE_WRAPPER(_rep.l._data); + PLUGIFY_ASSERT(rep_.l.is_long_, "String has to be long when trying to get the long pointer"); + return PLUGIFY_ASAN_VOLATILE_WRAPPER(rep_.l.data_); } constexpr const_pointer get_long_pointer() const noexcept { - PLUGIFY_ASSERT(_rep.l._is_long, "String has to be long when trying to get the long pointer"); - return PLUGIFY_ASAN_VOLATILE_WRAPPER(_rep.l._data); + PLUGIFY_ASSERT(rep_.l.is_long_, "String has to be long when trying to get the long pointer"); + return PLUGIFY_ASAN_VOLATILE_WRAPPER(rep_.l.data_); } constexpr PLUGIFY_INTERNAL_MEMORY_ACCESS pointer get_short_pointer() noexcept { return PLUGIFY_ASAN_VOLATILE_WRAPPER( - std::pointer_traits::pointer_to(_rep.s._data[0]) + std::pointer_traits::pointer_to(rep_.s.data_[0]) ); } constexpr PLUGIFY_INTERNAL_MEMORY_ACCESS const_pointer get_short_pointer() const noexcept { return PLUGIFY_ASAN_VOLATILE_WRAPPER( - std::pointer_traits::pointer_to(_rep.s._data[0]) + std::pointer_traits::pointer_to(rep_.s.data_[0]) ); } @@ -2094,22 +2094,22 @@ namespace plg { constexpr void reset_internal_buffer() { annotate_delete(); if (is_long()) { - alloc_traits::deallocate(_alloc, get_long_pointer(), get_long_cap()); + alloc_traits::deallocate(alloc_, get_long_pointer(), get_long_cap()); } - _rep.s = short_(); + rep_.s = short_(); } // Replace the current buffer with alloc; the first size elements constitute a string constexpr void replace_internal_buffer(long_ alloc) { reset_internal_buffer(); - _rep.l = alloc; + rep_.l = alloc; } // Initialize the internal buffer to hold size elements // The elements and null terminator have to be set by the caller constexpr pointer init_internal_buffer(size_type size) { if (std::is_constant_evaluated()) { - _rep = rep(); + rep_ = rep(); } if (size > max_size()) { @@ -2121,7 +2121,7 @@ namespace plg { annotate_new(size); return get_short_pointer(); } else { - _rep.l = allocate_long_buffer(_alloc, size); + rep_.l = allocate_long_buffer(alloc_, size); annotate_new(size); return get_long_pointer(); } @@ -2270,18 +2270,18 @@ namespace plg { } constexpr void copy_assign_alloc(const basic_string& str, std::true_type) { - if (_alloc == str._alloc) { - _alloc = str._alloc; + if (alloc_ == str.alloc_) { + alloc_ = str.alloc_; } else { if (!str.is_long()) { reset_internal_buffer(); - _alloc = str._alloc; + alloc_ = str.alloc_; } else { annotate_delete(); [[maybe_unused]] auto guard = make_scope_guard(annotate_new_size(*this)); - auto alloc = str._alloc; + auto alloc = str.alloc_; replace_internal_buffer(allocate_long_buffer(alloc, str.size())); - _alloc = std::move(alloc); + alloc_ = std::move(alloc); } } } @@ -2307,7 +2307,7 @@ namespace plg { basic_string& c, std::true_type ) noexcept(std::is_nothrow_move_assignable_v) { - _alloc = std::move(c._alloc); + alloc_ = std::move(c.alloc_); } constexpr void move_assign_alloc(basic_string&, std::false_type) noexcept { @@ -2433,7 +2433,7 @@ namespace plg { template constexpr void basic_string::init_with_sentinel(InputIterator first, Sentinel last) { - _rep = rep(); + rep_ = rep(); annotate_new(0); #if PLUGIFY_HAS_EXCEPTIONS @@ -2500,23 +2500,23 @@ namespace plg { : ms; annotate_delete(); [[maybe_unused]] auto guard = make_scope_guard(annotate_new_size(*this)); - long_ buffer = allocate_long_buffer(_alloc, cap); + long_ buffer = allocate_long_buffer(alloc_, cap); if (n_copy != 0) { - traits_type::copy(std::to_address(buffer._data), std::to_address(old_p), n_copy); + traits_type::copy(std::to_address(buffer.data_), std::to_address(old_p), n_copy); } if (n_add != 0) { - traits_type::copy(std::to_address(buffer._data) + n_copy, p_new_stuff, n_add); + traits_type::copy(std::to_address(buffer.data_) + n_copy, p_new_stuff, n_add); } size_type sec_cp_sz = old_sz - n_del - n_copy; if (sec_cp_sz != 0) { traits_type::copy( - std::to_address(buffer._data) + n_copy + n_add, + std::to_address(buffer.data_) + n_copy + n_add, std::to_address(old_p) + n_copy + n_del, sec_cp_sz ); } - buffer._size = n_copy + n_add + sec_cp_sz; - traits_type::assign(buffer._data[buffer._size], value_type()); + buffer.size_ = n_copy + n_add + sec_cp_sz; + traits_type::assign(buffer.data_[buffer.size_], value_type()); replace_internal_buffer(buffer); } @@ -2539,14 +2539,14 @@ namespace plg { size_type cap = old_cap < ms / 2 - alignment ? recommend(std::max(old_cap + delta_cap, 2 * old_cap)) : ms; - long_ buffer = allocate_long_buffer(_alloc, cap); + long_ buffer = allocate_long_buffer(alloc_, cap); if (n_copy != 0) { - traits_type::copy(std::to_address(buffer._data), std::to_address(old_p), n_copy); + traits_type::copy(std::to_address(buffer.data_), std::to_address(old_p), n_copy); } size_type sec_cp_sz = old_sz - n_del - n_copy; if (sec_cp_sz != 0) { traits_type::copy( - std::to_address(buffer._data) + n_copy + n_add, + std::to_address(buffer.data_) + n_copy + n_add, std::to_address(old_p) + n_copy + n_del, sec_cp_sz ); @@ -2554,7 +2554,7 @@ namespace plg { // This is -1 to make sure the caller sets the size properly, since old versions of this // function didn't set the size at all. - buffer._size = npos; + buffer.size_ = npos; replace_internal_buffer(buffer); set_long_size(old_sz - n_del + n_add); } @@ -2671,7 +2671,7 @@ namespace plg { annotate_delete(); [[maybe_unused]] auto guard = make_scope_guard(annotate_new_size(*this)); - _rep = str._rep; + rep_ = str.rep_; return *this; } @@ -2681,7 +2681,7 @@ namespace plg { basic_string::move_assign(basic_string& str, std::false_type) noexcept( alloc_traits::is_always_equal::value ) { - if (_alloc != str._alloc) { + if (alloc_ != str.alloc_) { assign(str); } else { move_assign(str, std::true_type()); @@ -2699,7 +2699,7 @@ namespace plg { bool str_was_short = !str.is_long(); move_assign_alloc(str); - _rep = str._rep; + rep_ = str.rep_; str.set_short_size(0); traits_type::assign(str.get_short_pointer()[0], value_type()); @@ -2728,7 +2728,7 @@ namespace plg { template constexpr void basic_string::assign_with_sentinel(InputIterator first, Sentinel last) { - const basic_string temp(init_with_sentinel_tag(), std::move(first), std::move(last), _alloc); + const basic_string temp(init_with_sentinel_tag(), std::move(first), std::move(last), alloc_); assign(temp.data(), temp.size()); } @@ -2974,7 +2974,7 @@ namespace plg { if (string_is_trivial_iterator_v && !addr_in_range(*first)) { return insert_from_safe_copy(n, ip, std::move(first), std::move(last)); } else { - const basic_string temp(init_with_sentinel_tag(), std::move(first), std::move(last), _alloc); + const basic_string temp(init_with_sentinel_tag(), std::move(first), std::move(last), alloc_); return insert_from_safe_copy(n, ip, temp.begin(), temp.end()); } } @@ -3228,9 +3228,9 @@ namespace plg { } [[maybe_unused]] annotation_guard g(*this); - long_ buffer = allocate_long_buffer(_alloc, requested_capacity); - buffer._size = size(); - traits_type::copy(std::to_address(buffer._data), data(), buffer._size + 1); + long_ buffer = allocate_long_buffer(alloc_, requested_capacity); + buffer.size_ = size(); + traits_type::copy(std::to_address(buffer.data_), data(), buffer.size_ + 1); replace_internal_buffer(buffer); } @@ -3252,7 +3252,7 @@ namespace plg { [[maybe_unused]] annotation_guard g(*this); set_short_size(size); traits_type::copy(std::to_address(get_short_pointer()), std::to_address(ptr), size + 1); - alloc_traits::deallocate(_alloc, ptr, cap); + alloc_traits::deallocate(alloc_, ptr, cap); return; } @@ -3260,18 +3260,18 @@ namespace plg { try { #endif // PLUGIFY_HAS_EXCEPTIONS [[maybe_unused]] annotation_guard g(*this); - long_ buffer = allocate_long_buffer(_alloc, size); + long_ buffer = allocate_long_buffer(alloc_, size); // The Standard mandates shrink_to_fit() does not increase the capacity. // With equal capacity keep the existing buffer. This avoids extra work // due to swapping the elements. - if (buffer._cap * endian_factor - 1 >= capacity()) { - alloc_traits::deallocate(_alloc, buffer._data, buffer._cap * endian_factor); + if (buffer.cap_ * endian_factor - 1 >= capacity()) { + alloc_traits::deallocate(alloc_, buffer.data_, buffer.cap_ * endian_factor); return; } traits_type::copy( - std::to_address(buffer._data), + std::to_address(buffer.data_), std::to_address(get_long_pointer()), size + 1 ); @@ -3316,7 +3316,7 @@ namespace plg { template inline constexpr void basic_string::swap(basic_string& str) noexcept { PLUGIFY_ASSERT( - alloc_traits::propagate_on_container_swap::value || alloc_traits::is_always_equal::value || _alloc == str._alloc, + alloc_traits::propagate_on_container_swap::value || alloc_traits::is_always_equal::value || alloc_ == str.alloc_, "swapping non-equal allocators" ); if (!is_long()) { @@ -3325,8 +3325,8 @@ namespace plg { if (this != std::addressof(str) && !str.is_long()) { str.annotate_delete(); } - std::swap(_rep, str._rep); - swap_allocator(_alloc, str._alloc); + std::swap(rep_, str.rep_); + swap_allocator(alloc_, str.alloc_); if (!is_long()) { annotate_new(get_short_size()); } diff --git a/test/example_plugin/external/plugify/include/plg/uninitialized.hpp b/test/example_plugin/external/plugify/include/plg/uninitialized.hpp index 9cc3400..85c277b 100644 --- a/test/example_plugin/external/plugify/include/plg/uninitialized.hpp +++ b/test/example_plugin/external/plugify/include/plg/uninitialized.hpp @@ -51,16 +51,16 @@ namespace plg { class AllocatorDestroyRangeReverse { public: AllocatorDestroyRangeReverse(Alloc& alloc, Iter& first, Iter& last) - : _alloc(alloc), _first(first), _last(last) {} + : alloc_(alloc), first_(first), last_(last) {} void operator()() const { - allocator_destroy(_alloc, std::reverse_iterator(_last), std::reverse_iterator(_first)); + allocator_destroy(alloc_, std::reverse_iterator(last_), std::reverse_iterator(first_)); } private: - Alloc& _alloc; - Iter& _first; - Iter& _last; + Alloc& alloc_; + Iter& first_; + Iter& last_; }; // Copy-construct [first1, last1) in [first2, first2 + N), where N is @@ -123,7 +123,7 @@ namespace plg { // - is_copy_constructible // - is_trivially_relocatable template - void uninitialized_allocator_relocate(Alloc& alloc, T* first, T* last, T* result) { + constexpr void uninitialized_allocator_relocate(Alloc& alloc, T* first, T* last, T* result) { if (std::is_constant_evaluated() || !is_trivially_relocatable::value || !allocator_has_trivial_move_construct::value || diff --git a/test/example_plugin/external/plugify/include/plg/variant.hpp b/test/example_plugin/external/plugify/include/plg/variant.hpp index 9e7ada0..4c68ac4 100644 --- a/test/example_plugin/external/plugify/include/plg/variant.hpp +++ b/test/example_plugin/external/plugify/include/plg/variant.hpp @@ -26,13 +26,13 @@ namespace plg { #if PLUGIFY_HAS_EXCEPTIONS class bad_variant_access : public std::exception { public: - explicit bad_variant_access(const char* str) noexcept : message{str} {} + explicit bad_variant_access(const char* str) noexcept : message_{str} {} bad_variant_access() noexcept = default; bad_variant_access(const bad_variant_access&) noexcept = default; bad_variant_access& operator=(const bad_variant_access&) noexcept = default; - const char* what() const noexcept override { return message; } + const char* what() const noexcept override { return message_; } private: - const char* message = ""; // llvm test requires a well formed what() on default init + const char* message_ = ""; // llvm test requires a well formed what() on default init }; #endif // PLUGIFY_HAS_EXCEPTIONS @@ -575,7 +575,7 @@ namespace plg { constexpr variant() noexcept(std::is_nothrow_default_constructible_v>) requires std::is_default_constructible_v> - : _storage{in_place_index<0>}, _current{0} + : storage_{in_place_index<0>}, current_{0} {} // copy constructor (trivial) @@ -587,7 +587,7 @@ namespace plg { // copy constructor constexpr variant(const variant& o) requires (has_copy_ctor and not trivial_copy_ctor) - : _storage{detail::dummy_type{}} { + : storage_{detail::dummy_type{}} { construct_from(o); } @@ -600,7 +600,7 @@ namespace plg { constexpr variant(variant&& o) noexcept((std::is_nothrow_move_constructible_v && ...)) requires (has_move_ctor and not trivial_move_ctor) - : _storage{detail::dummy_type{}} { + : storage_{detail::dummy_type{}} { construct_from(static_cast(o)); } @@ -616,7 +616,7 @@ namespace plg { template requires (Index < size && std::is_constructible_v, Args&&...>) explicit constexpr variant(in_place_index_t tag, Args&&... args) - : _storage{tag, static_cast(args)...}, _current(Index) + : storage_{tag, static_cast(args)...}, current_(Index) {} // construct a given type @@ -633,7 +633,7 @@ namespace plg { std::is_constructible_v, std::initializer_list&, Args&&...> ) explicit constexpr variant(in_place_index_t tag, std::initializer_list list, Args&&... args) - : _storage{tag, list, PLG_FWD(args)...}, _current{Index} + : storage_{tag, list, PLG_FWD(args)...}, current_{Index} {} template @@ -642,7 +642,7 @@ namespace plg { && std::is_constructible_v&, Args&&...> ) explicit constexpr variant(in_place_type_t, std::initializer_list list, Args&&... args) - : _storage{in_place_index>, list, PLG_FWD(args)...}, _current{index_of } + : storage_{in_place_index>, list, PLG_FWD(args)...}, current_{index_of } {} // ================================ destructors (20.7.3.3) @@ -714,7 +714,7 @@ namespace plg { using related_type = detail::best_overload_match; constexpr auto new_index = index_of; - if (_current == new_index) + if (current_ == new_index) unsafe_get() = PLG_FWD(t); else { constexpr bool do_simple_emplace = @@ -765,12 +765,12 @@ namespace plg { constexpr bool valueless_by_exception() const noexcept { if constexpr (can_be_valueless) - return _current == npos; + return current_ == npos; else return false; } constexpr index_type index() const noexcept { - return _current; + return current_; } // =================================== swap (20.7.3.7) @@ -785,7 +785,7 @@ namespace plg { constexpr auto impl_one_valueless = [](auto&& full, auto& empty) { detail::visit_with_index(PLG_FWD(full), detail::emplace_no_dtor_from_elem{empty}); full.reset_no_check(); - full._current = npos; + full.current_ = npos; }; switch (static_cast(index() == npos) + static_cast(o.index() == npos) * 2) { @@ -837,29 +837,29 @@ namespace plg { template constexpr auto& unsafe_get() & noexcept { static_assert(Idx < size); - PLUGIFY_ASSERT(_current == Idx, ""); - return _storage.template get(); + PLUGIFY_ASSERT(current_ == Idx, ""); + return storage_.template get(); } template constexpr auto&& unsafe_get() && noexcept { static_assert(Idx < size); - PLUGIFY_ASSERT(_current == Idx, ""); - return PLG_MOV(_storage.template get()); + PLUGIFY_ASSERT(current_ == Idx, ""); + return PLG_MOV(storage_.template get()); } template constexpr const auto& unsafe_get() const & noexcept { static_assert(Idx < size); - PLUGIFY_ASSERT(_current == Idx, ""); - return _storage.template get(); + PLUGIFY_ASSERT(current_ == Idx, ""); + return storage_.template get(); } template constexpr const auto&& unsafe_get() const && noexcept { static_assert(Idx < size); - PLUGIFY_ASSERT(_current == Idx, ""); - return PLG_MOV(_storage.template get()); + PLUGIFY_ASSERT(current_ == Idx, ""); + return PLG_MOV(storage_.template get()); } private: @@ -868,9 +868,9 @@ namespace plg { constexpr void assign_from(Other&& o, Fn&& fn) { if constexpr (can_be_valueless) { if (o.index() == npos) { - if (_current != npos) { + if (current_ != npos) { reset_no_check(); - _current = npos; + current_ = npos; } return; } @@ -906,7 +906,7 @@ namespace plg { { static_assert(can_be_valueless, "Internal error : the possibly valueless branch of emplace was taken despite |can_be_valueless| being false"); - _current = npos; + current_ = npos; do_emplace_no_dtor(PLG_FWD(args)...); } } @@ -916,7 +916,7 @@ namespace plg { template constexpr void do_emplace_no_dtor(Args&&... args) { - _current = static_cast(Idx); + current_ = static_cast(Idx); auto* ptr = detail::addressof(unsafe_get()); @@ -950,7 +950,7 @@ namespace plg { constexpr void construct_from(Other&& o) { if constexpr (can_be_valueless) if (o.valueless_by_exception()) { - _current = npos; + current_ = npos; return; } @@ -960,11 +960,11 @@ namespace plg { template friend struct detail::emplace_no_dtor_from_elem; - storage _storage; + storage storage_; #if INTPTR_MAX == INT32_MAX - volatile char pad[8]; + volatile char padding_[8]; #endif - index_type _current; + index_type current_; }; // ================================= value access (20.7.5) diff --git a/test/example_plugin/external/plugify/include/plg/vector.hpp b/test/example_plugin/external/plugify/include/plg/vector.hpp index cd26021..56884fc 100644 --- a/test/example_plugin/external/plugify/include/plg/vector.hpp +++ b/test/example_plugin/external/plugify/include/plg/vector.hpp @@ -94,7 +94,7 @@ namespace plg { constexpr vector() noexcept(std::is_nothrow_default_constructible_v) = default; constexpr explicit vector(const allocator_type& a) noexcept - : _alloc(a) { + : alloc_(a) { } constexpr explicit vector(size_type n) { @@ -108,7 +108,7 @@ namespace plg { constexpr explicit vector(size_type n, const allocator_type& a) - : _alloc(a) { + : alloc_(a) { auto guard = make_exception_guard(destroy_vector(*this)); if (n > 0) { vallocate(n); @@ -128,7 +128,7 @@ namespace plg { constexpr vector(size_type n, const value_type& x, const allocator_type& a) - : _alloc(a) { + : alloc_(a) { auto guard = make_exception_guard(destroy_vector(*this)); if (n > 0) { vallocate(n); @@ -146,7 +146,7 @@ namespace plg { template constexpr vector(InputIterator first, InputIterator last, const allocator_type& a) - : _alloc(a) { + : alloc_(a) { init_with_sentinel(first, last); } @@ -160,7 +160,7 @@ namespace plg { template constexpr vector(ForwardIterator first, ForwardIterator last, const allocator_type& a) - : _alloc(a) { + : alloc_(a) { size_type n = static_cast(std::distance(first, last)); init_with_size(first, last, n); } @@ -171,7 +171,7 @@ namespace plg { std::from_range_t, Range&& range, const allocator_type& alloc = allocator_type() - ) : _alloc(alloc) { + ) : alloc_(alloc) { if constexpr (std::ranges::forward_range || std::ranges::sized_range) { auto n = static_cast(std::ranges::distance(range)); init_with_size(std::ranges::begin(range), std::ranges::end(range), n); @@ -190,10 +190,10 @@ namespace plg { } constexpr void operator()() { - if (vec_._begin != nullptr) { + if (vec_.begin_ != nullptr) { vec_.clear(); vec_.annotate_delete(); - alloc_traits::deallocate(vec_._alloc, vec_._begin, vec_.capacity()); + alloc_traits::deallocate(vec_.alloc_, vec_.begin_, vec_.capacity()); } } @@ -207,14 +207,14 @@ namespace plg { } constexpr vector(const vector& x) - : _alloc(alloc_traits::select_on_container_copy_construction(x._alloc)) { - init_with_size(x._begin, x._end, x.size()); + : alloc_(alloc_traits::select_on_container_copy_construction(x.alloc_)) { + init_with_size(x.begin_, x.end_, x.size()); } constexpr vector(const vector& x, const std::type_identity_t& a) - : _alloc(a) { - init_with_size(x._begin, x._end, x.size()); + : alloc_(a) { + init_with_size(x.begin_, x.end_, x.size()); } constexpr vector& operator=(const vector& x); @@ -225,7 +225,7 @@ namespace plg { constexpr vector(std::initializer_list il, const allocator_type& a) - : _alloc(a) { + : alloc_(a) { init_with_size(il.begin(), il.end(), il.size()); } @@ -286,28 +286,28 @@ namespace plg { [[nodiscard]] constexpr allocator_type get_allocator() const noexcept { - return this->_alloc; + return this->alloc_; } // // Iterators // [[nodiscard]] constexpr iterator begin() noexcept { - return make_iter(add_alignment_assumption(this->_begin)); + return make_iter(add_alignment_assumption(this->begin_)); } [[nodiscard]] constexpr const_iterator begin() const noexcept { - return make_iter(add_alignment_assumption(this->_begin)); + return make_iter(add_alignment_assumption(this->begin_)); } [[nodiscard]] constexpr iterator end() noexcept { - return make_iter(add_alignment_assumption(this->_end)); + return make_iter(add_alignment_assumption(this->end_)); } [[nodiscard]] constexpr const_iterator end() const noexcept { - return make_iter(add_alignment_assumption(this->_end)); + return make_iter(add_alignment_assumption(this->end_)); } [[nodiscard]] constexpr reverse_iterator @@ -354,23 +354,23 @@ namespace plg { // [vector.capacity], capacity // [[nodiscard]] constexpr size_type size() const noexcept { - return static_cast(this->_end - this->_begin); + return static_cast(this->end_ - this->begin_); } [[nodiscard]] constexpr size_type capacity() const noexcept { - return static_cast(this->_cap - this->_begin); + return static_cast(this->cap_ - this->begin_); } [[nodiscard]] constexpr bool empty() const noexcept { - return this->_begin == this->_end; + return this->begin_ == this->end_; } [[nodiscard]] constexpr size_type max_size() const noexcept { return std::min( - alloc_traits::max_size(this->_alloc), + alloc_traits::max_size(this->alloc_), std::numeric_limits::max() ); } @@ -384,20 +384,20 @@ namespace plg { [[nodiscard]] constexpr reference operator[](size_type n) noexcept { PLUGIFY_ASSERT(n < size(), "vector[] index out of bounds"); - return this->_begin[n]; + return this->begin_[n]; } [[nodiscard]] constexpr const_reference operator[](size_type n) const noexcept { PLUGIFY_ASSERT(n < size(), "vector[] index out of bounds"); - return this->_begin[n]; + return this->begin_[n]; } [[nodiscard]] constexpr reference at(size_type n) { if (n >= size()) { this->throw_out_of_range(); } - return this->_begin[n]; + return this->begin_[n]; } [[nodiscard]] constexpr const_reference @@ -405,29 +405,29 @@ namespace plg { if (n >= size()) { this->throw_out_of_range(); } - return this->_begin[n]; + return this->begin_[n]; } [[nodiscard]] constexpr reference front() noexcept { PLUGIFY_ASSERT(!empty(), "front() called on an empty vector"); - return *this->_begin; + return *this->begin_; } [[nodiscard]] constexpr const_reference front() const noexcept { PLUGIFY_ASSERT(!empty(), "front() called on an empty vector"); - return *this->_begin; + return *this->begin_; } [[nodiscard]] constexpr reference back() noexcept { PLUGIFY_ASSERT(!empty(), "back() called on an empty vector"); - return *(this->_end - 1); + return *(this->end_ - 1); } [[nodiscard]] constexpr const_reference back() const noexcept { PLUGIFY_ASSERT(!empty(), "back() called on an empty vector"); - return *(this->_end - 1); + return *(this->end_ - 1); } // @@ -435,12 +435,12 @@ namespace plg { // [[nodiscard]] constexpr value_type* data() noexcept { - return std::to_address(this->_begin); + return std::to_address(this->begin_); } [[nodiscard]] constexpr const value_type* data() const noexcept { - return std::to_address(this->_begin); + return std::to_address(this->begin_); } // @@ -467,7 +467,7 @@ namespace plg { "We assume that we have enough space to insert an element at the end of the vector" ); ConstructTransaction tx(*this, 1); - alloc_traits::construct(this->_alloc, std::to_address(tx.pos_), std::forward(args)...); + alloc_traits::construct(this->alloc_, std::to_address(tx.pos_), std::forward(args)...); ++tx.pos_; } @@ -480,7 +480,7 @@ namespace plg { constexpr void pop_back() { PLUGIFY_ASSERT(!empty(), "vector::pop_back called on an empty vector"); - this->destruct_at_end(this->_end - 1); + this->destruct_at_end(this->end_ - 1); } constexpr iterator @@ -532,7 +532,7 @@ namespace plg { constexpr void clear() noexcept { size_type old_size = size(); - base_destruct_at_end(this->_begin); + base_destruct_at_end(this->begin_); annotate_shrink(old_size); } @@ -545,16 +545,16 @@ namespace plg { constexpr bool invariants() const; private: - pointer _begin = nullptr; - pointer _end = nullptr; - pointer _cap = nullptr; + pointer begin_ = nullptr; + pointer end_ = nullptr; + pointer cap_ = nullptr; PLUGIFY_NO_UNIQUE_ADDRESS - allocator_type _alloc; + allocator_type alloc_; // Allocate space for n objects // throws length_error if n > max_size() // throws (probably bad_alloc) if memory run out - // Precondition: _begin == _end == _cap == nullptr + // Precondition: begin_ == end_ == cap_ == nullptr // Precondition: n > 0 // Postcondition: capacity() >= n // Postcondition: size() == 0 @@ -562,10 +562,10 @@ namespace plg { if (n > max_size()) { this->throw_length_error(); } - auto allocation = allocate_at_least(this->_alloc, n); - _begin = allocation.ptr; - _end = allocation.ptr; - _cap = _begin + allocation.count; + auto allocation = allocate_at_least(this->alloc_, n); + begin_ = allocation.ptr; + end_ = allocation.ptr; + cap_ = begin_ + allocation.count; annotate_new(0); } @@ -617,7 +617,7 @@ namespace plg { insert_assign_n_unchecked(Iterator first, difference_type n, pointer position) { for (pointer end_position = position + n; position != end_position; ++position, (void) ++first) { - detail::temp_value tmp(this->_alloc, *first); + detail::temp_value tmp(this->alloc_, *first); *position = std::move(tmp.get()); } } @@ -722,15 +722,15 @@ namespace plg { constexpr explicit ConstructTransaction(vector& v, size_type n) : v_(v) - , pos_(v._end) - , new_end_(v._end + n) { + , pos_(v.end_) + , new_end_(v.end_ + n) { v.annotate_increase(n); } constexpr ~ConstructTransaction() { - v_._end = pos_; + v_.end_ = pos_; if (pos_ != new_end_) { - v_.annotate_shrink(new_end_ - v_._begin); + v_.annotate_shrink(new_end_ - v_.begin_); } } @@ -744,11 +744,11 @@ namespace plg { constexpr void base_destruct_at_end(pointer new_last) noexcept { - pointer soon_to_be_end = this->_end; + pointer soon_to_be_end = this->end_; while (new_last != soon_to_be_end) { - alloc_traits::destroy(this->_alloc, std::to_address(--soon_to_be_end)); + alloc_traits::destroy(this->alloc_, std::to_address(--soon_to_be_end)); } - this->_end = new_last; + this->end_ = new_last; } constexpr void copy_assign_alloc(const vector& c) { @@ -779,13 +779,13 @@ namespace plg { constexpr void copy_assign_alloc(const vector& c, std::true_type) { - if (this->_alloc != c._alloc) { + if (this->alloc_ != c.alloc_) { clear(); annotate_delete(); - alloc_traits::deallocate(this->_alloc, this->_begin, capacity()); - this->_begin = this->_end = this->_cap = nullptr; + alloc_traits::deallocate(this->alloc_, this->begin_, capacity()); + this->begin_ = this->end_ = this->cap_ = nullptr; } - this->_alloc = c._alloc; + this->alloc_ = c.alloc_; } constexpr void @@ -796,7 +796,7 @@ namespace plg { move_assign_alloc(vector& c, std::true_type) noexcept( std::is_nothrow_move_assignable_v ) { - this->_alloc = std::move(c._alloc); + this->alloc_ = std::move(c.alloc_); } constexpr void @@ -820,18 +820,18 @@ namespace plg { constexpr void swap_layouts(split_buffer& sb) { - auto vector_begin = _begin; - auto vector_sentinel = _end; - auto vector_cap = _cap; + auto vector_begin = begin_; + auto vector_sentinel = end_; + auto vector_cap = cap_; auto sb_begin = sb.begin(); auto sb_sentinel = sb.raw_sentinel(); auto sb_cap = sb.raw_capacity(); // TODO: replace with set_valid_range and set_capacity when vector supports it. - _begin = sb_begin; - _end = sb_sentinel; - _cap = sb_cap; + begin_ = sb_begin; + end_ = sb_sentinel; + cap_ = sb_cap; sb.set_valid_range(vector_begin, vector_sentinel); sb.set_capacity(vector_cap); @@ -852,33 +852,33 @@ namespace plg { -> vector, Alloc>; #endif - // swap_out_circular_buffer relocates the objects in [_begin, _end) into the front of v and - // swaps the buffers of *this and v. It is assumed that v provides space for exactly (_end - - // _begin) objects in the front. This function has a strong exception guarantee. + // swap_out_circular_buffer relocates the objects in [begin_, end_) into the front of v and + // swaps the buffers of *this and v. It is assumed that v provides space for exactly (end_ - + // begin_) objects in the front. This function has a strong exception guarantee. template constexpr void vector::swap_out_circular_buffer(split_buffer& v) { annotate_delete(); auto new_begin = v.begin() - size(); uninitialized_allocator_relocate( - this->_alloc, - std::to_address(_begin), - std::to_address(_end), + this->alloc_, + std::to_address(begin_), + std::to_address(end_), std::to_address(new_begin) ); v.set_valid_range(new_begin, v.end()); - _end = _begin; // All the objects have been destroyed by relocating them. + end_ = begin_; // All the objects have been destroyed by relocating them. swap_layouts(v); v.set_data(v.begin()); annotate_new(size()); } - // swap_out_circular_buffer relocates the objects in [_begin, p) into the front of v, the - // objects in [p, _end) into the back of v and swaps the buffers of *this and v. It is assumed - // that v provides space for exactly (p - _begin) objects in the front and space for at least - // (_end - p) objects in the back. This function has a strong exception guarantee if _begin == p - // || _end == p. + // swap_out_circular_buffer relocates the objects in [begin_, p) into the front of v, the + // objects in [p, end_) into the back of v and swaps the buffers of *this and v. It is assumed + // that v provides space for exactly (p - begin_) objects in the front and space for at least + // (end_ - p) objects in the back. This function has a strong exception guarantee if begin_ == p + // || end_ == p. template constexpr typename vector::pointer vector::swap_out_circular_buffer( @@ -888,27 +888,27 @@ namespace plg { annotate_delete(); pointer ret = v.begin(); - // Relocate [p, _end) first to avoid having a hole in [_begin, _end) - // in case something in [_begin, p) throws. + // Relocate [p, end_) first to avoid having a hole in [begin_, end_) + // in case something in [begin_, p) throws. uninitialized_allocator_relocate( - this->_alloc, + this->alloc_, std::to_address(p), - std::to_address(_end), + std::to_address(end_), std::to_address(v.end()) ); - auto relocated_so_far = _end - p; + auto relocated_so_far = end_ - p; v.set_sentinel(v.end() + relocated_so_far); - _end = p; // The objects in [p, _end) have been destroyed by relocating them. - auto new_begin = v.begin() - (p - _begin); + end_ = p; // The objects in [p, end_) have been destroyed by relocating them. + auto new_begin = v.begin() - (p - begin_); uninitialized_allocator_relocate( - this->_alloc, - std::to_address(_begin), + this->alloc_, + std::to_address(begin_), std::to_address(p), std::to_address(new_begin) ); v.set_valid_range(new_begin, v.end()); - _end = _begin; // All the objects have been destroyed by relocating them. + end_ = begin_; // All the objects have been destroyed by relocating them. swap_layouts(v); v.set_data(v.begin()); annotate_new(size()); @@ -917,11 +917,11 @@ namespace plg { template constexpr void vector::vdeallocate() noexcept { - if (this->_begin != nullptr) { + if (this->begin_ != nullptr) { clear(); annotate_delete(); - alloc_traits::deallocate(this->_alloc, this->_begin, capacity()); - this->_begin = this->_end = this->_cap = nullptr; + alloc_traits::deallocate(this->alloc_, this->begin_, capacity()); + this->begin_ = this->end_ = this->cap_ = nullptr; } } @@ -941,7 +941,7 @@ namespace plg { return std::max(2 * cap, new_size); } - // Default constructs n objects starting at _end + // Default constructs n objects starting at end_ // throws if construction throws // Precondition: n > 0 // Precondition: size() + n <= capacity() @@ -951,11 +951,11 @@ namespace plg { ConstructTransaction tx(*this, n); const_pointer new_end = tx.new_end_; for (pointer pos = tx.pos_; pos != new_end; tx.pos_ = ++pos) { - alloc_traits::construct(this->_alloc, std::to_address(pos)); + alloc_traits::construct(this->alloc_, std::to_address(pos)); } } - // Copy constructs n objects starting at _end from x + // Copy constructs n objects starting at end_ from x // throws if construction throws // Precondition: n > 0 // Precondition: size() + n <= capacity() @@ -967,7 +967,7 @@ namespace plg { ConstructTransaction tx(*this, n); const_pointer new_end = tx.new_end_; for (pointer pos = tx.pos_; pos != new_end; tx.pos_ = ++pos) { - alloc_traits::construct(this->_alloc, std::to_address(pos), x); + alloc_traits::construct(this->alloc_, std::to_address(pos), x); } } @@ -977,39 +977,39 @@ namespace plg { vector::construct_at_end(InputIterator first, Sentinel last, size_type n) { ConstructTransaction tx(*this, n); tx.pos_ = uninitialized_allocator_copy( - this->_alloc, + this->alloc_, std::move(first), std::move(last), tx.pos_ ); } - // Default constructs n objects starting at _end + // Default constructs n objects starting at end_ // throws if construction throws // Postcondition: size() == size() + n // Exception safety: strong. template constexpr void vector::append(size_type n) { - if (static_cast(this->_cap - this->_end) >= n) { + if (static_cast(this->cap_ - this->end_) >= n) { this->construct_at_end(n); } else { - split_buffer v(recommend(size() + n), size(), this->_alloc); + split_buffer v(recommend(size() + n), size(), this->alloc_); v.construct_at_end(n); swap_out_circular_buffer(v); } } - // Default constructs n objects starting at _end + // Default constructs n objects starting at end_ // throws if construction throws // Postcondition: size() == size() + n // Exception safety: strong. template constexpr void vector::append(size_type n, const_reference x) { - if (static_cast(this->_cap - this->_end) >= n) { + if (static_cast(this->cap_ - this->end_) >= n) { this->construct_at_end(n, x); } else { - split_buffer v(recommend(size() + n), size(), this->_alloc); + split_buffer v(recommend(size() + n), size(), this->alloc_); v.construct_at_end(n, x); swap_out_circular_buffer(v); } @@ -1018,22 +1018,22 @@ namespace plg { template constexpr inline vector::vector(vector&& x) noexcept - : _alloc(std::move(x._alloc)) { - this->_begin = x._begin; - this->_end = x._end; - this->_cap = x._cap; - x._begin = x._end = x._cap = nullptr; + : alloc_(std::move(x.alloc_)) { + this->begin_ = x.begin_; + this->end_ = x.end_; + this->cap_ = x.cap_; + x.begin_ = x.end_ = x.cap_ = nullptr; } template constexpr inline vector::vector(vector&& x, const std::type_identity_t& a) - : _alloc(a) { - if (a == x._alloc) { - this->_begin = x._begin; - this->_end = x._end; - this->_cap = x._cap; - x._begin = x._end = x._cap = nullptr; + : alloc_(a) { + if (a == x.alloc_) { + this->begin_ = x.begin_; + this->end_ = x.end_; + this->cap_ = x.cap_; + x.begin_ = x.end_ = x.cap_ = nullptr; } else { using Ip = std::move_iterator; init_with_size(Ip(x.begin()), Ip(x.end()), x.size()); @@ -1045,7 +1045,7 @@ namespace plg { vector::move_assign(vector& c, std::false_type) noexcept( alloc_traits::is_always_equal::value ) { - if (this->_alloc != c._alloc) { + if (this->alloc_ != c.alloc_) { using Ip = std::move_iterator; assign(Ip(c.begin()), Ip(c.end())); } else { @@ -1060,10 +1060,10 @@ namespace plg { ) { vdeallocate(); move_assign_alloc(c); // this can throw - this->_begin = c._begin; - this->_end = c._end; - this->_cap = c._cap; - c._begin = c._end = c._cap = nullptr; + this->begin_ = c.begin_; + this->end_ = c.end_; + this->cap_ = c.cap_; + c.begin_ = c.end_ = c.cap_ = nullptr; } template @@ -1071,7 +1071,7 @@ namespace plg { vector::operator=(const vector& x) { if (this != std::addressof(x)) { copy_assign_alloc(x); - assign(x._begin, x._end); + assign(x.begin_, x.end_); } return *this; } @@ -1080,11 +1080,11 @@ namespace plg { template constexpr void vector::assign_with_sentinel(Iterator first, Sentinel last) { - pointer cur = _begin; - for (; first != last && cur != _end; ++first, (void) ++cur) { + pointer cur = begin_; + for (; first != last && cur != end_; ++first, (void) ++cur) { *cur = *first; } - if (cur != _end) { + if (cur != end_) { destruct_at_end(cur); } else { for (; first != last; ++first) { @@ -1101,15 +1101,15 @@ namespace plg { if (new_size <= capacity()) { if (new_size > size()) { #if PLUGIFY_HAS_CXX23 - auto mid = std::ranges::copy_n(std::move(first), size(), this->_begin).in; + auto mid = std::ranges::copy_n(std::move(first), size(), this->begin_).in; construct_at_end(std::move(mid), std::move(last), new_size - size()); #else Iterator mid = std::next(first, size()); - std::copy(first, mid, this->_begin); + std::copy(first, mid, this->begin_); construct_at_end(mid, last, new_size - size()); #endif } else { - pointer m = std::copy(std::move(first), last, this->_begin); + pointer m = std::copy(std::move(first), last, this->begin_); this->destruct_at_end(m); } } else { @@ -1124,11 +1124,11 @@ namespace plg { vector::assign(size_type n, const_reference u) { if (n <= capacity()) { size_type s = size(); - std::fill_n(this->_begin, std::min(n, s), u); + std::fill_n(this->begin_, std::min(n, s), u); if (n > s) { construct_at_end(n - s, u); } else { - this->destruct_at_end(this->_begin + n); + this->destruct_at_end(this->begin_ + n); } } else { vdeallocate(); @@ -1143,7 +1143,7 @@ namespace plg { if (n > max_size()) { this->throw_length_error(); } - split_buffer v(n, size(), this->_alloc); + split_buffer v(n, size(), this->alloc_); swap_out_circular_buffer(v); } } @@ -1154,7 +1154,7 @@ namespace plg { #if PLUGIFY_HAS_EXCEPTIONS try { #endif // PLUGIFY_HAS_EXCEPTIONS - split_buffer v(size(), size(), this->_alloc); + split_buffer v(size(), size(), this->alloc_); // The Standard mandates shrink_to_fit() does not increase the capacity. // With equal capacity keep the existing buffer. This avoids extra work // due to swapping the elements. @@ -1172,13 +1172,13 @@ namespace plg { template constexpr typename vector::pointer vector::emplace_back_slow_path(Args&&... args) { - split_buffer v(recommend(size() + 1), size(), this->_alloc); + split_buffer v(recommend(size() + 1), size(), this->alloc_); // v.emplace_back(std::forward(args)...); pointer end = v.end(); - alloc_traits::construct(this->_alloc, std::to_address(end), std::forward(args)...); + alloc_traits::construct(this->alloc_, std::to_address(end), std::forward(args)...); v.set_sentinel(++end); swap_out_circular_buffer(v); - return this->_end; + return this->end_; } // This makes the compiler inline `else()` if `cond` is known to be false. Currently LLVM @@ -1207,9 +1207,9 @@ namespace plg { constexpr inline typename vector::reference vector::emplace_back(Args&&... args) { - pointer end = this->_end; + pointer end = this->end_; if_likely_else( - end < this->_cap, + end < this->cap_, [&] { emplace_back_assume_capacity(std::forward(args)...); ++end; @@ -1217,7 +1217,7 @@ namespace plg { [&] { end = emplace_back_slow_path(std::forward(args)...); } ); - this->_end = end; + this->end_ = end; return *(end - 1); } @@ -1230,8 +1230,8 @@ namespace plg { "vector::erase(iterator) called with a non-dereferenceable iterator" ); difference_type ps = position - cbegin(); - pointer p = this->_begin + ps; - this->destruct_at_end(std::move(p + 1, this->_end, p)); + pointer p = this->begin_ + ps; + this->destruct_at_end(std::move(p + 1, this->end_, p)); return make_iter(p); } @@ -1242,9 +1242,9 @@ namespace plg { first <= last, "vector::erase(first, last) called with invalid range" ); - pointer p = this->_begin + (first - begin()); + pointer p = this->begin_ + (first - begin()); if (first != last) { - this->destruct_at_end(std::move(p + (last - first), this->_end, p)); + this->destruct_at_end(std::move(p + (last - first), this->end_, p)); } return make_iter(p); } @@ -1252,13 +1252,13 @@ namespace plg { template constexpr void vector::move_range(pointer from_s, pointer from_e, pointer to) { - pointer old_last = this->_end; + pointer old_last = this->end_; difference_type n = old_last - to; { pointer i = from_s + n; ConstructTransaction tx(*this, from_e - i); for (pointer pos = tx.pos_; i < from_e; ++i, (void) ++pos, tx.pos_ = pos) { - alloc_traits::construct(this->_alloc, std::to_address(pos), std::move(*i)); + alloc_traits::construct(this->alloc_, std::to_address(pos), std::move(*i)); } } std::move_backward(from_s, from_s + n, old_last); @@ -1267,16 +1267,16 @@ namespace plg { template constexpr typename vector::iterator vector::insert(const_iterator position, const_reference x) { - pointer p = this->_begin + (position - begin()); - if (this->_end < this->_cap) { - if (p == this->_end) { + pointer p = this->begin_ + (position - begin()); + if (this->end_ < this->cap_) { + if (p == this->end_) { emplace_back_assume_capacity(x); } else { - move_range(p, this->_end, p + 1); + move_range(p, this->end_, p + 1); const_pointer xr = std::pointer_traits::pointer_to(x); if (is_pointer_in_range( std::to_address(p), - std::to_address(_end), + std::to_address(end_), std::addressof(x) )) { ++xr; @@ -1286,8 +1286,8 @@ namespace plg { } else { split_buffer v( recommend(size() + 1), - p - this->_begin, - this->_alloc + p - this->begin_, + this->alloc_ ); v.emplace_back(x); p = swap_out_circular_buffer(v, p); @@ -1298,19 +1298,19 @@ namespace plg { template constexpr typename vector::iterator vector::insert(const_iterator position, value_type&& x) { - pointer p = this->_begin + (position - begin()); - if (this->_end < this->_cap) { - if (p == this->_end) { + pointer p = this->begin_ + (position - begin()); + if (this->end_ < this->cap_) { + if (p == this->end_) { emplace_back_assume_capacity(std::move(x)); } else { - move_range(p, this->_end, p + 1); + move_range(p, this->end_, p + 1); *p = std::move(x); } } else { split_buffer v( recommend(size() + 1), - p - this->_begin, - this->_alloc + p - this->begin_, + this->alloc_ ); v.emplace_back(std::move(x)); p = swap_out_circular_buffer(v, p); @@ -1322,20 +1322,20 @@ namespace plg { template constexpr typename vector::iterator vector::emplace(const_iterator position, Args&&... args) { - pointer p = this->_begin + (position - begin()); - if (this->_end < this->_cap) { - if (p == this->_end) { + pointer p = this->begin_ + (position - begin()); + if (this->end_ < this->cap_) { + if (p == this->end_) { emplace_back_assume_capacity(std::forward(args)...); } else { - detail::temp_value tmp(this->_alloc, std::forward(args)...); - move_range(p, this->_end, p + 1); + detail::temp_value tmp(this->alloc_, std::forward(args)...); + move_range(p, this->end_, p + 1); *p = std::move(tmp.get()); } } else { split_buffer v( recommend(size() + 1), - p - this->_begin, - this->_alloc + p - this->begin_, + this->alloc_ ); v.emplace_back(std::forward(args)...); p = swap_out_circular_buffer(v, p); @@ -1346,13 +1346,13 @@ namespace plg { template constexpr typename vector::iterator vector::insert(const_iterator position, size_type n, const_reference x) { - pointer p = this->_begin + (position - begin()); + pointer p = this->begin_ + (position - begin()); if (n > 0) { - if (n <= static_cast(this->_cap - this->_end)) { + if (n <= static_cast(this->cap_ - this->end_)) { size_type old_n = n; - pointer old_last = this->_end; - if (n > static_cast(this->_end - p)) { - size_type cx = n - (this->_end - p); + pointer old_last = this->end_; + if (n > static_cast(this->end_ - p)) { + size_type cx = n - (this->end_ - p); construct_at_end(cx, x); n -= cx; } @@ -1361,7 +1361,7 @@ namespace plg { const_pointer xr = std::pointer_traits::pointer_to(x); if (is_pointer_in_range( std::to_address(p), - std::to_address(_end), + std::to_address(end_), std::addressof(x) )) { xr += old_n; @@ -1371,8 +1371,8 @@ namespace plg { } else { split_buffer v( recommend(size() + n), - p - this->_begin, - this->_alloc + p - this->begin_, + this->alloc_ ); v.construct_at_end(n, x); p = swap_out_circular_buffer(v, p); @@ -1390,37 +1390,37 @@ namespace plg { Sentinel last ) { difference_type off = position - begin(); - pointer p = this->_begin + off; - pointer old_last = this->_end; - for (; this->_end != this->_cap && first != last; ++first) { + pointer p = this->begin_ + off; + pointer old_last = this->end_; + for (; this->end_ != this->cap_ && first != last; ++first) { emplace_back_assume_capacity(*first); } if (first == last) { - (void) std::rotate(p, old_last, this->_end); + (void) std::rotate(p, old_last, this->end_); } else { - split_buffer v(_alloc); + split_buffer v(alloc_); auto guard = make_exception_guard( - AllocatorDestroyRangeReverse(_alloc, old_last, this->_end) + AllocatorDestroyRangeReverse(alloc_, old_last, this->end_) ); v.construct_at_end_with_sentinel(std::move(first), std::move(last)); split_buffer merged( recommend(size() + v.size()), off, - _alloc + alloc_ ); // has `off` positions available at the front uninitialized_allocator_relocate( - _alloc, + alloc_, std::to_address(old_last), - std::to_address(this->_end), + std::to_address(this->end_), std::to_address(merged.end()) ); - guard.complete(); // Release the guard once objects in [old_last_, _end) have been + guard.complete(); // Release the guard once objects in [old_last_, end_) have been // successfully relocated. - merged.set_sentinel(merged.end() + (this->_end - old_last)); - this->_end = old_last; + merged.set_sentinel(merged.end() + (this->end_ - old_last)); + this->end_ = old_last; uninitialized_allocator_relocate( - _alloc, + alloc_, std::to_address(v.begin()), std::to_address(v.end()), std::to_address(merged.end()) @@ -1441,16 +1441,16 @@ namespace plg { Sentinel last, difference_type n ) { - pointer p = this->_begin + (position - begin()); + pointer p = this->begin_ + (position - begin()); if (n > 0) { - if (n <= this->_cap - this->_end) { - pointer old_last = this->_end; - difference_type dx = this->_end - p; + if (n <= this->cap_ - this->end_) { + pointer old_last = this->end_; + difference_type dx = this->end_ - p; if (n > dx) { #if PLUGIFY_HAS_CXX23 if constexpr (!std::forward_iterator) { construct_at_end(std::move(first), std::move(last), n); - std::rotate(p, old_last, this->_end); + std::rotate(p, old_last, this->end_); } else #endif { @@ -1468,8 +1468,8 @@ namespace plg { } else { split_buffer v( recommend(size() + n), - p - this->_begin, - this->_alloc + p - this->begin_, + this->alloc_ ); v.construct_at_end_with_size(std::move(first), n); p = swap_out_circular_buffer(v, p); @@ -1484,7 +1484,7 @@ namespace plg { if (cs < sz) { this->append(sz - cs); } else if (cs > sz) { - this->destruct_at_end(this->_begin + sz); + this->destruct_at_end(this->begin_ + sz); } } @@ -1495,7 +1495,7 @@ namespace plg { if (cs < sz) { this->append(sz - cs, x); } else if (cs > sz) { - this->destruct_at_end(this->_begin + sz); + this->destruct_at_end(this->begin_ + sz); } } @@ -1504,30 +1504,30 @@ namespace plg { noexcept { PLUGIFY_ASSERT( - alloc_traits::propagate_on_container_swap::value || this->_alloc == x._alloc, + alloc_traits::propagate_on_container_swap::value || this->alloc_ == x.alloc_, "vector::swap: Either propagate_on_container_swap must be true" " or the allocators must compare equal" ); - std::swap(this->_begin, x._begin); - std::swap(this->_end, x._end); - std::swap(this->_cap, x._cap); - swap_allocator(this->_alloc, x._alloc); + std::swap(this->begin_, x.begin_); + std::swap(this->end_, x.end_); + std::swap(this->cap_, x.cap_); + swap_allocator(this->alloc_, x.alloc_); } template constexpr bool vector::invariants() const { - if (this->_begin == nullptr) { - if (this->_end != nullptr || this->_cap != nullptr) { + if (this->begin_ == nullptr) { + if (this->end_ != nullptr || this->cap_ != nullptr) { return false; } } else { - if (this->_begin > this->_end) { + if (this->begin_ > this->end_) { return false; } - if (this->_begin == this->_cap) { + if (this->begin_ == this->cap_) { return false; } - if (this->_end > this->_cap) { + if (this->end_ > this->cap_) { return false; } } diff --git a/test/example_plugin/external/plugify/include/plg/version.hpp b/test/example_plugin/external/plugify/include/plg/version.hpp index b8e8c00..f3bf16d 100644 --- a/test/example_plugin/external/plugify/include/plg/version.hpp +++ b/test/example_plugin/external/plugify/include/plg/version.hpp @@ -91,38 +91,38 @@ namespace plg { constexpr version& operator=(const version&) = default; constexpr version& operator=(version&&) = default; - constexpr I1 major() const noexcept { return _major; } - constexpr I2 minor() const noexcept { return _minor; } - constexpr I3 patch() const noexcept { return _patch; } + constexpr I1 major() const noexcept { return major_; } + constexpr I2 minor() const noexcept { return minor_; } + constexpr I3 patch() const noexcept { return patch_; } - constexpr const string& prerelease_tag() const { return _prerelease_tag; } - constexpr const string& build_metadata() const { return _build_metadata; } + constexpr const string& prerelease_tag() const { return prerelease_tag_; } + constexpr const string& build_metadata() const { return build_metadata_; } constexpr string to_string() const; private: - I1 _major = 0; - I2 _minor = 1; - I3 _patch = 0; - string _prerelease_tag; - string _build_metadata; + I1 major_ = 0; + I2 minor_ = 1; + I3 patch_ = 0; + string prerelease_tag_; + string build_metadata_; - vector _prerelease_identifiers; + vector prerelease_identifiers_; constexpr std::size_t length() const noexcept { - return detail::length(_major) + detail::length(_minor) + detail::length(_patch) + 2 - + (_prerelease_tag.empty() ? 0 : _prerelease_tag.length() + 1) - + (_build_metadata.empty() ? 0 : _build_metadata.length() + 1); + return detail::length(major_) + detail::length(minor_) + detail::length(patch_) + 2 + + (prerelease_tag_.empty() ? 0 : prerelease_tag_.length() + 1) + + (build_metadata_.empty() ? 0 : build_metadata_.length() + 1); } constexpr void clear() noexcept { - _major = 0; - _minor = 1; - _patch = 0; + major_ = 0; + minor_ = 1; + patch_ = 0; - _prerelease_tag.clear(); - _prerelease_identifiers.clear(); - _build_metadata.clear(); + prerelease_tag_.clear(); + prerelease_identifiers_.clear(); + build_metadata_.clear(); } }; @@ -132,23 +132,23 @@ namespace plg { detail::resize_uninitialized{}.resize(result, length()); auto* it = result.end(); - if (!_build_metadata.empty()) { - it = std::copy_backward(_build_metadata.begin(), _build_metadata.end(), it); + if (!build_metadata_.empty()) { + it = std::copy_backward(build_metadata_.begin(), build_metadata_.end(), it); *(--it) = '+'; } - if (!_prerelease_tag.empty()) { - it = std::copy_backward(_prerelease_tag.begin(), _prerelease_tag.end(), it); + if (!prerelease_tag_.empty()) { + it = std::copy_backward(prerelease_tag_.begin(), prerelease_tag_.end(), it); *(--it) = '-'; } - it = detail::to_chars(it, _patch); + it = detail::to_chars(it, patch_); *(--it) = '.'; - it = detail::to_chars(it, _minor); + it = detail::to_chars(it, minor_); *(--it) = '.'; - it = detail::to_chars(it, _major); + it = detail::to_chars(it, major_); return result; } @@ -273,28 +273,28 @@ namespace plg { class token_stream { public: constexpr token_stream() = default; - constexpr explicit token_stream(vector tokens) noexcept : _tokens(std::move(tokens)) {} + constexpr explicit token_stream(vector tokens) noexcept : tokens_(std::move(tokens)) {} constexpr void push(const token& token) noexcept { - _tokens.push_back(token); + tokens_.push_back(token); } constexpr token advance() noexcept { - const token token = get(_current); - ++_current; + const token token = get(current_); + ++current_; return token; } constexpr token peek(std::size_t k = 0) const noexcept { - return get(_current + k); + return get(current_ + k); } constexpr token previous() const noexcept { - return get(_current - 1); + return get(current_ - 1); } constexpr bool advance_if_match(token& token, token_type type) noexcept { - if (get(_current).type != type) { + if (get(current_).type != type) { return false; } @@ -316,20 +316,20 @@ namespace plg { } private: - std::size_t _current = 0; - vector _tokens; + std::size_t current_ = 0; + vector tokens_; constexpr token get(std::size_t i) const noexcept { - return _tokens[i]; + return tokens_[i]; } }; class lexer { public: - explicit constexpr lexer(std::string_view text) noexcept : _text{text}, _current_pos{0} {} + explicit constexpr lexer(std::string_view text) noexcept : text_{text}, current_pos_{0} {} constexpr from_chars_result scan_tokens(token_stream& token_stream) noexcept { - from_chars_result result{ _text.data(), std::errc{} }; + from_chars_result result{ text_.data(), std::errc{} }; while (!is_eol()) { result = scan_token(token_stream); @@ -338,14 +338,14 @@ namespace plg { } } - token_stream.push({ token_type::eol, {}, _text.data() + _text.size() }); + token_stream.push({ token_type::eol, {}, text_.data() + text_.size() }); return result; } private: - std::string_view _text; - std::size_t _current_pos; + std::string_view text_; + std::size_t current_pos_; constexpr from_chars_result scan_token(token_stream& stream) noexcept { const char c = advance(); @@ -399,8 +399,8 @@ namespace plg { } constexpr char advance() noexcept { - char c = _text[_current_pos]; - _current_pos += 1; + char c = text_[current_pos_]; + current_pos_ += 1; return c; } @@ -409,40 +409,40 @@ namespace plg { return false; } - if (_text[_current_pos] != c) { + if (text_[current_pos_] != c) { return false; } - _current_pos += 1; + current_pos_ += 1; return true; } constexpr const char* get_prev_symbol() const noexcept { - return _text.data() + _current_pos - 1; + return text_.data() + current_pos_ - 1; } - constexpr bool is_eol() const noexcept { return _current_pos >= _text.size(); } + constexpr bool is_eol() const noexcept { return current_pos_ >= text_.size(); } }; class prerelease_comparator { public: template [[nodiscard]] constexpr int compare(const version& lhs, const version& rhs) const noexcept { - if (lhs._prerelease_identifiers.empty() != rhs._prerelease_identifiers.empty()) { - return static_cast(rhs._prerelease_identifiers.size()) - static_cast(lhs._prerelease_identifiers.size()); + if (lhs.prerelease_identifiers_.empty() != rhs.prerelease_identifiers_.empty()) { + return static_cast(rhs.prerelease_identifiers_.size()) - static_cast(lhs.prerelease_identifiers_.size()); } - const std::size_t count = std::min(lhs._prerelease_identifiers.size(), rhs._prerelease_identifiers.size()); + const std::size_t count = std::min(lhs.prerelease_identifiers_.size(), rhs.prerelease_identifiers_.size()); for (std::size_t i = 0; i < count; ++i) { - const int compare_result = compare_identifier(lhs._prerelease_identifiers[i], rhs._prerelease_identifiers[i]); + const int compare_result = compare_identifier(lhs.prerelease_identifiers_[i], rhs.prerelease_identifiers_[i]); if (compare_result != 0) { return compare_result; } } - return static_cast(lhs._prerelease_identifiers.size()) - static_cast(rhs._prerelease_identifiers.size()); + return static_cast(lhs.prerelease_identifiers_.size()) - static_cast(rhs.prerelease_identifiers_.size()); } private: @@ -459,45 +459,45 @@ namespace plg { class version_parser { public: - constexpr explicit version_parser(token_stream& stream) : _stream{stream} { + constexpr explicit version_parser(token_stream& stream) : stream_{stream} { } template constexpr from_chars_result parse(version& out) noexcept { out.clear(); - from_chars_result result = parse_number(out._major); + from_chars_result result = parse_number(out.major_); if (!result) { return result; } - if (!_stream.consume(token_type::dot)) { - return failure(_stream.previous().lexeme); + if (!stream_.consume(token_type::dot)) { + return failure(stream_.previous().lexeme); } - result = parse_number(out._minor); + result = parse_number(out.minor_); if (!result) { return result; } - if (!_stream.consume(token_type::dot)) { - return failure(_stream.previous().lexeme); + if (!stream_.consume(token_type::dot)) { + return failure(stream_.previous().lexeme); } - result = parse_number(out._patch); + result = parse_number(out.patch_); if (!result) { return result; } - if (_stream.advance_if_match(token_type::hyphen)) { - result = parse_prerelease_tag(out._prerelease_tag, out._prerelease_identifiers); + if (stream_.advance_if_match(token_type::hyphen)) { + result = parse_prerelease_tag(out.prerelease_tag_, out.prerelease_identifiers_); if (!result) { return result; } } - if (_stream.advance_if_match(token_type::plus)) { - result = parse_build_metadata(out._build_metadata); + if (stream_.advance_if_match(token_type::plus)) { + result = parse_build_metadata(out.build_metadata_); if (!result) { return result; } @@ -508,11 +508,11 @@ namespace plg { private: - token_stream& _stream; + token_stream& stream_; template constexpr from_chars_result parse_number(Int& out) { - token token = _stream.advance(); + token token = stream_.advance(); if (!is_digit(token)) { return failure(token.lexeme); @@ -523,16 +523,16 @@ namespace plg { if (first_digit == 0) { out = static_cast(result); - return success(_stream.peek().lexeme); + return success(stream_.peek().lexeme); } - while (_stream.advance_if_match(token, token_type::digit)) { + while (stream_.advance_if_match(token, token_type::digit)) { result = result * 10 + std::get(token.value); } if (detail::number_in_range(result)) { out = static_cast(result); - return success(_stream.peek().lexeme); + return success(stream_.peek().lexeme); } return failure(token.lexeme, std::errc::result_out_of_range); @@ -554,10 +554,10 @@ namespace plg { result.append(identifier); out_identifiers.push_back(make_prerelease_identifier(identifier)); - } while (_stream.advance_if_match(token_type::dot)); + } while (stream_.advance_if_match(token_type::dot)); out = result; - return success(_stream.peek().lexeme); + return success(stream_.peek().lexeme); } constexpr from_chars_result parse_build_metadata(string& out) { @@ -574,15 +574,15 @@ namespace plg { } result.append(identifier); - } while (_stream.advance_if_match(token_type::dot)); + } while (stream_.advance_if_match(token_type::dot)); out = result; - return success(_stream.peek().lexeme); + return success(stream_.peek().lexeme); } constexpr from_chars_result parse_prerelease_identifier(string& out) { string result; - token token = _stream.advance(); + token token = stream_.advance(); do { switch (token.type) { @@ -613,10 +613,10 @@ namespace plg { default: return failure(token.lexeme); } - } while (_stream.advance_if_match(token, token_type::hyphen) || _stream.advance_if_match(token, token_type::letter) || _stream.advance_if_match(token, token_type::digit)); + } while (stream_.advance_if_match(token, token_type::hyphen) || stream_.advance_if_match(token, token_type::letter) || stream_.advance_if_match(token, token_type::digit)); out = result; - return success(_stream.peek().lexeme); + return success(stream_.peek().lexeme); } constexpr detail::prerelease_identifier make_prerelease_identifier(const string& identifier) { @@ -632,7 +632,7 @@ namespace plg { constexpr from_chars_result parse_build_identifier(string& out) { string result; - token token = _stream.advance(); + token token = stream_.advance(); do { switch (token.type) { @@ -651,10 +651,10 @@ namespace plg { default: return failure(token.lexeme); } - } while (_stream.advance_if_match(token, token_type::hyphen) || _stream.advance_if_match(token, token_type::letter) || _stream.advance_if_match(token, token_type::digit)); + } while (stream_.advance_if_match(token, token_type::hyphen) || stream_.advance_if_match(token, token_type::letter) || stream_.advance_if_match(token, token_type::digit)); out = result; - return success(_stream.peek().lexeme); + return success(stream_.peek().lexeme); } constexpr bool is_leading_zero(int digit) noexcept { @@ -667,7 +667,7 @@ namespace plg { int digits = 0; while (true) { - const token token = _stream.peek(k); + const token token = stream_.peek(k); if (!is_alphanumeric(token)) { break; @@ -803,44 +803,44 @@ namespace plg { template class range_comparator { public: - constexpr range_comparator(const version& v, range_operator op) noexcept : _v(v), _op(op) {} + constexpr range_comparator(const version& v, range_operator op) noexcept : v_(v), op_(op) {} constexpr bool contains(const version& other) const noexcept { - switch (_op) { + switch (op_) { case range_operator::less: - return detail::compare_parsed(other, _v, version_compare_option::include_prerelease) < 0; + return detail::compare_parsed(other, v_, version_compare_option::include_prerelease) < 0; case range_operator::less_or_equal: - return detail::compare_parsed(other, _v, version_compare_option::include_prerelease) <= 0; + return detail::compare_parsed(other, v_, version_compare_option::include_prerelease) <= 0; case range_operator::greater: - return detail::compare_parsed(other, _v, version_compare_option::include_prerelease) > 0; + return detail::compare_parsed(other, v_, version_compare_option::include_prerelease) > 0; case range_operator::greater_or_equal: - return detail::compare_parsed(other, _v, version_compare_option::include_prerelease) >= 0; + return detail::compare_parsed(other, v_, version_compare_option::include_prerelease) >= 0; case range_operator::equal: - return detail::compare_parsed(other, _v, version_compare_option::include_prerelease) == 0; + return detail::compare_parsed(other, v_, version_compare_option::include_prerelease) == 0; } return false; } - constexpr const version& get_version() const noexcept { return _v; } + constexpr const version& get_version() const noexcept { return v_; } - constexpr range_operator get_operator() const noexcept { return _op; } + constexpr range_operator get_operator() const noexcept { return op_; } constexpr string to_string() const { string result; - switch (_op) { + switch (op_) { case range_operator::less: result += "<"; break; case range_operator::less_or_equal: result += "<="; break; case range_operator::greater: result += ">"; break; case range_operator::greater_or_equal: result += ">="; break; case range_operator::equal: result += "="; break; } - result += _v.to_string(); + result += v_.to_string(); return result; } private: - version _v; - range_operator _op; + version v_; + range_operator op_; }; class range_parser; @@ -857,40 +857,40 @@ namespace plg { } } - return std::all_of(_ranges_comparators.begin(), _ranges_comparators.end(), [&](const auto& ranges_comparator) { + return std::all_of(ranges_comparators_.begin(), ranges_comparators_.end(), [&](const auto& ranges_comparator) { return ranges_comparator.contains(v); }); } constexpr auto begin() const noexcept { - return _ranges_comparators.begin(); + return ranges_comparators_.begin(); } constexpr auto end() const noexcept { - return _ranges_comparators.end(); + return ranges_comparators_.end(); } constexpr std::size_t size() const noexcept { - return _ranges_comparators.size(); + return ranges_comparators_.size(); } constexpr bool empty() const noexcept { - return _ranges_comparators.empty(); + return ranges_comparators_.empty(); } constexpr string to_string() const { - return join(_ranges_comparators, " "); + return join(ranges_comparators_, " "); } private: - vector> _ranges_comparators; + vector> ranges_comparators_; constexpr bool match_at_least_one_comparator_with_prerelease(const version& v) const noexcept { if (v.prerelease_tag().empty()) { return true; } - return std::any_of(_ranges_comparators.begin(), _ranges_comparators.end(), [&](const auto& ranges_comparator) { + return std::any_of(ranges_comparators_.begin(), ranges_comparators_.end(), [&](const auto& ranges_comparator) { const bool has_prerelease = !ranges_comparator.get_version().prerelease_tag().empty(); const bool equal_without_prerelease = detail::compare_parsed(v, ranges_comparator.get_version(), version_compare_option::exclude_prerelease) == 0; return has_prerelease && equal_without_prerelease; @@ -905,39 +905,39 @@ namespace plg { friend class detail::range_parser; constexpr bool contains(const version& v, version_compare_option option = version_compare_option::exclude_prerelease) const noexcept { - return std::any_of(_ranges.begin(), _ranges.end(), [&](const auto& range) { + return std::any_of(ranges_.begin(), ranges_.end(), [&](const auto& range) { return range.contains(v, option); }); } constexpr auto begin() const noexcept { - return _ranges.begin(); + return ranges_.begin(); } constexpr auto end() const noexcept { - return _ranges.end(); + return ranges_.end(); } constexpr std::size_t size() const noexcept { - return _ranges.size(); + return ranges_.size(); } constexpr bool empty() const noexcept { - return _ranges.empty(); + return ranges_.empty(); } constexpr string to_string() const { - return join(_ranges, " "); + return join(ranges_, " "); } private: - vector> _ranges; + vector> ranges_; }; namespace detail { class range_parser { public: - constexpr explicit range_parser(token_stream stream) noexcept : _stream(std::move(stream)) {} + constexpr explicit range_parser(token_stream stream) noexcept : stream_(std::move(stream)) {} template constexpr from_chars_result parse(range_set& out) noexcept { @@ -953,54 +953,54 @@ namespace plg { ranges.push_back(range); skip_whitespaces(); - } while (_stream.advance_if_match(token_type::logical_or)); + } while (stream_.advance_if_match(token_type::logical_or)); - out._ranges = std::move(ranges); + out.ranges_ = std::move(ranges); - return success(_stream.peek().lexeme); + return success(stream_.peek().lexeme); } private: - token_stream _stream; + token_stream stream_; template constexpr from_chars_result parse_range(detail::range& out) noexcept { do { skip_whitespaces(); - if (const auto res = parse_range_comparator(out._ranges_comparators); !res) { + if (const auto res = parse_range_comparator(out.ranges_comparators_); !res) { return res; } skip_whitespaces(); - } while (_stream.check(token_type::range_operator) || _stream.check(token_type::digit)); + } while (stream_.check(token_type::range_operator) || stream_.check(token_type::digit)); - return success(_stream.peek().lexeme); + return success(stream_.peek().lexeme); } template constexpr from_chars_result parse_range_comparator(vector>& out) noexcept { range_operator op = range_operator::equal; token token; - if (_stream.advance_if_match(token, token_type::range_operator)) { + if (stream_.advance_if_match(token, token_type::range_operator)) { op = std::get(token.value); } skip_whitespaces(); version ver; - version_parser parser{ _stream }; + version_parser parser{ stream_ }; if (const auto res = parser.parse(ver); !res) { return res; } out.emplace_back(ver, op); - return success(_stream.peek().lexeme); + return success(stream_.peek().lexeme); } constexpr void skip_whitespaces() noexcept { - while (_stream.advance_if_match(token_type::space)) { + while (stream_.advance_if_match(token_type::space)) { ; } } From 4248438f85e2d6332527765c9723781547f26b07 Mon Sep 17 00:00:00 2001 From: qubka Date: Sat, 1 Nov 2025 12:00:39 +0000 Subject: [PATCH 03/16] fix: add clang doc parser --- generator/clang_doc_parser.py | 539 ++++++++++++++++++++++++++++++++++ 1 file changed, 539 insertions(+) create mode 100644 generator/clang_doc_parser.py diff --git a/generator/clang_doc_parser.py b/generator/clang_doc_parser.py new file mode 100644 index 0000000..a70f6e9 --- /dev/null +++ b/generator/clang_doc_parser.py @@ -0,0 +1,539 @@ +#!/usr/bin/python3 +import argparse +import json +import yaml +import os +import re +from pathlib import Path + + +def map_type(t: str): + """Map a C++ type to a more user-friendly format.""" + switch_dict = { + 'plg::string': 'string', + 'plg::vector': 'string[]', + 'plg::str': 'string', + 'plg::any': 'any', + 'plg::vector': 'any[]', + + 'void': 'void', + 'bool': 'bool', + 'float': 'float', + 'double': 'double', + 'void*': 'ptr64', + 'char': 'char8', + 'signed char': 'char8', + 'char16_t': 'char16', + 'int8_t': 'int8', + 'int8': 'int8', + 'int16_t': 'int16', + 'int16': 'int16', + 'short': 'int16', + 'int32_t': 'int32', + 'int32': 'int32', + 'int': 'int32', + 'long': 'int32', + 'int64_t': 'int64', + 'int64': 'int64', + '__int64': 'int64', + 'long long': 'int64', + 'uint8_t': 'uint8', + 'uint8': 'uint8', + 'unsigned char': 'uint8', + 'byte': 'uint8', + 'uint16_t': 'uint16', + 'uint16': 'uint16', + 'unsigned short': 'uint16', + 'uint32_t': 'uint32', + 'uint32': 'uint32', + 'unsigned int': 'uint32', + 'unsigned long': 'uint32', + 'uint64_t': 'uint64', + 'uint64': 'uint64', + 'unsigned __int64': 'uint64', + 'unsigned long long': 'uint64', + + 'plg::vector': 'bool[]', + 'plg::vector': 'float[]', + 'plg::vector': 'double[]', + 'plg::vector': 'ptr64[]', + 'plg::vector': 'char16[]', + 'plg::vector': 'int8[]', + 'plg::vector': 'int8[]', + 'plg::vector': 'int16[]', + 'plg::vector': 'int16[]', + 'plg::vector': 'int16[]', + 'plg::vector': 'int32[]', + 'plg::vector': 'int32[]', + 'plg::vector': 'int32[]', + 'plg::vector': 'int32[]', + 'plg::vector': 'int64[]', + 'plg::vector': 'int64[]', + 'plg::vector<__int64>': 'int64[]', + 'plg::vector': 'int64[]', + 'plg::vector': 'uint8[]', + 'plg::vector': 'uint8[]', + 'plg::vector': 'uint8[]', + 'plg::vector': 'uint8[]', + 'plg::vector': 'uint16[]', + 'plg::vector': 'uint16[]', + 'plg::vector': 'uint16[]', + 'plg::vector': 'uint32[]', + 'plg::vector': 'uint32[]', + 'plg::vector': 'uint32[]', + 'plg::vector': 'uint32[]', + 'plg::vector': 'uint64[]', + 'plg::vector': 'uint64[]', + 'plg::vector': 'uint64[]', + 'plg::vector': 'uint64[]', + + 'plg::vector': 'vec3[]', + 'plg::vector': 'vec3[]', + 'plg::vector': 'vec3[]', + 'plg::vector': 'vec3[]', + 'plg::vector': 'vec3[]', + 'plg::vector': 'vec3[]', + 'plg::vector': 'vec3[]', + + 'plg::vector': 'vec2[]', + 'plg::vector': 'vec2[]', + 'plg::vector': 'vec2[]', + 'plg::vector': 'vec2[]', + 'plg::vector': 'vec2[]', + + 'plg::vector': 'vec4[]', + 'plg::vector': 'vec4[]', + 'plg::vector': 'vec4[]', + 'plg::vector': 'vec4[]', + 'plg::vector': 'vec4[]', + + 'plg::vector': 'mat4x4[]', + 'plg::vector': 'mat4x4[]', + 'plg::vector': 'mat4x4[]', + 'plg::vector': 'mat4x4[]', + + 'CPlayerSlot': 'int32', + 'CEntityHandle': 'int32', + 'Handle': 'uint64', + 'ConVarHandle': 'uint64', + 'plg::vector': 'uint64[]', + + 'plg::vec3': 'vec3', + 'vec3': 'vec3', + 'Vector': 'vec3', + 'QAngle': 'vec3', + 'Vector3D': 'vec3', + 'Vector3': 'vec3', + 'Vector3f': 'vec3', + + 'Vector2D': 'vec2', + 'plg::vec2': 'vec2', + 'vec2': 'vec2', + 'Vector2': 'vec2', + 'Vector2f': 'vec2', + + 'Vector4D': 'vec4', + 'plg::vec4': 'vec4', + 'vec4': 'vec4', + 'Vector4': 'vec4', + 'Vector4f': 'vec4', + + 'plg::mat4x4': 'mat4x4', + 'Matrix': 'mat4x4', + 'Matrix4x4': 'mat4x4', + 'mat4x4': 'mat4x4', + } + return switch_dict.get(t, '?') + + +def convert_type(type_str: str, enums_map: dict, typedefs_map: dict): + """ + Convert type string into its mapped type and reference flag. + Returns (mapped_type, is_reference) + """ + if not type_str: + return '?', False + + const = False + t = type_str.strip() + + # Remove const qualifier + if t.startswith('const '): + t = t[len('const '):] + const = True + + # Handle pointers + if t.endswith('*'): + return 'ptr64', False + + # Handle references + elif t.endswith('&'): + base_type = t[:-1].strip() + if base_type.startswith('const '): + base_type = base_type[len('const '):] + const = True + + # Check if it's an enum + if base_type in enums_map: + mapped = enums_map[base_type].get('BaseType', '?') + return mapped, not const + + # Check if it's a typedef + if base_type in typedefs_map: + return '?', not const # Typedefs usually stay as '?' + + return map_type(base_type), not const + + # Check if it's an enum + if t in enums_map: + return enums_map[t].get('BaseType', '?'), False + + # Check if it's a typedef + if t in typedefs_map: + return '?', False # Typedefs usually stay as '?' + + return map_type(t), False + + +def extract_text_from_description(description): + """ + Extract text content from clang-doc's structured description format. + Handles nested Children structures. + """ + if not description: + return "" + + texts = [] + + def traverse(node): + if isinstance(node, dict): + kind = node.get('Kind', '') + + # Extract direct text + if 'Text' in node: + text = node['Text'].strip() + if text: + texts.append(text) + + # Traverse children + if 'Children' in node: + for child in node['Children']: + traverse(child) + elif isinstance(node, list): + for item in node: + traverse(item) + + traverse(description) + return ' '.join(texts) + + +def extract_brief_description(description): + """Extract the brief description from the function's Description field.""" + if not description or not isinstance(description, list): + return None + + # Handle FullComment wrapper + for item in description: + if isinstance(item, dict) and item.get('Kind') == 'FullComment': + children = item.get('Children', []) + for child in children: + if isinstance(child, dict) and child.get('Kind') == 'BlockCommandComment': + if child.get('Name') == 'brief': + return extract_text_from_description(child.get('Children', [])) + + # Fallback: look directly for BlockCommandComment + for item in description: + if isinstance(item, dict) and item.get('Kind') == 'BlockCommandComment': + if item.get('Name') == 'brief': + return extract_text_from_description(item.get('Children', [])) + + return None + + +def extract_param_descriptions(description): + """Extract parameter descriptions from the function's Description field.""" + if not description or not isinstance(description, list): + return {} + + param_descriptions = {} + + # Handle FullComment wrapper + children_to_search = [] + for item in description: + if isinstance(item, dict) and item.get('Kind') == 'FullComment': + children_to_search = item.get('Children', []) + break + + # Fallback: search description directly + if not children_to_search: + children_to_search = description + + for item in children_to_search: + if isinstance(item, dict) and item.get('Kind') == 'ParamCommandComment': + param_name = item.get('ParamName') + if param_name: + desc_text = extract_text_from_description(item.get('Children', [])) + if desc_text: + param_descriptions[param_name] = desc_text + + return param_descriptions + + +def extract_return_description(description): + """Extract the return description from the function's Description field.""" + if not description or not isinstance(description, list): + return None + + # Handle FullComment wrapper + children_to_search = [] + for item in description: + if isinstance(item, dict) and item.get('Kind') == 'FullComment': + children_to_search = item.get('Children', []) + break + + # Fallback: search description directly + if not children_to_search: + children_to_search = description + + for item in children_to_search: + if isinstance(item, dict) and item.get('Kind') == 'BlockCommandComment': + if item.get('Name') == 'return': + return extract_text_from_description(item.get('Children', [])) + + return None + + +def build_enums_map(yaml_data): + """Build a map of enum names to their base types.""" + enums_map = {} + + if 'ChildEnums' in yaml_data: + for enum in yaml_data['ChildEnums']: + enum_name = enum.get('Name') + base_type_info = enum.get('BaseType', {}) + base_type = base_type_info.get('Type', {}).get('Name', 'int32') + + if enum_name: + enums_map[enum_name] = { + 'BaseType': map_type(base_type), + 'USR': enum.get('USR') + } + + return enums_map + + +def build_typedefs_map(yaml_data): + """Build a map of typedef names.""" + typedefs_map = {} + + if 'ChildTypedefs' in yaml_data: + for typedef in yaml_data['ChildTypedefs']: + typedef_name = typedef.get('Name') + if typedef_name: + typedefs_map[typedef_name] = { + 'Underlying': typedef.get('Underlying', {}).get('Name', '?'), + 'USR': typedef.get('USR') + } + + return typedefs_map + + +def process_function(function, enums_map, typedefs_map, group_name=None): + """Process a single function and convert it to the desired JSON format.""" + + # Extract function name + func_name = function.get('Name', 'Unknown') + + # Extract location info for group determination + def_location = function.get('DefLocation', {}) + filename = def_location.get('Filename', '') + + # Determine group name from filename if not provided + if not group_name and filename: + base_name = os.path.splitext(os.path.basename(filename))[0] + group_name = base_name.lower().capitalize() + + # Extract descriptions - handle both list and dict formats + description = function.get('Description') + if isinstance(description, dict): + description = description.get('Children', []) + elif not isinstance(description, list): + description = [] + + brief_desc = extract_brief_description(description) + param_descriptions = extract_param_descriptions(description) + return_desc = extract_return_description(description) + + # Process parameters + param_types = [] + params = function.get('Params', []) + + for param in params: + param_type_info = param.get('Type', {}) + param_type_name = param_type_info.get('QualName') or param_type_info.get('Name', '?') + param_name = param.get('Name', 'unknown') + + # Convert type + mapped_type, is_ref = convert_type(param_type_name, enums_map, typedefs_map) + + param_data = { + 'name': param_name, + 'type': mapped_type, + 'ref': is_ref + } + + # Add description if available + if param_name in param_descriptions: + param_data['description'] = param_descriptions[param_name] + + param_types.append(param_data) + + # Process return type + return_type_info = function.get('ReturnType', {}).get('Type', {}) + return_type_name = return_type_info.get('QualName') or return_type_info.get('Name', 'void') + mapped_return_type, _ = convert_type(return_type_name, enums_map, typedefs_map) + + ret_type = { + 'type': mapped_return_type + } + + if return_desc: + ret_type['description'] = return_desc + + # Build final function data + function_data = { + 'name': func_name, + 'funcName': func_name, + 'paramTypes': param_types, + 'retType': ret_type + } + + if group_name: + function_data['group'] = group_name + + if brief_desc: + function_data['description'] = brief_desc + + return function_data + + +def filter_functions(functions, name_filter=None, file_prefix=None): + """Filter functions by name or filename prefix.""" + filtered = [] + + for func in functions: + # Check name filter + if name_filter and name_filter.lower() not in func.get('name', '').lower(): + continue + + # Check file prefix filter + if file_prefix: + def_location = func.get('DefLocation', {}) + filename = def_location.get('Filename', '') + basename = os.path.basename(filename) + + if not basename.startswith(file_prefix): + continue + + filtered.append(func) + + return filtered + + +def process_yaml_file(yaml_file, name_filter=None, file_prefix=None): + """Process a single YAML file and extract functions.""" + with open(yaml_file, 'r') as f: + yaml_data = yaml.safe_load(f) + + if not yaml_data: + return [] + + # Build lookup maps + enums_map = build_enums_map(yaml_data) + typedefs_map = build_typedefs_map(yaml_data) + + # Process functions + all_functions = [] + + if 'ChildFunctions' in yaml_data: + for function in yaml_data['ChildFunctions']: + # Apply filters at the raw level + func_name = function.get('Name', '') + def_location = function.get('DefLocation', {}) + filename = def_location.get('Filename', '') + basename = os.path.basename(filename) + + # Check name filter + if name_filter and name_filter.lower() not in func_name.lower(): + continue + + # Check file prefix filter + if file_prefix and not basename.startswith(file_prefix): + continue + + # Process the function + func_data = process_function(function, enums_map, typedefs_map) + all_functions.append(func_data) + print(f'Processed: {func_name}') + + return all_functions + + +def main(input_path, output_file, name_filter=None, file_prefix=None): + """Main function to process YAML files and generate JSON output.""" + all_exported_methods = [] + + # Check if input is a file or directory + input_path_obj = Path(input_path) + + if input_path_obj.is_file(): + # Process single YAML file + all_exported_methods = process_yaml_file(input_path, name_filter, file_prefix) + elif input_path_obj.is_dir(): + # Process all YAML files in directory + for yaml_file in input_path_obj.glob('*.yaml'): + print(f'\nProcessing: {yaml_file}') + functions = process_yaml_file(yaml_file, name_filter, file_prefix) + all_exported_methods.extend(functions) + else: + print(f"Error: {input_path} is neither a file nor a directory") + return + + # Write output + with open(output_file, 'w') as f: + json.dump(all_exported_methods, f, indent=4) + + print(f'\nTotal functions exported: {len(all_exported_methods)}') + print(f'Output written to: {output_file}') + + +def get_args(): + parser = argparse.ArgumentParser( + description='Parse clang-doc YAML output and generate JSON for exported functions' + ) + parser.add_argument( + 'input_path', + help='Path to YAML file or directory containing YAML files' + ) + parser.add_argument( + 'output_file', + help='JSON file to output the processed results' + ) + parser.add_argument( + '--name-filter', + '-n', + help='Filter functions by name (case-insensitive substring match)', + default=None + ) + parser.add_argument( + '--file-prefix', + '-f', + help='Filter functions by source filename prefix', + default=None + ) + return parser.parse_args() + + +if __name__ == "__main__": + args = get_args() + main(args.input_path, args.output_file, args.name_filter, args.file_prefix) \ No newline at end of file From 95afaff4590ac1f73df5f14be9749559f6fe4f40 Mon Sep 17 00:00:00 2001 From: qubka Date: Sat, 1 Nov 2025 19:46:02 +0000 Subject: [PATCH 04/16] fix: add clang doc parser --- .../{clang_doc_parser.py => parser/parser.py} | 315 ++++++++++++++++-- .../parser_deprecated.py} | 2 + 2 files changed, 288 insertions(+), 29 deletions(-) rename generator/{clang_doc_parser.py => parser/parser.py} (59%) rename generator/{parser.py => parser/parser_deprecated.py} (99%) diff --git a/generator/clang_doc_parser.py b/generator/parser/parser.py similarity index 59% rename from generator/clang_doc_parser.py rename to generator/parser/parser.py index a70f6e9..e2d7ff7 100644 --- a/generator/clang_doc_parser.py +++ b/generator/parser/parser.py @@ -21,6 +21,8 @@ def map_type(t: str): 'float': 'float', 'double': 'double', 'void*': 'ptr64', + 'uintptr_t': 'ptr64', + 'intptr_t': 'ptr64', 'char': 'char8', 'signed char': 'char8', 'char16_t': 'char16', @@ -137,6 +139,7 @@ def map_type(t: str): 'vec4': 'vec4', 'Vector4': 'vec4', 'Vector4f': 'vec4', + 'Quaternion': 'vec4', 'plg::mat4x4': 'mat4x4', 'Matrix': 'mat4x4', @@ -179,8 +182,8 @@ def convert_type(type_str: str, enums_map: dict, typedefs_map: dict): return mapped, not const # Check if it's a typedef - if base_type in typedefs_map: - return '?', not const # Typedefs usually stay as '?' + #if base_type in typedefs_map: + # return '?', not const # Typedefs usually stay as '?' return map_type(base_type), not const @@ -189,8 +192,8 @@ def convert_type(type_str: str, enums_map: dict, typedefs_map: dict): return enums_map[t].get('BaseType', '?'), False # Check if it's a typedef - if t in typedefs_map: - return '?', False # Typedefs usually stay as '?' + #if t in typedefs_map: + # return '?', False # Typedefs usually stay as '?' return map_type(t), False @@ -303,8 +306,36 @@ def extract_return_description(description): return None +def extract_enum_description(description): + """Extract enum description from Description field.""" + if not description or not isinstance(description, list): + return None + + # Handle FullComment wrapper + children_to_search = [] + for item in description: + if isinstance(item, dict) and item.get('Kind') == 'FullComment': + children_to_search = item.get('Children', []) + break + + if not children_to_search: + children_to_search = description + + # Look for brief or first paragraph + for item in children_to_search: + if isinstance(item, dict): + if item.get('Kind') == 'BlockCommandComment' and item.get('Name') == 'brief': + return extract_text_from_description(item.get('Children', [])) + elif item.get('Kind') == 'ParagraphComment': + text = extract_text_from_description(item.get('Children', [])) + if text: + return text + + return None + + def build_enums_map(yaml_data): - """Build a map of enum names to their base types.""" + """Build a map of enum names to their base types and full structure.""" enums_map = {} if 'ChildEnums' in yaml_data: @@ -314,30 +345,235 @@ def build_enums_map(yaml_data): base_type = base_type_info.get('Type', {}).get('Name', 'int32') if enum_name: + # Extract enum description + enum_description = extract_enum_description(enum.get('Description', [])) + + # Extract enum values + enum_values = [] + members = enum.get('Members', []) + for member in members: + member_name = member.get('Name') + member_value = member.get('Value') + + # Try to parse value as integer + try: + member_value = int(member_value) if member_value is not None else None + except (ValueError, TypeError): + pass + + # Extract member description if available + member_desc = extract_text_from_description(member.get('Description', [])) + + value_entry = { + 'name': member_name, + 'value': member_value + } + + if member_desc: + value_entry['description'] = member_desc + + enum_values.append(value_entry) + enums_map[enum_name] = { 'BaseType': map_type(base_type), - 'USR': enum.get('USR') + 'USR': enum.get('USR'), + 'Name': enum_name, + 'Description': enum_description, + 'Values': enum_values } return enums_map -def build_typedefs_map(yaml_data): - """Build a map of typedef names.""" +def parse_function_pointer_signature(signature: str): + """ + Parse a function pointer signature string. + Example: 'ResultType (*)(int, CommandCallingContext, const plg::vector &)' + Returns: (return_type, [param_types]) + """ + if not signature or '(*)' not in signature: + return None, [] + + # Extract return type (everything before '(*)') + return_type_match = re.match(r'^\s*(.+?)\s*\(\*\)', signature) + if not return_type_match: + return None, [] + + return_type = return_type_match.group(1).strip() + + # Extract parameters (everything after '(*)') + params_start = signature.find('(*)') + 3 + params_str = signature[params_start:].strip() + + if not params_str.startswith('(') or not params_str.endswith(')'): + return return_type, [] + + # Remove outer parentheses + params_str = params_str[1:-1].strip() + + if not params_str or params_str == 'void': + return return_type, [] + + # Parse parameters - this is tricky due to nested templates and pointers + params = [] + current_param = "" + depth = 0 # Track < > nesting + + for char in params_str: + if char == '<': + depth += 1 + current_param += char + elif char == '>': + depth -= 1 + current_param += char + elif char == ',' and depth == 0: + # Found a parameter separator + if current_param.strip(): + params.append(current_param.strip()) + current_param = "" + else: + current_param += char + + # Don't forget the last parameter + if current_param.strip(): + params.append(current_param.strip()) + + return return_type, params + + +def build_typedefs_map(yaml_data, enums_map): + """Build a map of typedef names with parsed function signatures.""" typedefs_map = {} if 'ChildTypedefs' in yaml_data: for typedef in yaml_data['ChildTypedefs']: typedef_name = typedef.get('Name') + underlying_name = typedef.get('Underlying', {}).get('Name', '') + if typedef_name: - typedefs_map[typedef_name] = { - 'Underlying': typedef.get('Underlying', {}).get('Name', '?'), - 'USR': typedef.get('USR') + typedef_entry = { + 'Underlying': underlying_name, + 'USR': typedef.get('USR'), + 'Description': extract_text_from_description(typedef.get('Description', [])) } + # Check if it's a function pointer + if '(*)' in underlying_name: + return_type, param_types = parse_function_pointer_signature(underlying_name) + typedef_entry['IsFunctionPointer'] = True + typedef_entry['ReturnType'] = return_type + typedef_entry['ParamTypes'] = param_types + else: + typedef_entry['IsFunctionPointer'] = False + + typedefs_map[typedef_name] = typedef_entry + return typedefs_map +def build_enum_structure(enum_name: str, enums_map: dict, filter_sentinel_values=True): + """Build enum structure for inclusion in parameter.""" + if enum_name not in enums_map: + return None + + enum_info = enums_map[enum_name] + + enum_struct = { + 'name': enum_info['Name'] + } + + if enum_info.get('Description'): + enum_struct['description'] = enum_info['Description'] + + # Add values, optionally filtering out sentinel values + sentinel_names = {'Count', 'MAX', 'Max', 'INVALID', 'Invalid', 'NUM', 'Num'} if filter_sentinel_values else set() + + values = [] + for value in enum_info.get('Values', []): + # Filter out sentinel values + if value.get('name') and value.get('name') not in sentinel_names: + value_entry = { + 'name': value['name'], + 'value': value.get('value') + } + if value.get('description'): + value_entry['description'] = value['description'] + values.append(value_entry) + + if values: + enum_struct['values'] = values + + return enum_struct + + +def build_function_prototype(typedef_name: str, typedefs_map: dict, enums_map: dict): + """Build function prototype structure for function pointer typedefs.""" + if typedef_name not in typedefs_map: + return None + + typedef_info = typedefs_map[typedef_name] + + if not typedef_info.get('IsFunctionPointer'): + return None + + prototype = { + 'name': typedef_name, + 'funcName': typedef_name + } + + # Add description if available + if typedef_info.get('Description'): + prototype['description'] = typedef_info['Description'] + + # Process parameters + param_types_list = [] + param_type_names = typedef_info.get('ParamTypes', []) + + for i, param_type_str in enumerate(param_type_names): + # Generate parameter name + param_name = f"param{i+1}" + + # Convert the parameter type + mapped_type, is_ref = convert_type(param_type_str, enums_map, typedefs_map) + + param_data = { + 'name': param_name, + 'type': mapped_type, + 'ref': is_ref + } + + # Check if parameter is an enum and add enum structure + # Extract base type name without const, &, * + base_type_name = param_type_str.replace('const', '').replace('&', '').replace('*', '').strip() + if base_type_name in enums_map: + enum_struct = build_enum_structure(base_type_name, enums_map) + if enum_struct: + param_data['enum'] = enum_struct + + param_types_list.append(param_data) + + prototype['paramTypes'] = param_types_list + + # Process return type + return_type_str = typedef_info.get('ReturnType', 'void') + mapped_return_type, _ = convert_type(return_type_str, enums_map, typedefs_map) + + ret_type = { + 'type': mapped_return_type + } + + # Check if return type is an enum + base_return_type = return_type_str.replace('const', '').replace('&', '').replace('*', '').strip() + if base_return_type in enums_map: + enum_struct = build_enum_structure(base_return_type, enums_map) + if enum_struct: + ret_type['enum'] = enum_struct + + prototype['retType'] = ret_type + + return prototype + + def process_function(function, enums_map, typedefs_map, group_name=None): """Process a single function and convert it to the desired JSON format.""" @@ -376,6 +612,9 @@ def process_function(function, enums_map, typedefs_map, group_name=None): # Convert type mapped_type, is_ref = convert_type(param_type_name, enums_map, typedefs_map) + # Extract base type name for enum/typedef lookup + base_type_name = param_type_name.replace('const', '').replace('&', '').replace('*', '').strip() + param_data = { 'name': param_name, 'type': mapped_type, @@ -386,6 +625,19 @@ def process_function(function, enums_map, typedefs_map, group_name=None): if param_name in param_descriptions: param_data['description'] = param_descriptions[param_name] + # Check if parameter is an enum and add enum structure + if base_type_name in enums_map: + enum_struct = build_enum_structure(base_type_name, enums_map) + if enum_struct: + param_data['enum'] = enum_struct + + # Check if parameter is a function pointer typedef and add prototype + elif base_type_name in typedefs_map and typedefs_map[base_type_name].get('IsFunctionPointer'): + param_data['type'] = 'function' + prototype = build_function_prototype(base_type_name, typedefs_map, enums_map) + if prototype: + param_data['prototype'] = prototype + param_types.append(param_data) # Process return type @@ -400,6 +652,13 @@ def process_function(function, enums_map, typedefs_map, group_name=None): if return_desc: ret_type['description'] = return_desc + # Check if return type is an enum and add enum structure + base_return_type = return_type_name.replace('const', '').replace('&', '').replace('*', '').strip() + if base_return_type in enums_map: + enum_struct = build_enum_structure(base_return_type, enums_map) + if enum_struct: + ret_type['enum'] = enum_struct + # Build final function data function_data = { 'name': func_name, @@ -417,7 +676,7 @@ def process_function(function, enums_map, typedefs_map, group_name=None): return function_data -def filter_functions(functions, name_filter=None, file_prefix=None): +def filter_functions(functions, name_filter=None, file_filter=None): """Filter functions by name or filename prefix.""" filtered = [] @@ -427,12 +686,11 @@ def filter_functions(functions, name_filter=None, file_prefix=None): continue # Check file prefix filter - if file_prefix: + if file_filter: def_location = func.get('DefLocation', {}) - filename = def_location.get('Filename', '') - basename = os.path.basename(filename) + file_name = def_location.get('Filename', '') - if not basename.startswith(file_prefix): + if file_filter and file_filter.lower() not in file_name.lower(): continue filtered.append(func) @@ -440,7 +698,7 @@ def filter_functions(functions, name_filter=None, file_prefix=None): return filtered -def process_yaml_file(yaml_file, name_filter=None, file_prefix=None): +def process_yaml_file(yaml_file, name_filter=None, file_filter=None): """Process a single YAML file and extract functions.""" with open(yaml_file, 'r') as f: yaml_data = yaml.safe_load(f) @@ -448,9 +706,9 @@ def process_yaml_file(yaml_file, name_filter=None, file_prefix=None): if not yaml_data: return [] - # Build lookup maps + # Build lookup maps - enums first, then typedefs (which may reference enums) enums_map = build_enums_map(yaml_data) - typedefs_map = build_typedefs_map(yaml_data) + typedefs_map = build_typedefs_map(yaml_data, enums_map) # Process functions all_functions = [] @@ -460,15 +718,14 @@ def process_yaml_file(yaml_file, name_filter=None, file_prefix=None): # Apply filters at the raw level func_name = function.get('Name', '') def_location = function.get('DefLocation', {}) - filename = def_location.get('Filename', '') - basename = os.path.basename(filename) + file_name = def_location.get('Filename', '') # Check name filter if name_filter and name_filter.lower() not in func_name.lower(): continue - # Check file prefix filter - if file_prefix and not basename.startswith(file_prefix): + # Check file filter + if file_filter and file_filter.lower() not in file_name.lower(): continue # Process the function @@ -479,7 +736,7 @@ def process_yaml_file(yaml_file, name_filter=None, file_prefix=None): return all_functions -def main(input_path, output_file, name_filter=None, file_prefix=None): +def main(input_path, output_file, name_filter=None, file_filter=None): """Main function to process YAML files and generate JSON output.""" all_exported_methods = [] @@ -488,12 +745,12 @@ def main(input_path, output_file, name_filter=None, file_prefix=None): if input_path_obj.is_file(): # Process single YAML file - all_exported_methods = process_yaml_file(input_path, name_filter, file_prefix) + all_exported_methods = process_yaml_file(input_path, name_filter, file_filter) elif input_path_obj.is_dir(): # Process all YAML files in directory for yaml_file in input_path_obj.glob('*.yaml'): print(f'\nProcessing: {yaml_file}') - functions = process_yaml_file(yaml_file, name_filter, file_prefix) + functions = process_yaml_file(yaml_file, name_filter, file_filter) all_exported_methods.extend(functions) else: print(f"Error: {input_path} is neither a file nor a directory") @@ -526,9 +783,9 @@ def get_args(): default=None ) parser.add_argument( - '--file-prefix', + '--file-filter', '-f', - help='Filter functions by source filename prefix', + help='Filter functions by source path prefix', default=None ) return parser.parse_args() @@ -536,4 +793,4 @@ def get_args(): if __name__ == "__main__": args = get_args() - main(args.input_path, args.output_file, args.name_filter, args.file_prefix) \ No newline at end of file + main(args.input_path, args.output_file, args.name_filter, args.file_filter) \ No newline at end of file diff --git a/generator/parser.py b/generator/parser/parser_deprecated.py similarity index 99% rename from generator/parser.py rename to generator/parser/parser_deprecated.py index e29aa2a..30846a9 100644 --- a/generator/parser.py +++ b/generator/parser/parser_deprecated.py @@ -69,6 +69,8 @@ def map_type(t: str): 'float': 'float', 'double': 'double', 'void*': 'ptr64', + 'uintptr_t': 'ptr64', + 'intptr_t': 'ptr64', 'char': 'char8', 'signed char': 'char8', 'char16_t': 'char16', From 5b3ee8d2114367317b4785e6ff0797dc3ac5f24f Mon Sep 17 00:00:00 2001 From: qubka Date: Sat, 1 Nov 2025 19:46:04 +0000 Subject: [PATCH 05/16] fix: add clang doc parser --- generator/parser/README.md | 331 +++++++++++++++++++++++++++++++++++++ 1 file changed, 331 insertions(+) create mode 100644 generator/parser/README.md diff --git a/generator/parser/README.md b/generator/parser/README.md new file mode 100644 index 0000000..a42eef0 --- /dev/null +++ b/generator/parser/README.md @@ -0,0 +1,331 @@ +# Clang-Doc YAML to JSON Parser + +A Python script that parses clang-doc's YAML output and converts it into a structured JSON format suitable for the Plugify project. + +## Overview + +This script replaces the previous parser that used cxxheaderparser to directly parse C++ files with Doxygen comments. The new approach leverages clang-doc's YAML output, which provides more accurate and complete information about functions, enums, and typedefs. + +## Features + +- **Parses clang-doc YAML output**: Extracts function signatures, parameters, return types, and documentation +- **Type mapping**: Converts C++ types to simplified user-friendly types (e.g., `plg::string` → `string`) +- **Enum handling**: Automatically resolves enum types to their base types +- **Enum structure generation**: Includes full enum definitions with values and descriptions +- **Function typedef parsing**: Parses function pointer typedefs and generates complete prototypes +- **Nested enum support**: Handles enums within function prototypes +- **Typedef support**: Identifies and marks typedef parameters +- **Description extraction**: Extracts Doxygen/brief descriptions, parameter descriptions, and return descriptions +- **Filtering**: Filter functions by name or source file prefix +- **Batch processing**: Process single YAML files or entire directories + +## Requirements + +- Python 3.6+ +- PyYAML + +Install dependencies: +```bash +pip install pyyaml +``` + +## Usage + +### Basic Usage + +```bash +python3 clang_doc_parser.py +``` + +**Arguments:** +- `input_path`: Path to a YAML file or directory containing YAML files +- `output_file`: Path to the output JSON file + +### Examples + +1. **Process a single YAML file:** + ```bash + python3 clang_doc_parser.py index.yaml output.json + ``` + +2. **Process all YAML files in a directory:** + ```bash + python3 clang_doc_parser.py ./docs output.json + ``` + +3. **Filter by function name:** + ```bash + python3 clang_doc_parser.py index.yaml output.json --name-filter "Command" + ``` + This will only include functions with "Command" in their name. + +4. **Filter by source file prefix:** + ```bash + python3 clang_doc_parser.py index.yaml output.json --file-filter "commands" + ``` + This will only include functions from files starting with "commands" (e.g., `commands.cpp`). + +5. **Combine filters:** + ```bash + python3 clang_doc_parser.py index.yaml output.json --name-filter "Add" --file-filter "commands" + ``` + +### Command-Line Options + +- `--name-filter` / `-n`: Filter functions by name (case-insensitive substring match) +- `--file-filter` / `-f`: Filter functions by source filename prefix +- `--help` / `-h`: Show help message + +## Integration with CMake + +To integrate clang-doc into your CMake project: + +```cmake +find_program(CLANG_DOC clang-doc) +if(CLANG_DOC) + add_custom_target(docs + COMMAND ${CLANG_DOC} + --executor=all-TUs + -p ${CMAKE_CURRENT_BINARY_DIR} + --output=${CMAKE_CURRENT_SOURCE_DIR}/docs + --extra-arg=-Wno-error + --format=yaml + ${CMAKE_SOURCE_DIR}/src/*.cpp + WORKING_DIRECTORY ${CMAKE_BINARY_DIR} + COMMENT "Generating documentation with clang-doc" + ) +endif() +``` + +Then run: +```bash +cmake --build . --target docs +python3 clang_doc_parser.py docs/index.yaml exported_functions.json +``` + +## Output Format + +The script generates JSON with comprehensive type information including enum structures and function prototypes. + +### Basic Function Example + +```json +{ + "name": "AddAdminCommand", + "group": "Commands", + "description": "Creates a console command as an administrative command.", + "funcName": "AddAdminCommand", + "paramTypes": [ + { + "name": "name", + "type": "string", + "ref": false, + "description": "The name of the console command." + } + ], + "retType": { + "type": "bool", + "description": "A boolean indicating whether the command was successfully added." + } +} +``` + +### Parameter with Enum Structure + +When a parameter uses an enum type, the full enum definition is included: + +```json +{ + "name": "mode", + "type": "uint8", + "ref": false, + "description": "Whether the hook was in post mode (after processing) or pre mode (before processing).", + "enum": { + "name": "HookMode", + "description": "Enum representing the type of callback.", + "values": [ + { + "name": "Pre", + "value": 0, + "description": "Callback will be executed before the original function" + }, + { + "name": "Post", + "value": 1, + "description": "Callback will be executed after the original function" + } + ] + } +} +``` + +### Parameter with Function Prototype + +When a parameter is a function pointer typedef, the complete function signature is included: + +```json +{ + "name": "callback", + "type": "function", + "ref": false, + "description": "A callback function that is invoked when the command is executed.", + "prototype": { + "name": "CommandCallback", + "funcName": "CommandCallback", + "description": "Handles the execution of a command triggered by a caller.", + "paramTypes": [ + { + "name": "param1", + "type": "int32", + "ref": false + }, + { + "name": "param2", + "type": "int32", + "ref": false, + "enum": { + "name": "CommandCallingContext", + "description": "The command execution context.", + "values": [ + { + "name": "Console", + "value": 0, + "description": "The command execute from the client's console." + } + ] + } + } + ], + "retType": { + "type": "int32", + "enum": { + "name": "ResultType", + "description": "Enum representing the possible results of an operation.", + "values": [...] + } + } + } +} +``` + +### Field Descriptions + +- `name`: Function name +- `group`: Derived from the source filename (e.g., "Commands" from `commands.cpp`) +- `description`: Brief description from Doxygen comments +- `funcName`: Function name (same as `name`) +- `paramTypes`: Array of parameter objects: + - `name`: Parameter name + - `type`: Mapped type (e.g., "string", "int32", "vec3[]", "function") + - `ref`: Boolean indicating if it's a reference parameter + - `description`: Parameter description from Doxygen comments (if available) + - `enum`: (Optional) Full enum structure if parameter is an enum type + - `prototype`: (Optional) Full function signature if parameter is a function pointer typedef +- `retType`: Return type object: + - `type`: Mapped return type + - `description`: Return description from Doxygen comments (if available) + - `enum`: (Optional) Full enum structure if return type is an enum + +## Advanced Features + +### Enum Structure Generation + +The parser automatically detects enum types and includes their complete definition: +- Enum name and description +- All enum values with their numeric values +- Per-value descriptions (if documented) +- Automatically filters out sentinel values like "Count", "MAX", "INVALID" + +### Function Pointer Typedef Parsing + +The parser can parse function pointer typedefs from their underlying signature: +- Extracts return type and parameter types +- Recursively processes parameter types (including nested enums) +- Generates parameter names (param1, param2, etc.) +- Includes full function description from typedef documentation + +**Note**: Parameter names in function prototypes are auto-generated as `param1`, `param2`, etc. To include meaningful parameter names and descriptions, you'll need to add them manually or extend the parser to read from additional documentation sources. + +### Nested Enum Support + +Enums can appear at multiple levels: +- Function parameters +- Function return types +- Function prototype parameters (within typedef) +- Function prototype return types (within typedef) + +All enum references include the complete enum structure with values and descriptions. + +## Type Mapping + +The script maps C++ types to simplified types: + +| C++ Type | Mapped Type | +|----------|-------------| +| `plg::string`, `const plg::string &` | `string` | +| `plg::vector` | `string[]` | +| `int`, `int32_t`, `long` | `int32` | +| `int64_t`, `long long` | `int64` | +| `bool` | `bool` | +| `float` | `float` | +| `double` | `double` | +| `void*` | `ptr64` | +| `plg::vector` | `int32[]` | +| `Vector`, `QAngle`, `plg::vec3` | `vec3` | +| Enums | Base type (e.g., `uint8`, `int32`) + enum structure | +| Function pointer typedefs | `function` + prototype structure | +| Other typedefs | `?` | + +Pointers (except `void*`) are mapped to `ptr64`, and unknown types default to `?`. + +## Advantages over Previous Parser + +1. **More accurate parsing**: Leverages Clang's AST instead of regex-based parsing +2. **Better enum handling**: Automatically resolves enum base types and includes full enum definitions +3. **Function typedef support**: Parses function pointer signatures from typedefs +4. **Structured documentation**: Extracts Doxygen comments in a more reliable way +5. **Type safety**: Uses Clang's type system for accurate type information +6. **Better scalability**: Can handle complex C++ constructs that regex parsing struggled with +7. **Nested type support**: Handles enums within function prototypes and other complex scenarios + +## Troubleshooting + +### No functions exported +- Ensure your YAML file contains a `ChildFunctions` section +- Check that your filters aren't too restrictive +- Verify the YAML file is properly formatted + +### Type showing as '?' +- The type is not in the type mapping dictionary +- You can add custom type mappings to the `map_type()` function + +### Missing descriptions +- Ensure your source files have proper Doxygen comments with `@brief`, `@param`, and `@return` tags +- Verify clang-doc is extracting the comments (check the YAML file) + +### Missing enum structures +- Verify the enum is defined in the YAML file's `ChildEnums` section +- Ensure the enum has proper Doxygen documentation +- Check that enum values are documented + +### Function prototype parameters have generic names +- This is expected behavior - clang-doc doesn't preserve parameter names in typedef signatures +- Parameter names are auto-generated as `param1`, `param2`, etc. +- To add meaningful names, you can either: + - Manually edit the JSON output + - Extend the parser to read parameter metadata from additional sources + - Use wrapper functions with documented parameters instead of raw typedefs + +## Configuration + +### Filtering Sentinel Enum Values + +By default, the parser filters out common sentinel enum values like "Count", "MAX", "INVALID", etc. You can customize this behavior by modifying the `sentinel_names` set in the `build_enum_structure()` function: + +```python +sentinel_names = {'Count', 'MAX', 'Max', 'INVALID', 'Invalid', 'NUM', 'Num'} +``` + +## License + +This script is part of the Plugify project. From cf9fdbfe9f55c8f666f5c0664f1ee6b7313d22c9 Mon Sep 17 00:00:00 2001 From: qubka Date: Sat, 1 Nov 2025 23:29:28 +0000 Subject: [PATCH 06/16] fix: move tools to separate folders --- tools/generator/README.md | 218 ++++++++++++++++++ {generator => tools/generator}/converter.py | 0 {generator => tools/generator}/generator.py | 0 .../generator}/run_generator.bat | 0 .../generator}/run_generator.sh | 0 {generator => tools}/parser/README.md | 0 {generator => tools}/parser/parser.py | 0 .../parser/parser_deprecated.py | 0 8 files changed, 218 insertions(+) create mode 100644 tools/generator/README.md rename {generator => tools/generator}/converter.py (100%) rename {generator => tools/generator}/generator.py (100%) rename {generator => tools/generator}/run_generator.bat (100%) rename {generator => tools/generator}/run_generator.sh (100%) rename {generator => tools}/parser/README.md (100%) rename {generator => tools}/parser/parser.py (100%) rename {generator => tools}/parser/parser_deprecated.py (100%) diff --git a/tools/generator/README.md b/tools/generator/README.md new file mode 100644 index 0000000..c698b63 --- /dev/null +++ b/tools/generator/README.md @@ -0,0 +1,218 @@ +# Plugify C++ Header Generator + +A Python tool that automatically generates C++ header files with type-safe bindings for Plugify plugins from JSON manifest files. + +## Overview + +This generator reads `.pplugin` JSON manifest files and produces corresponding C++ header files (`.hpp`) that provide: +- Type-safe function wrappers +- Enum definitions +- Delegate (function pointer) type definitions +- Automatic method pointer resolution +- Doxygen-compatible documentation comments + +## Requirements + +- Python 3.10 or higher +- Input: `.pplugin` JSON manifest file +- Output: A directory for generated headers + +## Installation + +No installation required. Simply download the `generator.py` script and ensure it's executable: + +```bash +chmod +x generator.py +``` + +## Usage + +### Basic Syntax + +```bash +python3 generator.py [--override] +``` + +### Arguments + +| Argument | Required | Description | +|----------|----------|-------------| +| `manifest_path` | Yes | Path to the `.pplugin` JSON manifest file | +| `output_directory` | Yes | Directory where the generated header will be saved | +| `--override` | No | Overwrite existing files (otherwise, script exits if file exists) | + +### Examples + +**Generate a header file:** +```bash +python3 generator.py my_plugin.pplugin ./output +``` + +**Override existing files:** +```bash +python3 generator.py my_plugin.pplugin ./output --override +``` + +**Result:** +``` +Header generated at: ./output/pps/my_plugin.hpp +``` + +## Input Format + +The script expects a JSON manifest file with the following structure: + +```json +{ + "name": "my_plugin", + "methods": [ + { + "name": "MyFunction", + "description": "Does something useful", + "retType": { + "type": "int32", + "description": "Return value description" + }, + "paramTypes": [ + { + "name": "value", + "type": "float", + "description": "Parameter description" + } + ] + } + ] +} +``` + +### Supported Types + +**Basic types:** `void`, `bool`, `char8`, `char16`, `int8`, `int16`, `int32`, `int64`, `uint8`, `uint16`, `uint32`, `uint64`, `ptr64`, `float`, `double`, `string`, `any`, `function` + +**Vector types:** `vec2`, `vec3`, `vec4`, `mat4x4` + +**Array types:** Add `[]` suffix (e.g., `int32[]`, `string[]`, `vec2[]`) + +**Special features:** +- Enums with custom types +- Delegates (function pointers) +- Reference parameters (`"ref": true`) +- Default parameter values + +## Output Format + +The generated header includes: + +```cpp +#pragma once + +#include +#include +#include + +namespace my_plugin { + // Enums + enum class MyEnum : int32_t { /* ... */ }; + + // Delegates + using MyCallback = void (*)(int32_t); + + // Function wrappers + /** + * @brief Does something useful + * @function MyFunction + * @param value (float): Parameter description + * @return int32: Return value description + */ + inline int32_t MyFunction(float value) { + using MyFunctionFn = int32_t (*)(float); + static MyFunctionFn __func = nullptr; + if (__func == nullptr) + plg::GetMethodPtr2("my_plugin.MyFunction", + reinterpret_cast(&__func)); + return __func(value); + } +} +``` + +## Features + +### Automatic Type Conversion +- Converts JSON types to appropriate C++ types +- Handles value types, references, and return types differently +- Supports vectors with `plg::vector` + +### Name Sanitization +- Automatically appends `_` to C++ reserved keywords +- Prevents naming conflicts + +### Documentation Generation +- Creates Doxygen-style comments from JSON descriptions +- Documents parameters and return types + +### Duplicate Prevention +- Tracks generated enums and delegates +- Avoids duplicate definitions + +## Error Handling + +The script will exit with an error if: +- Manifest file doesn't exist +- Output directory doesn't exist +- Output file already exists (without `--override`) +- JSON parsing fails +- Unsupported type is encountered + +## Integration + +Include the generated header in your C++ project: + +```cpp +#include "pps/my_plugin.hpp" + +int main() { + float result = my_plugin::MyFunction(3.14f); + return 0; +} +``` + +## Troubleshooting + +**"Manifest file does not exist"** +- Check the path to your `.pplugin` file + +**"Output directory does not exist"** +- Create the output directory first: `mkdir -p output` + +**"Output file already exists"** +- Use `--override` flag or delete existing file + +**"Unsupported type"** +- Check that all types in your manifest are in the supported types list + +## Download Generator Script + +The generator script is available at: +- **GitHub Repository:** https://github.com/untrustedmodders/plugify-module-cpp +- **Direct Link:** https://raw.githubusercontent.com/untrustedmodders/plugify-module-cpp/main/generator/generator.py + +### Quick Download + +```bash +# Using wget +wget https://raw.githubusercontent.com/untrustedmodders/plugify-module-cpp/main/generator/generator.py + +# Using curl +curl -O https://raw.githubusercontent.com/untrustedmodders/plugify-module-cpp/main/generator/generator.py + +# Make it executable +chmod +x generator.py +``` + +## License + +[Add license information] + +## Contributing + +For issues, feature requests, or contributions, please visit the GitHub repository. diff --git a/generator/converter.py b/tools/generator/converter.py similarity index 100% rename from generator/converter.py rename to tools/generator/converter.py diff --git a/generator/generator.py b/tools/generator/generator.py similarity index 100% rename from generator/generator.py rename to tools/generator/generator.py diff --git a/generator/run_generator.bat b/tools/generator/run_generator.bat similarity index 100% rename from generator/run_generator.bat rename to tools/generator/run_generator.bat diff --git a/generator/run_generator.sh b/tools/generator/run_generator.sh similarity index 100% rename from generator/run_generator.sh rename to tools/generator/run_generator.sh diff --git a/generator/parser/README.md b/tools/parser/README.md similarity index 100% rename from generator/parser/README.md rename to tools/parser/README.md diff --git a/generator/parser/parser.py b/tools/parser/parser.py similarity index 100% rename from generator/parser/parser.py rename to tools/parser/parser.py diff --git a/generator/parser/parser_deprecated.py b/tools/parser/parser_deprecated.py similarity index 100% rename from generator/parser/parser_deprecated.py rename to tools/parser/parser_deprecated.py From 2e535cc34b8e8afdaa178815891ff4206b4dd70f Mon Sep 17 00:00:00 2001 From: qubka Date: Thu, 13 Nov 2025 23:32:10 +0000 Subject: [PATCH 07/16] docs: move tools again --- {tools/generator => generator}/README.md | 0 {tools/generator => generator}/generator.py | 0 .../generator => generator}/run_generator.bat | 0 .../generator => generator}/run_generator.sh | 0 {tools/parser => parser}/README.md | 0 {tools/parser => parser}/parser.py | 0 {tools/parser => parser}/parser_deprecated.py | 0 tools/generator/converter.py | 188 ------------------ 8 files changed, 188 deletions(-) rename {tools/generator => generator}/README.md (100%) rename {tools/generator => generator}/generator.py (100%) rename {tools/generator => generator}/run_generator.bat (100%) rename {tools/generator => generator}/run_generator.sh (100%) rename {tools/parser => parser}/README.md (100%) rename {tools/parser => parser}/parser.py (100%) rename {tools/parser => parser}/parser_deprecated.py (100%) delete mode 100644 tools/generator/converter.py diff --git a/tools/generator/README.md b/generator/README.md similarity index 100% rename from tools/generator/README.md rename to generator/README.md diff --git a/tools/generator/generator.py b/generator/generator.py similarity index 100% rename from tools/generator/generator.py rename to generator/generator.py diff --git a/tools/generator/run_generator.bat b/generator/run_generator.bat similarity index 100% rename from tools/generator/run_generator.bat rename to generator/run_generator.bat diff --git a/tools/generator/run_generator.sh b/generator/run_generator.sh similarity index 100% rename from tools/generator/run_generator.sh rename to generator/run_generator.sh diff --git a/tools/parser/README.md b/parser/README.md similarity index 100% rename from tools/parser/README.md rename to parser/README.md diff --git a/tools/parser/parser.py b/parser/parser.py similarity index 100% rename from tools/parser/parser.py rename to parser/parser.py diff --git a/tools/parser/parser_deprecated.py b/parser/parser_deprecated.py similarity index 100% rename from tools/parser/parser_deprecated.py rename to parser/parser_deprecated.py diff --git a/tools/generator/converter.py b/tools/generator/converter.py deleted file mode 100644 index 9352c97..0000000 --- a/tools/generator/converter.py +++ /dev/null @@ -1,188 +0,0 @@ -#!/usr/bin/env python3 -""" -Convert JSON manifest to README markdown table format -""" - -import json -import sys -from typing import Dict, List, Any - - -def format_type(param_type: str, is_ref: bool = False) -> str: - """Format a parameter type for display in signature""" - # Add reference indicator if needed - if is_ref: - return f"{param_type}&" - return param_type - - -def format_signature(method: Dict[str, Any]) -> str: - """Format method signature from JSON data""" - func_name = method.get('funcName', method.get('name', 'Unknown')) - - # Format parameters - params = [] - for param in method.get('paramTypes', []): - param_name = param.get('name', '') - param_type = param.get('type', 'any') - is_ref = param.get('ref', False) - - formatted_type = format_type(param_type, is_ref) - params.append(f"{param_name}: {formatted_type}") - - # Format return type - ret_type = method.get('retType', {}) - return_type = ret_type.get('type', 'void') - - # Construct signature - signature = f"{func_name}({', '.join(params)}): {return_type}" - - return signature - - -def escape_pipe(text: str) -> str: - """Escape pipe characters in text for markdown tables""" - return text.replace('|', '\\|') - - -def generate_markdown_table(methods: List[Dict[str, Any]], group_by: bool = False) -> str: - """Generate markdown table from methods list""" - lines = [] - - if group_by: - # Group methods by their 'group' field - grouped = {} - for method in methods: - group = method.get('group', 'Other') - if group not in grouped: - grouped[group] = [] - grouped[group].append(method) - - # Generate table for each group - for group_name in sorted(grouped.keys()): - lines.append(f"\n### {group_name}\n") - lines.append(f"
Open methods list \n") - lines.append("| Function | Signature | Description |") - lines.append("|----------|-----------|-------------|") - - for method in grouped[group_name]: - name = method.get('name', 'Unknown') - signature = format_signature(method) - description = method.get('description', '') - - # Escape pipe characters - name = escape_pipe(name) - signature = escape_pipe(signature) - description = escape_pipe(description) - - lines.append(f"| {name} | `{signature}` | {description} |") - - lines.append("\n
\n") - else: - # Single table for all methods - lines.append(f"
Open methods list \n") - lines.append("| Function | Signature | Description |") - lines.append("|----------|-----------|-------------|") - - for method in methods: - name = method.get('name', 'Unknown') - signature = format_signature(method) - description = method.get('description', '') - - # Escape pipe characters - name = escape_pipe(name) - signature = escape_pipe(signature) - description = escape_pipe(description) - - lines.append(f"| {name} | `{signature}` | {description} |") - - lines.append("\n
\n") - return '\n'.join(lines) - - -def main(): - """Main function to convert JSON to README table""" - - # Check command line arguments - if len(sys.argv) < 2: - print("Usage: python json_to_readme.py [output.md]") - print("\nOptions:") - print(" --group Group methods by their 'group' field") - sys.exit(1) - - input_file = sys.argv[1] - output_file = None - group_by = False - - # Parse arguments - for i, arg in enumerate(sys.argv[2:], 2): - if arg == '--group': - group_by = True - else: - output_file = arg - - # If no output file specified, use input filename with .md extension - if not output_file: - output_file = input_file.rsplit('.', 1)[0] + '_methods.md' - - try: - # Read JSON file - with open(input_file, 'r', encoding='utf-8') as f: - data = json.load(f) - - # Extract methods - methods = data.get('methods', []) - - if not methods: - print("Warning: No methods found in JSON file") - sys.exit(1) - - # Generate markdown table - markdown_content = f"# API Methods\n\n" - markdown_content += f"Generated from: {input_file}\n\n" - markdown_content += f"Total methods: {len(methods)}\n\n" - markdown_content += generate_markdown_table(methods, group_by) - - # Write to output file - with open(output_file, 'w', encoding='utf-8') as f: - f.write(markdown_content) - - print(f"Successfully converted {len(methods)} methods") - print(f"Output written to: {output_file}") - - # Print summary of groups if available - groups = set(m.get('group', 'Other') for m in methods) - if len(groups) > 1: - print(f"Found {len(groups)} groups: {', '.join(sorted(groups))}") - print("Tip: Use --group flag to group methods in the output") - - except FileNotFoundError: - print(f"Error: File '{input_file}' not found") - sys.exit(1) - except json.JSONDecodeError as e: - print(f"Error: Invalid JSON in file '{input_file}': {e}") - sys.exit(1) - except Exception as e: - print(f"Error: {e}") - sys.exit(1) - - -# Alternative function for direct string conversion (can be imported and used in other scripts) -def json_string_to_markdown_table(json_string: str, group_by: bool = False) -> str: - """Convert JSON string directly to markdown table string""" - try: - data = json.loads(json_string) - methods = data.get('methods', []) - - if not methods: - return "No methods found in JSON" - - return generate_markdown_table(methods, group_by) - except json.JSONDecodeError as e: - return f"Error parsing JSON: {e}" - except Exception as e: - return f"Error: {e}" - - -if __name__ == "__main__": - main() \ No newline at end of file From 401ec2caf368c5616fbb63908e9ddc09b2b13e1b Mon Sep 17 00:00:00 2001 From: qubka Date: Thu, 13 Nov 2025 23:32:50 +0000 Subject: [PATCH 08/16] fix: update deps --- external/plugify | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/external/plugify b/external/plugify index df3298e..419d98e 160000 --- a/external/plugify +++ b/external/plugify @@ -1 +1 @@ -Subproject commit df3298ef363adec30bb621004cebd4f0ebd9ee19 +Subproject commit 419d98e3c86892e7ac1c6468d564bde35d26ba29 From 62f2baca2affbfa530bcf4be2e7b7fdbf13bb8b4 Mon Sep 17 00:00:00 2001 From: qubka Date: Sun, 16 Nov 2025 18:13:16 +0000 Subject: [PATCH 09/16] fix: update notify --- .github/workflows/cmake-multiple-platform.yml | 35 +++++++++++-------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/.github/workflows/cmake-multiple-platform.yml b/.github/workflows/cmake-multiple-platform.yml index 9b993da..cd9e702 100644 --- a/.github/workflows/cmake-multiple-platform.yml +++ b/.github/workflows/cmake-multiple-platform.yml @@ -415,26 +415,31 @@ jobs: runs-on: ubuntu-latest steps: - name: Send Discord Notification - if: ${{ success() }} - env: - DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }} - uses: Ilshidur/action-discord@0.3.2 + if: ${{ needs.build.result == 'success' && needs.package.result == 'success' && needs.repository.result == 'success' }} + uses: tsickert/discord-webhook@v7.0.0 with: - args: | - 🎉 **New Release: ${{ env.PROJECT_NAME }} ${{ needs.setup.outputs.tag_name }}** + webhook-url: ${{ secrets.DISCORD_WEBHOOK }} + embed-description: | + ## <:plugin_creator:1336096248515657880> New Release: ${{ env.PROJECT_NAME }} ${{ needs.setup.outputs.tag_name }} + + ### <:link:1342486300653129811> Downloads + -# <:curved_arrow_right:1342544469148565545> [${{ needs.setup.outputs.tag_name }}](${{ needs.package.outputs.url }}) - 📦 **Downloads:** [${{ needs.setup.outputs.tag_name }}](${{ needs.package.outputs.url }}) - 🐍 **Conda Channel:** https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/ + ### 🐍 Conda Channel + -# <:curved_arrow_right:1342544469148565545> https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/ - Install via conda: + <:blank:1335697913464098908> + **Install via conda:** ```bash conda install -c https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/ ${{ env.PROJECT_NAME }} ``` - + embed-color: 955135 + - name: Send Failure Notification - if: ${{ failure() }} - env: - DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }} - uses: Ilshidur/action-discord@0.3.2 + if: ${{ needs.build.result == 'failure' || needs.package.result == 'failure' || needs.repository.result == 'failure' }} + uses: tsickert/discord-webhook@v7.0.0 with: - args: "⚠️ Release workflow failed for ${{ env.PROJECT_NAME }} ${{ needs.setup.outputs.tag_name }}" + webhook-url: ${{ secrets.DISCORD_WEBHOOK }} + embed-description: | + ## Release workflow failed for ${{ env.PROJECT_NAME }} ${{ needs.setup.outputs.tag_name }} + embed-color: 16221227 From 0bc30cbaf46f58a80aa18775a2728b3f4961a776 Mon Sep 17 00:00:00 2001 From: qubka Date: Sun, 16 Nov 2025 21:54:48 +0000 Subject: [PATCH 10/16] fix: update deps --- external/plugify | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/external/plugify b/external/plugify index 419d98e..f0b7aa9 160000 --- a/external/plugify +++ b/external/plugify @@ -1 +1 @@ -Subproject commit 419d98e3c86892e7ac1c6468d564bde35d26ba29 +Subproject commit f0b7aa9213b675d6122a52256e1bed42d8125ecf From dd35f352d44b86cb901873be1867f5b4e9aa8530 Mon Sep 17 00:00:00 2001 From: Nikita Ushakov Date: Thu, 20 Nov 2025 18:03:13 +0000 Subject: [PATCH 11/16] fix: add initial class testing --- .../cross_call_master.pplugin | 551 ++++++++++++++++++ test/cross_call_master/plugin.cpp | 398 ++++++++++++- 2 files changed, 947 insertions(+), 2 deletions(-) diff --git a/test/cross_call_master/cross_call_master.pplugin b/test/cross_call_master/cross_call_master.pplugin index 5df1025..ca4c340 100644 --- a/test/cross_call_master/cross_call_master.pplugin +++ b/test/cross_call_master/cross_call_master.pplugin @@ -4408,6 +4408,557 @@ "retType": { "type": "string" } + }, + + // classes + { + "name": "ConnectionCreate", + "funcName": "ConnectionCreate", + "description": "Creates a new Connection with specified host and port.", + "paramTypes": [ + { + "name": "host", + "type": "string", + "ref": false, + "description": "The host address to connect to." + }, + { + "name": "port", + "type": "int32", + "ref": false, + "description": "The port number." + } + ], + "retType": { + "type": "ptr64", + "description": "A handle to the created Connection." + } + }, + { + "name": "ConnectionCreateSecure", + "funcName": "ConnectionCreateSecure", + "description": "Creates a new secure Connection with SSL/TLS.", + "paramTypes": [ + { + "name": "host", + "type": "string", + "ref": false, + "description": "The host address to connect to." + }, + { + "name": "port", + "type": "int32", + "ref": false, + "description": "The port number." + }, + { + "name": "useSsl", + "type": "bool", + "ref": false, + "description": "Whether to use SSL/TLS encryption." + } + ], + "retType": { + "type": "ptr64", + "description": "A handle to the created secure Connection." + } + }, + { + "name": "ConnectionDestroy", + "funcName": "ConnectionDestroy", + "description": "Destroys a Connection and releases its resources.", + "paramTypes": [ + { + "name": "connection", + "type": "ptr64", + "ref": false, + "description": "The Connection handle to destroy." + } + ], + "retType": { + "type": "void" + } + }, + { + "name": "ConnectionConnect", + "funcName": "ConnectionConnect", + "description": "Establishes the connection.", + "paramTypes": [ + { + "name": "connection", + "type": "ptr64", + "ref": false, + "description": "The Connection handle." + } + ], + "retType": { + "type": "bool", + "description": "True if connection was successful, false otherwise." + } + }, + { + "name": "ConnectionDisconnect", + "funcName": "ConnectionDisconnect", + "description": "Closes the connection.", + "paramTypes": [ + { + "name": "connection", + "type": "ptr64", + "ref": false, + "description": "The Connection handle." + } + ], + "retType": { + "type": "void" + } + }, + { + "name": "ConnectionIsConnected", + "funcName": "ConnectionIsConnected", + "description": "Checks if the connection is currently active.", + "paramTypes": [ + { + "name": "connection", + "type": "ptr64", + "ref": false, + "description": "The Connection handle." + } + ], + "retType": { + "type": "bool", + "description": "True if connected, false otherwise." + } + }, + { + "name": "ConnectionSendData", + "funcName": "ConnectionSendData", + "description": "Sends data through the connection.", + "paramTypes": [ + { + "name": "connection", + "type": "ptr64", + "ref": false, + "description": "The Connection handle." + }, + { + "name": "data", + "type": "string", + "ref": false, + "description": "The data to send." + } + ], + "retType": { + "type": "int32", + "description": "Number of bytes sent, or -1 on error." + } + }, + { + "name": "ConnectionReceiveData", + "funcName": "ConnectionReceiveData", + "description": "Receives data from the connection.", + "paramTypes": [ + { + "name": "connection", + "type": "ptr64", + "ref": false, + "description": "The Connection handle." + } + ], + "retType": { + "type": "string", + "description": "The received data, or empty string if no data available." + } + }, + { + "name": "ConnectionGetHost", + "funcName": "ConnectionGetHost", + "description": "Gets the host address of the connection.", + "paramTypes": [ + { + "name": "connection", + "type": "ptr64", + "ref": false, + "description": "The Connection handle." + } + ], + "retType": { + "type": "string", + "description": "The host address." + } + }, + { + "name": "ConnectionGetPort", + "funcName": "ConnectionGetPort", + "description": "Gets the port number of the connection.", + "paramTypes": [ + { + "name": "connection", + "type": "ptr64", + "ref": false, + "description": "The Connection handle." + } + ], + "retType": { + "type": "int32", + "description": "The port number." + } + }, + { + "name": "ConnectionGetTotalConnections", + "funcName": "ConnectionGetTotalConnections", + "description": "Gets the total number of active connections (static utility).", + "paramTypes": [], + "retType": { + "type": "int32", + "description": "The number of active connections." + } + }, + { + "name": "StatisticsCreate", + "funcName": "StatisticsCreate", + "description": "Creates a new Statistics tracker.", + "paramTypes": [ + { + "name": "name", + "type": "string", + "ref": false, + "description": "The name of the statistics tracker." + } + ], + "retType": { + "type": "ptr64", + "description": "A handle to the created Statistics." + } + }, + { + "name": "StatisticsCreateWithCapacity", + "funcName": "StatisticsCreateWithCapacity", + "description": "Creates a new Statistics tracker with initial capacity.", + "paramTypes": [ + { + "name": "name", + "type": "string", + "ref": false, + "description": "The name of the statistics tracker." + }, + { + "name": "capacity", + "type": "int32", + "ref": false, + "description": "Initial capacity for data storage." + } + ], + "retType": { + "type": "ptr64", + "description": "A handle to the created Statistics." + } + }, + { + "name": "StatisticsIncrement", + "funcName": "StatisticsIncrement", + "description": "Increments the counter by one.", + "paramTypes": [ + { + "name": "statistics", + "type": "ptr64", + "ref": false, + "description": "The Statistics handle." + } + ], + "retType": { + "type": "void" + } + }, + { + "name": "StatisticsIncrementBy", + "funcName": "StatisticsIncrementBy", + "description": "Increments the counter by a specific amount.", + "paramTypes": [ + { + "name": "statistics", + "type": "ptr64", + "ref": false, + "description": "The Statistics handle." + }, + { + "name": "amount", + "type": "int32", + "ref": false, + "description": "The amount to increment by." + } + ], + "retType": { + "type": "void" + } + }, + { + "name": "StatisticsDecrement", + "funcName": "StatisticsDecrement", + "description": "Decrements the counter by one.", + "paramTypes": [ + { + "name": "statistics", + "type": "ptr64", + "ref": false, + "description": "The Statistics handle." + } + ], + "retType": { + "type": "void" + } + }, + { + "name": "StatisticsGetCount", + "funcName": "StatisticsGetCount", + "description": "Gets the current count value.", + "paramTypes": [ + { + "name": "statistics", + "type": "ptr64", + "ref": false, + "description": "The Statistics handle." + } + ], + "retType": { + "type": "int32", + "description": "The current count." + } + }, + { + "name": "StatisticsReset", + "funcName": "StatisticsReset", + "description": "Resets the counter to zero.", + "paramTypes": [ + { + "name": "statistics", + "type": "ptr64", + "ref": false, + "description": "The Statistics handle." + } + ], + "retType": { + "type": "void" + } + }, + { + "name": "StatisticsGetName", + "funcName": "StatisticsGetName", + "description": "Gets the name of the statistics tracker.", + "paramTypes": [ + { + "name": "statistics", + "type": "ptr64", + "ref": false, + "description": "The Statistics handle." + } + ], + "retType": { + "type": "string", + "description": "The name of the tracker." + } + }, + { + "name": "StatisticsAddValue", + "funcName": "StatisticsAddValue", + "description": "Adds a value to the statistics dataset.", + "paramTypes": [ + { + "name": "statistics", + "type": "ptr64", + "ref": false, + "description": "The Statistics handle." + }, + { + "name": "value", + "type": "double", + "ref": false, + "description": "The value to add." + } + ], + "retType": { + "type": "void" + } + }, + { + "name": "StatisticsGetAverage", + "funcName": "StatisticsGetAverage", + "description": "Calculates the average of all values.", + "paramTypes": [ + { + "name": "statistics", + "type": "ptr64", + "ref": false, + "description": "The Statistics handle." + } + ], + "retType": { + "type": "double", + "description": "The average value." + } + }, + { + "name": "StatisticsGetMin", + "funcName": "StatisticsGetMin", + "description": "Gets the minimum value.", + "paramTypes": [ + { + "name": "statistics", + "type": "ptr64", + "ref": false, + "description": "The Statistics handle." + } + ], + "retType": { + "type": "double", + "description": "The minimum value." + } + }, + { + "name": "StatisticsGetMax", + "funcName": "StatisticsGetMax", + "description": "Gets the maximum value.", + "paramTypes": [ + { + "name": "statistics", + "type": "ptr64", + "ref": false, + "description": "The Statistics handle." + } + ], + "retType": { + "type": "double", + "description": "The maximum value." + } + }, + { + "name": "StatisticsGetGlobalCount", + "funcName": "StatisticsGetGlobalCount", + "description": "Gets the total number of Statistics instances created (static utility).", + "paramTypes": [], + "retType": { + "type": "int32", + "description": "The total number of Statistics instances." + } + } + ], + "classes": [ + { + "name": "Connection", + "description": "RAII wrapper for network Connection handle. Manages connection lifecycle with automatic cleanup on disposal.", + "handleType": "ptr64", + "constructors": [ + "ConnectionCreate", + "ConnectionCreateSecure" + ], + "destructor": "ConnectionDestroy", + "bindings": [ + { + "name": "Connect", + "method": "ConnectionConnect", + "bindSelf": true + }, + { + "name": "Disconnect", + "method": "ConnectionDisconnect", + "bindSelf": true + }, + { + "name": "IsConnected", + "method": "ConnectionIsConnected", + "bindSelf": true + }, + { + "name": "SendData", + "method": "ConnectionSendData", + "bindSelf": true + }, + { + "name": "ReceiveData", + "method": "ConnectionReceiveData", + "bindSelf": true + }, + { + "name": "GetHost", + "method": "ConnectionGetHost", + "bindSelf": true + }, + { + "name": "GetPort", + "method": "ConnectionGetPort", + "bindSelf": true + }, + { + "name": "GetTotalConnections", + "method": "ConnectionGetTotalConnections", + "bindSelf": false + } + ] + }, + { + "name": "Statistics", + "description": "Lightweight wrapper for statistics tracking. Does not require explicit cleanup as it manages no external resources.", + "handleType": "ptr64", + "constructors": [ + "StatisticsCreate", + "StatisticsCreateWithCapacity" + ], + "bindings": [ + { + "name": "Increment", + "method": "StatisticsIncrement", + "bindSelf": true + }, + { + "name": "IncrementBy", + "method": "StatisticsIncrementBy", + "bindSelf": true + }, + { + "name": "Decrement", + "method": "StatisticsDecrement", + "bindSelf": true + }, + { + "name": "GetCount", + "method": "StatisticsGetCount", + "bindSelf": true + }, + { + "name": "Reset", + "method": "StatisticsReset", + "bindSelf": true + }, + { + "name": "GetName", + "method": "StatisticsGetName", + "bindSelf": true + }, + { + "name": "AddValue", + "method": "StatisticsAddValue", + "bindSelf": true + }, + { + "name": "GetAverage", + "method": "StatisticsGetAverage", + "bindSelf": true + }, + { + "name": "GetMin", + "method": "StatisticsGetMin", + "bindSelf": true + }, + { + "name": "GetMax", + "method": "StatisticsGetMax", + "bindSelf": true + }, + { + "name": "GetGlobalCount", + "method": "StatisticsGetGlobalCount", + "bindSelf": false + } + ] } ] } diff --git a/test/cross_call_master/plugin.cpp b/test/cross_call_master/plugin.cpp index fb53fc6..e8cc3c0 100644 --- a/test/cross_call_master/plugin.cpp +++ b/test/cross_call_master/plugin.cpp @@ -1,11 +1,18 @@ #include "simple_tests.hpp" -#include -#include #include #include #include #include + +#include +#include +#include +#include +#include +#include #include +#include +#include #define TEST_NO_PARAM_ONLY_RETURN_PRIMITIVES (1 << 0) #define TEST_NO_PARAM_ONLY_RETURN_OBJECTS (1 << 1) @@ -575,6 +582,7 @@ class CrossCallMaster final : public plg::IPluginEntry { ReverseParamsVariants(); ReverseParamsFunctions(); _tests.Run(); + } void OnPluginEnd() final { @@ -4848,4 +4856,390 @@ PLUGIN_API plg::string CallFuncEnumCallback(cross_call_worker::FuncEnum func) { return std::format("{}|{}", ret, p2); } +// classes + +// Global counters for tracking lifecycle +static std::atomic g_connection_create_count{0}; +static std::atomic g_connection_destroy_count{0}; +static std::atomic g_connection_active_count{0}; + +static std::atomic g_statistics_create_count{0}; +static std::atomic g_statistics_active_count{0}; + +// Mutex for thread-safe logging +static std::mutex g_log_mutex; + +// Helper function for thread-safe logging +template +void SafeLog(std::format_string fmt, Args&&... args) { + std::lock_guard lock(g_log_mutex); + std::println(fmt, std::forward(args)...); +} + +//============================================================================= +// Connection Class - WITH DESTRUCTOR +//============================================================================= +class Connection { +private: + plg::string m_host; + int32_t m_port; + bool m_useSsl; + bool m_connected; + int m_instanceId; + plg::string m_receiveBuffer; + +public: + Connection(const plg::string& host, int32_t port, bool useSsl = false) + : m_host(host), m_port(port), m_useSsl(useSsl), m_connected(false) { + + m_instanceId = ++g_connection_create_count; + ++g_connection_active_count; + + SafeLog("[Connection] Constructor called: Instance #{} | Host: {} | Port: {} | SSL: {} | Active: {}", + m_instanceId, m_host, m_port, m_useSsl, g_connection_active_count.load()); + } + + ~Connection() { + ++g_connection_destroy_count; + --g_connection_active_count; + + SafeLog("[Connection] Destructor called: Instance #{} | Host: {} | Port: {} | Destroyed: {} | Active: {}", + m_instanceId, m_host, m_port, g_connection_destroy_count.load(), g_connection_active_count.load()); + + if (m_connected) { + SafeLog("[Connection] Warning: Instance #{} destroyed while still connected!", m_instanceId); + } + } + + bool Connect() { + if (m_connected) { + SafeLog("[Connection] Instance #{} already connected", m_instanceId); + return true; + } + + SafeLog("[Connection] Instance #{} connecting to {}:{}...", m_instanceId, m_host, m_port); + m_connected = true; + m_receiveBuffer = std::format("Welcome to {}:{}", m_host, m_port); + SafeLog("[Connection] Instance #{} connected successfully", m_instanceId); + return true; + } + + void Disconnect() { + if (!m_connected) { + SafeLog("[Connection] Instance #{} already disconnected", m_instanceId); + return; + } + + SafeLog("[Connection] Instance #{} disconnecting from {}:{}...", m_instanceId, m_host, m_port); + m_connected = false; + m_receiveBuffer.clear(); + SafeLog("[Connection] Instance #{} disconnected", m_instanceId); + } + + bool IsConnected() const { + return m_connected; + } + + int32_t SendData(const plg::string& data) { + if (!m_connected) { + SafeLog("[Connection] Instance #{} ERROR: Cannot send, not connected", m_instanceId); + return -1; + } + + SafeLog("[Connection] Instance #{} sending {} bytes: '{}'", m_instanceId, data.size(), data); + // Simulate sending data and update receive buffer + m_receiveBuffer = std::format("Echo: {}", data); + return static_cast(data.size()); + } + + plg::string ReceiveData() { + if (!m_connected) { + SafeLog("[Connection] Instance #{} ERROR: Cannot receive, not connected", m_instanceId); + return ""; + } + + plg::string data = m_receiveBuffer; + m_receiveBuffer.clear(); + SafeLog("[Connection] Instance #{} received {} bytes", m_instanceId, data.size()); + return data; + } + + const plg::string& GetHost() const { return m_host; } + int32_t GetPort() const { return m_port; } + int GetInstanceId() const { return m_instanceId; } +}; + +//============================================================================= +// Statistics Class - WITHOUT DESTRUCTOR (lightweight) +//============================================================================= +class Statistics { +private: + plg::string m_name; + int32_t m_count; + int m_instanceId; + std::vector m_values; + +public: + Statistics(const plg::string& name, int32_t capacity = 100) + : m_name(name), m_count(0) { + + m_instanceId = ++g_statistics_create_count; + ++g_statistics_active_count; + m_values.reserve(capacity); + + SafeLog("[Statistics] Constructor called: Instance #{} | Name: '{}' | Capacity: {} | Active: {}", + m_instanceId, m_name, capacity, g_statistics_active_count.load()); + } + + // Note: No destructor in manifest, but we can still track in C++ + ~Statistics() { + --g_statistics_active_count; + SafeLog("[Statistics] Destructor called (C++ cleanup): Instance #{} | Name: '{}' | Final Count: {} | Active: {}", + m_instanceId, m_name, m_count, g_statistics_active_count.load()); + } + + void Increment() { + ++m_count; + SafeLog("[Statistics] Instance #{} incremented: Count = {}", m_instanceId, m_count); + } + + void IncrementBy(int32_t amount) { + m_count += amount; + SafeLog("[Statistics] Instance #{} incremented by {}: Count = {}", m_instanceId, amount, m_count); + } + + void Decrement() { + --m_count; + SafeLog("[Statistics] Instance #{} decremented: Count = {}", m_instanceId, m_count); + } + + int32_t GetCount() const { + return m_count; + } + + void Reset() { + SafeLog("[Statistics] Instance #{} reset: {} -> 0", m_instanceId, m_count); + m_count = 0; + m_values.clear(); + } + + const plg::string& GetName() const { + return m_name; + } + + void AddValue(double value) { + m_values.push_back(value); + SafeLog("[Statistics] Instance #{} added value: {} (total values: {})", m_instanceId, value, m_values.size()); + } + + double GetAverage() const { + if (m_values.empty()) return 0.0; + double sum = std::accumulate(m_values.begin(), m_values.end(), 0.0); + return sum / m_values.size(); + } + + double GetMin() const { + if (m_values.empty()) return 0.0; + return *std::min_element(m_values.begin(), m_values.end()); + } + + double GetMax() const { + if (m_values.empty()) return 0.0; + return *std::max_element(m_values.begin(), m_values.end()); + } + + int GetInstanceId() const { return m_instanceId; } +}; + +//============================================================================= +// Connection Exported Functions +//============================================================================= + +extern "C" +PLUGIN_API void* ConnectionCreate(const plg::string& host, int32_t port) { + try { + auto conn = new Connection(host, port, false); + SafeLog("[EXPORT] ConnectionCreate: Created instance #{} -> ptr: {}", + conn->GetInstanceId(), static_cast(conn)); + return static_cast(conn); + } catch (const std::exception& e) { + SafeLog("[EXPORT] ConnectionCreate: FAILED with exception: {}", e.what()); + return nullptr; + } +} + +extern "C" +PLUGIN_API void* ConnectionCreateSecure(const plg::string& host, int32_t port, bool useSsl) { + try { + auto conn = new Connection(host, port, useSsl); + SafeLog("[EXPORT] ConnectionCreateSecure: Created instance #{} -> ptr: {}", + conn->GetInstanceId(), static_cast(conn)); + return static_cast(conn); + } catch (const std::exception& e) { + SafeLog("[EXPORT] ConnectionCreateSecure: FAILED with exception: {}", e.what()); + return nullptr; + } +} + +extern "C" +PLUGIN_API void ConnectionDestroy(void* connection) { + if (!connection) { + SafeLog("[EXPORT] ConnectionDestroy: Called with nullptr!"); + return; + } + + auto conn = reinterpret_cast(connection); + int id = conn->GetInstanceId(); + SafeLog("[EXPORT] ConnectionDestroy: Destroying instance #{} at ptr: {}", id, connection); + delete conn; + SafeLog("[EXPORT] ConnectionDestroy: Instance #{} destroyed successfully", id); +} + +extern "C" +PLUGIN_API bool ConnectionConnect(void* connection) { + if (!connection) return false; + return reinterpret_cast(connection)->Connect(); +} + +extern "C" +PLUGIN_API void ConnectionDisconnect(void* connection) { + if (!connection) return; + reinterpret_cast(connection)->Disconnect(); +} + +extern "C" +PLUGIN_API bool ConnectionIsConnected(void* connection) { + if (!connection) return false; + return reinterpret_cast(connection)->IsConnected(); +} + +extern "C" +PLUGIN_API int32_t ConnectionSendData(void* connection, const plg::string& data) { + if (!connection) return -1; + return reinterpret_cast(connection)->SendData(data); +} + +extern "C" +PLUGIN_API plg::string ConnectionReceiveData(void* connection) { + if (!connection) return ""; + return reinterpret_cast(connection)->ReceiveData(); +} + +extern "C" +PLUGIN_API plg::string ConnectionGetHost(void* connection) { + if (!connection) return ""; + return reinterpret_cast(connection)->GetHost(); +} + +extern "C" +PLUGIN_API int32_t ConnectionGetPort(void* connection) { + if (!connection) return -1; + return reinterpret_cast(connection)->GetPort(); +} + +extern "C" +PLUGIN_API int32_t ConnectionGetTotalConnections() { + int active = g_connection_active_count.load(); + SafeLog("[EXPORT] ConnectionGetTotalConnections: Active = {}", active); + return active; +} + +//============================================================================= +// Statistics Exported Functions +//============================================================================= + +extern "C" +PLUGIN_API void* StatisticsCreate(const plg::string& name) { + try { + auto stats = new Statistics(name); + SafeLog("[EXPORT] StatisticsCreate: Created instance #{} -> ptr: {}", + stats->GetInstanceId(), static_cast(stats)); + return static_cast(stats); + } catch (const std::exception& e) { + SafeLog("[EXPORT] StatisticsCreate: FAILED with exception: {}", e.what()); + return nullptr; + } +} + +extern "C" +PLUGIN_API void* StatisticsCreateWithCapacity(const plg::string& name, int32_t capacity) { + try { + auto stats = new Statistics(name, capacity); + SafeLog("[EXPORT] StatisticsCreateWithCapacity: Created instance #{} -> ptr: {}", + stats->GetInstanceId(), static_cast(stats)); + return static_cast(stats); + } catch (const std::exception& e) { + SafeLog("[EXPORT] StatisticsCreateWithCapacity: FAILED with exception: {}", e.what()); + return nullptr; + } +} + +extern "C" +PLUGIN_API void StatisticsIncrement(void* statistics) { + if (!statistics) return; + reinterpret_cast(statistics)->Increment(); +} + +extern "C" +PLUGIN_API void StatisticsIncrementBy(void* statistics, int32_t amount) { + if (!statistics) return; + reinterpret_cast(statistics)->IncrementBy(amount); +} + +extern "C" +PLUGIN_API void StatisticsDecrement(void* statistics) { + if (!statistics) return; + reinterpret_cast(statistics)->Decrement(); +} + +extern "C" +PLUGIN_API int32_t StatisticsGetCount(void* statistics) { + if (!statistics) return 0; + return reinterpret_cast(statistics)->GetCount(); +} + +extern "C" +PLUGIN_API void StatisticsReset(void* statistics) { + if (!statistics) return; + reinterpret_cast(statistics)->Reset(); +} + +extern "C" +PLUGIN_API plg::string StatisticsGetName(void* statistics) { + if (!statistics) return ""; + return reinterpret_cast(statistics)->GetName(); +} + +extern "C" +PLUGIN_API void StatisticsAddValue(void* statistics, double value) { + if (!statistics) return; + reinterpret_cast(statistics)->AddValue(value); +} + +extern "C" +PLUGIN_API double StatisticsGetAverage(void* statistics) { + if (!statistics) return 0.0; + return reinterpret_cast(statistics)->GetAverage(); +} + +extern "C" +PLUGIN_API double StatisticsGetMin(void* statistics) { + if (!statistics) return 0.0; + return reinterpret_cast(statistics)->GetMin(); +} + +extern "C" +PLUGIN_API double StatisticsGetMax(void* statistics) { + if (!statistics) return 0.0; + return reinterpret_cast(statistics)->GetMax(); +} + +extern "C" +PLUGIN_API int32_t StatisticsGetGlobalCount() { + int created = g_statistics_create_count.load(); + int active = g_statistics_active_count.load(); + SafeLog("[EXPORT] StatisticsGetGlobalCount: Total Created = {}, Active = {}", created, active); + return created; +} + PLUGIFY_WARN_POP() From e44e0dd752a4608f0822f8ebc3c9f2e9195ffe25 Mon Sep 17 00:00:00 2001 From: qubka Date: Thu, 20 Nov 2025 22:31:12 +0000 Subject: [PATCH 12/16] fix: update test for classes --- .../cross_call_master.pplugin | 610 +- test/cross_call_master/plugin.cpp | 502 +- .../plugify/include/pps/cross_call_master.hpp | 5178 +++++++---------- 3 files changed, 2304 insertions(+), 3986 deletions(-) diff --git a/test/cross_call_master/cross_call_master.pplugin b/test/cross_call_master/cross_call_master.pplugin index ca4c340..e84f7ca 100644 --- a/test/cross_call_master/cross_call_master.pplugin +++ b/test/cross_call_master/cross_call_master.pplugin @@ -4410,554 +4410,262 @@ } }, - // classes + + { - "name": "ConnectionCreate", - "funcName": "ConnectionCreate", - "description": "Creates a new Connection with specified host and port.", + "name": "ResourceHandleCreate", + "funcName": "ResourceHandleCreate", + "group": "Resource", "paramTypes": [ - { - "name": "host", - "type": "string", - "ref": false, - "description": "The host address to connect to." - }, - { - "name": "port", - "type": "int32", - "ref": false, - "description": "The port number." - } + { "name": "id", "type": "int32", "ref": false }, + { "name": "name", "type": "string", "ref": false } ], - "retType": { - "type": "ptr64", - "description": "A handle to the created Connection." - } + "retType": { "type": "ptr64" } }, { - "name": "ConnectionCreateSecure", - "funcName": "ConnectionCreateSecure", - "description": "Creates a new secure Connection with SSL/TLS.", - "paramTypes": [ - { - "name": "host", - "type": "string", - "ref": false, - "description": "The host address to connect to." - }, - { - "name": "port", - "type": "int32", - "ref": false, - "description": "The port number." - }, - { - "name": "useSsl", - "type": "bool", - "ref": false, - "description": "Whether to use SSL/TLS encryption." - } - ], - "retType": { - "type": "ptr64", - "description": "A handle to the created secure Connection." - } + "name": "ResourceHandleCreateDefault", + "funcName": "ResourceHandleCreateDefault", + "group": "Resource", + "paramTypes": [], + "retType": { "type": "ptr64" } }, { - "name": "ConnectionDestroy", - "funcName": "ConnectionDestroy", - "description": "Destroys a Connection and releases its resources.", + "name": "ResourceHandleDestroy", + "funcName": "ResourceHandleDestroy", + "group": "Resource", "paramTypes": [ - { - "name": "connection", - "type": "ptr64", - "ref": false, - "description": "The Connection handle to destroy." - } + { "name": "handle", "type": "ptr64", "ref": false } ], - "retType": { - "type": "void" - } + "retType": { "type": "void" } }, { - "name": "ConnectionConnect", - "funcName": "ConnectionConnect", - "description": "Establishes the connection.", + "name": "ResourceHandleGetId", + "funcName": "ResourceHandleGetId", + "group": "Resource", "paramTypes": [ - { - "name": "connection", - "type": "ptr64", - "ref": false, - "description": "The Connection handle." - } + { "name": "handle", "type": "ptr64", "ref": false } ], - "retType": { - "type": "bool", - "description": "True if connection was successful, false otherwise." - } + "retType": { "type": "int32" } }, { - "name": "ConnectionDisconnect", - "funcName": "ConnectionDisconnect", - "description": "Closes the connection.", + "name": "ResourceHandleGetName", + "funcName": "ResourceHandleGetName", + "group": "Resource", "paramTypes": [ - { - "name": "connection", - "type": "ptr64", - "ref": false, - "description": "The Connection handle." - } + { "name": "handle", "type": "ptr64", "ref": false } ], - "retType": { - "type": "void" - } + "retType": { "type": "string" } }, { - "name": "ConnectionIsConnected", - "funcName": "ConnectionIsConnected", - "description": "Checks if the connection is currently active.", + "name": "ResourceHandleSetName", + "funcName": "ResourceHandleSetName", + "group": "Resource", "paramTypes": [ - { - "name": "connection", - "type": "ptr64", - "ref": false, - "description": "The Connection handle." - } + { "name": "handle", "type": "ptr64", "ref": false }, + { "name": "name", "type": "string", "ref": false } ], - "retType": { - "type": "bool", - "description": "True if connected, false otherwise." - } + "retType": { "type": "void" } }, { - "name": "ConnectionSendData", - "funcName": "ConnectionSendData", - "description": "Sends data through the connection.", + "name": "ResourceHandleIncrementCounter", + "funcName": "ResourceHandleIncrementCounter", + "group": "Resource", "paramTypes": [ - { - "name": "connection", - "type": "ptr64", - "ref": false, - "description": "The Connection handle." - }, - { - "name": "data", - "type": "string", - "ref": false, - "description": "The data to send." - } + { "name": "handle", "type": "ptr64", "ref": false } ], - "retType": { - "type": "int32", - "description": "Number of bytes sent, or -1 on error." - } + "retType": { "type": "void" } }, { - "name": "ConnectionReceiveData", - "funcName": "ConnectionReceiveData", - "description": "Receives data from the connection.", + "name": "ResourceHandleGetCounter", + "funcName": "ResourceHandleGetCounter", + "group": "Resource", "paramTypes": [ - { - "name": "connection", - "type": "ptr64", - "ref": false, - "description": "The Connection handle." - } + { "name": "handle", "type": "ptr64", "ref": false } ], - "retType": { - "type": "string", - "description": "The received data, or empty string if no data available." - } + "retType": { "type": "int32" } }, { - "name": "ConnectionGetHost", - "funcName": "ConnectionGetHost", - "description": "Gets the host address of the connection.", + "name": "ResourceHandleAddData", + "funcName": "ResourceHandleAddData", + "group": "Resource", "paramTypes": [ - { - "name": "connection", - "type": "ptr64", - "ref": false, - "description": "The Connection handle." - } + { "name": "handle", "type": "ptr64", "ref": false }, + { "name": "value", "type": "float", "ref": false } ], - "retType": { - "type": "string", - "description": "The host address." - } + "retType": { "type": "void" } }, { - "name": "ConnectionGetPort", - "funcName": "ConnectionGetPort", - "description": "Gets the port number of the connection.", + "name": "ResourceHandleGetData", + "funcName": "ResourceHandleGetData", + "group": "Resource", "paramTypes": [ - { - "name": "connection", - "type": "ptr64", - "ref": false, - "description": "The Connection handle." - } + { "name": "handle", "type": "ptr64", "ref": false } ], - "retType": { - "type": "int32", - "description": "The port number." - } + "retType": { "type": "float[]" } }, { - "name": "ConnectionGetTotalConnections", - "funcName": "ConnectionGetTotalConnections", - "description": "Gets the total number of active connections (static utility).", + "name": "ResourceHandleGetAliveCount", + "funcName": "ResourceHandleGetAliveCount", + "group": "Resource", "paramTypes": [], - "retType": { - "type": "int32", - "description": "The number of active connections." - } + "retType": { "type": "int32" } }, { - "name": "StatisticsCreate", - "funcName": "StatisticsCreate", - "description": "Creates a new Statistics tracker.", - "paramTypes": [ - { - "name": "name", - "type": "string", - "ref": false, - "description": "The name of the statistics tracker." - } - ], - "retType": { - "type": "ptr64", - "description": "A handle to the created Statistics." - } + "name": "ResourceHandleGetTotalCreated", + "funcName": "ResourceHandleGetTotalCreated", + "group": "Resource", + "paramTypes": [], + "retType": { "type": "int32" } }, { - "name": "StatisticsCreateWithCapacity", - "funcName": "StatisticsCreateWithCapacity", - "description": "Creates a new Statistics tracker with initial capacity.", - "paramTypes": [ - { - "name": "name", - "type": "string", - "ref": false, - "description": "The name of the statistics tracker." - }, - { - "name": "capacity", - "type": "int32", - "ref": false, - "description": "Initial capacity for data storage." - } - ], - "retType": { - "type": "ptr64", - "description": "A handle to the created Statistics." - } + "name": "ResourceHandleGetTotalDestroyed", + "funcName": "ResourceHandleGetTotalDestroyed", + "group": "Resource", + "paramTypes": [], + "retType": { "type": "int32" } }, { - "name": "StatisticsIncrement", - "funcName": "StatisticsIncrement", - "description": "Increments the counter by one.", + "name": "CounterCreate", + "funcName": "CounterCreate", + "group": "Counter", "paramTypes": [ - { - "name": "statistics", - "type": "ptr64", - "ref": false, - "description": "The Statistics handle." - } + { "name": "initialValue", "type": "int64", "ref": false } ], - "retType": { - "type": "void" - } + "retType": { "type": "ptr64" } }, { - "name": "StatisticsIncrementBy", - "funcName": "StatisticsIncrementBy", - "description": "Increments the counter by a specific amount.", - "paramTypes": [ - { - "name": "statistics", - "type": "ptr64", - "ref": false, - "description": "The Statistics handle." - }, - { - "name": "amount", - "type": "int32", - "ref": false, - "description": "The amount to increment by." - } - ], - "retType": { - "type": "void" - } + "name": "CounterCreateZero", + "funcName": "CounterCreateZero", + "group": "Counter", + "paramTypes": [], + "retType": { "type": "ptr64" } }, { - "name": "StatisticsDecrement", - "funcName": "StatisticsDecrement", - "description": "Decrements the counter by one.", + "name": "CounterGetValue", + "funcName": "CounterGetValue", + "group": "Counter", "paramTypes": [ - { - "name": "statistics", - "type": "ptr64", - "ref": false, - "description": "The Statistics handle." - } + { "name": "counter", "type": "ptr64", "ref": false } ], - "retType": { - "type": "void" - } + "retType": { "type": "int64" } }, { - "name": "StatisticsGetCount", - "funcName": "StatisticsGetCount", - "description": "Gets the current count value.", + "name": "CounterSetValue", + "funcName": "CounterSetValue", + "group": "Counter", "paramTypes": [ - { - "name": "statistics", - "type": "ptr64", - "ref": false, - "description": "The Statistics handle." - } + { "name": "counter", "type": "ptr64", "ref": false }, + { "name": "value", "type": "int64", "ref": false } ], - "retType": { - "type": "int32", - "description": "The current count." - } + "retType": { "type": "void" } }, { - "name": "StatisticsReset", - "funcName": "StatisticsReset", - "description": "Resets the counter to zero.", + "name": "CounterIncrement", + "funcName": "CounterIncrement", + "group": "Counter", "paramTypes": [ - { - "name": "statistics", - "type": "ptr64", - "ref": false, - "description": "The Statistics handle." - } + { "name": "counter", "type": "ptr64", "ref": false } ], - "retType": { - "type": "void" - } + "retType": { "type": "void" } }, { - "name": "StatisticsGetName", - "funcName": "StatisticsGetName", - "description": "Gets the name of the statistics tracker.", + "name": "CounterDecrement", + "funcName": "CounterDecrement", + "group": "Counter", "paramTypes": [ - { - "name": "statistics", - "type": "ptr64", - "ref": false, - "description": "The Statistics handle." - } + { "name": "counter", "type": "ptr64", "ref": false } ], - "retType": { - "type": "string", - "description": "The name of the tracker." - } + "retType": { "type": "void" } }, { - "name": "StatisticsAddValue", - "funcName": "StatisticsAddValue", - "description": "Adds a value to the statistics dataset.", + "name": "CounterAdd", + "funcName": "CounterAdd", + "group": "Counter", "paramTypes": [ - { - "name": "statistics", - "type": "ptr64", - "ref": false, - "description": "The Statistics handle." - }, - { - "name": "value", - "type": "double", - "ref": false, - "description": "The value to add." - } + { "name": "counter", "type": "ptr64", "ref": false }, + { "name": "amount", "type": "int64", "ref": false } ], - "retType": { - "type": "void" - } + "retType": { "type": "void" } }, { - "name": "StatisticsGetAverage", - "funcName": "StatisticsGetAverage", - "description": "Calculates the average of all values.", + "name": "CounterReset", + "funcName": "CounterReset", + "group": "Counter", "paramTypes": [ - { - "name": "statistics", - "type": "ptr64", - "ref": false, - "description": "The Statistics handle." - } + { "name": "counter", "type": "ptr64", "ref": false } ], - "retType": { - "type": "double", - "description": "The average value." - } + "retType": { "type": "void" } }, { - "name": "StatisticsGetMin", - "funcName": "StatisticsGetMin", - "description": "Gets the minimum value.", + "name": "CounterIsPositive", + "funcName": "CounterIsPositive", + "group": "Counter", "paramTypes": [ - { - "name": "statistics", - "type": "ptr64", - "ref": false, - "description": "The Statistics handle." - } + { "name": "counter", "type": "ptr64", "ref": false } ], - "retType": { - "type": "double", - "description": "The minimum value." - } + "retType": { "type": "bool" } }, { - "name": "StatisticsGetMax", - "funcName": "StatisticsGetMax", - "description": "Gets the maximum value.", + "name": "CounterCompare", + "funcName": "CounterCompare", + "group": "Counter", "paramTypes": [ - { - "name": "statistics", - "type": "ptr64", - "ref": false, - "description": "The Statistics handle." - } + { "name": "value1", "type": "int64", "ref": false }, + { "name": "value2", "type": "int64", "ref": false } ], - "retType": { - "type": "double", - "description": "The maximum value." - } + "retType": { "type": "int32" } }, { - "name": "StatisticsGetGlobalCount", - "funcName": "StatisticsGetGlobalCount", - "description": "Gets the total number of Statistics instances created (static utility).", - "paramTypes": [], - "retType": { - "type": "int32", - "description": "The total number of Statistics instances." - } + "name": "CounterSum", + "funcName": "CounterSum", + "group": "Counter", + "paramTypes": [ + { "name": "values", "type": "int64[]", "ref": false } + ], + "retType": { "type": "int64" } } ], "classes": [ { - "name": "Connection", - "description": "RAII wrapper for network Connection handle. Manages connection lifecycle with automatic cleanup on disposal.", + "name": "ResourceHandle", + "description": "RAII wrapper for ResourceHandle pointer", "handleType": "ptr64", "constructors": [ - "ConnectionCreate", - "ConnectionCreateSecure" + "ResourceHandleCreate", + "ResourceHandleCreateDefault" ], - "destructor": "ConnectionDestroy", - "bindings": [ - { - "name": "Connect", - "method": "ConnectionConnect", - "bindSelf": true - }, - { - "name": "Disconnect", - "method": "ConnectionDisconnect", - "bindSelf": true - }, - { - "name": "IsConnected", - "method": "ConnectionIsConnected", - "bindSelf": true - }, - { - "name": "SendData", - "method": "ConnectionSendData", - "bindSelf": true - }, - { - "name": "ReceiveData", - "method": "ConnectionReceiveData", - "bindSelf": true - }, - { - "name": "GetHost", - "method": "ConnectionGetHost", - "bindSelf": true - }, - { - "name": "GetPort", - "method": "ConnectionGetPort", - "bindSelf": true - }, - { - "name": "GetTotalConnections", - "method": "ConnectionGetTotalConnections", - "bindSelf": false - } + "destructor": "ResourceHandleDestroy", + "methods": [ + { "name": "GetId", "method": "ResourceHandleGetId", "bindSelf": true }, + { "name": "GetName", "method": "ResourceHandleGetName", "bindSelf": true }, + { "name": "SetName", "method": "ResourceHandleSetName", "bindSelf": true }, + { "name": "IncrementCounter", "method": "ResourceHandleIncrementCounter", "bindSelf": true }, + { "name": "GetCounter", "method": "ResourceHandleGetCounter", "bindSelf": true }, + { "name": "AddData", "method": "ResourceHandleAddData", "bindSelf": true }, + { "name": "GetData", "method": "ResourceHandleGetData", "bindSelf": true }, + { "name": "GetAliveCount", "method": "ResourceHandleGetAliveCount", "bindSelf": false }, + { "name": "GetTotalCreated", "method": "ResourceHandleGetTotalCreated", "bindSelf": false }, + { "name": "GetTotalDestroyed", "method": "ResourceHandleGetTotalDestroyed", "bindSelf": false } ] }, { - "name": "Statistics", - "description": "Lightweight wrapper for statistics tracking. Does not require explicit cleanup as it manages no external resources.", + "name": "Counter", "handleType": "ptr64", "constructors": [ - "StatisticsCreate", - "StatisticsCreateWithCapacity" + "CounterCreate", + "CounterCreateZero" ], - "bindings": [ - { - "name": "Increment", - "method": "StatisticsIncrement", - "bindSelf": true - }, - { - "name": "IncrementBy", - "method": "StatisticsIncrementBy", - "bindSelf": true - }, - { - "name": "Decrement", - "method": "StatisticsDecrement", - "bindSelf": true - }, - { - "name": "GetCount", - "method": "StatisticsGetCount", - "bindSelf": true - }, - { - "name": "Reset", - "method": "StatisticsReset", - "bindSelf": true - }, - { - "name": "GetName", - "method": "StatisticsGetName", - "bindSelf": true - }, - { - "name": "AddValue", - "method": "StatisticsAddValue", - "bindSelf": true - }, - { - "name": "GetAverage", - "method": "StatisticsGetAverage", - "bindSelf": true - }, - { - "name": "GetMin", - "method": "StatisticsGetMin", - "bindSelf": true - }, - { - "name": "GetMax", - "method": "StatisticsGetMax", - "bindSelf": true - }, - { - "name": "GetGlobalCount", - "method": "StatisticsGetGlobalCount", - "bindSelf": false - } + "destructor": null, + "methods": [ + { "name": "GetValue", "method": "CounterGetValue", "bindSelf": true }, + { "name": "SetValue", "method": "CounterSetValue", "bindSelf": true }, + { "name": "Increment", "method": "CounterIncrement", "bindSelf": true }, + { "name": "Decrement", "method": "CounterDecrement", "bindSelf": true }, + { "name": "Add", "method": "CounterAdd", "bindSelf": true }, + { "name": "Reset", "method": "CounterReset", "bindSelf": true }, + { "name": "IsPositive", "method": "CounterIsPositive", "bindSelf": true }, + { "name": "Compare", "method": "CounterCompare", "bindSelf": false }, + { "name": "Sum", "method": "CounterSum", "bindSelf": false } ] } ] diff --git a/test/cross_call_master/plugin.cpp b/test/cross_call_master/plugin.cpp index e8cc3c0..3aadcd6 100644 --- a/test/cross_call_master/plugin.cpp +++ b/test/cross_call_master/plugin.cpp @@ -4858,388 +4858,266 @@ PLUGIN_API plg::string CallFuncEnumCallback(cross_call_worker::FuncEnum func) { // classes -// Global counters for tracking lifecycle -static std::atomic g_connection_create_count{0}; -static std::atomic g_connection_destroy_count{0}; -static std::atomic g_connection_active_count{0}; - -static std::atomic g_statistics_create_count{0}; -static std::atomic g_statistics_active_count{0}; - -// Mutex for thread-safe logging -static std::mutex g_log_mutex; - -// Helper function for thread-safe logging -template -void SafeLog(std::format_string fmt, Args&&... args) { - std::lock_guard lock(g_log_mutex); - std::println(fmt, std::forward(args)...); -} - -//============================================================================= -// Connection Class - WITH DESTRUCTOR -//============================================================================= -class Connection { -private: - plg::string m_host; - int32_t m_port; - bool m_useSsl; - bool m_connected; - int m_instanceId; - plg::string m_receiveBuffer; - +class ResourceHandle { public: - Connection(const plg::string& host, int32_t port, bool useSsl = false) - : m_host(host), m_port(port), m_useSsl(useSsl), m_connected(false) { - - m_instanceId = ++g_connection_create_count; - ++g_connection_active_count; - - SafeLog("[Connection] Constructor called: Instance #{} | Host: {} | Port: {} | SSL: {} | Active: {}", - m_instanceId, m_host, m_port, m_useSsl, g_connection_active_count.load()); - } - - ~Connection() { - ++g_connection_destroy_count; - --g_connection_active_count; - - SafeLog("[Connection] Destructor called: Instance #{} | Host: {} | Port: {} | Destroyed: {} | Active: {}", - m_instanceId, m_host, m_port, g_connection_destroy_count.load(), g_connection_active_count.load()); - - if (m_connected) { - SafeLog("[Connection] Warning: Instance #{} destroyed while still connected!", m_instanceId); - } - } - - bool Connect() { - if (m_connected) { - SafeLog("[Connection] Instance #{} already connected", m_instanceId); - return true; - } - - SafeLog("[Connection] Instance #{} connecting to {}:{}...", m_instanceId, m_host, m_port); - m_connected = true; - m_receiveBuffer = std::format("Welcome to {}:{}", m_host, m_port); - SafeLog("[Connection] Instance #{} connected successfully", m_instanceId); - return true; - } - - void Disconnect() { - if (!m_connected) { - SafeLog("[Connection] Instance #{} already disconnected", m_instanceId); - return; - } - - SafeLog("[Connection] Instance #{} disconnecting from {}:{}...", m_instanceId, m_host, m_port); - m_connected = false; - m_receiveBuffer.clear(); - SafeLog("[Connection] Instance #{} disconnected", m_instanceId); + int32_t id; + plg::string name; + int32_t counter; + std::vector data; + + // Static tracking variables + static std::atomic s_aliveCount; + static std::atomic s_totalCreated; + static std::atomic s_totalDestroyed; + static std::mutex s_mutex; + + ResourceHandle(int32_t id, const plg::string& name) + : id(id), name(name), counter(0) { + s_aliveCount++; + s_totalCreated++; + std::lock_guard lock(s_mutex); + std::println("[LIFECYCLE] ResourceHandle CREATED: ID={}, Name='{}', Alive={}, TotalCreated={}", + id, name, s_aliveCount.load(), s_totalCreated.load()); } - bool IsConnected() const { - return m_connected; - } - - int32_t SendData(const plg::string& data) { - if (!m_connected) { - SafeLog("[Connection] Instance #{} ERROR: Cannot send, not connected", m_instanceId); - return -1; - } - - SafeLog("[Connection] Instance #{} sending {} bytes: '{}'", m_instanceId, data.size(), data); - // Simulate sending data and update receive buffer - m_receiveBuffer = std::format("Echo: {}", data); - return static_cast(data.size()); - } - - plg::string ReceiveData() { - if (!m_connected) { - SafeLog("[Connection] Instance #{} ERROR: Cannot receive, not connected", m_instanceId); - return ""; - } - - plg::string data = m_receiveBuffer; - m_receiveBuffer.clear(); - SafeLog("[Connection] Instance #{} received {} bytes", m_instanceId, data.size()); - return data; + ~ResourceHandle() { + s_aliveCount--; + s_totalDestroyed++; + std::lock_guard lock(s_mutex); + std::println("[LIFECYCLE] ResourceHandle DESTROYED: ID={}, Name='{}', Counter={}, DataSize={}, Alive={}, TotalDestroyed={}", + id, name, counter, data.size(), s_aliveCount.load(), s_totalDestroyed.load()); } - const plg::string& GetHost() const { return m_host; } - int32_t GetPort() const { return m_port; } - int GetInstanceId() const { return m_instanceId; } + // Delete copy operations to ensure proper lifecycle + ResourceHandle(const ResourceHandle&) = delete; + ResourceHandle& operator=(const ResourceHandle&) = delete; }; -//============================================================================= -// Statistics Class - WITHOUT DESTRUCTOR (lightweight) -//============================================================================= -class Statistics { -private: - plg::string m_name; - int32_t m_count; - int m_instanceId; - std::vector m_values; - -public: - Statistics(const plg::string& name, int32_t capacity = 100) - : m_name(name), m_count(0) { - - m_instanceId = ++g_statistics_create_count; - ++g_statistics_active_count; - m_values.reserve(capacity); - - SafeLog("[Statistics] Constructor called: Instance #{} | Name: '{}' | Capacity: {} | Active: {}", - m_instanceId, m_name, capacity, g_statistics_active_count.load()); - } - - // Note: No destructor in manifest, but we can still track in C++ - ~Statistics() { - --g_statistics_active_count; - SafeLog("[Statistics] Destructor called (C++ cleanup): Instance #{} | Name: '{}' | Final Count: {} | Active: {}", - m_instanceId, m_name, m_count, g_statistics_active_count.load()); - } +// Initialize static members +std::atomic ResourceHandle::s_aliveCount{0}; +std::atomic ResourceHandle::s_totalCreated{0}; +std::atomic ResourceHandle::s_totalDestroyed{0}; +std::mutex ResourceHandle::s_mutex; - void Increment() { - ++m_count; - SafeLog("[Statistics] Instance #{} incremented: Count = {}", m_instanceId, m_count); - } - - void IncrementBy(int32_t amount) { - m_count += amount; - SafeLog("[Statistics] Instance #{} incremented by {}: Count = {}", m_instanceId, amount, m_count); - } - - void Decrement() { - --m_count; - SafeLog("[Statistics] Instance #{} decremented: Count = {}", m_instanceId, m_count); - } - - int32_t GetCount() const { - return m_count; - } - - void Reset() { - SafeLog("[Statistics] Instance #{} reset: {} -> 0", m_instanceId, m_count); - m_count = 0; - m_values.clear(); +// ResourceHandle exported functions +PLUGIN_API void* ResourceHandleCreate(int32_t id, const plg::string& name) { + try { + return new ResourceHandle(id, name); + } catch (const std::exception& e) { + std::println("[ERROR] ResourceHandleCreate failed: {}", e.what()); + return nullptr; } +} - const plg::string& GetName() const { - return m_name; +PLUGIN_API void* ResourceHandleCreateDefault() { + static std::atomic nextId{1000}; + int32_t id = nextId++; + try { + return new ResourceHandle(id, std::format("Resource_{}", id)); + } catch (const std::exception& e) { + std::println("[ERROR] ResourceHandleCreateDefault failed: {}", e.what()); + return nullptr; } +} - void AddValue(double value) { - m_values.push_back(value); - SafeLog("[Statistics] Instance #{} added value: {} (total values: {})", m_instanceId, value, m_values.size()); +PLUGIN_API void ResourceHandleDestroy(void* handle) { + if (handle) { + delete static_cast(handle); + } else { + std::println("[WARNING] ResourceHandleDestroy called with nullptr"); } +} - double GetAverage() const { - if (m_values.empty()) return 0.0; - double sum = std::accumulate(m_values.begin(), m_values.end(), 0.0); - return sum / m_values.size(); +PLUGIN_API int32_t ResourceHandleGetId(void* handle) { + if (!handle) { + std::println("[ERROR] ResourceHandleGetId: handle is null"); + return -1; } + return static_cast(handle)->id; +} - double GetMin() const { - if (m_values.empty()) return 0.0; - return *std::min_element(m_values.begin(), m_values.end()); +PLUGIN_API plg::string ResourceHandleGetName(void* handle) { + if (!handle) { + std::println("[ERROR] ResourceHandleGetName: handle is null"); + return ""; } + return static_cast(handle)->name; +} - double GetMax() const { - if (m_values.empty()) return 0.0; - return *std::max_element(m_values.begin(), m_values.end()); +PLUGIN_API void ResourceHandleSetName(void* handle, const plg::string& name) { + if (!handle) { + std::println("[ERROR] ResourceHandleSetName: handle is null"); + return; } + auto* res = static_cast(handle); + std::println("[ACTION] ResourceHandle ID={}: Name changed from '{}' to '{}'", + res->id, res->name, name); + res->name = name; +} - int GetInstanceId() const { return m_instanceId; } -}; - -//============================================================================= -// Connection Exported Functions -//============================================================================= - -extern "C" -PLUGIN_API void* ConnectionCreate(const plg::string& host, int32_t port) { - try { - auto conn = new Connection(host, port, false); - SafeLog("[EXPORT] ConnectionCreate: Created instance #{} -> ptr: {}", - conn->GetInstanceId(), static_cast(conn)); - return static_cast(conn); - } catch (const std::exception& e) { - SafeLog("[EXPORT] ConnectionCreate: FAILED with exception: {}", e.what()); - return nullptr; +PLUGIN_API void ResourceHandleIncrementCounter(void* handle) { + if (!handle) { + std::println("[ERROR] ResourceHandleIncrementCounter: handle is null"); + return; } + auto* res = static_cast(handle); + res->counter++; + std::println("[ACTION] ResourceHandle ID={}: Counter incremented to {}", res->id, res->counter); } -extern "C" -PLUGIN_API void* ConnectionCreateSecure(const plg::string& host, int32_t port, bool useSsl) { - try { - auto conn = new Connection(host, port, useSsl); - SafeLog("[EXPORT] ConnectionCreateSecure: Created instance #{} -> ptr: {}", - conn->GetInstanceId(), static_cast(conn)); - return static_cast(conn); - } catch (const std::exception& e) { - SafeLog("[EXPORT] ConnectionCreateSecure: FAILED with exception: {}", e.what()); - return nullptr; +PLUGIN_API int32_t ResourceHandleGetCounter(void* handle) { + if (!handle) { + std::println("[ERROR] ResourceHandleGetCounter: handle is null"); + return -1; } + return static_cast(handle)->counter; } -extern "C" -PLUGIN_API void ConnectionDestroy(void* connection) { - if (!connection) { - SafeLog("[EXPORT] ConnectionDestroy: Called with nullptr!"); +PLUGIN_API void ResourceHandleAddData(void* handle, float value) { + if (!handle) { + std::println("[ERROR] ResourceHandleAddData: handle is null"); return; } - - auto conn = reinterpret_cast(connection); - int id = conn->GetInstanceId(); - SafeLog("[EXPORT] ConnectionDestroy: Destroying instance #{} at ptr: {}", id, connection); - delete conn; - SafeLog("[EXPORT] ConnectionDestroy: Instance #{} destroyed successfully", id); -} - -extern "C" -PLUGIN_API bool ConnectionConnect(void* connection) { - if (!connection) return false; - return reinterpret_cast(connection)->Connect(); + auto* res = static_cast(handle); + res->data.push_back(value); + std::println("[ACTION] ResourceHandle ID={}: Added data value {}, total data points: {}", + res->id, value, res->data.size()); } -extern "C" -PLUGIN_API void ConnectionDisconnect(void* connection) { - if (!connection) return; - reinterpret_cast(connection)->Disconnect(); +PLUGIN_API plg::vector ResourceHandleGetData(void* handle) { + if (!handle) { + std::println("[ERROR] ResourceHandleGetData: handle is null"); + return {}; + } + auto* res = static_cast(handle); + return plg::vector(res->data.begin(), res->data.end()); } -extern "C" -PLUGIN_API bool ConnectionIsConnected(void* connection) { - if (!connection) return false; - return reinterpret_cast(connection)->IsConnected(); +PLUGIN_API int32_t ResourceHandleGetAliveCount() { + int32_t count = ResourceHandle::s_aliveCount.load(); + std::println("[STATS] ResourceHandle: {} instances currently alive", count); + return count; } -extern "C" -PLUGIN_API int32_t ConnectionSendData(void* connection, const plg::string& data) { - if (!connection) return -1; - return reinterpret_cast(connection)->SendData(data); +PLUGIN_API int32_t ResourceHandleGetTotalCreated() { + int32_t count = ResourceHandle::s_totalCreated.load(); + std::println("[STATS] ResourceHandle: {} total instances created", count); + return count; } -extern "C" -PLUGIN_API plg::string ConnectionReceiveData(void* connection) { - if (!connection) return ""; - return reinterpret_cast(connection)->ReceiveData(); +PLUGIN_API int32_t ResourceHandleGetTotalDestroyed() { + int32_t count = ResourceHandle::s_totalDestroyed.load(); + std::println("[STATS] ResourceHandle: {} total instances destroyed", count); + return count; } -extern "C" -PLUGIN_API plg::string ConnectionGetHost(void* connection) { - if (!connection) return ""; - return reinterpret_cast(connection)->GetHost(); -} +// ============================================================================ +// Counter - Class WITHOUT destructor (lightweight wrapper) +// ============================================================================ -extern "C" -PLUGIN_API int32_t ConnectionGetPort(void* connection) { - if (!connection) return -1; - return reinterpret_cast(connection)->GetPort(); -} +struct Counter { + int64_t value; -extern "C" -PLUGIN_API int32_t ConnectionGetTotalConnections() { - int active = g_connection_active_count.load(); - SafeLog("[EXPORT] ConnectionGetTotalConnections: Active = {}", active); - return active; -} + explicit Counter(int64_t val) : value(val) { + std::println("[COUNTER] Counter created with value: {}", value); + } -//============================================================================= -// Statistics Exported Functions -//============================================================================= + // Note: No destructor logging since this is a lightweight wrapper +}; -extern "C" -PLUGIN_API void* StatisticsCreate(const plg::string& name) { +// Counter exported functions +PLUGIN_API void* CounterCreate(int64_t initialValue) { try { - auto stats = new Statistics(name); - SafeLog("[EXPORT] StatisticsCreate: Created instance #{} -> ptr: {}", - stats->GetInstanceId(), static_cast(stats)); - return static_cast(stats); + return new Counter(initialValue); } catch (const std::exception& e) { - SafeLog("[EXPORT] StatisticsCreate: FAILED with exception: {}", e.what()); + std::println("[ERROR] CounterCreate failed: {}", e.what()); return nullptr; } } -extern "C" -PLUGIN_API void* StatisticsCreateWithCapacity(const plg::string& name, int32_t capacity) { +PLUGIN_API void* CounterCreateZero() { try { - auto stats = new Statistics(name, capacity); - SafeLog("[EXPORT] StatisticsCreateWithCapacity: Created instance #{} -> ptr: {}", - stats->GetInstanceId(), static_cast(stats)); - return static_cast(stats); + return new Counter(0); } catch (const std::exception& e) { - SafeLog("[EXPORT] StatisticsCreateWithCapacity: FAILED with exception: {}", e.what()); + std::println("[ERROR] CounterCreateZero failed: {}", e.what()); return nullptr; } } -extern "C" -PLUGIN_API void StatisticsIncrement(void* statistics) { - if (!statistics) return; - reinterpret_cast(statistics)->Increment(); -} - -extern "C" -PLUGIN_API void StatisticsIncrementBy(void* statistics, int32_t amount) { - if (!statistics) return; - reinterpret_cast(statistics)->IncrementBy(amount); -} - -extern "C" -PLUGIN_API void StatisticsDecrement(void* statistics) { - if (!statistics) return; - reinterpret_cast(statistics)->Decrement(); +PLUGIN_API int64_t CounterGetValue(void* counter) { + if (!counter) { + std::println("[ERROR] CounterGetValue: counter is null"); + return 0; + } + return static_cast(counter)->value; } -extern "C" -PLUGIN_API int32_t StatisticsGetCount(void* statistics) { - if (!statistics) return 0; - return reinterpret_cast(statistics)->GetCount(); +PLUGIN_API void CounterSetValue(void* counter, int64_t value) { + if (!counter) { + std::println("[ERROR] CounterSetValue: counter is null"); + return; + } + auto* cnt = static_cast(counter); + std::println("[COUNTER] Counter value changed: {} -> {}", cnt->value, value); + cnt->value = value; } -extern "C" -PLUGIN_API void StatisticsReset(void* statistics) { - if (!statistics) return; - reinterpret_cast(statistics)->Reset(); +PLUGIN_API void CounterIncrement(void* counter) { + if (!counter) { + std::println("[ERROR] CounterIncrement: counter is null"); + return; + } + auto* cnt = static_cast(counter); + cnt->value++; + std::println("[COUNTER] Counter incremented to: {}", cnt->value); } -extern "C" -PLUGIN_API plg::string StatisticsGetName(void* statistics) { - if (!statistics) return ""; - return reinterpret_cast(statistics)->GetName(); +PLUGIN_API void CounterDecrement(void* counter) { + if (!counter) { + std::println("[ERROR] CounterDecrement: counter is null"); + return; + } + auto* cnt = static_cast(counter); + cnt->value--; + std::println("[COUNTER] Counter decremented to: {}", cnt->value); } -extern "C" -PLUGIN_API void StatisticsAddValue(void* statistics, double value) { - if (!statistics) return; - reinterpret_cast(statistics)->AddValue(value); +PLUGIN_API void CounterAdd(void* counter, int64_t amount) { + if (!counter) { + std::println("[ERROR] CounterAdd: counter is null"); + return; + } + auto* cnt = static_cast(counter); + cnt->value += amount; + std::println("[COUNTER] Counter added {}, new value: {}", amount, cnt->value); } -extern "C" -PLUGIN_API double StatisticsGetAverage(void* statistics) { - if (!statistics) return 0.0; - return reinterpret_cast(statistics)->GetAverage(); +PLUGIN_API void CounterReset(void* counter) { + if (!counter) { + std::println("[ERROR] CounterReset: counter is null"); + return; + } + auto* cnt = static_cast(counter); + std::println("[COUNTER] Counter reset from {} to 0", cnt->value); + cnt->value = 0; } -extern "C" -PLUGIN_API double StatisticsGetMin(void* statistics) { - if (!statistics) return 0.0; - return reinterpret_cast(statistics)->GetMin(); +PLUGIN_API bool CounterIsPositive(void* counter) { + if (!counter) { + std::println("[ERROR] CounterIsPositive: counter is null"); + return false; + } + return static_cast(counter)->value > 0; } -extern "C" -PLUGIN_API double StatisticsGetMax(void* statistics) { - if (!statistics) return 0.0; - return reinterpret_cast(statistics)->GetMax(); +PLUGIN_API int32_t CounterCompare(int64_t value1, int64_t value2) { + if (value1 < value2) return -1; + if (value1 > value2) return 1; + return 0; } -extern "C" -PLUGIN_API int32_t StatisticsGetGlobalCount() { - int created = g_statistics_create_count.load(); - int active = g_statistics_active_count.load(); - SafeLog("[EXPORT] StatisticsGetGlobalCount: Total Created = {}, Active = {}", created, active); - return created; +PLUGIN_API int64_t CounterSum(const plg::vector& values) { + return std::accumulate(values.begin(), values.end(), int64_t{0}); } PLUGIFY_WARN_POP() diff --git a/test/cross_call_worker/external/plugify/include/pps/cross_call_master.hpp b/test/cross_call_worker/external/plugify/include/pps/cross_call_master.hpp index e1333ef..d287b43 100644 --- a/test/cross_call_worker/external/plugify/include/pps/cross_call_master.hpp +++ b/test/cross_call_worker/external/plugify/include/pps/cross_call_master.hpp @@ -4,3229 +4,1961 @@ #include #include -// Generated from cross_call_master.pplugin by https://github.com/untrustedmodders/plugify-module-cpp/blob/main/generator/generator.py +// Generated from cross_call_master.pplugin namespace cross_call_master { - enum class Example : int32_t { - First = 1, - Second = 2, - Third = 3, - Forth = 4, - }; - - using NoParamReturnFunctionCallbackFunc = int32_t (*)(); - using FuncVoid = void (*)(); - using FuncBool = bool (*)(); - using FuncChar8 = char (*)(); - using FuncChar16 = char16_t (*)(); - using FuncInt8 = int8_t (*)(); - using FuncInt16 = int16_t (*)(); - using FuncInt32 = int32_t (*)(); - using FuncInt64 = int64_t (*)(); - using FuncUInt8 = uint8_t (*)(); - using FuncUInt16 = uint16_t (*)(); - using FuncUInt32 = uint32_t (*)(); - using FuncUInt64 = uint64_t (*)(); - using FuncPtr = void* (*)(); - using FuncFloat = float (*)(); - using FuncDouble = double (*)(); - using FuncString = plg::string (*)(); - using FuncAny = plg::any (*)(); - using FuncFunction = void* (*)(); - using FuncBoolVector = plg::vector (*)(); - using FuncChar8Vector = plg::vector (*)(); - using FuncChar16Vector = plg::vector (*)(); - using FuncInt8Vector = plg::vector (*)(); - using FuncInt16Vector = plg::vector (*)(); - using FuncInt32Vector = plg::vector (*)(); - using FuncInt64Vector = plg::vector (*)(); - using FuncUInt8Vector = plg::vector (*)(); - using FuncUInt16Vector = plg::vector (*)(); - using FuncUInt32Vector = plg::vector (*)(); - using FuncUInt64Vector = plg::vector (*)(); - using FuncPtrVector = plg::vector (*)(); - using FuncFloatVector = plg::vector (*)(); - using FuncDoubleVector = plg::vector (*)(); - using FuncStringVector = plg::vector (*)(); - using FuncAnyVector = plg::vector (*)(); - using FuncVec2Vector = plg::vector (*)(); - using FuncVec3Vector = plg::vector (*)(); - using FuncVec4Vector = plg::vector (*)(); - using FuncMat4x4Vector = plg::vector (*)(); - using FuncVec2 = plg::vec2 (*)(); - using FuncVec3 = plg::vec3 (*)(); - using FuncVec4 = plg::vec4 (*)(); - using FuncMat4x4 = plg::mat4x4 (*)(); - using Func1 = int32_t (*)(const plg::vec3 &); - using Func2 = char (*)(float, int64_t); - using Func3 = void (*)(void *, const plg::vec4 &, const plg::string &); - using Func4 = plg::vec4 (*)(bool, int32_t, char16_t, const plg::mat4x4 &); - using Func5 = bool (*)(int8_t, const plg::vec2 &, void *, double, const plg::vector &); - using Func6 = int64_t (*)(const plg::string &, float, const plg::vector &, int16_t, - const plg::vector &, void *); - using Func7 = double (*)(const plg::vector &, uint16_t, char16_t, const plg::vector &, - const plg::vec4 &, bool, uint64_t); - using Func8 = plg::mat4x4 (*)(const plg::vec3 &, const plg::vector &, int16_t, bool, const plg::vec4 &, - const plg::vector &, char16_t, int32_t); - using Func9 = void (*)(float, const plg::vec2 &, const plg::vector &, uint64_t, bool, const plg::string &, - const plg::vec4 &, int16_t, void *); - using Func10 = uint32_t (*)(const plg::vec4 &, const plg::mat4x4 &, const plg::vector &, uint64_t, - const plg::vector &, int32_t, bool, const plg::vec2 &, int64_t, double); - using Func11 = void* (*)(const plg::vector &, char16_t, uint8_t, double, const plg::vec3 &, - const plg::vector &, int64_t, uint16_t, float, const plg::vec2 &, uint32_t); - using Func12 = bool (*)(void *, const plg::vector &, uint32_t, double, bool, int32_t, int8_t, uint64_t, - float, const plg::vector &, int64_t, char); - using Func13 = plg::string (*)(int64_t, const plg::vector &, uint16_t, float, const plg::vector &, - const plg::vec4 &, const plg::string &, int32_t, const plg::vec3 &, void *, - const plg::vec2 &, const plg::vector &, int16_t); - using Func14 = plg::vector (*)(const plg::vector &, const plg::vector &, - const plg::mat4x4 &, bool, char16_t, int32_t, - const plg::vector &, uint16_t, const plg::vector &, - int8_t, const plg::vec3 &, const plg::vec4 &, double, void *); - using Func15 = int16_t (*)(const plg::vector &, const plg::mat4x4 &, const plg::vec4 &, void *, uint64_t, - const plg::vector &, bool, float, const plg::vector &, uint8_t, - int32_t, const plg::vec2 &, uint16_t, double, const plg::vector &); - using Func16 = void* (*)(const plg::vector &, int16_t, const plg::vector &, const plg::vec4 &, - const plg::mat4x4 &, const plg::vec2 &, const plg::vector &, - const plg::vector &, const plg::string &, int64_t, const plg::vector &, - const plg::vec3 &, float, double, int8_t, uint16_t); - using Func17 = void (*)(int32_t &); - using Func18 = plg::vec2 (*)(int8_t &, int16_t &); - using Func19 = void (*)(uint32_t &, plg::vec3 &, plg::vector &); - using Func20 = int32_t (*)(char16_t &, plg::vec4 &, plg::vector &, char &); - using Func21 = float (*)(plg::mat4x4 &, plg::vector &, plg::vec2 &, bool &, double &); - using Func22 = uint64_t (*)(void *&, uint32_t &, plg::vector &, int16_t &, plg::string &, plg::vec4 &); - using Func23 = void (*)(uint64_t &, plg::vec2 &, plg::vector &, char16_t &, float &, int8_t &, - plg::vector &); - using Func24 = plg::mat4x4 (*)(plg::vector &, int64_t &, plg::vector &, plg::vec4 &, uint64_t &, - plg::vector &, double &, plg::vector &); - using Func25 = double (*)(int32_t &, plg::vector &, bool &, uint8_t &, plg::string &, plg::vec3 &, - int64_t &, plg::vec4 &, uint16_t &); - using Func26 = char (*)(char16_t &, plg::vec2 &, plg::mat4x4 &, plg::vector &, int16_t &, uint64_t &, - uint32_t &, plg::vector &, void *&, bool &); - using Func27 = uint8_t (*)(float &, plg::vec3 &, void *&, plg::vec2 &, plg::vector &, plg::mat4x4 &, - bool &, plg::vec4 &, int8_t &, int32_t &, plg::vector &); - using Func28 = plg::string (*)(void *&, uint16_t &, plg::vector &, plg::mat4x4 &, float &, plg::vec4 &, - plg::string &, plg::vector &, int64_t &, bool &, plg::vec3 &, - plg::vector &); - using Func29 = plg::vector (*)(plg::vec4 &, int32_t &, plg::vector &, double &, bool &, - int8_t &, plg::vector &, float &, plg::string &, - plg::mat4x4 &, uint64_t &, plg::vec3 &, plg::vector &); - using Func30 = int32_t (*)(void *&, plg::vec4 &, int64_t &, plg::vector &, bool &, plg::string &, - plg::vec3 &, plg::vector &, float &, plg::vec2 &, plg::mat4x4 &, int8_t &, - plg::vector &, double &); - using Func31 = plg::vec3 (*)(char &, uint32_t &, plg::vector &, plg::vec4 &, plg::string &, bool &, - int64_t &, plg::vec2 &, int8_t &, uint16_t &, plg::vector &, plg::mat4x4 &, - plg::vec3 &, float &, plg::vector &); - using Func32 = double (*)(int32_t &, uint16_t &, plg::vector &, plg::vec4 &, void *&, - plg::vector &, plg::mat4x4 &, uint64_t &, plg::string &, int64_t &, plg::vec2 &, - plg::vector &, bool &, plg::vec3 &, uint8_t &, plg::vector &); - using Func33 = void (*)(plg::any &); - using FuncEnum = plg::vector (*)(Example, plg::vector &); - - /** - * @brief No description provided. - * - * @function ReverseReturn - * @param returnString (string): No description available. - */ - inline void ReverseReturn(const plg::string &returnString) { - using ReverseReturnFn = void (*)(const plg::string &); - static ReverseReturnFn __func = nullptr; - if (__func == nullptr) - plg::GetMethodPtr2("cross_call_master.ReverseReturn", reinterpret_cast(&__func)); - __func(returnString); - } - - /** - * @brief No description provided. - * - * @function NoParamReturnVoidCallback - */ - inline void NoParamReturnVoidCallback() { - using NoParamReturnVoidCallbackFn = void (*)(); - static NoParamReturnVoidCallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.NoParamReturnVoidCallback", - reinterpret_cast(&__func)); - __func(); - } - - /** - * @brief No description provided. - * - * @function NoParamReturnBoolCallback - * - * @return bool: No description available. - */ - inline bool NoParamReturnBoolCallback() { - using NoParamReturnBoolCallbackFn = bool (*)(); - static NoParamReturnBoolCallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.NoParamReturnBoolCallback", - reinterpret_cast(&__func)); - return __func(); - } - - /** - * @brief No description provided. - * - * @function NoParamReturnChar8Callback - * - * @return char8: No description available. - */ - inline char NoParamReturnChar8Callback() { - using NoParamReturnChar8CallbackFn = char (*)(); - static NoParamReturnChar8CallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.NoParamReturnChar8Callback", - reinterpret_cast(&__func)); - return __func(); - } - - /** - * @brief No description provided. - * - * @function NoParamReturnChar16Callback - * - * @return char16: No description available. - */ - inline char16_t NoParamReturnChar16Callback() { - using NoParamReturnChar16CallbackFn = char16_t (*)(); - static NoParamReturnChar16CallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.NoParamReturnChar16Callback", - reinterpret_cast(&__func)); - return __func(); - } - - /** - * @brief No description provided. - * - * @function NoParamReturnInt8Callback - * - * @return int8: No description available. - */ - inline int8_t NoParamReturnInt8Callback() { - using NoParamReturnInt8CallbackFn = int8_t (*)(); - static NoParamReturnInt8CallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.NoParamReturnInt8Callback", - reinterpret_cast(&__func)); - return __func(); - } - - /** - * @brief No description provided. - * - * @function NoParamReturnInt16Callback - * - * @return int16: No description available. - */ - inline int16_t NoParamReturnInt16Callback() { - using NoParamReturnInt16CallbackFn = int16_t (*)(); - static NoParamReturnInt16CallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.NoParamReturnInt16Callback", - reinterpret_cast(&__func)); - return __func(); - } - - /** - * @brief No description provided. - * - * @function NoParamReturnInt32Callback - * - * @return int32: No description available. - */ - inline int32_t NoParamReturnInt32Callback() { - using NoParamReturnInt32CallbackFn = int32_t (*)(); - static NoParamReturnInt32CallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.NoParamReturnInt32Callback", - reinterpret_cast(&__func)); - return __func(); - } - - /** - * @brief No description provided. - * - * @function NoParamReturnInt64Callback - * - * @return int64: No description available. - */ - inline int64_t NoParamReturnInt64Callback() { - using NoParamReturnInt64CallbackFn = int64_t (*)(); - static NoParamReturnInt64CallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.NoParamReturnInt64Callback", - reinterpret_cast(&__func)); - return __func(); - } - - /** - * @brief No description provided. - * - * @function NoParamReturnUInt8Callback - * - * @return uint8: No description available. - */ - inline uint8_t NoParamReturnUInt8Callback() { - using NoParamReturnUInt8CallbackFn = uint8_t (*)(); - static NoParamReturnUInt8CallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.NoParamReturnUInt8Callback", - reinterpret_cast(&__func)); - return __func(); - } - - /** - * @brief No description provided. - * - * @function NoParamReturnUInt16Callback - * - * @return uint16: No description available. - */ - inline uint16_t NoParamReturnUInt16Callback() { - using NoParamReturnUInt16CallbackFn = uint16_t (*)(); - static NoParamReturnUInt16CallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.NoParamReturnUInt16Callback", - reinterpret_cast(&__func)); - return __func(); - } - - /** - * @brief No description provided. - * - * @function NoParamReturnUInt32Callback - * - * @return uint32: No description available. - */ - inline uint32_t NoParamReturnUInt32Callback() { - using NoParamReturnUInt32CallbackFn = uint32_t (*)(); - static NoParamReturnUInt32CallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.NoParamReturnUInt32Callback", - reinterpret_cast(&__func)); - return __func(); - } - - /** - * @brief No description provided. - * - * @function NoParamReturnUInt64Callback - * - * @return uint64: No description available. - */ - inline uint64_t NoParamReturnUInt64Callback() { - using NoParamReturnUInt64CallbackFn = uint64_t (*)(); - static NoParamReturnUInt64CallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.NoParamReturnUInt64Callback", - reinterpret_cast(&__func)); - return __func(); - } - - /** - * @brief No description provided. - * - * @function NoParamReturnPointerCallback - * - * @return ptr64: No description available. - */ - inline void *NoParamReturnPointerCallback() { - using NoParamReturnPointerCallbackFn = void* (*)(); - static NoParamReturnPointerCallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.NoParamReturnPointerCallback", - reinterpret_cast(&__func)); - return __func(); - } - - /** - * @brief No description provided. - * - * @function NoParamReturnFloatCallback - * - * @return float: No description available. - */ - inline float NoParamReturnFloatCallback() { - using NoParamReturnFloatCallbackFn = float (*)(); - static NoParamReturnFloatCallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.NoParamReturnFloatCallback", - reinterpret_cast(&__func)); - return __func(); - } - - /** - * @brief No description provided. - * - * @function NoParamReturnDoubleCallback - * - * @return double: No description available. - */ - inline double NoParamReturnDoubleCallback() { - using NoParamReturnDoubleCallbackFn = double (*)(); - static NoParamReturnDoubleCallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.NoParamReturnDoubleCallback", - reinterpret_cast(&__func)); - return __func(); - } - - /** - * @brief No description provided. - * - * @function NoParamReturnFunctionCallback - * - * @return function: No description available. - */ - inline NoParamReturnFunctionCallbackFunc NoParamReturnFunctionCallback() { - using NoParamReturnFunctionCallbackFn = NoParamReturnFunctionCallbackFunc (*)(); - static NoParamReturnFunctionCallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.NoParamReturnFunctionCallback", - reinterpret_cast(&__func)); - return __func(); - } - - /** - * @brief No description provided. - * - * @function NoParamReturnStringCallback - * - * @return string: No description available. - */ - inline plg::string NoParamReturnStringCallback() { - using NoParamReturnStringCallbackFn = plg::string (*)(); - static NoParamReturnStringCallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.NoParamReturnStringCallback", - reinterpret_cast(&__func)); - return __func(); - } - - /** - * @brief No description provided. - * - * @function NoParamReturnAnyCallback - * - * @return any: No description available. - */ - inline plg::any NoParamReturnAnyCallback() { - using NoParamReturnAnyCallbackFn = plg::any (*)(); - static NoParamReturnAnyCallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.NoParamReturnAnyCallback", - reinterpret_cast(&__func)); - return __func(); - } - - /** - * @brief No description provided. - * - * @function NoParamReturnArrayBoolCallback - * - * @return bool[]: No description available. - */ - inline plg::vector NoParamReturnArrayBoolCallback() { - using NoParamReturnArrayBoolCallbackFn = plg::vector (*)(); - static NoParamReturnArrayBoolCallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.NoParamReturnArrayBoolCallback", - reinterpret_cast(&__func)); - return __func(); - } - - /** - * @brief No description provided. - * - * @function NoParamReturnArrayChar8Callback - * - * @return char8[]: No description available. - */ - inline plg::vector NoParamReturnArrayChar8Callback() { - using NoParamReturnArrayChar8CallbackFn = plg::vector (*)(); - static NoParamReturnArrayChar8CallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.NoParamReturnArrayChar8Callback", - reinterpret_cast(&__func)); - return __func(); - } - - /** - * @brief No description provided. - * - * @function NoParamReturnArrayChar16Callback - * - * @return char16[]: No description available. - */ - inline plg::vector NoParamReturnArrayChar16Callback() { - using NoParamReturnArrayChar16CallbackFn = plg::vector (*)(); - static NoParamReturnArrayChar16CallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.NoParamReturnArrayChar16Callback", - reinterpret_cast(&__func)); - return __func(); - } - - /** - * @brief No description provided. - * - * @function NoParamReturnArrayInt8Callback - * - * @return int8[]: No description available. - */ - inline plg::vector NoParamReturnArrayInt8Callback() { - using NoParamReturnArrayInt8CallbackFn = plg::vector (*)(); - static NoParamReturnArrayInt8CallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.NoParamReturnArrayInt8Callback", - reinterpret_cast(&__func)); - return __func(); - } - - /** - * @brief No description provided. - * - * @function NoParamReturnArrayInt16Callback - * - * @return int16[]: No description available. - */ - inline plg::vector NoParamReturnArrayInt16Callback() { - using NoParamReturnArrayInt16CallbackFn = plg::vector (*)(); - static NoParamReturnArrayInt16CallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.NoParamReturnArrayInt16Callback", - reinterpret_cast(&__func)); - return __func(); - } - - /** - * @brief No description provided. - * - * @function NoParamReturnArrayInt32Callback - * - * @return int32[]: No description available. - */ - inline plg::vector NoParamReturnArrayInt32Callback() { - using NoParamReturnArrayInt32CallbackFn = plg::vector (*)(); - static NoParamReturnArrayInt32CallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.NoParamReturnArrayInt32Callback", - reinterpret_cast(&__func)); - return __func(); - } - - /** - * @brief No description provided. - * - * @function NoParamReturnArrayInt64Callback - * - * @return int64[]: No description available. - */ - inline plg::vector NoParamReturnArrayInt64Callback() { - using NoParamReturnArrayInt64CallbackFn = plg::vector (*)(); - static NoParamReturnArrayInt64CallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.NoParamReturnArrayInt64Callback", - reinterpret_cast(&__func)); - return __func(); - } - - /** - * @brief No description provided. - * - * @function NoParamReturnArrayUInt8Callback - * - * @return uint8[]: No description available. - */ - inline plg::vector NoParamReturnArrayUInt8Callback() { - using NoParamReturnArrayUInt8CallbackFn = plg::vector (*)(); - static NoParamReturnArrayUInt8CallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.NoParamReturnArrayUInt8Callback", - reinterpret_cast(&__func)); - return __func(); - } - - /** - * @brief No description provided. - * - * @function NoParamReturnArrayUInt16Callback - * - * @return uint16[]: No description available. - */ - inline plg::vector NoParamReturnArrayUInt16Callback() { - using NoParamReturnArrayUInt16CallbackFn = plg::vector (*)(); - static NoParamReturnArrayUInt16CallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.NoParamReturnArrayUInt16Callback", - reinterpret_cast(&__func)); - return __func(); - } - - /** - * @brief No description provided. - * - * @function NoParamReturnArrayUInt32Callback - * - * @return uint32[]: No description available. - */ - inline plg::vector NoParamReturnArrayUInt32Callback() { - using NoParamReturnArrayUInt32CallbackFn = plg::vector (*)(); - static NoParamReturnArrayUInt32CallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.NoParamReturnArrayUInt32Callback", - reinterpret_cast(&__func)); - return __func(); - } - - /** - * @brief No description provided. - * - * @function NoParamReturnArrayUInt64Callback - * - * @return uint64[]: No description available. - */ - inline plg::vector NoParamReturnArrayUInt64Callback() { - using NoParamReturnArrayUInt64CallbackFn = plg::vector (*)(); - static NoParamReturnArrayUInt64CallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.NoParamReturnArrayUInt64Callback", - reinterpret_cast(&__func)); - return __func(); - } - - /** - * @brief No description provided. - * - * @function NoParamReturnArrayPointerCallback - * - * @return ptr64[]: No description available. - */ - inline plg::vector NoParamReturnArrayPointerCallback() { - using NoParamReturnArrayPointerCallbackFn = plg::vector (*)(); - static NoParamReturnArrayPointerCallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.NoParamReturnArrayPointerCallback", - reinterpret_cast(&__func)); - return __func(); - } - - /** - * @brief No description provided. - * - * @function NoParamReturnArrayFloatCallback - * - * @return float[]: No description available. - */ - inline plg::vector NoParamReturnArrayFloatCallback() { - using NoParamReturnArrayFloatCallbackFn = plg::vector (*)(); - static NoParamReturnArrayFloatCallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.NoParamReturnArrayFloatCallback", - reinterpret_cast(&__func)); - return __func(); - } - - /** - * @brief No description provided. - * - * @function NoParamReturnArrayDoubleCallback - * - * @return double[]: No description available. - */ - inline plg::vector NoParamReturnArrayDoubleCallback() { - using NoParamReturnArrayDoubleCallbackFn = plg::vector (*)(); - static NoParamReturnArrayDoubleCallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.NoParamReturnArrayDoubleCallback", - reinterpret_cast(&__func)); - return __func(); - } - - /** - * @brief No description provided. - * - * @function NoParamReturnArrayStringCallback - * - * @return string[]: No description available. - */ - inline plg::vector NoParamReturnArrayStringCallback() { - using NoParamReturnArrayStringCallbackFn = plg::vector (*)(); - static NoParamReturnArrayStringCallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.NoParamReturnArrayStringCallback", - reinterpret_cast(&__func)); - return __func(); - } - - /** - * @brief No description provided. - * - * @function NoParamReturnArrayAnyCallback - * - * @return any[]: No description available. - */ - inline plg::vector NoParamReturnArrayAnyCallback() { - using NoParamReturnArrayAnyCallbackFn = plg::vector (*)(); - static NoParamReturnArrayAnyCallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.NoParamReturnArrayAnyCallback", - reinterpret_cast(&__func)); - return __func(); - } - - /** - * @brief No description provided. - * - * @function NoParamReturnArrayVector2Callback - * - * @return vec2[]: No description available. - */ - inline plg::vector NoParamReturnArrayVector2Callback() { - using NoParamReturnArrayVector2CallbackFn = plg::vector (*)(); - static NoParamReturnArrayVector2CallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.NoParamReturnArrayVector2Callback", - reinterpret_cast(&__func)); - return __func(); - } - - /** - * @brief No description provided. - * - * @function NoParamReturnArrayVector3Callback - * - * @return vec3[]: No description available. - */ - inline plg::vector NoParamReturnArrayVector3Callback() { - using NoParamReturnArrayVector3CallbackFn = plg::vector (*)(); - static NoParamReturnArrayVector3CallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.NoParamReturnArrayVector3Callback", - reinterpret_cast(&__func)); - return __func(); - } - - /** - * @brief No description provided. - * - * @function NoParamReturnArrayVector4Callback - * - * @return vec4[]: No description available. - */ - inline plg::vector NoParamReturnArrayVector4Callback() { - using NoParamReturnArrayVector4CallbackFn = plg::vector (*)(); - static NoParamReturnArrayVector4CallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.NoParamReturnArrayVector4Callback", - reinterpret_cast(&__func)); - return __func(); - } - - /** - * @brief No description provided. - * - * @function NoParamReturnArrayMatrix4x4Callback - * - * @return mat4x4[]: No description available. - */ - inline plg::vector NoParamReturnArrayMatrix4x4Callback() { - using NoParamReturnArrayMatrix4x4CallbackFn = plg::vector (*)(); - static NoParamReturnArrayMatrix4x4CallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.NoParamReturnArrayMatrix4x4Callback", - reinterpret_cast(&__func)); - return __func(); - } - - /** - * @brief No description provided. - * - * @function NoParamReturnVector2Callback - * - * @return vec2: No description available. - */ - inline plg::vec2 NoParamReturnVector2Callback() { - using NoParamReturnVector2CallbackFn = plg::vec2 (*)(); - static NoParamReturnVector2CallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.NoParamReturnVector2Callback", - reinterpret_cast(&__func)); - return __func(); - } - - /** - * @brief No description provided. - * - * @function NoParamReturnVector3Callback - * - * @return vec3: No description available. - */ - inline plg::vec3 NoParamReturnVector3Callback() { - using NoParamReturnVector3CallbackFn = plg::vec3 (*)(); - static NoParamReturnVector3CallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.NoParamReturnVector3Callback", - reinterpret_cast(&__func)); - return __func(); - } - - /** - * @brief No description provided. - * - * @function NoParamReturnVector4Callback - * - * @return vec4: No description available. - */ - inline plg::vec4 NoParamReturnVector4Callback() { - using NoParamReturnVector4CallbackFn = plg::vec4 (*)(); - static NoParamReturnVector4CallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.NoParamReturnVector4Callback", - reinterpret_cast(&__func)); - return __func(); - } - - /** - * @brief No description provided. - * - * @function NoParamReturnMatrix4x4Callback - * - * @return mat4x4: No description available. - */ - inline plg::mat4x4 NoParamReturnMatrix4x4Callback() { - using NoParamReturnMatrix4x4CallbackFn = plg::mat4x4 (*)(); - static NoParamReturnMatrix4x4CallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.NoParamReturnMatrix4x4Callback", - reinterpret_cast(&__func)); - return __func(); - } - - /** - * @brief No description provided. - * - * @function Param1Callback - * @param a (int32): No description available. - */ - inline void Param1Callback(int32_t a) { - using Param1CallbackFn = void (*)(int32_t); - static Param1CallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.Param1Callback", - reinterpret_cast(&__func)); - __func(a); - } - - /** - * @brief No description provided. - * - * @function Param2Callback - * @param a (int32): No description available. - * @param b (float): No description available. - */ - inline void Param2Callback(int32_t a, float b) { - using Param2CallbackFn = void (*)(int32_t, float); - static Param2CallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.Param2Callback", - reinterpret_cast(&__func)); - __func(a, b); - } - - /** - * @brief No description provided. - * - * @function Param3Callback - * @param a (int32): No description available. - * @param b (float): No description available. - * @param c (double): No description available. - */ - inline void Param3Callback(int32_t a, float b, double c) { - using Param3CallbackFn = void (*)(int32_t, float, double); - static Param3CallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.Param3Callback", - reinterpret_cast(&__func)); - __func(a, b, c); - } - - /** - * @brief No description provided. - * - * @function Param4Callback - * @param a (int32): No description available. - * @param b (float): No description available. - * @param c (double): No description available. - * @param d (vec4): No description available. - */ - inline void Param4Callback(int32_t a, float b, double c, const plg::vec4 &d) { - using Param4CallbackFn = void (*)(int32_t, float, double, const plg::vec4 &); - static Param4CallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.Param4Callback", - reinterpret_cast(&__func)); - __func(a, b, c, d); - } - - /** - * @brief No description provided. - * - * @function Param5Callback - * @param a (int32): No description available. - * @param b (float): No description available. - * @param c (double): No description available. - * @param d (vec4): No description available. - * @param e (int64[]): No description available. - */ - inline void Param5Callback(int32_t a, float b, double c, const plg::vec4 &d, const plg::vector &e) { - using Param5CallbackFn = void (*)(int32_t, float, double, const plg::vec4 &, const plg::vector &); - static Param5CallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.Param5Callback", - reinterpret_cast(&__func)); - __func(a, b, c, d, e); - } - - /** - * @brief No description provided. - * - * @function Param6Callback - * @param a (int32): No description available. - * @param b (float): No description available. - * @param c (double): No description available. - * @param d (vec4): No description available. - * @param e (int64[]): No description available. - * @param f (char8): No description available. - */ - inline void Param6Callback(int32_t a, float b, double c, const plg::vec4 &d, const plg::vector &e, - char f) { - using Param6CallbackFn = void (*)(int32_t, float, double, const plg::vec4 &, const plg::vector &, - char); - static Param6CallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.Param6Callback", - reinterpret_cast(&__func)); - __func(a, b, c, d, e, f); - } - - /** - * @brief No description provided. - * - * @function Param7Callback - * @param a (int32): No description available. - * @param b (float): No description available. - * @param c (double): No description available. - * @param d (vec4): No description available. - * @param e (int64[]): No description available. - * @param f (char8): No description available. - * @param g (string): No description available. - */ - inline void Param7Callback(int32_t a, float b, double c, const plg::vec4 &d, const plg::vector &e, char f, - const plg::string &g) { - using Param7CallbackFn = void (*)(int32_t, float, double, const plg::vec4 &, const plg::vector &, char, - const plg::string &); - static Param7CallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.Param7Callback", - reinterpret_cast(&__func)); - __func(a, b, c, d, e, f, g); - } - - /** - * @brief No description provided. - * - * @function Param8Callback - * @param a (int32): No description available. - * @param b (float): No description available. - * @param c (double): No description available. - * @param d (vec4): No description available. - * @param e (int64[]): No description available. - * @param f (char8): No description available. - * @param g (string): No description available. - * @param h (char16): No description available. - */ - inline void Param8Callback(int32_t a, float b, double c, const plg::vec4 &d, const plg::vector &e, char f, - const plg::string &g, char16_t h) { - using Param8CallbackFn = void (*)(int32_t, float, double, const plg::vec4 &, const plg::vector &, char, - const plg::string &, char16_t); - static Param8CallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.Param8Callback", - reinterpret_cast(&__func)); - __func(a, b, c, d, e, f, g, h); - } - - /** - * @brief No description provided. - * - * @function Param9Callback - * @param a (int32): No description available. - * @param b (float): No description available. - * @param c (double): No description available. - * @param d (vec4): No description available. - * @param e (int64[]): No description available. - * @param f (char8): No description available. - * @param g (string): No description available. - * @param h (char16): No description available. - * @param k (int16): No description available. - */ - inline void Param9Callback(int32_t a, float b, double c, const plg::vec4 &d, const plg::vector &e, char f, - const plg::string &g, char16_t h, int16_t k) { - using Param9CallbackFn = void (*)(int32_t, float, double, const plg::vec4 &, const plg::vector &, char, - const plg::string &, char16_t, int16_t); - static Param9CallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.Param9Callback", - reinterpret_cast(&__func)); - __func(a, b, c, d, e, f, g, h, k); - } - - /** - * @brief No description provided. - * - * @function Param10Callback - * @param a (int32): No description available. - * @param b (float): No description available. - * @param c (double): No description available. - * @param d (vec4): No description available. - * @param e (int64[]): No description available. - * @param f (char8): No description available. - * @param g (string): No description available. - * @param h (char16): No description available. - * @param k (int16): No description available. - * @param l (ptr64): No description available. - */ - inline void Param10Callback(int32_t a, float b, double c, const plg::vec4 &d, const plg::vector &e, char f, - const plg::string &g, char16_t h, int16_t k, void *l) { - using Param10CallbackFn = void (*)(int32_t, float, double, const plg::vec4 &, const plg::vector &, - char, const plg::string &, char16_t, int16_t, void *); - static Param10CallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.Param10Callback", - reinterpret_cast(&__func)); - __func(a, b, c, d, e, f, g, h, k, l); - } - - /** - * @brief No description provided. - * - * @function ParamRef1Callback - * @param a (int32): No description available. - */ - inline void ParamRef1Callback(int32_t &a) { - using ParamRef1CallbackFn = void (*)(int32_t &); - static ParamRef1CallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.ParamRef1Callback", - reinterpret_cast(&__func)); - __func(a); - } - - /** - * @brief No description provided. - * - * @function ParamRef2Callback - * @param a (int32): No description available. - * @param b (float): No description available. - */ - inline void ParamRef2Callback(int32_t &a, float &b) { - using ParamRef2CallbackFn = void (*)(int32_t &, float &); - static ParamRef2CallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.ParamRef2Callback", - reinterpret_cast(&__func)); - __func(a, b); - } - - /** - * @brief No description provided. - * - * @function ParamRef3Callback - * @param a (int32): No description available. - * @param b (float): No description available. - * @param c (double): No description available. - */ - inline void ParamRef3Callback(int32_t &a, float &b, double &c) { - using ParamRef3CallbackFn = void (*)(int32_t &, float &, double &); - static ParamRef3CallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.ParamRef3Callback", - reinterpret_cast(&__func)); - __func(a, b, c); - } - - /** - * @brief No description provided. - * - * @function ParamRef4Callback - * @param a (int32): No description available. - * @param b (float): No description available. - * @param c (double): No description available. - * @param d (vec4): No description available. - */ - inline void ParamRef4Callback(int32_t &a, float &b, double &c, plg::vec4 &d) { - using ParamRef4CallbackFn = void (*)(int32_t &, float &, double &, plg::vec4 &); - static ParamRef4CallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.ParamRef4Callback", - reinterpret_cast(&__func)); - __func(a, b, c, d); - } - - /** - * @brief No description provided. - * - * @function ParamRef5Callback - * @param a (int32): No description available. - * @param b (float): No description available. - * @param c (double): No description available. - * @param d (vec4): No description available. - * @param e (int64[]): No description available. - */ - inline void ParamRef5Callback(int32_t &a, float &b, double &c, plg::vec4 &d, plg::vector &e) { - using ParamRef5CallbackFn = void (*)(int32_t &, float &, double &, plg::vec4 &, plg::vector &); - static ParamRef5CallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.ParamRef5Callback", - reinterpret_cast(&__func)); - __func(a, b, c, d, e); - } - - /** - * @brief No description provided. - * - * @function ParamRef6Callback - * @param a (int32): No description available. - * @param b (float): No description available. - * @param c (double): No description available. - * @param d (vec4): No description available. - * @param e (int64[]): No description available. - * @param f (char8): No description available. - */ - inline void ParamRef6Callback(int32_t &a, float &b, double &c, plg::vec4 &d, plg::vector &e, char &f) { - using ParamRef6CallbackFn = void (*)(int32_t &, float &, double &, plg::vec4 &, plg::vector &, char &); - static ParamRef6CallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.ParamRef6Callback", - reinterpret_cast(&__func)); - __func(a, b, c, d, e, f); - } - - /** - * @brief No description provided. - * - * @function ParamRef7Callback - * @param a (int32): No description available. - * @param b (float): No description available. - * @param c (double): No description available. - * @param d (vec4): No description available. - * @param e (int64[]): No description available. - * @param f (char8): No description available. - * @param g (string): No description available. - */ - inline void ParamRef7Callback(int32_t &a, float &b, double &c, plg::vec4 &d, plg::vector &e, char &f, - plg::string &g) { - using ParamRef7CallbackFn = void (*)(int32_t &, float &, double &, plg::vec4 &, plg::vector &, char &, - plg::string &); - static ParamRef7CallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.ParamRef7Callback", - reinterpret_cast(&__func)); - __func(a, b, c, d, e, f, g); - } - - /** - * @brief No description provided. - * - * @function ParamRef8Callback - * @param a (int32): No description available. - * @param b (float): No description available. - * @param c (double): No description available. - * @param d (vec4): No description available. - * @param e (int64[]): No description available. - * @param f (char8): No description available. - * @param g (string): No description available. - * @param h (char16): No description available. - */ - inline void ParamRef8Callback(int32_t &a, float &b, double &c, plg::vec4 &d, plg::vector &e, char &f, - plg::string &g, char16_t &h) { - using ParamRef8CallbackFn = void (*)(int32_t &, float &, double &, plg::vec4 &, plg::vector &, char &, - plg::string &, char16_t &); - static ParamRef8CallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.ParamRef8Callback", - reinterpret_cast(&__func)); - __func(a, b, c, d, e, f, g, h); - } - - /** - * @brief No description provided. - * - * @function ParamRef9Callback - * @param a (int32): No description available. - * @param b (float): No description available. - * @param c (double): No description available. - * @param d (vec4): No description available. - * @param e (int64[]): No description available. - * @param f (char8): No description available. - * @param g (string): No description available. - * @param h (char16): No description available. - * @param k (int16): No description available. - */ - inline void ParamRef9Callback(int32_t &a, float &b, double &c, plg::vec4 &d, plg::vector &e, char &f, - plg::string &g, char16_t &h, int16_t &k) { - using ParamRef9CallbackFn = void (*)(int32_t &, float &, double &, plg::vec4 &, plg::vector &, char &, - plg::string &, char16_t &, int16_t &); - static ParamRef9CallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.ParamRef9Callback", - reinterpret_cast(&__func)); - __func(a, b, c, d, e, f, g, h, k); - } - - /** - * @brief No description provided. - * - * @function ParamRef10Callback - * @param a (int32): No description available. - * @param b (float): No description available. - * @param c (double): No description available. - * @param d (vec4): No description available. - * @param e (int64[]): No description available. - * @param f (char8): No description available. - * @param g (string): No description available. - * @param h (char16): No description available. - * @param k (int16): No description available. - * @param l (ptr64): No description available. - */ - inline void ParamRef10Callback(int32_t &a, float &b, double &c, plg::vec4 &d, plg::vector &e, char &f, - plg::string &g, char16_t &h, int16_t &k, void *&l) { - using ParamRef10CallbackFn = void (*)(int32_t &, float &, double &, plg::vec4 &, plg::vector &, char &, - plg::string &, char16_t &, int16_t &, void *&); - static ParamRef10CallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.ParamRef10Callback", - reinterpret_cast(&__func)); - __func(a, b, c, d, e, f, g, h, k, l); - } - - /** - * @brief No description provided. - * - * @function ParamRefVectorsCallback - * @param p1 (bool[]): No description available. - * @param p2 (char8[]): No description available. - * @param p3 (char16[]): No description available. - * @param p4 (int8[]): No description available. - * @param p5 (int16[]): No description available. - * @param p6 (int32[]): No description available. - * @param p7 (int64[]): No description available. - * @param p8 (uint8[]): No description available. - * @param p9 (uint16[]): No description available. - * @param p10 (uint32[]): No description available. - * @param p11 (uint64[]): No description available. - * @param p12 (ptr64[]): No description available. - * @param p13 (float[]): No description available. - * @param p14 (double[]): No description available. - * @param p15 (string[]): No description available. - */ - inline void ParamRefVectorsCallback(plg::vector &p1, plg::vector &p2, plg::vector &p3, - plg::vector &p4, plg::vector &p5, plg::vector &p6, - plg::vector &p7, plg::vector &p8, plg::vector &p9, - plg::vector &p10, plg::vector &p11, - plg::vector &p12, plg::vector &p13, plg::vector &p14, - plg::vector &p15) { - using ParamRefVectorsCallbackFn = void (*)(plg::vector &, plg::vector &, plg::vector &, - plg::vector &, plg::vector &, - plg::vector &, plg::vector &, - plg::vector &, plg::vector &, - plg::vector &, plg::vector &, - plg::vector &, plg::vector &, plg::vector &, - plg::vector &); - static ParamRefVectorsCallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.ParamRefVectorsCallback", - reinterpret_cast(&__func)); - __func(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15); - } - - /** - * @brief No description provided. - * - * @function ParamAllPrimitivesCallback - * @param p1 (bool): No description available. - * @param p2 (char8): No description available. - * @param p3 (char16): No description available. - * @param p4 (int8): No description available. - * @param p5 (int16): No description available. - * @param p6 (int32): No description available. - * @param p7 (int64): No description available. - * @param p8 (uint8): No description available. - * @param p9 (uint16): No description available. - * @param p10 (uint32): No description available. - * @param p11 (uint64): No description available. - * @param p12 (ptr64): No description available. - * @param p13 (float): No description available. - * @param p14 (double): No description available. - * - * @return int64: No description available. - */ - inline int64_t ParamAllPrimitivesCallback(bool p1, char p2, char16_t p3, int8_t p4, int16_t p5, int32_t p6, - int64_t p7, uint8_t p8, uint16_t p9, uint32_t p10, uint64_t p11, - void *p12, float p13, double p14) { - using ParamAllPrimitivesCallbackFn = int64_t (*)(bool, char, char16_t, int8_t, int16_t, int32_t, int64_t, - uint8_t, uint16_t, uint32_t, uint64_t, void *, float, double); - static ParamAllPrimitivesCallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.ParamAllPrimitivesCallback", - reinterpret_cast(&__func)); - return __func(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14); - } - - /** - * @brief No description provided. - * - * @function ParamEnumCallback - * @param p1 (int32): No description available. - * @param p2 (int32[]): No description available. - * - * @return int32: No description available. - */ - inline int32_t ParamEnumCallback(Example p1, const plg::vector &p2) { - using ParamEnumCallbackFn = int32_t (*)(Example, const plg::vector &); - static ParamEnumCallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.ParamEnumCallback", - reinterpret_cast(&__func)); - return __func(p1, p2); - } - - /** - * @brief No description provided. - * - * @function ParamEnumRefCallback - * @param p1 (int32): No description available. - * @param p2 (int32[]): No description available. - * - * @return int32: No description available. - */ - inline int32_t ParamEnumRefCallback(Example &p1, plg::vector &p2) { - using ParamEnumRefCallbackFn = int32_t (*)(Example &, plg::vector &); - static ParamEnumRefCallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.ParamEnumRefCallback", - reinterpret_cast(&__func)); - return __func(p1, p2); - } - - /** - * @brief No description provided. - * - * @function ParamVariantCallback - * @param p1 (any): No description available. - * @param p2 (any[]): No description available. - */ - inline void ParamVariantCallback(const plg::any &p1, const plg::vector &p2) { - using ParamVariantCallbackFn = void (*)(const plg::any &, const plg::vector &); - static ParamVariantCallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.ParamVariantCallback", - reinterpret_cast(&__func)); - __func(p1, p2); - } - - /** - * @brief No description provided. - * - * @function ParamVariantRefCallback - * @param p1 (any): No description available. - * @param p2 (any[]): No description available. - */ - inline void ParamVariantRefCallback(plg::any &p1, plg::vector &p2) { - using ParamVariantRefCallbackFn = void (*)(plg::any &, plg::vector &); - static ParamVariantRefCallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.ParamVariantRefCallback", - reinterpret_cast(&__func)); - __func(p1, p2); - } - - /** - * @brief No description provided. - * - * @function CallFuncVoidCallback - * @param func (function): No description available. - * - * @callback FuncVoid - * @brief No description provided. - * - * - * @return (callback): void: No description available. - */ - inline void CallFuncVoidCallback(FuncVoid func) { - using CallFuncVoidCallbackFn = void (*)(FuncVoid); - static CallFuncVoidCallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFuncVoidCallback", - reinterpret_cast(&__func)); - __func(func); - } - - /** - * @brief No description provided. - * - * @function CallFuncBoolCallback - * @param func (function): No description available. - * - * @return bool: No description available. - * - * @callback FuncBool - * @brief No description provided. - * - * - * @return (callback): bool: No description available. - */ - inline bool CallFuncBoolCallback(FuncBool func) { - using CallFuncBoolCallbackFn = bool (*)(FuncBool); - static CallFuncBoolCallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFuncBoolCallback", - reinterpret_cast(&__func)); - return __func(func); - } - - /** - * @brief No description provided. - * - * @function CallFuncChar8Callback - * @param func (function): No description available. - * - * @return char8: No description available. - * - * @callback FuncChar8 - * @brief No description provided. - * - * - * @return (callback): char8: No description available. - */ - inline char CallFuncChar8Callback(FuncChar8 func) { - using CallFuncChar8CallbackFn = char (*)(FuncChar8); - static CallFuncChar8CallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFuncChar8Callback", - reinterpret_cast(&__func)); - return __func(func); - } - - /** - * @brief No description provided. - * - * @function CallFuncChar16Callback - * @param func (function): No description available. - * - * @return char16: No description available. - * - * @callback FuncChar16 - * @brief No description provided. - * - * - * @return (callback): char16: No description available. - */ - inline char16_t CallFuncChar16Callback(FuncChar16 func) { - using CallFuncChar16CallbackFn = char16_t (*)(FuncChar16); - static CallFuncChar16CallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFuncChar16Callback", - reinterpret_cast(&__func)); - return __func(func); - } - - /** - * @brief No description provided. - * - * @function CallFuncInt8Callback - * @param func (function): No description available. - * - * @return int8: No description available. - * - * @callback FuncInt8 - * @brief No description provided. - * - * - * @return (callback): int8: No description available. - */ - inline int8_t CallFuncInt8Callback(FuncInt8 func) { - using CallFuncInt8CallbackFn = int8_t (*)(FuncInt8); - static CallFuncInt8CallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFuncInt8Callback", - reinterpret_cast(&__func)); - return __func(func); - } - - /** - * @brief No description provided. - * - * @function CallFuncInt16Callback - * @param func (function): No description available. - * - * @return int16: No description available. - * - * @callback FuncInt16 - * @brief No description provided. - * - * - * @return (callback): int16: No description available. - */ - inline int16_t CallFuncInt16Callback(FuncInt16 func) { - using CallFuncInt16CallbackFn = int16_t (*)(FuncInt16); - static CallFuncInt16CallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFuncInt16Callback", - reinterpret_cast(&__func)); - return __func(func); - } - - /** - * @brief No description provided. - * - * @function CallFuncInt32Callback - * @param func (function): No description available. - * - * @return int32: No description available. - * - * @callback FuncInt32 - * @brief No description provided. - * - * - * @return (callback): int32: No description available. - */ - inline int32_t CallFuncInt32Callback(FuncInt32 func) { - using CallFuncInt32CallbackFn = int32_t (*)(FuncInt32); - static CallFuncInt32CallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFuncInt32Callback", - reinterpret_cast(&__func)); - return __func(func); - } - - /** - * @brief No description provided. - * - * @function CallFuncInt64Callback - * @param func (function): No description available. - * - * @return int64: No description available. - * - * @callback FuncInt64 - * @brief No description provided. - * - * - * @return (callback): int64: No description available. - */ - inline int64_t CallFuncInt64Callback(FuncInt64 func) { - using CallFuncInt64CallbackFn = int64_t (*)(FuncInt64); - static CallFuncInt64CallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFuncInt64Callback", - reinterpret_cast(&__func)); - return __func(func); - } - - /** - * @brief No description provided. - * - * @function CallFuncUInt8Callback - * @param func (function): No description available. - * - * @return uint8: No description available. - * - * @callback FuncUInt8 - * @brief No description provided. - * - * - * @return (callback): uint8: No description available. - */ - inline uint8_t CallFuncUInt8Callback(FuncUInt8 func) { - using CallFuncUInt8CallbackFn = uint8_t (*)(FuncUInt8); - static CallFuncUInt8CallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFuncUInt8Callback", - reinterpret_cast(&__func)); - return __func(func); - } - - /** - * @brief No description provided. - * - * @function CallFuncUInt16Callback - * @param func (function): No description available. - * - * @return uint16: No description available. - * - * @callback FuncUInt16 - * @brief No description provided. - * - * - * @return (callback): uint16: No description available. - */ - inline uint16_t CallFuncUInt16Callback(FuncUInt16 func) { - using CallFuncUInt16CallbackFn = uint16_t (*)(FuncUInt16); - static CallFuncUInt16CallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFuncUInt16Callback", - reinterpret_cast(&__func)); - return __func(func); - } - - /** - * @brief No description provided. - * - * @function CallFuncUInt32Callback - * @param func (function): No description available. - * - * @return uint32: No description available. - * - * @callback FuncUInt32 - * @brief No description provided. - * - * - * @return (callback): uint32: No description available. - */ - inline uint32_t CallFuncUInt32Callback(FuncUInt32 func) { - using CallFuncUInt32CallbackFn = uint32_t (*)(FuncUInt32); - static CallFuncUInt32CallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFuncUInt32Callback", - reinterpret_cast(&__func)); - return __func(func); - } - - /** - * @brief No description provided. - * - * @function CallFuncUInt64Callback - * @param func (function): No description available. - * - * @return uint64: No description available. - * - * @callback FuncUInt64 - * @brief No description provided. - * - * - * @return (callback): uint64: No description available. - */ - inline uint64_t CallFuncUInt64Callback(FuncUInt64 func) { - using CallFuncUInt64CallbackFn = uint64_t (*)(FuncUInt64); - static CallFuncUInt64CallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFuncUInt64Callback", - reinterpret_cast(&__func)); - return __func(func); - } - - /** - * @brief No description provided. - * - * @function CallFuncPtrCallback - * @param func (function): No description available. - * - * @return ptr64: No description available. - * - * @callback FuncPtr - * @brief No description provided. - * - * - * @return (callback): ptr64: No description available. - */ - inline void *CallFuncPtrCallback(FuncPtr func) { - using CallFuncPtrCallbackFn = void* (*)(FuncPtr); - static CallFuncPtrCallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFuncPtrCallback", - reinterpret_cast(&__func)); - return __func(func); - } - - /** - * @brief No description provided. - * - * @function CallFuncFloatCallback - * @param func (function): No description available. - * - * @return float: No description available. - * - * @callback FuncFloat - * @brief No description provided. - * - * - * @return (callback): float: No description available. - */ - inline float CallFuncFloatCallback(FuncFloat func) { - using CallFuncFloatCallbackFn = float (*)(FuncFloat); - static CallFuncFloatCallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFuncFloatCallback", - reinterpret_cast(&__func)); - return __func(func); - } - - /** - * @brief No description provided. - * - * @function CallFuncDoubleCallback - * @param func (function): No description available. - * - * @return double: No description available. - * - * @callback FuncDouble - * @brief No description provided. - * - * - * @return (callback): double: No description available. - */ - inline double CallFuncDoubleCallback(FuncDouble func) { - using CallFuncDoubleCallbackFn = double (*)(FuncDouble); - static CallFuncDoubleCallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFuncDoubleCallback", - reinterpret_cast(&__func)); - return __func(func); - } - - /** - * @brief No description provided. - * - * @function CallFuncStringCallback - * @param func (function): No description available. - * - * @return string: No description available. - * - * @callback FuncString - * @brief No description provided. - * - * - * @return (callback): string: No description available. - */ - inline plg::string CallFuncStringCallback(FuncString func) { - using CallFuncStringCallbackFn = plg::string (*)(FuncString); - static CallFuncStringCallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFuncStringCallback", - reinterpret_cast(&__func)); - return __func(func); - } - - /** - * @brief No description provided. - * - * @function CallFuncAnyCallback - * @param func (function): No description available. - * - * @return any: No description available. - * - * @callback FuncAny - * @brief No description provided. - * - * - * @return (callback): any: No description available. - */ - inline plg::any CallFuncAnyCallback(FuncAny func) { - using CallFuncAnyCallbackFn = plg::any (*)(FuncAny); - static CallFuncAnyCallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFuncAnyCallback", - reinterpret_cast(&__func)); - return __func(func); - } - - /** - * @brief No description provided. - * - * @function CallFuncFunctionCallback - * @param func (function): No description available. - * - * @return ptr64: No description available. - * - * @callback FuncFunction - * @brief No description provided. - * - * - * @return (callback): function: No description available. - */ - inline void *CallFuncFunctionCallback(FuncFunction func) { - using CallFuncFunctionCallbackFn = void* (*)(FuncFunction); - static CallFuncFunctionCallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFuncFunctionCallback", - reinterpret_cast(&__func)); - return __func(func); - } - - /** - * @brief No description provided. - * - * @function CallFuncBoolVectorCallback - * @param func (function): No description available. - * - * @return bool[]: No description available. - * - * @callback FuncBoolVector - * @brief No description provided. - * - * - * @return (callback): bool[]: No description available. - */ - inline plg::vector CallFuncBoolVectorCallback(FuncBoolVector func) { - using CallFuncBoolVectorCallbackFn = plg::vector (*)(FuncBoolVector); - static CallFuncBoolVectorCallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFuncBoolVectorCallback", - reinterpret_cast(&__func)); - return __func(func); - } - - /** - * @brief No description provided. - * - * @function CallFuncChar8VectorCallback - * @param func (function): No description available. - * - * @return char8[]: No description available. - * - * @callback FuncChar8Vector - * @brief No description provided. - * - * - * @return (callback): char8[]: No description available. - */ - inline plg::vector CallFuncChar8VectorCallback(FuncChar8Vector func) { - using CallFuncChar8VectorCallbackFn = plg::vector (*)(FuncChar8Vector); - static CallFuncChar8VectorCallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFuncChar8VectorCallback", - reinterpret_cast(&__func)); - return __func(func); - } - - /** - * @brief No description provided. - * - * @function CallFuncChar16VectorCallback - * @param func (function): No description available. - * - * @return char16[]: No description available. - * - * @callback FuncChar16Vector - * @brief No description provided. - * - * - * @return (callback): char16[]: No description available. - */ - inline plg::vector CallFuncChar16VectorCallback(FuncChar16Vector func) { - using CallFuncChar16VectorCallbackFn = plg::vector (*)(FuncChar16Vector); - static CallFuncChar16VectorCallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFuncChar16VectorCallback", - reinterpret_cast(&__func)); - return __func(func); - } - - /** - * @brief No description provided. - * - * @function CallFuncInt8VectorCallback - * @param func (function): No description available. - * - * @return int8[]: No description available. - * - * @callback FuncInt8Vector - * @brief No description provided. - * - * - * @return (callback): int8[]: No description available. - */ - inline plg::vector CallFuncInt8VectorCallback(FuncInt8Vector func) { - using CallFuncInt8VectorCallbackFn = plg::vector (*)(FuncInt8Vector); - static CallFuncInt8VectorCallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFuncInt8VectorCallback", - reinterpret_cast(&__func)); - return __func(func); - } - - /** - * @brief No description provided. - * - * @function CallFuncInt16VectorCallback - * @param func (function): No description available. - * - * @return int16[]: No description available. - * - * @callback FuncInt16Vector - * @brief No description provided. - * - * - * @return (callback): int16[]: No description available. - */ - inline plg::vector CallFuncInt16VectorCallback(FuncInt16Vector func) { - using CallFuncInt16VectorCallbackFn = plg::vector (*)(FuncInt16Vector); - static CallFuncInt16VectorCallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFuncInt16VectorCallback", - reinterpret_cast(&__func)); - return __func(func); - } - - /** - * @brief No description provided. - * - * @function CallFuncInt32VectorCallback - * @param func (function): No description available. - * - * @return int32[]: No description available. - * - * @callback FuncInt32Vector - * @brief No description provided. - * - * - * @return (callback): int32[]: No description available. - */ - inline plg::vector CallFuncInt32VectorCallback(FuncInt32Vector func) { - using CallFuncInt32VectorCallbackFn = plg::vector (*)(FuncInt32Vector); - static CallFuncInt32VectorCallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFuncInt32VectorCallback", - reinterpret_cast(&__func)); - return __func(func); - } - - /** - * @brief No description provided. - * - * @function CallFuncInt64VectorCallback - * @param func (function): No description available. - * - * @return int64[]: No description available. - * - * @callback FuncInt64Vector - * @brief No description provided. - * - * - * @return (callback): int64[]: No description available. - */ - inline plg::vector CallFuncInt64VectorCallback(FuncInt64Vector func) { - using CallFuncInt64VectorCallbackFn = plg::vector (*)(FuncInt64Vector); - static CallFuncInt64VectorCallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFuncInt64VectorCallback", - reinterpret_cast(&__func)); - return __func(func); - } - - /** - * @brief No description provided. - * - * @function CallFuncUInt8VectorCallback - * @param func (function): No description available. - * - * @return uint8[]: No description available. - * - * @callback FuncUInt8Vector - * @brief No description provided. - * - * - * @return (callback): uint8[]: No description available. - */ - inline plg::vector CallFuncUInt8VectorCallback(FuncUInt8Vector func) { - using CallFuncUInt8VectorCallbackFn = plg::vector (*)(FuncUInt8Vector); - static CallFuncUInt8VectorCallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFuncUInt8VectorCallback", - reinterpret_cast(&__func)); - return __func(func); - } - - /** - * @brief No description provided. - * - * @function CallFuncUInt16VectorCallback - * @param func (function): No description available. - * - * @return uint16[]: No description available. - * - * @callback FuncUInt16Vector - * @brief No description provided. - * - * - * @return (callback): uint16[]: No description available. - */ - inline plg::vector CallFuncUInt16VectorCallback(FuncUInt16Vector func) { - using CallFuncUInt16VectorCallbackFn = plg::vector (*)(FuncUInt16Vector); - static CallFuncUInt16VectorCallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFuncUInt16VectorCallback", - reinterpret_cast(&__func)); - return __func(func); - } - - /** - * @brief No description provided. - * - * @function CallFuncUInt32VectorCallback - * @param func (function): No description available. - * - * @return uint32[]: No description available. - * - * @callback FuncUInt32Vector - * @brief No description provided. - * - * - * @return (callback): uint32[]: No description available. - */ - inline plg::vector CallFuncUInt32VectorCallback(FuncUInt32Vector func) { - using CallFuncUInt32VectorCallbackFn = plg::vector (*)(FuncUInt32Vector); - static CallFuncUInt32VectorCallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFuncUInt32VectorCallback", - reinterpret_cast(&__func)); - return __func(func); - } - - /** - * @brief No description provided. - * - * @function CallFuncUInt64VectorCallback - * @param func (function): No description available. - * - * @return uint64[]: No description available. - * - * @callback FuncUInt64Vector - * @brief No description provided. - * - * - * @return (callback): uint64[]: No description available. - */ - inline plg::vector CallFuncUInt64VectorCallback(FuncUInt64Vector func) { - using CallFuncUInt64VectorCallbackFn = plg::vector (*)(FuncUInt64Vector); - static CallFuncUInt64VectorCallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFuncUInt64VectorCallback", - reinterpret_cast(&__func)); - return __func(func); - } - - /** - * @brief No description provided. - * - * @function CallFuncPtrVectorCallback - * @param func (function): No description available. - * - * @return ptr64[]: No description available. - * - * @callback FuncPtrVector - * @brief No description provided. - * - * - * @return (callback): ptr64[]: No description available. - */ - inline plg::vector CallFuncPtrVectorCallback(FuncPtrVector func) { - using CallFuncPtrVectorCallbackFn = plg::vector (*)(FuncPtrVector); - static CallFuncPtrVectorCallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFuncPtrVectorCallback", - reinterpret_cast(&__func)); - return __func(func); - } - - /** - * @brief No description provided. - * - * @function CallFuncFloatVectorCallback - * @param func (function): No description available. - * - * @return float[]: No description available. - * - * @callback FuncFloatVector - * @brief No description provided. - * - * - * @return (callback): float[]: No description available. - */ - inline plg::vector CallFuncFloatVectorCallback(FuncFloatVector func) { - using CallFuncFloatVectorCallbackFn = plg::vector (*)(FuncFloatVector); - static CallFuncFloatVectorCallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFuncFloatVectorCallback", - reinterpret_cast(&__func)); - return __func(func); - } - - /** - * @brief No description provided. - * - * @function CallFuncDoubleVectorCallback - * @param func (function): No description available. - * - * @return double[]: No description available. - * - * @callback FuncDoubleVector - * @brief No description provided. - * - * - * @return (callback): double[]: No description available. - */ - inline plg::vector CallFuncDoubleVectorCallback(FuncDoubleVector func) { - using CallFuncDoubleVectorCallbackFn = plg::vector (*)(FuncDoubleVector); - static CallFuncDoubleVectorCallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFuncDoubleVectorCallback", - reinterpret_cast(&__func)); - return __func(func); - } - - /** - * @brief No description provided. - * - * @function CallFuncStringVectorCallback - * @param func (function): No description available. - * - * @return string[]: No description available. - * - * @callback FuncStringVector - * @brief No description provided. - * - * - * @return (callback): string[]: No description available. - */ - inline plg::vector CallFuncStringVectorCallback(FuncStringVector func) { - using CallFuncStringVectorCallbackFn = plg::vector (*)(FuncStringVector); - static CallFuncStringVectorCallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFuncStringVectorCallback", - reinterpret_cast(&__func)); - return __func(func); - } - - /** - * @brief No description provided. - * - * @function CallFuncAnyVectorCallback - * @param func (function): No description available. - * - * @return any[]: No description available. - * - * @callback FuncAnyVector - * @brief No description provided. - * - * - * @return (callback): any[]: No description available. - */ - inline plg::vector CallFuncAnyVectorCallback(FuncAnyVector func) { - using CallFuncAnyVectorCallbackFn = plg::vector (*)(FuncAnyVector); - static CallFuncAnyVectorCallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFuncAnyVectorCallback", - reinterpret_cast(&__func)); - return __func(func); - } - - /** - * @brief No description provided. - * - * @function CallFuncVec2VectorCallback - * @param func (function): No description available. - * - * @return vec2[]: No description available. - * - * @callback FuncVec2Vector - * @brief No description provided. - * - * - * @return (callback): vec2[]: No description available. - */ - inline plg::vector CallFuncVec2VectorCallback(FuncVec2Vector func) { - using CallFuncVec2VectorCallbackFn = plg::vector (*)(FuncVec2Vector); - static CallFuncVec2VectorCallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFuncVec2VectorCallback", - reinterpret_cast(&__func)); - return __func(func); - } - - /** - * @brief No description provided. - * - * @function CallFuncVec3VectorCallback - * @param func (function): No description available. - * - * @return vec3[]: No description available. - * - * @callback FuncVec3Vector - * @brief No description provided. - * - * - * @return (callback): vec3[]: No description available. - */ - inline plg::vector CallFuncVec3VectorCallback(FuncVec3Vector func) { - using CallFuncVec3VectorCallbackFn = plg::vector (*)(FuncVec3Vector); - static CallFuncVec3VectorCallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFuncVec3VectorCallback", - reinterpret_cast(&__func)); - return __func(func); - } - - /** - * @brief No description provided. - * - * @function CallFuncVec4VectorCallback - * @param func (function): No description available. - * - * @return vec4[]: No description available. - * - * @callback FuncVec4Vector - * @brief No description provided. - * - * - * @return (callback): vec4[]: No description available. - */ - inline plg::vector CallFuncVec4VectorCallback(FuncVec4Vector func) { - using CallFuncVec4VectorCallbackFn = plg::vector (*)(FuncVec4Vector); - static CallFuncVec4VectorCallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFuncVec4VectorCallback", - reinterpret_cast(&__func)); - return __func(func); - } - - /** - * @brief No description provided. - * - * @function CallFuncMat4x4VectorCallback - * @param func (function): No description available. - * - * @return mat4x4[]: No description available. - * - * @callback FuncMat4x4Vector - * @brief No description provided. - * - * - * @return (callback): mat4x4[]: No description available. - */ - inline plg::vector CallFuncMat4x4VectorCallback(FuncMat4x4Vector func) { - using CallFuncMat4x4VectorCallbackFn = plg::vector (*)(FuncMat4x4Vector); - static CallFuncMat4x4VectorCallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFuncMat4x4VectorCallback", - reinterpret_cast(&__func)); - return __func(func); - } - - /** - * @brief No description provided. - * - * @function CallFuncVec2Callback - * @param func (function): No description available. - * - * @return vec2: No description available. - * - * @callback FuncVec2 - * @brief No description provided. - * - * - * @return (callback): vec2: No description available. - */ - inline plg::vec2 CallFuncVec2Callback(FuncVec2 func) { - using CallFuncVec2CallbackFn = plg::vec2 (*)(FuncVec2); - static CallFuncVec2CallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFuncVec2Callback", - reinterpret_cast(&__func)); - return __func(func); - } - - /** - * @brief No description provided. - * - * @function CallFuncVec3Callback - * @param func (function): No description available. - * - * @return vec3: No description available. - * - * @callback FuncVec3 - * @brief No description provided. - * - * - * @return (callback): vec3: No description available. - */ - inline plg::vec3 CallFuncVec3Callback(FuncVec3 func) { - using CallFuncVec3CallbackFn = plg::vec3 (*)(FuncVec3); - static CallFuncVec3CallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFuncVec3Callback", - reinterpret_cast(&__func)); - return __func(func); - } - - /** - * @brief No description provided. - * - * @function CallFuncVec4Callback - * @param func (function): No description available. - * - * @return vec4: No description available. - * - * @callback FuncVec4 - * @brief No description provided. - * - * - * @return (callback): vec4: No description available. - */ - inline plg::vec4 CallFuncVec4Callback(FuncVec4 func) { - using CallFuncVec4CallbackFn = plg::vec4 (*)(FuncVec4); - static CallFuncVec4CallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFuncVec4Callback", - reinterpret_cast(&__func)); - return __func(func); - } - - /** - * @brief No description provided. - * - * @function CallFuncMat4x4Callback - * @param func (function): No description available. - * - * @return mat4x4: No description available. - * - * @callback FuncMat4x4 - * @brief No description provided. - * - * - * @return (callback): mat4x4: No description available. - */ - inline plg::mat4x4 CallFuncMat4x4Callback(FuncMat4x4 func) { - using CallFuncMat4x4CallbackFn = plg::mat4x4 (*)(FuncMat4x4); - static CallFuncMat4x4CallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFuncMat4x4Callback", - reinterpret_cast(&__func)); - return __func(func); - } - - /** - * @brief No description provided. - * - * @function CallFunc1Callback - * @param func (function): No description available. - * - * @return int32: No description available. - * - * @callback Func1 - * @brief No description provided. - * - * @param a (vec3): No description available. - * - * @return (callback): int32: No description available. - */ - inline int32_t CallFunc1Callback(Func1 func) { - using CallFunc1CallbackFn = int32_t (*)(Func1); - static CallFunc1CallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFunc1Callback", - reinterpret_cast(&__func)); - return __func(func); - } - - /** - * @brief No description provided. - * - * @function CallFunc2Callback - * @param func (function): No description available. - * - * @return char8: No description available. - * - * @callback Func2 - * @brief No description provided. - * - * @param a (float): No description available. - * @param b (int64): No description available. - * - * @return (callback): char8: No description available. - */ - inline char CallFunc2Callback(Func2 func) { - using CallFunc2CallbackFn = char (*)(Func2); - static CallFunc2CallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFunc2Callback", - reinterpret_cast(&__func)); - return __func(func); - } - - /** - * @brief No description provided. - * - * @function CallFunc3Callback - * @param func (function): No description available. - * - * @callback Func3 - * @brief No description provided. - * - * @param a (ptr64): No description available. - * @param b (vec4): No description available. - * @param c (string): No description available. - * - * @return (callback): void: No description available. - */ - inline void CallFunc3Callback(Func3 func) { - using CallFunc3CallbackFn = void (*)(Func3); - static CallFunc3CallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFunc3Callback", - reinterpret_cast(&__func)); - __func(func); - } - - /** - * @brief No description provided. - * - * @function CallFunc4Callback - * @param func (function): No description available. - * - * @return vec4: No description available. - * - * @callback Func4 - * @brief No description provided. - * - * @param a (bool): No description available. - * @param b (int32): No description available. - * @param c (char16): No description available. - * @param d (mat4x4): No description available. - * - * @return (callback): vec4: No description available. - */ - inline plg::vec4 CallFunc4Callback(Func4 func) { - using CallFunc4CallbackFn = plg::vec4 (*)(Func4); - static CallFunc4CallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFunc4Callback", - reinterpret_cast(&__func)); - return __func(func); - } - - /** - * @brief No description provided. - * - * @function CallFunc5Callback - * @param func (function): No description available. - * - * @return bool: No description available. - * - * @callback Func5 - * @brief No description provided. - * - * @param a (int8): No description available. - * @param b (vec2): No description available. - * @param c (ptr64): No description available. - * @param d (double): No description available. - * @param e (uint64[]): No description available. - * - * @return (callback): bool: No description available. - */ - inline bool CallFunc5Callback(Func5 func) { - using CallFunc5CallbackFn = bool (*)(Func5); - static CallFunc5CallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFunc5Callback", - reinterpret_cast(&__func)); - return __func(func); - } - - /** - * @brief No description provided. - * - * @function CallFunc6Callback - * @param func (function): No description available. - * - * @return int64: No description available. - * - * @callback Func6 - * @brief No description provided. - * - * @param a (string): No description available. - * @param b (float): No description available. - * @param c (float[]): No description available. - * @param d (int16): No description available. - * @param e (uint8[]): No description available. - * @param f (ptr64): No description available. - * - * @return (callback): int64: No description available. - */ - inline int64_t CallFunc6Callback(Func6 func) { - using CallFunc6CallbackFn = int64_t (*)(Func6); - static CallFunc6CallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFunc6Callback", - reinterpret_cast(&__func)); - return __func(func); - } - - /** - * @brief No description provided. - * - * @function CallFunc7Callback - * @param func (function): No description available. - * - * @return double: No description available. - * - * @callback Func7 - * @brief No description provided. - * - * @param vecC (char8[]): No description available. - * @param u16 (uint16): No description available. - * @param ch16 (char16): No description available. - * @param vecU32 (uint32[]): No description available. - * @param vec4 (vec4): No description available. - * @param b (bool): No description available. - * @param u64 (uint64): No description available. - * - * @return (callback): double: No description available. - */ - inline double CallFunc7Callback(Func7 func) { - using CallFunc7CallbackFn = double (*)(Func7); - static CallFunc7CallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFunc7Callback", - reinterpret_cast(&__func)); - return __func(func); - } - - /** - * @brief No description provided. - * - * @function CallFunc8Callback - * @param func (function): No description available. - * - * @return mat4x4: No description available. - * - * @callback Func8 - * @brief No description provided. - * - * @param vec3 (vec3): No description available. - * @param vecU32 (uint32[]): No description available. - * @param i16 (int16): No description available. - * @param b (bool): No description available. - * @param vec4 (vec4): No description available. - * @param vecC16 (char16[]): No description available. - * @param ch16 (char16): No description available. - * @param i32 (int32): No description available. - * - * @return (callback): mat4x4: No description available. - */ - inline plg::mat4x4 CallFunc8Callback(Func8 func) { - using CallFunc8CallbackFn = plg::mat4x4 (*)(Func8); - static CallFunc8CallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFunc8Callback", - reinterpret_cast(&__func)); - return __func(func); - } - - /** - * @brief No description provided. - * - * @function CallFunc9Callback - * @param func (function): No description available. - * - * @callback Func9 - * @brief No description provided. - * - * @param f (float): No description available. - * @param vec2 (vec2): No description available. - * @param vecI8 (int8[]): No description available. - * @param u64 (uint64): No description available. - * @param b (bool): No description available. - * @param str (string): No description available. - * @param vec4 (vec4): No description available. - * @param i16 (int16): No description available. - * @param ptr (ptr64): No description available. - * - * @return (callback): void: No description available. - */ - inline void CallFunc9Callback(Func9 func) { - using CallFunc9CallbackFn = void (*)(Func9); - static CallFunc9CallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFunc9Callback", - reinterpret_cast(&__func)); - __func(func); - } - - /** - * @brief No description provided. - * - * @function CallFunc10Callback - * @param func (function): No description available. - * - * @return uint32: No description available. - * - * @callback Func10 - * @brief No description provided. - * - * @param vec4 (vec4): No description available. - * @param mat (mat4x4): No description available. - * @param vecU32 (uint32[]): No description available. - * @param u64 (uint64): No description available. - * @param vecC (char8[]): No description available. - * @param i32 (int32): No description available. - * @param b (bool): No description available. - * @param vec2 (vec2): No description available. - * @param i64 (int64): No description available. - * @param d (double): No description available. - * - * @return (callback): uint32: No description available. - */ - inline uint32_t CallFunc10Callback(Func10 func) { - using CallFunc10CallbackFn = uint32_t (*)(Func10); - static CallFunc10CallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFunc10Callback", - reinterpret_cast(&__func)); - return __func(func); - } - - /** - * @brief No description provided. - * - * @function CallFunc11Callback - * @param func (function): No description available. - * - * @return ptr64: No description available. - * - * @callback Func11 - * @brief No description provided. - * - * @param vecB (bool[]): No description available. - * @param ch16 (char16): No description available. - * @param u8 (uint8): No description available. - * @param d (double): No description available. - * @param vec3 (vec3): No description available. - * @param vecI8 (int8[]): No description available. - * @param i64 (int64): No description available. - * @param u16 (uint16): No description available. - * @param f (float): No description available. - * @param vec2 (vec2): No description available. - * @param u32 (uint32): No description available. - * - * @return (callback): ptr64: No description available. - */ - inline void *CallFunc11Callback(Func11 func) { - using CallFunc11CallbackFn = void* (*)(Func11); - static CallFunc11CallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFunc11Callback", - reinterpret_cast(&__func)); - return __func(func); - } - - /** - * @brief No description provided. - * - * @function CallFunc12Callback - * @param func (function): No description available. - * - * @return bool: No description available. - * - * @callback Func12 - * @brief No description provided. - * - * @param ptr (ptr64): No description available. - * @param vecD (double[]): No description available. - * @param u32 (uint32): No description available. - * @param d (double): No description available. - * @param b (bool): No description available. - * @param i32 (int32): No description available. - * @param i8 (int8): No description available. - * @param u64 (uint64): No description available. - * @param f (float): No description available. - * @param vecPtr (ptr64[]): No description available. - * @param i64 (int64): No description available. - * @param ch (char8): No description available. - * - * @return (callback): bool: No description available. - */ - inline bool CallFunc12Callback(Func12 func) { - using CallFunc12CallbackFn = bool (*)(Func12); - static CallFunc12CallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFunc12Callback", - reinterpret_cast(&__func)); - return __func(func); - } - - /** - * @brief No description provided. - * - * @function CallFunc13Callback - * @param func (function): No description available. - * - * @return string: No description available. - * - * @callback Func13 - * @brief No description provided. - * - * @param i64 (int64): No description available. - * @param vecC (char8[]): No description available. - * @param d (uint16): No description available. - * @param f (float): No description available. - * @param b (bool[]): No description available. - * @param vec4 (vec4): No description available. - * @param str (string): No description available. - * @param int32 (int32): No description available. - * @param vec3 (vec3): No description available. - * @param ptr (ptr64): No description available. - * @param vec2 (vec2): No description available. - * @param arr (uint8[]): No description available. - * @param i16 (int16): No description available. - * - * @return (callback): string: No description available. - */ - inline plg::string CallFunc13Callback(Func13 func) { - using CallFunc13CallbackFn = plg::string (*)(Func13); - static CallFunc13CallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFunc13Callback", - reinterpret_cast(&__func)); - return __func(func); - } - - /** - * @brief No description provided. - * - * @function CallFunc14Callback - * @param func (function): No description available. - * - * @return string[]: No description available. - * - * @callback Func14 - * @brief No description provided. - * - * @param vecC (char8[]): No description available. - * @param vecU32 (uint32[]): No description available. - * @param mat (mat4x4): No description available. - * @param b (bool): No description available. - * @param ch16 (char16): No description available. - * @param i32 (int32): No description available. - * @param vecF (float[]): No description available. - * @param u16 (uint16): No description available. - * @param vecU8 (uint8[]): No description available. - * @param i8 (int8): No description available. - * @param vec3 (vec3): No description available. - * @param vec4 (vec4): No description available. - * @param d (double): No description available. - * @param ptr (ptr64): No description available. - * - * @return (callback): string[]: No description available. - */ - inline plg::vector CallFunc14Callback(Func14 func) { - using CallFunc14CallbackFn = plg::vector (*)(Func14); - static CallFunc14CallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFunc14Callback", - reinterpret_cast(&__func)); - return __func(func); - } - - /** - * @brief No description provided. - * - * @function CallFunc15Callback - * @param func (function): No description available. - * - * @return int16: No description available. - * - * @callback Func15 - * @brief No description provided. - * - * @param vecI16 (int16[]): No description available. - * @param mat (mat4x4): No description available. - * @param vec4 (vec4): No description available. - * @param ptr (ptr64): No description available. - * @param u64 (uint64): No description available. - * @param vecU32 (uint32[]): No description available. - * @param b (bool): No description available. - * @param f (float): No description available. - * @param vecC16 (char16[]): No description available. - * @param u8 (uint8): No description available. - * @param i32 (int32): No description available. - * @param vec2 (vec2): No description available. - * @param u16 (uint16): No description available. - * @param d (double): No description available. - * @param vecU8 (uint8[]): No description available. - * - * @return (callback): int16: No description available. - */ - inline int16_t CallFunc15Callback(Func15 func) { - using CallFunc15CallbackFn = int16_t (*)(Func15); - static CallFunc15CallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFunc15Callback", - reinterpret_cast(&__func)); - return __func(func); - } - - /** - * @brief No description provided. - * - * @function CallFunc16Callback - * @param func (function): No description available. - * - * @return ptr64: No description available. - * - * @callback Func16 - * @brief No description provided. - * - * @param vecB (bool[]): No description available. - * @param i16 (int16): No description available. - * @param vecI8 (int8[]): No description available. - * @param vec4 (vec4): No description available. - * @param mat (mat4x4): No description available. - * @param vec2 (vec2): No description available. - * @param vecU64 (uint64[]): No description available. - * @param vecC (char8[]): No description available. - * @param str (string): No description available. - * @param i64 (int64): No description available. - * @param vecU32 (uint32[]): No description available. - * @param vec3 (vec3): No description available. - * @param f (float): No description available. - * @param d (double): No description available. - * @param i8 (int8): No description available. - * @param u16 (uint16): No description available. - * - * @return (callback): ptr64: No description available. - */ - inline void *CallFunc16Callback(Func16 func) { - using CallFunc16CallbackFn = void* (*)(Func16); - static CallFunc16CallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFunc16Callback", - reinterpret_cast(&__func)); - return __func(func); - } - - /** - * @brief No description provided. - * - * @function CallFunc17Callback - * @param func (function): No description available. - * - * @return string: No description available. - * - * @callback Func17 - * @brief No description provided. - * - * @param i32 (int32): No description available. - * - * @return (callback): void: No description available. - */ - inline plg::string CallFunc17Callback(Func17 func) { - using CallFunc17CallbackFn = plg::string (*)(Func17); - static CallFunc17CallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFunc17Callback", - reinterpret_cast(&__func)); - return __func(func); - } - - /** - * @brief No description provided. - * - * @function CallFunc18Callback - * @param func (function): No description available. - * - * @return string: No description available. - * - * @callback Func18 - * @brief No description provided. - * - * @param i8 (int8): No description available. - * @param i16 (int16): No description available. - * - * @return (callback): vec2: No description available. - */ - inline plg::string CallFunc18Callback(Func18 func) { - using CallFunc18CallbackFn = plg::string (*)(Func18); - static CallFunc18CallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFunc18Callback", - reinterpret_cast(&__func)); - return __func(func); - } - - /** - * @brief No description provided. - * - * @function CallFunc19Callback - * @param func (function): No description available. - * - * @return string: No description available. - * - * @callback Func19 - * @brief No description provided. - * - * @param u32 (uint32): No description available. - * @param vec3 (vec3): No description available. - * @param vecU32 (uint32[]): No description available. - * - * @return (callback): void: No description available. - */ - inline plg::string CallFunc19Callback(Func19 func) { - using CallFunc19CallbackFn = plg::string (*)(Func19); - static CallFunc19CallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFunc19Callback", - reinterpret_cast(&__func)); - return __func(func); - } - - /** - * @brief No description provided. - * - * @function CallFunc20Callback - * @param func (function): No description available. - * - * @return string: No description available. - * - * @callback Func20 - * @brief No description provided. - * - * @param ch16 (char16): No description available. - * @param vec4 (vec4): No description available. - * @param vecU64 (uint64[]): No description available. - * @param ch (char8): No description available. - * - * @return (callback): int32: No description available. - */ - inline plg::string CallFunc20Callback(Func20 func) { - using CallFunc20CallbackFn = plg::string (*)(Func20); - static CallFunc20CallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFunc20Callback", - reinterpret_cast(&__func)); - return __func(func); - } - - /** - * @brief No description provided. - * - * @function CallFunc21Callback - * @param func (function): No description available. - * - * @return string: No description available. - * - * @callback Func21 - * @brief No description provided. - * - * @param mat (mat4x4): No description available. - * @param vecI32 (int32[]): No description available. - * @param vec2 (vec2): No description available. - * @param b (bool): No description available. - * @param extraParam (double): No description available. - * - * @return (callback): float: No description available. - */ - inline plg::string CallFunc21Callback(Func21 func) { - using CallFunc21CallbackFn = plg::string (*)(Func21); - static CallFunc21CallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFunc21Callback", - reinterpret_cast(&__func)); - return __func(func); - } - - /** - * @brief No description provided. - * - * @function CallFunc22Callback - * @param func (function): No description available. - * - * @return string: No description available. - * - * @callback Func22 - * @brief No description provided. - * - * @param ptr64Ref (ptr64): No description available. - * @param uint32Ref (uint32): No description available. - * @param vectorDoubleRef (double[]): No description available. - * @param int16Ref (int16): No description available. - * @param plgStringRef (string): No description available. - * @param plgVector4Ref (vec4): No description available. - * - * @return (callback): uint64: No description available. - */ - inline plg::string CallFunc22Callback(Func22 func) { - using CallFunc22CallbackFn = plg::string (*)(Func22); - static CallFunc22CallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFunc22Callback", - reinterpret_cast(&__func)); - return __func(func); - } - - /** - * @brief No description provided. - * - * @function CallFunc23Callback - * @param func (function): No description available. - * - * @return string: No description available. - * - * @callback Func23 - * @brief No description provided. - * - * @param uint64Ref (uint64): No description available. - * @param plgVector2Ref (vec2): No description available. - * @param vectorInt16Ref (int16[]): No description available. - * @param char16Ref (char16): No description available. - * @param floatRef (float): No description available. - * @param int8Ref (int8): No description available. - * @param vectorUInt8Ref (uint8[]): No description available. - * - * @return (callback): void: No description available. - */ - inline plg::string CallFunc23Callback(Func23 func) { - using CallFunc23CallbackFn = plg::string (*)(Func23); - static CallFunc23CallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFunc23Callback", - reinterpret_cast(&__func)); - return __func(func); - } - - /** - * @brief No description provided. - * - * @function CallFunc24Callback - * @param func (function): No description available. - * - * @return string: No description available. - * - * @callback Func24 - * @brief No description provided. - * - * @param vectorCharRef (char8[]): No description available. - * @param int64Ref (int64): No description available. - * @param vectorUInt8Ref (uint8[]): No description available. - * @param plgVector4Ref (vec4): No description available. - * @param uint64Ref (uint64): No description available. - * @param vectorptr64Ref (ptr64[]): No description available. - * @param doubleRef (double): No description available. - * @param vectorptr64Ref2 (ptr64[]): No description available. - * - * @return (callback): mat4x4: No description available. - */ - inline plg::string CallFunc24Callback(Func24 func) { - using CallFunc24CallbackFn = plg::string (*)(Func24); - static CallFunc24CallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFunc24Callback", - reinterpret_cast(&__func)); - return __func(func); - } - - /** - * @brief No description provided. - * - * @function CallFunc25Callback - * @param func (function): No description available. - * - * @return string: No description available. - * - * @callback Func25 - * @brief No description provided. - * - * @param int32Ref (int32): No description available. - * @param vectorptr64Ref (ptr64[]): No description available. - * @param boolRef (bool): No description available. - * @param uint8Ref (uint8): No description available. - * @param plgStringRef (string): No description available. - * @param plgVector3Ref (vec3): No description available. - * @param int64Ref (int64): No description available. - * @param plgVector4Ref (vec4): No description available. - * @param uint16Ref (uint16): No description available. - * - * @return (callback): double: No description available. - */ - inline plg::string CallFunc25Callback(Func25 func) { - using CallFunc25CallbackFn = plg::string (*)(Func25); - static CallFunc25CallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFunc25Callback", - reinterpret_cast(&__func)); - return __func(func); - } - - /** - * @brief No description provided. - * - * @function CallFunc26Callback - * @param func (function): No description available. - * - * @return string: No description available. - * - * @callback Func26 - * @brief No description provided. - * - * @param char16Ref (char16): No description available. - * @param plgVector2Ref (vec2): No description available. - * @param plgMatrix4x4Ref (mat4x4): No description available. - * @param vectorFloatRef (float[]): No description available. - * @param int16Ref (int16): No description available. - * @param uint64Ref (uint64): No description available. - * @param uint32Ref (uint32): No description available. - * @param vectorUInt16Ref (uint16[]): No description available. - * @param ptr64Ref (ptr64): No description available. - * @param boolRef (bool): No description available. - * - * @return (callback): char8: No description available. - */ - inline plg::string CallFunc26Callback(Func26 func) { - using CallFunc26CallbackFn = plg::string (*)(Func26); - static CallFunc26CallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFunc26Callback", - reinterpret_cast(&__func)); - return __func(func); - } - - /** - * @brief No description provided. - * - * @function CallFunc27Callback - * @param func (function): No description available. - * - * @return string: No description available. - * - * @callback Func27 - * @brief No description provided. - * - * @param floatRef (float): No description available. - * @param plgVector3Ref (vec3): No description available. - * @param ptr64Ref (ptr64): No description available. - * @param plgVector2Ref (vec2): No description available. - * @param vectorInt16Ref (int16[]): No description available. - * @param plgMatrix4x4Ref (mat4x4): No description available. - * @param boolRef (bool): No description available. - * @param plgVector4Ref (vec4): No description available. - * @param int8Ref (int8): No description available. - * @param int32Ref (int32): No description available. - * @param vectorUInt8Ref (uint8[]): No description available. - * - * @return (callback): uint8: No description available. - */ - inline plg::string CallFunc27Callback(Func27 func) { - using CallFunc27CallbackFn = plg::string (*)(Func27); - static CallFunc27CallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFunc27Callback", - reinterpret_cast(&__func)); - return __func(func); - } - - /** - * @brief No description provided. - * - * @function CallFunc28Callback - * @param func (function): No description available. - * - * @return string: No description available. - * - * @callback Func28 - * @brief No description provided. - * - * @param ptr64Ref (ptr64): No description available. - * @param uint16Ref (uint16): No description available. - * @param vectorUInt32Ref (uint32[]): No description available. - * @param plgMatrix4x4Ref (mat4x4): No description available. - * @param floatRef (float): No description available. - * @param plgVector4Ref (vec4): No description available. - * @param plgStringRef (string): No description available. - * @param vectorUInt64Ref (uint64[]): No description available. - * @param int64Ref (int64): No description available. - * @param boolRef (bool): No description available. - * @param plgVector3Ref (vec3): No description available. - * @param vectorFloatRef (float[]): No description available. - * - * @return (callback): string: No description available. - */ - inline plg::string CallFunc28Callback(Func28 func) { - using CallFunc28CallbackFn = plg::string (*)(Func28); - static CallFunc28CallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFunc28Callback", - reinterpret_cast(&__func)); - return __func(func); - } - - /** - * @brief No description provided. - * - * @function CallFunc29Callback - * @param func (function): No description available. - * - * @return string: No description available. - * - * @callback Func29 - * @brief No description provided. - * - * @param plgVector4Ref (vec4): No description available. - * @param int32Ref (int32): No description available. - * @param vectorInt8Ref (int8[]): No description available. - * @param doubleRef (double): No description available. - * @param boolRef (bool): No description available. - * @param int8Ref (int8): No description available. - * @param vectorUInt16Ref (uint16[]): No description available. - * @param floatRef (float): No description available. - * @param plgStringRef (string): No description available. - * @param plgMatrix4x4Ref (mat4x4): No description available. - * @param uint64Ref (uint64): No description available. - * @param plgVector3Ref (vec3): No description available. - * @param vectorInt64Ref (int64[]): No description available. - * - * @return (callback): string[]: No description available. - */ - inline plg::string CallFunc29Callback(Func29 func) { - using CallFunc29CallbackFn = plg::string (*)(Func29); - static CallFunc29CallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFunc29Callback", - reinterpret_cast(&__func)); - return __func(func); - } - - /** - * @brief No description provided. - * - * @function CallFunc30Callback - * @param func (function): No description available. - * - * @return string: No description available. - * - * @callback Func30 - * @brief No description provided. - * - * @param ptr64Ref (ptr64): No description available. - * @param plgVector4Ref (vec4): No description available. - * @param int64Ref (int64): No description available. - * @param vectorUInt32Ref (uint32[]): No description available. - * @param boolRef (bool): No description available. - * @param plgStringRef (string): No description available. - * @param plgVector3Ref (vec3): No description available. - * @param vectorUInt8Ref (uint8[]): No description available. - * @param floatRef (float): No description available. - * @param plgVector2Ref (vec2): No description available. - * @param plgMatrix4x4Ref (mat4x4): No description available. - * @param int8Ref (int8): No description available. - * @param vectorFloatRef (float[]): No description available. - * @param doubleRef (double): No description available. - * - * @return (callback): int32: No description available. - */ - inline plg::string CallFunc30Callback(Func30 func) { - using CallFunc30CallbackFn = plg::string (*)(Func30); - static CallFunc30CallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFunc30Callback", - reinterpret_cast(&__func)); - return __func(func); - } - - /** - * @brief No description provided. - * - * @function CallFunc31Callback - * @param func (function): No description available. - * - * @return string: No description available. - * - * @callback Func31 - * @brief No description provided. - * - * @param charRef (char8): No description available. - * @param uint32Ref (uint32): No description available. - * @param vectorUInt64Ref (uint64[]): No description available. - * @param plgVector4Ref (vec4): No description available. - * @param plgStringRef (string): No description available. - * @param boolRef (bool): No description available. - * @param int64Ref (int64): No description available. - * @param vec2Ref (vec2): No description available. - * @param int8Ref (int8): No description available. - * @param uint16Ref (uint16): No description available. - * @param vectorInt16Ref (int16[]): No description available. - * @param mat4x4Ref (mat4x4): No description available. - * @param vec3Ref (vec3): No description available. - * @param floatRef (float): No description available. - * @param vectorDoubleRef (double[]): No description available. - * - * @return (callback): vec3: No description available. - */ - inline plg::string CallFunc31Callback(Func31 func) { - using CallFunc31CallbackFn = plg::string (*)(Func31); - static CallFunc31CallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFunc31Callback", - reinterpret_cast(&__func)); - return __func(func); - } - - /** - * @brief No description provided. - * - * @function CallFunc32Callback - * @param func (function): No description available. - * - * @return string: No description available. - * - * @callback Func32 - * @brief No description provided. - * - * @param p1 (int32): No description available. - * @param p2 (uint16): No description available. - * @param p3 (int8[]): No description available. - * @param p4 (vec4): No description available. - * @param p5 (ptr64): No description available. - * @param p6 (uint32[]): No description available. - * @param p7 (mat4x4): No description available. - * @param p8 (uint64): No description available. - * @param p9 (string): No description available. - * @param p10 (int64): No description available. - * @param p11 (vec2): No description available. - * @param p12 (int8[]): No description available. - * @param p13 (bool): No description available. - * @param p14 (vec3): No description available. - * @param p15 (uint8): No description available. - * @param p16 (char16[]): No description available. - * - * @return (callback): double: No description available. - */ - inline plg::string CallFunc32Callback(Func32 func) { - using CallFunc32CallbackFn = plg::string (*)(Func32); - static CallFunc32CallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFunc32Callback", - reinterpret_cast(&__func)); - return __func(func); - } - - /** - * @brief No description provided. - * - * @function CallFunc33Callback - * @param func (function): No description available. - * - * @return string: No description available. - * - * @callback Func33 - * @brief No description provided. - * - * @param variant (any): No description available. - * - * @return (callback): void: No description available. - */ - inline plg::string CallFunc33Callback(Func33 func) { - using CallFunc33CallbackFn = plg::string (*)(Func33); - static CallFunc33CallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFunc33Callback", - reinterpret_cast(&__func)); - return __func(func); - } - - /** - * @brief No description provided. - * - * @function CallFuncEnumCallback - * @param func (function): No description available. - * - * @return string: No description available. - * - * @callback FuncEnum - * @brief No description provided. - * - * @param p1 (int32): No description available. - * @param p2 (int32[]): No description available. - * - * @return (callback): int32[]: No description available. - */ - inline plg::string CallFuncEnumCallback(FuncEnum func) { - using CallFuncEnumCallbackFn = plg::string (*)(FuncEnum); - static CallFuncEnumCallbackFn __func = nullptr; - if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFuncEnumCallback", - reinterpret_cast(&__func)); - return __func(func); - } + + using NoParamReturnFunctionCallbackFunc = int32_t (*)(); + + enum class Example : int32_t { + First = 1, + Second = 2, + Third = 3, + Forth = 4 + }; + + using FuncVoid = void (*)(); + + using FuncBool = bool (*)(); + + using FuncChar8 = char (*)(); + + using FuncChar16 = char16_t (*)(); + + using FuncInt8 = int8_t (*)(); + + using FuncInt16 = int16_t (*)(); + + using FuncInt32 = int32_t (*)(); + + using FuncInt64 = int64_t (*)(); + + using FuncUInt8 = uint8_t (*)(); + + using FuncUInt16 = uint16_t (*)(); + + using FuncUInt32 = uint32_t (*)(); + + using FuncUInt64 = uint64_t (*)(); + + using FuncPtr = void* (*)(); + + using FuncFloat = float (*)(); + + using FuncDouble = double (*)(); + + using FuncString = plg::string (*)(); + + using FuncAny = plg::any (*)(); + + using FuncFunction = void* (*)(); + + using FuncBoolVector = plg::vector (*)(); + + using FuncChar8Vector = plg::vector (*)(); + + using FuncChar16Vector = plg::vector (*)(); + + using FuncInt8Vector = plg::vector (*)(); + + using FuncInt16Vector = plg::vector (*)(); + + using FuncInt32Vector = plg::vector (*)(); + + using FuncInt64Vector = plg::vector (*)(); + + using FuncUInt8Vector = plg::vector (*)(); + + using FuncUInt16Vector = plg::vector (*)(); + + using FuncUInt32Vector = plg::vector (*)(); + + using FuncUInt64Vector = plg::vector (*)(); + + using FuncPtrVector = plg::vector (*)(); + + using FuncFloatVector = plg::vector (*)(); + + using FuncDoubleVector = plg::vector (*)(); + + using FuncStringVector = plg::vector (*)(); + + using FuncAnyVector = plg::vector (*)(); + + using FuncVec2Vector = plg::vector (*)(); + + using FuncVec3Vector = plg::vector (*)(); + + using FuncVec4Vector = plg::vector (*)(); + + using FuncMat4x4Vector = plg::vector (*)(); + + using FuncVec2 = plg::vec2 (*)(); + + using FuncVec3 = plg::vec3 (*)(); + + using FuncVec4 = plg::vec4 (*)(); + + using FuncMat4x4 = plg::mat4x4 (*)(); + + using Func1 = int32_t (*)(const plg::vec3&); + + using Func2 = char (*)(float, int64_t); + + using Func3 = void (*)(void*, const plg::vec4&, const plg::string&); + + using Func4 = plg::vec4 (*)(bool, int32_t, char16_t, const plg::mat4x4&); + + using Func5 = bool (*)(int8_t, const plg::vec2&, void*, double, const plg::vector&); + + using Func6 = int64_t (*)(const plg::string&, float, const plg::vector&, int16_t, const plg::vector&, void*); + + using Func7 = double (*)(const plg::vector&, uint16_t, char16_t, const plg::vector&, const plg::vec4&, bool, uint64_t); + + using Func8 = plg::mat4x4 (*)(const plg::vec3&, const plg::vector&, int16_t, bool, const plg::vec4&, const plg::vector&, char16_t, int32_t); + + using Func9 = void (*)(float, const plg::vec2&, const plg::vector&, uint64_t, bool, const plg::string&, const plg::vec4&, int16_t, void*); + + using Func10 = uint32_t (*)(const plg::vec4&, const plg::mat4x4&, const plg::vector&, uint64_t, const plg::vector&, int32_t, bool, const plg::vec2&, int64_t, double); + + using Func11 = void* (*)(const plg::vector&, char16_t, uint8_t, double, const plg::vec3&, const plg::vector&, int64_t, uint16_t, float, const plg::vec2&, uint32_t); + + using Func12 = bool (*)(void*, const plg::vector&, uint32_t, double, bool, int32_t, int8_t, uint64_t, float, const plg::vector&, int64_t, char); + + using Func13 = plg::string (*)(int64_t, const plg::vector&, uint16_t, float, const plg::vector&, const plg::vec4&, const plg::string&, int32_t, const plg::vec3&, void*, const plg::vec2&, const plg::vector&, int16_t); + + using Func14 = plg::vector (*)(const plg::vector&, const plg::vector&, const plg::mat4x4&, bool, char16_t, int32_t, const plg::vector&, uint16_t, const plg::vector&, int8_t, const plg::vec3&, const plg::vec4&, double, void*); + + using Func15 = int16_t (*)(const plg::vector&, const plg::mat4x4&, const plg::vec4&, void*, uint64_t, const plg::vector&, bool, float, const plg::vector&, uint8_t, int32_t, const plg::vec2&, uint16_t, double, const plg::vector&); + + using Func16 = void* (*)(const plg::vector&, int16_t, const plg::vector&, const plg::vec4&, const plg::mat4x4&, const plg::vec2&, const plg::vector&, const plg::vector&, const plg::string&, int64_t, const plg::vector&, const plg::vec3&, float, double, int8_t, uint16_t); + + using Func17 = void (*)(int32_t&); + + using Func18 = plg::vec2 (*)(int8_t&, int16_t&); + + using Func19 = void (*)(uint32_t&, plg::vec3&, plg::vector&); + + using Func20 = int32_t (*)(char16_t&, plg::vec4&, plg::vector&, char&); + + using Func21 = float (*)(plg::mat4x4&, plg::vector&, plg::vec2&, bool&, double&); + + using Func22 = uint64_t (*)(void*&, uint32_t&, plg::vector&, int16_t&, plg::string&, plg::vec4&); + + using Func23 = void (*)(uint64_t&, plg::vec2&, plg::vector&, char16_t&, float&, int8_t&, plg::vector&); + + using Func24 = plg::mat4x4 (*)(plg::vector&, int64_t&, plg::vector&, plg::vec4&, uint64_t&, plg::vector&, double&, plg::vector&); + + using Func25 = double (*)(int32_t&, plg::vector&, bool&, uint8_t&, plg::string&, plg::vec3&, int64_t&, plg::vec4&, uint16_t&); + + using Func26 = char (*)(char16_t&, plg::vec2&, plg::mat4x4&, plg::vector&, int16_t&, uint64_t&, uint32_t&, plg::vector&, void*&, bool&); + + using Func27 = uint8_t (*)(float&, plg::vec3&, void*&, plg::vec2&, plg::vector&, plg::mat4x4&, bool&, plg::vec4&, int8_t&, int32_t&, plg::vector&); + + using Func28 = plg::string (*)(void*&, uint16_t&, plg::vector&, plg::mat4x4&, float&, plg::vec4&, plg::string&, plg::vector&, int64_t&, bool&, plg::vec3&, plg::vector&); + + using Func29 = plg::vector (*)(plg::vec4&, int32_t&, plg::vector&, double&, bool&, int8_t&, plg::vector&, float&, plg::string&, plg::mat4x4&, uint64_t&, plg::vec3&, plg::vector&); + + using Func30 = int32_t (*)(void*&, plg::vec4&, int64_t&, plg::vector&, bool&, plg::string&, plg::vec3&, plg::vector&, float&, plg::vec2&, plg::mat4x4&, int8_t&, plg::vector&, double&); + + using Func31 = plg::vec3 (*)(char&, uint32_t&, plg::vector&, plg::vec4&, plg::string&, bool&, int64_t&, plg::vec2&, int8_t&, uint16_t&, plg::vector&, plg::mat4x4&, plg::vec3&, float&, plg::vector&); + + using Func32 = double (*)(int32_t&, uint16_t&, plg::vector&, plg::vec4&, void*&, plg::vector&, plg::mat4x4&, uint64_t&, plg::string&, int64_t&, plg::vec2&, plg::vector&, bool&, plg::vec3&, uint8_t&, plg::vector&); + + using Func33 = void (*)(plg::any&); + + using FuncEnum = plg::vector (*)(Example, plg::vector); + + + /** + * @function ReverseReturn + * @param returnString (string) + */ + inline void ReverseReturn(const plg::string& returnString) { + using ReverseReturnFn = void (*)(const plg::string&); + static ReverseReturnFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.ReverseReturn", reinterpret_cast(&__func)); + __func(returnString); + } + + /** + * @function NoParamReturnVoidCallback + */ + inline void NoParamReturnVoidCallback() { + using NoParamReturnVoidCallbackFn = void (*)(); + static NoParamReturnVoidCallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.NoParamReturnVoidCallback", reinterpret_cast(&__func)); + __func(); + } + + /** + * @function NoParamReturnBoolCallback + * @return bool + */ + inline bool NoParamReturnBoolCallback() { + using NoParamReturnBoolCallbackFn = bool (*)(); + static NoParamReturnBoolCallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.NoParamReturnBoolCallback", reinterpret_cast(&__func)); + return __func(); + } + + /** + * @function NoParamReturnChar8Callback + * @return char8 + */ + inline char NoParamReturnChar8Callback() { + using NoParamReturnChar8CallbackFn = char (*)(); + static NoParamReturnChar8CallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.NoParamReturnChar8Callback", reinterpret_cast(&__func)); + return __func(); + } + + /** + * @function NoParamReturnChar16Callback + * @return char16 + */ + inline char16_t NoParamReturnChar16Callback() { + using NoParamReturnChar16CallbackFn = char16_t (*)(); + static NoParamReturnChar16CallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.NoParamReturnChar16Callback", reinterpret_cast(&__func)); + return __func(); + } + + /** + * @function NoParamReturnInt8Callback + * @return int8 + */ + inline int8_t NoParamReturnInt8Callback() { + using NoParamReturnInt8CallbackFn = int8_t (*)(); + static NoParamReturnInt8CallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.NoParamReturnInt8Callback", reinterpret_cast(&__func)); + return __func(); + } + + /** + * @function NoParamReturnInt16Callback + * @return int16 + */ + inline int16_t NoParamReturnInt16Callback() { + using NoParamReturnInt16CallbackFn = int16_t (*)(); + static NoParamReturnInt16CallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.NoParamReturnInt16Callback", reinterpret_cast(&__func)); + return __func(); + } + + /** + * @function NoParamReturnInt32Callback + * @return int32 + */ + inline int32_t NoParamReturnInt32Callback() { + using NoParamReturnInt32CallbackFn = int32_t (*)(); + static NoParamReturnInt32CallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.NoParamReturnInt32Callback", reinterpret_cast(&__func)); + return __func(); + } + + /** + * @function NoParamReturnInt64Callback + * @return int64 + */ + inline int64_t NoParamReturnInt64Callback() { + using NoParamReturnInt64CallbackFn = int64_t (*)(); + static NoParamReturnInt64CallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.NoParamReturnInt64Callback", reinterpret_cast(&__func)); + return __func(); + } + + /** + * @function NoParamReturnUInt8Callback + * @return uint8 + */ + inline uint8_t NoParamReturnUInt8Callback() { + using NoParamReturnUInt8CallbackFn = uint8_t (*)(); + static NoParamReturnUInt8CallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.NoParamReturnUInt8Callback", reinterpret_cast(&__func)); + return __func(); + } + + /** + * @function NoParamReturnUInt16Callback + * @return uint16 + */ + inline uint16_t NoParamReturnUInt16Callback() { + using NoParamReturnUInt16CallbackFn = uint16_t (*)(); + static NoParamReturnUInt16CallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.NoParamReturnUInt16Callback", reinterpret_cast(&__func)); + return __func(); + } + + /** + * @function NoParamReturnUInt32Callback + * @return uint32 + */ + inline uint32_t NoParamReturnUInt32Callback() { + using NoParamReturnUInt32CallbackFn = uint32_t (*)(); + static NoParamReturnUInt32CallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.NoParamReturnUInt32Callback", reinterpret_cast(&__func)); + return __func(); + } + + /** + * @function NoParamReturnUInt64Callback + * @return uint64 + */ + inline uint64_t NoParamReturnUInt64Callback() { + using NoParamReturnUInt64CallbackFn = uint64_t (*)(); + static NoParamReturnUInt64CallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.NoParamReturnUInt64Callback", reinterpret_cast(&__func)); + return __func(); + } + + /** + * @function NoParamReturnPointerCallback + * @return ptr64 + */ + inline void* NoParamReturnPointerCallback() { + using NoParamReturnPointerCallbackFn = void* (*)(); + static NoParamReturnPointerCallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.NoParamReturnPointerCallback", reinterpret_cast(&__func)); + return __func(); + } + + /** + * @function NoParamReturnFloatCallback + * @return float + */ + inline float NoParamReturnFloatCallback() { + using NoParamReturnFloatCallbackFn = float (*)(); + static NoParamReturnFloatCallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.NoParamReturnFloatCallback", reinterpret_cast(&__func)); + return __func(); + } + + /** + * @function NoParamReturnDoubleCallback + * @return double + */ + inline double NoParamReturnDoubleCallback() { + using NoParamReturnDoubleCallbackFn = double (*)(); + static NoParamReturnDoubleCallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.NoParamReturnDoubleCallback", reinterpret_cast(&__func)); + return __func(); + } + + /** + * @function NoParamReturnFunctionCallback + * @return function + */ + inline NoParamReturnFunctionCallbackFunc NoParamReturnFunctionCallback() { + using NoParamReturnFunctionCallbackFn = NoParamReturnFunctionCallbackFunc (*)(); + static NoParamReturnFunctionCallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.NoParamReturnFunctionCallback", reinterpret_cast(&__func)); + return __func(); + } + + /** + * @function NoParamReturnStringCallback + * @return string + */ + inline plg::string NoParamReturnStringCallback() { + using NoParamReturnStringCallbackFn = plg::string (*)(); + static NoParamReturnStringCallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.NoParamReturnStringCallback", reinterpret_cast(&__func)); + return __func(); + } + + /** + * @function NoParamReturnAnyCallback + * @return any + */ + inline plg::any NoParamReturnAnyCallback() { + using NoParamReturnAnyCallbackFn = plg::any (*)(); + static NoParamReturnAnyCallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.NoParamReturnAnyCallback", reinterpret_cast(&__func)); + return __func(); + } + + /** + * @function NoParamReturnArrayBoolCallback + * @return bool[] + */ + inline plg::vector NoParamReturnArrayBoolCallback() { + using NoParamReturnArrayBoolCallbackFn = plg::vector (*)(); + static NoParamReturnArrayBoolCallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.NoParamReturnArrayBoolCallback", reinterpret_cast(&__func)); + return __func(); + } + + /** + * @function NoParamReturnArrayChar8Callback + * @return char8[] + */ + inline plg::vector NoParamReturnArrayChar8Callback() { + using NoParamReturnArrayChar8CallbackFn = plg::vector (*)(); + static NoParamReturnArrayChar8CallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.NoParamReturnArrayChar8Callback", reinterpret_cast(&__func)); + return __func(); + } + + /** + * @function NoParamReturnArrayChar16Callback + * @return char16[] + */ + inline plg::vector NoParamReturnArrayChar16Callback() { + using NoParamReturnArrayChar16CallbackFn = plg::vector (*)(); + static NoParamReturnArrayChar16CallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.NoParamReturnArrayChar16Callback", reinterpret_cast(&__func)); + return __func(); + } + + /** + * @function NoParamReturnArrayInt8Callback + * @return int8[] + */ + inline plg::vector NoParamReturnArrayInt8Callback() { + using NoParamReturnArrayInt8CallbackFn = plg::vector (*)(); + static NoParamReturnArrayInt8CallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.NoParamReturnArrayInt8Callback", reinterpret_cast(&__func)); + return __func(); + } + + /** + * @function NoParamReturnArrayInt16Callback + * @return int16[] + */ + inline plg::vector NoParamReturnArrayInt16Callback() { + using NoParamReturnArrayInt16CallbackFn = plg::vector (*)(); + static NoParamReturnArrayInt16CallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.NoParamReturnArrayInt16Callback", reinterpret_cast(&__func)); + return __func(); + } + + /** + * @function NoParamReturnArrayInt32Callback + * @return int32[] + */ + inline plg::vector NoParamReturnArrayInt32Callback() { + using NoParamReturnArrayInt32CallbackFn = plg::vector (*)(); + static NoParamReturnArrayInt32CallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.NoParamReturnArrayInt32Callback", reinterpret_cast(&__func)); + return __func(); + } + + /** + * @function NoParamReturnArrayInt64Callback + * @return int64[] + */ + inline plg::vector NoParamReturnArrayInt64Callback() { + using NoParamReturnArrayInt64CallbackFn = plg::vector (*)(); + static NoParamReturnArrayInt64CallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.NoParamReturnArrayInt64Callback", reinterpret_cast(&__func)); + return __func(); + } + + /** + * @function NoParamReturnArrayUInt8Callback + * @return uint8[] + */ + inline plg::vector NoParamReturnArrayUInt8Callback() { + using NoParamReturnArrayUInt8CallbackFn = plg::vector (*)(); + static NoParamReturnArrayUInt8CallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.NoParamReturnArrayUInt8Callback", reinterpret_cast(&__func)); + return __func(); + } + + /** + * @function NoParamReturnArrayUInt16Callback + * @return uint16[] + */ + inline plg::vector NoParamReturnArrayUInt16Callback() { + using NoParamReturnArrayUInt16CallbackFn = plg::vector (*)(); + static NoParamReturnArrayUInt16CallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.NoParamReturnArrayUInt16Callback", reinterpret_cast(&__func)); + return __func(); + } + + /** + * @function NoParamReturnArrayUInt32Callback + * @return uint32[] + */ + inline plg::vector NoParamReturnArrayUInt32Callback() { + using NoParamReturnArrayUInt32CallbackFn = plg::vector (*)(); + static NoParamReturnArrayUInt32CallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.NoParamReturnArrayUInt32Callback", reinterpret_cast(&__func)); + return __func(); + } + + /** + * @function NoParamReturnArrayUInt64Callback + * @return uint64[] + */ + inline plg::vector NoParamReturnArrayUInt64Callback() { + using NoParamReturnArrayUInt64CallbackFn = plg::vector (*)(); + static NoParamReturnArrayUInt64CallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.NoParamReturnArrayUInt64Callback", reinterpret_cast(&__func)); + return __func(); + } + + /** + * @function NoParamReturnArrayPointerCallback + * @return ptr64[] + */ + inline plg::vector NoParamReturnArrayPointerCallback() { + using NoParamReturnArrayPointerCallbackFn = plg::vector (*)(); + static NoParamReturnArrayPointerCallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.NoParamReturnArrayPointerCallback", reinterpret_cast(&__func)); + return __func(); + } + + /** + * @function NoParamReturnArrayFloatCallback + * @return float[] + */ + inline plg::vector NoParamReturnArrayFloatCallback() { + using NoParamReturnArrayFloatCallbackFn = plg::vector (*)(); + static NoParamReturnArrayFloatCallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.NoParamReturnArrayFloatCallback", reinterpret_cast(&__func)); + return __func(); + } + + /** + * @function NoParamReturnArrayDoubleCallback + * @return double[] + */ + inline plg::vector NoParamReturnArrayDoubleCallback() { + using NoParamReturnArrayDoubleCallbackFn = plg::vector (*)(); + static NoParamReturnArrayDoubleCallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.NoParamReturnArrayDoubleCallback", reinterpret_cast(&__func)); + return __func(); + } + + /** + * @function NoParamReturnArrayStringCallback + * @return string[] + */ + inline plg::vector NoParamReturnArrayStringCallback() { + using NoParamReturnArrayStringCallbackFn = plg::vector (*)(); + static NoParamReturnArrayStringCallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.NoParamReturnArrayStringCallback", reinterpret_cast(&__func)); + return __func(); + } + + /** + * @function NoParamReturnArrayAnyCallback + * @return any[] + */ + inline plg::vector NoParamReturnArrayAnyCallback() { + using NoParamReturnArrayAnyCallbackFn = plg::vector (*)(); + static NoParamReturnArrayAnyCallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.NoParamReturnArrayAnyCallback", reinterpret_cast(&__func)); + return __func(); + } + + /** + * @function NoParamReturnArrayVector2Callback + * @return vec2[] + */ + inline plg::vector NoParamReturnArrayVector2Callback() { + using NoParamReturnArrayVector2CallbackFn = plg::vector (*)(); + static NoParamReturnArrayVector2CallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.NoParamReturnArrayVector2Callback", reinterpret_cast(&__func)); + return __func(); + } + + /** + * @function NoParamReturnArrayVector3Callback + * @return vec3[] + */ + inline plg::vector NoParamReturnArrayVector3Callback() { + using NoParamReturnArrayVector3CallbackFn = plg::vector (*)(); + static NoParamReturnArrayVector3CallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.NoParamReturnArrayVector3Callback", reinterpret_cast(&__func)); + return __func(); + } + + /** + * @function NoParamReturnArrayVector4Callback + * @return vec4[] + */ + inline plg::vector NoParamReturnArrayVector4Callback() { + using NoParamReturnArrayVector4CallbackFn = plg::vector (*)(); + static NoParamReturnArrayVector4CallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.NoParamReturnArrayVector4Callback", reinterpret_cast(&__func)); + return __func(); + } + + /** + * @function NoParamReturnArrayMatrix4x4Callback + * @return mat4x4[] + */ + inline plg::vector NoParamReturnArrayMatrix4x4Callback() { + using NoParamReturnArrayMatrix4x4CallbackFn = plg::vector (*)(); + static NoParamReturnArrayMatrix4x4CallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.NoParamReturnArrayMatrix4x4Callback", reinterpret_cast(&__func)); + return __func(); + } + + /** + * @function NoParamReturnVector2Callback + * @return vec2 + */ + inline plg::vec2 NoParamReturnVector2Callback() { + using NoParamReturnVector2CallbackFn = plg::vec2 (*)(); + static NoParamReturnVector2CallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.NoParamReturnVector2Callback", reinterpret_cast(&__func)); + return __func(); + } + + /** + * @function NoParamReturnVector3Callback + * @return vec3 + */ + inline plg::vec3 NoParamReturnVector3Callback() { + using NoParamReturnVector3CallbackFn = plg::vec3 (*)(); + static NoParamReturnVector3CallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.NoParamReturnVector3Callback", reinterpret_cast(&__func)); + return __func(); + } + + /** + * @function NoParamReturnVector4Callback + * @return vec4 + */ + inline plg::vec4 NoParamReturnVector4Callback() { + using NoParamReturnVector4CallbackFn = plg::vec4 (*)(); + static NoParamReturnVector4CallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.NoParamReturnVector4Callback", reinterpret_cast(&__func)); + return __func(); + } + + /** + * @function NoParamReturnMatrix4x4Callback + * @return mat4x4 + */ + inline plg::mat4x4 NoParamReturnMatrix4x4Callback() { + using NoParamReturnMatrix4x4CallbackFn = plg::mat4x4 (*)(); + static NoParamReturnMatrix4x4CallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.NoParamReturnMatrix4x4Callback", reinterpret_cast(&__func)); + return __func(); + } + + /** + * @function Param1Callback + * @param a (int32) + */ + inline void Param1Callback(int32_t a) { + using Param1CallbackFn = void (*)(int32_t); + static Param1CallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.Param1Callback", reinterpret_cast(&__func)); + __func(a); + } + + /** + * @function Param2Callback + * @param a (int32) + * @param b (float) + */ + inline void Param2Callback(int32_t a, float b) { + using Param2CallbackFn = void (*)(int32_t, float); + static Param2CallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.Param2Callback", reinterpret_cast(&__func)); + __func(a, b); + } + + /** + * @function Param3Callback + * @param a (int32) + * @param b (float) + * @param c (double) + */ + inline void Param3Callback(int32_t a, float b, double c) { + using Param3CallbackFn = void (*)(int32_t, float, double); + static Param3CallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.Param3Callback", reinterpret_cast(&__func)); + __func(a, b, c); + } + + /** + * @function Param4Callback + * @param a (int32) + * @param b (float) + * @param c (double) + * @param d (vec4) + */ + inline void Param4Callback(int32_t a, float b, double c, const plg::vec4& d) { + using Param4CallbackFn = void (*)(int32_t, float, double, const plg::vec4&); + static Param4CallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.Param4Callback", reinterpret_cast(&__func)); + __func(a, b, c, d); + } + + /** + * @function Param5Callback + * @param a (int32) + * @param b (float) + * @param c (double) + * @param d (vec4) + * @param e (int64[]) + */ + inline void Param5Callback(int32_t a, float b, double c, const plg::vec4& d, const plg::vector& e) { + using Param5CallbackFn = void (*)(int32_t, float, double, const plg::vec4&, const plg::vector&); + static Param5CallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.Param5Callback", reinterpret_cast(&__func)); + __func(a, b, c, d, e); + } + + /** + * @function Param6Callback + * @param a (int32) + * @param b (float) + * @param c (double) + * @param d (vec4) + * @param e (int64[]) + * @param f (char8) + */ + inline void Param6Callback(int32_t a, float b, double c, const plg::vec4& d, const plg::vector& e, char f) { + using Param6CallbackFn = void (*)(int32_t, float, double, const plg::vec4&, const plg::vector&, char); + static Param6CallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.Param6Callback", reinterpret_cast(&__func)); + __func(a, b, c, d, e, f); + } + + /** + * @function Param7Callback + * @param a (int32) + * @param b (float) + * @param c (double) + * @param d (vec4) + * @param e (int64[]) + * @param f (char8) + * @param g (string) + */ + inline void Param7Callback(int32_t a, float b, double c, const plg::vec4& d, const plg::vector& e, char f, const plg::string& g) { + using Param7CallbackFn = void (*)(int32_t, float, double, const plg::vec4&, const plg::vector&, char, const plg::string&); + static Param7CallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.Param7Callback", reinterpret_cast(&__func)); + __func(a, b, c, d, e, f, g); + } + + /** + * @function Param8Callback + * @param a (int32) + * @param b (float) + * @param c (double) + * @param d (vec4) + * @param e (int64[]) + * @param f (char8) + * @param g (string) + * @param h (char16) + */ + inline void Param8Callback(int32_t a, float b, double c, const plg::vec4& d, const plg::vector& e, char f, const plg::string& g, char16_t h) { + using Param8CallbackFn = void (*)(int32_t, float, double, const plg::vec4&, const plg::vector&, char, const plg::string&, char16_t); + static Param8CallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.Param8Callback", reinterpret_cast(&__func)); + __func(a, b, c, d, e, f, g, h); + } + + /** + * @function Param9Callback + * @param a (int32) + * @param b (float) + * @param c (double) + * @param d (vec4) + * @param e (int64[]) + * @param f (char8) + * @param g (string) + * @param h (char16) + * @param k (int16) + */ + inline void Param9Callback(int32_t a, float b, double c, const plg::vec4& d, const plg::vector& e, char f, const plg::string& g, char16_t h, int16_t k) { + using Param9CallbackFn = void (*)(int32_t, float, double, const plg::vec4&, const plg::vector&, char, const plg::string&, char16_t, int16_t); + static Param9CallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.Param9Callback", reinterpret_cast(&__func)); + __func(a, b, c, d, e, f, g, h, k); + } + + /** + * @function Param10Callback + * @param a (int32) + * @param b (float) + * @param c (double) + * @param d (vec4) + * @param e (int64[]) + * @param f (char8) + * @param g (string) + * @param h (char16) + * @param k (int16) + * @param l (ptr64) + */ + inline void Param10Callback(int32_t a, float b, double c, const plg::vec4& d, const plg::vector& e, char f, const plg::string& g, char16_t h, int16_t k, void* l) { + using Param10CallbackFn = void (*)(int32_t, float, double, const plg::vec4&, const plg::vector&, char, const plg::string&, char16_t, int16_t, void*); + static Param10CallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.Param10Callback", reinterpret_cast(&__func)); + __func(a, b, c, d, e, f, g, h, k, l); + } + + /** + * @function ParamRef1Callback + * @param a (int32&) + */ + inline void ParamRef1Callback(int32_t& a) { + using ParamRef1CallbackFn = void (*)(int32_t&); + static ParamRef1CallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.ParamRef1Callback", reinterpret_cast(&__func)); + __func(a); + } + + /** + * @function ParamRef2Callback + * @param a (int32&) + * @param b (float&) + */ + inline void ParamRef2Callback(int32_t& a, float& b) { + using ParamRef2CallbackFn = void (*)(int32_t&, float&); + static ParamRef2CallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.ParamRef2Callback", reinterpret_cast(&__func)); + __func(a, b); + } + + /** + * @function ParamRef3Callback + * @param a (int32&) + * @param b (float&) + * @param c (double&) + */ + inline void ParamRef3Callback(int32_t& a, float& b, double& c) { + using ParamRef3CallbackFn = void (*)(int32_t&, float&, double&); + static ParamRef3CallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.ParamRef3Callback", reinterpret_cast(&__func)); + __func(a, b, c); + } + + /** + * @function ParamRef4Callback + * @param a (int32&) + * @param b (float&) + * @param c (double&) + * @param d (vec4&) + */ + inline void ParamRef4Callback(int32_t& a, float& b, double& c, plg::vec4& d) { + using ParamRef4CallbackFn = void (*)(int32_t&, float&, double&, plg::vec4&); + static ParamRef4CallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.ParamRef4Callback", reinterpret_cast(&__func)); + __func(a, b, c, d); + } + + /** + * @function ParamRef5Callback + * @param a (int32&) + * @param b (float&) + * @param c (double&) + * @param d (vec4&) + * @param e (int64[]&) + */ + inline void ParamRef5Callback(int32_t& a, float& b, double& c, plg::vec4& d, plg::vector& e) { + using ParamRef5CallbackFn = void (*)(int32_t&, float&, double&, plg::vec4&, plg::vector&); + static ParamRef5CallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.ParamRef5Callback", reinterpret_cast(&__func)); + __func(a, b, c, d, e); + } + + /** + * @function ParamRef6Callback + * @param a (int32&) + * @param b (float&) + * @param c (double&) + * @param d (vec4&) + * @param e (int64[]&) + * @param f (char8&) + */ + inline void ParamRef6Callback(int32_t& a, float& b, double& c, plg::vec4& d, plg::vector& e, char& f) { + using ParamRef6CallbackFn = void (*)(int32_t&, float&, double&, plg::vec4&, plg::vector&, char&); + static ParamRef6CallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.ParamRef6Callback", reinterpret_cast(&__func)); + __func(a, b, c, d, e, f); + } + + /** + * @function ParamRef7Callback + * @param a (int32&) + * @param b (float&) + * @param c (double&) + * @param d (vec4&) + * @param e (int64[]&) + * @param f (char8&) + * @param g (string&) + */ + inline void ParamRef7Callback(int32_t& a, float& b, double& c, plg::vec4& d, plg::vector& e, char& f, plg::string& g) { + using ParamRef7CallbackFn = void (*)(int32_t&, float&, double&, plg::vec4&, plg::vector&, char&, plg::string&); + static ParamRef7CallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.ParamRef7Callback", reinterpret_cast(&__func)); + __func(a, b, c, d, e, f, g); + } + + /** + * @function ParamRef8Callback + * @param a (int32&) + * @param b (float&) + * @param c (double&) + * @param d (vec4&) + * @param e (int64[]&) + * @param f (char8&) + * @param g (string&) + * @param h (char16&) + */ + inline void ParamRef8Callback(int32_t& a, float& b, double& c, plg::vec4& d, plg::vector& e, char& f, plg::string& g, char16_t& h) { + using ParamRef8CallbackFn = void (*)(int32_t&, float&, double&, plg::vec4&, plg::vector&, char&, plg::string&, char16_t&); + static ParamRef8CallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.ParamRef8Callback", reinterpret_cast(&__func)); + __func(a, b, c, d, e, f, g, h); + } + + /** + * @function ParamRef9Callback + * @param a (int32&) + * @param b (float&) + * @param c (double&) + * @param d (vec4&) + * @param e (int64[]&) + * @param f (char8&) + * @param g (string&) + * @param h (char16&) + * @param k (int16&) + */ + inline void ParamRef9Callback(int32_t& a, float& b, double& c, plg::vec4& d, plg::vector& e, char& f, plg::string& g, char16_t& h, int16_t& k) { + using ParamRef9CallbackFn = void (*)(int32_t&, float&, double&, plg::vec4&, plg::vector&, char&, plg::string&, char16_t&, int16_t&); + static ParamRef9CallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.ParamRef9Callback", reinterpret_cast(&__func)); + __func(a, b, c, d, e, f, g, h, k); + } + + /** + * @function ParamRef10Callback + * @param a (int32&) + * @param b (float&) + * @param c (double&) + * @param d (vec4&) + * @param e (int64[]&) + * @param f (char8&) + * @param g (string&) + * @param h (char16&) + * @param k (int16&) + * @param l (ptr64&) + */ + inline void ParamRef10Callback(int32_t& a, float& b, double& c, plg::vec4& d, plg::vector& e, char& f, plg::string& g, char16_t& h, int16_t& k, void*& l) { + using ParamRef10CallbackFn = void (*)(int32_t&, float&, double&, plg::vec4&, plg::vector&, char&, plg::string&, char16_t&, int16_t&, void*&); + static ParamRef10CallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.ParamRef10Callback", reinterpret_cast(&__func)); + __func(a, b, c, d, e, f, g, h, k, l); + } + + /** + * @function ParamRefVectorsCallback + * @param p1 (bool[]&) + * @param p2 (char8[]&) + * @param p3 (char16[]&) + * @param p4 (int8[]&) + * @param p5 (int16[]&) + * @param p6 (int32[]&) + * @param p7 (int64[]&) + * @param p8 (uint8[]&) + * @param p9 (uint16[]&) + * @param p10 (uint32[]&) + * @param p11 (uint64[]&) + * @param p12 (ptr64[]&) + * @param p13 (float[]&) + * @param p14 (double[]&) + * @param p15 (string[]&) + */ + inline void ParamRefVectorsCallback(plg::vector& p1, plg::vector& p2, plg::vector& p3, plg::vector& p4, plg::vector& p5, plg::vector& p6, plg::vector& p7, plg::vector& p8, plg::vector& p9, plg::vector& p10, plg::vector& p11, plg::vector& p12, plg::vector& p13, plg::vector& p14, plg::vector& p15) { + using ParamRefVectorsCallbackFn = void (*)(plg::vector&, plg::vector&, plg::vector&, plg::vector&, plg::vector&, plg::vector&, plg::vector&, plg::vector&, plg::vector&, plg::vector&, plg::vector&, plg::vector&, plg::vector&, plg::vector&, plg::vector&); + static ParamRefVectorsCallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.ParamRefVectorsCallback", reinterpret_cast(&__func)); + __func(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15); + } + + /** + * @function ParamAllPrimitivesCallback + * @param p1 (bool) + * @param p2 (char8) + * @param p3 (char16) + * @param p4 (int8) + * @param p5 (int16) + * @param p6 (int32) + * @param p7 (int64) + * @param p8 (uint8) + * @param p9 (uint16) + * @param p10 (uint32) + * @param p11 (uint64) + * @param p12 (ptr64) + * @param p13 (float) + * @param p14 (double) + * @return int64 + */ + inline int64_t ParamAllPrimitivesCallback(bool p1, char p2, char16_t p3, int8_t p4, int16_t p5, int32_t p6, int64_t p7, uint8_t p8, uint16_t p9, uint32_t p10, uint64_t p11, void* p12, float p13, double p14) { + using ParamAllPrimitivesCallbackFn = int64_t (*)(bool, char, char16_t, int8_t, int16_t, int32_t, int64_t, uint8_t, uint16_t, uint32_t, uint64_t, void*, float, double); + static ParamAllPrimitivesCallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.ParamAllPrimitivesCallback", reinterpret_cast(&__func)); + return __func(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14); + } + + /** + * @function ParamEnumCallback + * @param p1 (int32) + * @param p2 (int32[]) + * @return int32 + */ + inline int32_t ParamEnumCallback(Example p1, plg::vector p2) { + using ParamEnumCallbackFn = int32_t (*)(Example, plg::vector); + static ParamEnumCallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.ParamEnumCallback", reinterpret_cast(&__func)); + return __func(p1, p2); + } + + /** + * @function ParamEnumRefCallback + * @param p1 (int32&) + * @param p2 (int32[]&) + * @return int32 + */ + inline int32_t ParamEnumRefCallback(Example& p1, plg::vector p2) { + using ParamEnumRefCallbackFn = int32_t (*)(Example&, plg::vector); + static ParamEnumRefCallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.ParamEnumRefCallback", reinterpret_cast(&__func)); + return __func(p1, p2); + } + + /** + * @function ParamVariantCallback + * @param p1 (any) + * @param p2 (any[]) + */ + inline void ParamVariantCallback(const plg::any& p1, const plg::vector& p2) { + using ParamVariantCallbackFn = void (*)(const plg::any&, const plg::vector&); + static ParamVariantCallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.ParamVariantCallback", reinterpret_cast(&__func)); + __func(p1, p2); + } + + /** + * @function ParamVariantRefCallback + * @param p1 (any&) + * @param p2 (any[]&) + */ + inline void ParamVariantRefCallback(plg::any& p1, plg::vector& p2) { + using ParamVariantRefCallbackFn = void (*)(plg::any&, plg::vector&); + static ParamVariantRefCallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.ParamVariantRefCallback", reinterpret_cast(&__func)); + __func(p1, p2); + } + + /** + * @function CallFuncVoidCallback + * @param func (function) + */ + inline void CallFuncVoidCallback(FuncVoid func) { + using CallFuncVoidCallbackFn = void (*)(FuncVoid); + static CallFuncVoidCallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFuncVoidCallback", reinterpret_cast(&__func)); + __func(func); + } + + /** + * @function CallFuncBoolCallback + * @param func (function) + * @return bool + */ + inline bool CallFuncBoolCallback(FuncBool func) { + using CallFuncBoolCallbackFn = bool (*)(FuncBool); + static CallFuncBoolCallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFuncBoolCallback", reinterpret_cast(&__func)); + return __func(func); + } + + /** + * @function CallFuncChar8Callback + * @param func (function) + * @return char8 + */ + inline char CallFuncChar8Callback(FuncChar8 func) { + using CallFuncChar8CallbackFn = char (*)(FuncChar8); + static CallFuncChar8CallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFuncChar8Callback", reinterpret_cast(&__func)); + return __func(func); + } + + /** + * @function CallFuncChar16Callback + * @param func (function) + * @return char16 + */ + inline char16_t CallFuncChar16Callback(FuncChar16 func) { + using CallFuncChar16CallbackFn = char16_t (*)(FuncChar16); + static CallFuncChar16CallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFuncChar16Callback", reinterpret_cast(&__func)); + return __func(func); + } + + /** + * @function CallFuncInt8Callback + * @param func (function) + * @return int8 + */ + inline int8_t CallFuncInt8Callback(FuncInt8 func) { + using CallFuncInt8CallbackFn = int8_t (*)(FuncInt8); + static CallFuncInt8CallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFuncInt8Callback", reinterpret_cast(&__func)); + return __func(func); + } + + /** + * @function CallFuncInt16Callback + * @param func (function) + * @return int16 + */ + inline int16_t CallFuncInt16Callback(FuncInt16 func) { + using CallFuncInt16CallbackFn = int16_t (*)(FuncInt16); + static CallFuncInt16CallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFuncInt16Callback", reinterpret_cast(&__func)); + return __func(func); + } + + /** + * @function CallFuncInt32Callback + * @param func (function) + * @return int32 + */ + inline int32_t CallFuncInt32Callback(FuncInt32 func) { + using CallFuncInt32CallbackFn = int32_t (*)(FuncInt32); + static CallFuncInt32CallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFuncInt32Callback", reinterpret_cast(&__func)); + return __func(func); + } + + /** + * @function CallFuncInt64Callback + * @param func (function) + * @return int64 + */ + inline int64_t CallFuncInt64Callback(FuncInt64 func) { + using CallFuncInt64CallbackFn = int64_t (*)(FuncInt64); + static CallFuncInt64CallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFuncInt64Callback", reinterpret_cast(&__func)); + return __func(func); + } + + /** + * @function CallFuncUInt8Callback + * @param func (function) + * @return uint8 + */ + inline uint8_t CallFuncUInt8Callback(FuncUInt8 func) { + using CallFuncUInt8CallbackFn = uint8_t (*)(FuncUInt8); + static CallFuncUInt8CallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFuncUInt8Callback", reinterpret_cast(&__func)); + return __func(func); + } + + /** + * @function CallFuncUInt16Callback + * @param func (function) + * @return uint16 + */ + inline uint16_t CallFuncUInt16Callback(FuncUInt16 func) { + using CallFuncUInt16CallbackFn = uint16_t (*)(FuncUInt16); + static CallFuncUInt16CallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFuncUInt16Callback", reinterpret_cast(&__func)); + return __func(func); + } + + /** + * @function CallFuncUInt32Callback + * @param func (function) + * @return uint32 + */ + inline uint32_t CallFuncUInt32Callback(FuncUInt32 func) { + using CallFuncUInt32CallbackFn = uint32_t (*)(FuncUInt32); + static CallFuncUInt32CallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFuncUInt32Callback", reinterpret_cast(&__func)); + return __func(func); + } + + /** + * @function CallFuncUInt64Callback + * @param func (function) + * @return uint64 + */ + inline uint64_t CallFuncUInt64Callback(FuncUInt64 func) { + using CallFuncUInt64CallbackFn = uint64_t (*)(FuncUInt64); + static CallFuncUInt64CallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFuncUInt64Callback", reinterpret_cast(&__func)); + return __func(func); + } + + /** + * @function CallFuncPtrCallback + * @param func (function) + * @return ptr64 + */ + inline void* CallFuncPtrCallback(FuncPtr func) { + using CallFuncPtrCallbackFn = void* (*)(FuncPtr); + static CallFuncPtrCallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFuncPtrCallback", reinterpret_cast(&__func)); + return __func(func); + } + + /** + * @function CallFuncFloatCallback + * @param func (function) + * @return float + */ + inline float CallFuncFloatCallback(FuncFloat func) { + using CallFuncFloatCallbackFn = float (*)(FuncFloat); + static CallFuncFloatCallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFuncFloatCallback", reinterpret_cast(&__func)); + return __func(func); + } + + /** + * @function CallFuncDoubleCallback + * @param func (function) + * @return double + */ + inline double CallFuncDoubleCallback(FuncDouble func) { + using CallFuncDoubleCallbackFn = double (*)(FuncDouble); + static CallFuncDoubleCallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFuncDoubleCallback", reinterpret_cast(&__func)); + return __func(func); + } + + /** + * @function CallFuncStringCallback + * @param func (function) + * @return string + */ + inline plg::string CallFuncStringCallback(FuncString func) { + using CallFuncStringCallbackFn = plg::string (*)(FuncString); + static CallFuncStringCallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFuncStringCallback", reinterpret_cast(&__func)); + return __func(func); + } + + /** + * @function CallFuncAnyCallback + * @param func (function) + * @return any + */ + inline plg::any CallFuncAnyCallback(FuncAny func) { + using CallFuncAnyCallbackFn = plg::any (*)(FuncAny); + static CallFuncAnyCallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFuncAnyCallback", reinterpret_cast(&__func)); + return __func(func); + } + + /** + * @function CallFuncFunctionCallback + * @param func (function) + * @return ptr64 + */ + inline void* CallFuncFunctionCallback(FuncFunction func) { + using CallFuncFunctionCallbackFn = void* (*)(FuncFunction); + static CallFuncFunctionCallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFuncFunctionCallback", reinterpret_cast(&__func)); + return __func(func); + } + + /** + * @function CallFuncBoolVectorCallback + * @param func (function) + * @return bool[] + */ + inline plg::vector CallFuncBoolVectorCallback(FuncBoolVector func) { + using CallFuncBoolVectorCallbackFn = plg::vector (*)(FuncBoolVector); + static CallFuncBoolVectorCallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFuncBoolVectorCallback", reinterpret_cast(&__func)); + return __func(func); + } + + /** + * @function CallFuncChar8VectorCallback + * @param func (function) + * @return char8[] + */ + inline plg::vector CallFuncChar8VectorCallback(FuncChar8Vector func) { + using CallFuncChar8VectorCallbackFn = plg::vector (*)(FuncChar8Vector); + static CallFuncChar8VectorCallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFuncChar8VectorCallback", reinterpret_cast(&__func)); + return __func(func); + } + + /** + * @function CallFuncChar16VectorCallback + * @param func (function) + * @return char16[] + */ + inline plg::vector CallFuncChar16VectorCallback(FuncChar16Vector func) { + using CallFuncChar16VectorCallbackFn = plg::vector (*)(FuncChar16Vector); + static CallFuncChar16VectorCallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFuncChar16VectorCallback", reinterpret_cast(&__func)); + return __func(func); + } + + /** + * @function CallFuncInt8VectorCallback + * @param func (function) + * @return int8[] + */ + inline plg::vector CallFuncInt8VectorCallback(FuncInt8Vector func) { + using CallFuncInt8VectorCallbackFn = plg::vector (*)(FuncInt8Vector); + static CallFuncInt8VectorCallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFuncInt8VectorCallback", reinterpret_cast(&__func)); + return __func(func); + } + + /** + * @function CallFuncInt16VectorCallback + * @param func (function) + * @return int16[] + */ + inline plg::vector CallFuncInt16VectorCallback(FuncInt16Vector func) { + using CallFuncInt16VectorCallbackFn = plg::vector (*)(FuncInt16Vector); + static CallFuncInt16VectorCallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFuncInt16VectorCallback", reinterpret_cast(&__func)); + return __func(func); + } + + /** + * @function CallFuncInt32VectorCallback + * @param func (function) + * @return int32[] + */ + inline plg::vector CallFuncInt32VectorCallback(FuncInt32Vector func) { + using CallFuncInt32VectorCallbackFn = plg::vector (*)(FuncInt32Vector); + static CallFuncInt32VectorCallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFuncInt32VectorCallback", reinterpret_cast(&__func)); + return __func(func); + } + + /** + * @function CallFuncInt64VectorCallback + * @param func (function) + * @return int64[] + */ + inline plg::vector CallFuncInt64VectorCallback(FuncInt64Vector func) { + using CallFuncInt64VectorCallbackFn = plg::vector (*)(FuncInt64Vector); + static CallFuncInt64VectorCallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFuncInt64VectorCallback", reinterpret_cast(&__func)); + return __func(func); + } + + /** + * @function CallFuncUInt8VectorCallback + * @param func (function) + * @return uint8[] + */ + inline plg::vector CallFuncUInt8VectorCallback(FuncUInt8Vector func) { + using CallFuncUInt8VectorCallbackFn = plg::vector (*)(FuncUInt8Vector); + static CallFuncUInt8VectorCallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFuncUInt8VectorCallback", reinterpret_cast(&__func)); + return __func(func); + } + + /** + * @function CallFuncUInt16VectorCallback + * @param func (function) + * @return uint16[] + */ + inline plg::vector CallFuncUInt16VectorCallback(FuncUInt16Vector func) { + using CallFuncUInt16VectorCallbackFn = plg::vector (*)(FuncUInt16Vector); + static CallFuncUInt16VectorCallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFuncUInt16VectorCallback", reinterpret_cast(&__func)); + return __func(func); + } + + /** + * @function CallFuncUInt32VectorCallback + * @param func (function) + * @return uint32[] + */ + inline plg::vector CallFuncUInt32VectorCallback(FuncUInt32Vector func) { + using CallFuncUInt32VectorCallbackFn = plg::vector (*)(FuncUInt32Vector); + static CallFuncUInt32VectorCallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFuncUInt32VectorCallback", reinterpret_cast(&__func)); + return __func(func); + } + + /** + * @function CallFuncUInt64VectorCallback + * @param func (function) + * @return uint64[] + */ + inline plg::vector CallFuncUInt64VectorCallback(FuncUInt64Vector func) { + using CallFuncUInt64VectorCallbackFn = plg::vector (*)(FuncUInt64Vector); + static CallFuncUInt64VectorCallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFuncUInt64VectorCallback", reinterpret_cast(&__func)); + return __func(func); + } + + /** + * @function CallFuncPtrVectorCallback + * @param func (function) + * @return ptr64[] + */ + inline plg::vector CallFuncPtrVectorCallback(FuncPtrVector func) { + using CallFuncPtrVectorCallbackFn = plg::vector (*)(FuncPtrVector); + static CallFuncPtrVectorCallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFuncPtrVectorCallback", reinterpret_cast(&__func)); + return __func(func); + } + + /** + * @function CallFuncFloatVectorCallback + * @param func (function) + * @return float[] + */ + inline plg::vector CallFuncFloatVectorCallback(FuncFloatVector func) { + using CallFuncFloatVectorCallbackFn = plg::vector (*)(FuncFloatVector); + static CallFuncFloatVectorCallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFuncFloatVectorCallback", reinterpret_cast(&__func)); + return __func(func); + } + + /** + * @function CallFuncDoubleVectorCallback + * @param func (function) + * @return double[] + */ + inline plg::vector CallFuncDoubleVectorCallback(FuncDoubleVector func) { + using CallFuncDoubleVectorCallbackFn = plg::vector (*)(FuncDoubleVector); + static CallFuncDoubleVectorCallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFuncDoubleVectorCallback", reinterpret_cast(&__func)); + return __func(func); + } + + /** + * @function CallFuncStringVectorCallback + * @param func (function) + * @return string[] + */ + inline plg::vector CallFuncStringVectorCallback(FuncStringVector func) { + using CallFuncStringVectorCallbackFn = plg::vector (*)(FuncStringVector); + static CallFuncStringVectorCallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFuncStringVectorCallback", reinterpret_cast(&__func)); + return __func(func); + } + + /** + * @function CallFuncAnyVectorCallback + * @param func (function) + * @return any[] + */ + inline plg::vector CallFuncAnyVectorCallback(FuncAnyVector func) { + using CallFuncAnyVectorCallbackFn = plg::vector (*)(FuncAnyVector); + static CallFuncAnyVectorCallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFuncAnyVectorCallback", reinterpret_cast(&__func)); + return __func(func); + } + + /** + * @function CallFuncVec2VectorCallback + * @param func (function) + * @return vec2[] + */ + inline plg::vector CallFuncVec2VectorCallback(FuncVec2Vector func) { + using CallFuncVec2VectorCallbackFn = plg::vector (*)(FuncVec2Vector); + static CallFuncVec2VectorCallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFuncVec2VectorCallback", reinterpret_cast(&__func)); + return __func(func); + } + + /** + * @function CallFuncVec3VectorCallback + * @param func (function) + * @return vec3[] + */ + inline plg::vector CallFuncVec3VectorCallback(FuncVec3Vector func) { + using CallFuncVec3VectorCallbackFn = plg::vector (*)(FuncVec3Vector); + static CallFuncVec3VectorCallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFuncVec3VectorCallback", reinterpret_cast(&__func)); + return __func(func); + } + + /** + * @function CallFuncVec4VectorCallback + * @param func (function) + * @return vec4[] + */ + inline plg::vector CallFuncVec4VectorCallback(FuncVec4Vector func) { + using CallFuncVec4VectorCallbackFn = plg::vector (*)(FuncVec4Vector); + static CallFuncVec4VectorCallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFuncVec4VectorCallback", reinterpret_cast(&__func)); + return __func(func); + } + + /** + * @function CallFuncMat4x4VectorCallback + * @param func (function) + * @return mat4x4[] + */ + inline plg::vector CallFuncMat4x4VectorCallback(FuncMat4x4Vector func) { + using CallFuncMat4x4VectorCallbackFn = plg::vector (*)(FuncMat4x4Vector); + static CallFuncMat4x4VectorCallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFuncMat4x4VectorCallback", reinterpret_cast(&__func)); + return __func(func); + } + + /** + * @function CallFuncVec2Callback + * @param func (function) + * @return vec2 + */ + inline plg::vec2 CallFuncVec2Callback(FuncVec2 func) { + using CallFuncVec2CallbackFn = plg::vec2 (*)(FuncVec2); + static CallFuncVec2CallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFuncVec2Callback", reinterpret_cast(&__func)); + return __func(func); + } + + /** + * @function CallFuncVec3Callback + * @param func (function) + * @return vec3 + */ + inline plg::vec3 CallFuncVec3Callback(FuncVec3 func) { + using CallFuncVec3CallbackFn = plg::vec3 (*)(FuncVec3); + static CallFuncVec3CallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFuncVec3Callback", reinterpret_cast(&__func)); + return __func(func); + } + + /** + * @function CallFuncVec4Callback + * @param func (function) + * @return vec4 + */ + inline plg::vec4 CallFuncVec4Callback(FuncVec4 func) { + using CallFuncVec4CallbackFn = plg::vec4 (*)(FuncVec4); + static CallFuncVec4CallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFuncVec4Callback", reinterpret_cast(&__func)); + return __func(func); + } + + /** + * @function CallFuncMat4x4Callback + * @param func (function) + * @return mat4x4 + */ + inline plg::mat4x4 CallFuncMat4x4Callback(FuncMat4x4 func) { + using CallFuncMat4x4CallbackFn = plg::mat4x4 (*)(FuncMat4x4); + static CallFuncMat4x4CallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFuncMat4x4Callback", reinterpret_cast(&__func)); + return __func(func); + } + + /** + * @function CallFunc1Callback + * @param func (function) + * @return int32 + */ + inline int32_t CallFunc1Callback(Func1 func) { + using CallFunc1CallbackFn = int32_t (*)(Func1); + static CallFunc1CallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFunc1Callback", reinterpret_cast(&__func)); + return __func(func); + } + + /** + * @function CallFunc2Callback + * @param func (function) + * @return char8 + */ + inline char CallFunc2Callback(Func2 func) { + using CallFunc2CallbackFn = char (*)(Func2); + static CallFunc2CallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFunc2Callback", reinterpret_cast(&__func)); + return __func(func); + } + + /** + * @function CallFunc3Callback + * @param func (function) + */ + inline void CallFunc3Callback(Func3 func) { + using CallFunc3CallbackFn = void (*)(Func3); + static CallFunc3CallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFunc3Callback", reinterpret_cast(&__func)); + __func(func); + } + + /** + * @function CallFunc4Callback + * @param func (function) + * @return vec4 + */ + inline plg::vec4 CallFunc4Callback(Func4 func) { + using CallFunc4CallbackFn = plg::vec4 (*)(Func4); + static CallFunc4CallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFunc4Callback", reinterpret_cast(&__func)); + return __func(func); + } + + /** + * @function CallFunc5Callback + * @param func (function) + * @return bool + */ + inline bool CallFunc5Callback(Func5 func) { + using CallFunc5CallbackFn = bool (*)(Func5); + static CallFunc5CallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFunc5Callback", reinterpret_cast(&__func)); + return __func(func); + } + + /** + * @function CallFunc6Callback + * @param func (function) + * @return int64 + */ + inline int64_t CallFunc6Callback(Func6 func) { + using CallFunc6CallbackFn = int64_t (*)(Func6); + static CallFunc6CallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFunc6Callback", reinterpret_cast(&__func)); + return __func(func); + } + + /** + * @function CallFunc7Callback + * @param func (function) + * @return double + */ + inline double CallFunc7Callback(Func7 func) { + using CallFunc7CallbackFn = double (*)(Func7); + static CallFunc7CallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFunc7Callback", reinterpret_cast(&__func)); + return __func(func); + } + + /** + * @function CallFunc8Callback + * @param func (function) + * @return mat4x4 + */ + inline plg::mat4x4 CallFunc8Callback(Func8 func) { + using CallFunc8CallbackFn = plg::mat4x4 (*)(Func8); + static CallFunc8CallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFunc8Callback", reinterpret_cast(&__func)); + return __func(func); + } + + /** + * @function CallFunc9Callback + * @param func (function) + */ + inline void CallFunc9Callback(Func9 func) { + using CallFunc9CallbackFn = void (*)(Func9); + static CallFunc9CallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFunc9Callback", reinterpret_cast(&__func)); + __func(func); + } + + /** + * @function CallFunc10Callback + * @param func (function) + * @return uint32 + */ + inline uint32_t CallFunc10Callback(Func10 func) { + using CallFunc10CallbackFn = uint32_t (*)(Func10); + static CallFunc10CallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFunc10Callback", reinterpret_cast(&__func)); + return __func(func); + } + + /** + * @function CallFunc11Callback + * @param func (function) + * @return ptr64 + */ + inline void* CallFunc11Callback(Func11 func) { + using CallFunc11CallbackFn = void* (*)(Func11); + static CallFunc11CallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFunc11Callback", reinterpret_cast(&__func)); + return __func(func); + } + + /** + * @function CallFunc12Callback + * @param func (function) + * @return bool + */ + inline bool CallFunc12Callback(Func12 func) { + using CallFunc12CallbackFn = bool (*)(Func12); + static CallFunc12CallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFunc12Callback", reinterpret_cast(&__func)); + return __func(func); + } + + /** + * @function CallFunc13Callback + * @param func (function) + * @return string + */ + inline plg::string CallFunc13Callback(Func13 func) { + using CallFunc13CallbackFn = plg::string (*)(Func13); + static CallFunc13CallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFunc13Callback", reinterpret_cast(&__func)); + return __func(func); + } + + /** + * @function CallFunc14Callback + * @param func (function) + * @return string[] + */ + inline plg::vector CallFunc14Callback(Func14 func) { + using CallFunc14CallbackFn = plg::vector (*)(Func14); + static CallFunc14CallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFunc14Callback", reinterpret_cast(&__func)); + return __func(func); + } + + /** + * @function CallFunc15Callback + * @param func (function) + * @return int16 + */ + inline int16_t CallFunc15Callback(Func15 func) { + using CallFunc15CallbackFn = int16_t (*)(Func15); + static CallFunc15CallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFunc15Callback", reinterpret_cast(&__func)); + return __func(func); + } + + /** + * @function CallFunc16Callback + * @param func (function) + * @return ptr64 + */ + inline void* CallFunc16Callback(Func16 func) { + using CallFunc16CallbackFn = void* (*)(Func16); + static CallFunc16CallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFunc16Callback", reinterpret_cast(&__func)); + return __func(func); + } + + /** + * @function CallFunc17Callback + * @param func (function) + * @return string + */ + inline plg::string CallFunc17Callback(Func17 func) { + using CallFunc17CallbackFn = plg::string (*)(Func17); + static CallFunc17CallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFunc17Callback", reinterpret_cast(&__func)); + return __func(func); + } + + /** + * @function CallFunc18Callback + * @param func (function) + * @return string + */ + inline plg::string CallFunc18Callback(Func18 func) { + using CallFunc18CallbackFn = plg::string (*)(Func18); + static CallFunc18CallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFunc18Callback", reinterpret_cast(&__func)); + return __func(func); + } + + /** + * @function CallFunc19Callback + * @param func (function) + * @return string + */ + inline plg::string CallFunc19Callback(Func19 func) { + using CallFunc19CallbackFn = plg::string (*)(Func19); + static CallFunc19CallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFunc19Callback", reinterpret_cast(&__func)); + return __func(func); + } + + /** + * @function CallFunc20Callback + * @param func (function) + * @return string + */ + inline plg::string CallFunc20Callback(Func20 func) { + using CallFunc20CallbackFn = plg::string (*)(Func20); + static CallFunc20CallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFunc20Callback", reinterpret_cast(&__func)); + return __func(func); + } + + /** + * @function CallFunc21Callback + * @param func (function) + * @return string + */ + inline plg::string CallFunc21Callback(Func21 func) { + using CallFunc21CallbackFn = plg::string (*)(Func21); + static CallFunc21CallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFunc21Callback", reinterpret_cast(&__func)); + return __func(func); + } + + /** + * @function CallFunc22Callback + * @param func (function) + * @return string + */ + inline plg::string CallFunc22Callback(Func22 func) { + using CallFunc22CallbackFn = plg::string (*)(Func22); + static CallFunc22CallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFunc22Callback", reinterpret_cast(&__func)); + return __func(func); + } + + /** + * @function CallFunc23Callback + * @param func (function) + * @return string + */ + inline plg::string CallFunc23Callback(Func23 func) { + using CallFunc23CallbackFn = plg::string (*)(Func23); + static CallFunc23CallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFunc23Callback", reinterpret_cast(&__func)); + return __func(func); + } + + /** + * @function CallFunc24Callback + * @param func (function) + * @return string + */ + inline plg::string CallFunc24Callback(Func24 func) { + using CallFunc24CallbackFn = plg::string (*)(Func24); + static CallFunc24CallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFunc24Callback", reinterpret_cast(&__func)); + return __func(func); + } + + /** + * @function CallFunc25Callback + * @param func (function) + * @return string + */ + inline plg::string CallFunc25Callback(Func25 func) { + using CallFunc25CallbackFn = plg::string (*)(Func25); + static CallFunc25CallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFunc25Callback", reinterpret_cast(&__func)); + return __func(func); + } + + /** + * @function CallFunc26Callback + * @param func (function) + * @return string + */ + inline plg::string CallFunc26Callback(Func26 func) { + using CallFunc26CallbackFn = plg::string (*)(Func26); + static CallFunc26CallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFunc26Callback", reinterpret_cast(&__func)); + return __func(func); + } + + /** + * @function CallFunc27Callback + * @param func (function) + * @return string + */ + inline plg::string CallFunc27Callback(Func27 func) { + using CallFunc27CallbackFn = plg::string (*)(Func27); + static CallFunc27CallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFunc27Callback", reinterpret_cast(&__func)); + return __func(func); + } + + /** + * @function CallFunc28Callback + * @param func (function) + * @return string + */ + inline plg::string CallFunc28Callback(Func28 func) { + using CallFunc28CallbackFn = plg::string (*)(Func28); + static CallFunc28CallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFunc28Callback", reinterpret_cast(&__func)); + return __func(func); + } + + /** + * @function CallFunc29Callback + * @param func (function) + * @return string + */ + inline plg::string CallFunc29Callback(Func29 func) { + using CallFunc29CallbackFn = plg::string (*)(Func29); + static CallFunc29CallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFunc29Callback", reinterpret_cast(&__func)); + return __func(func); + } + + /** + * @function CallFunc30Callback + * @param func (function) + * @return string + */ + inline plg::string CallFunc30Callback(Func30 func) { + using CallFunc30CallbackFn = plg::string (*)(Func30); + static CallFunc30CallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFunc30Callback", reinterpret_cast(&__func)); + return __func(func); + } + + /** + * @function CallFunc31Callback + * @param func (function) + * @return string + */ + inline plg::string CallFunc31Callback(Func31 func) { + using CallFunc31CallbackFn = plg::string (*)(Func31); + static CallFunc31CallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFunc31Callback", reinterpret_cast(&__func)); + return __func(func); + } + + /** + * @function CallFunc32Callback + * @param func (function) + * @return string + */ + inline plg::string CallFunc32Callback(Func32 func) { + using CallFunc32CallbackFn = plg::string (*)(Func32); + static CallFunc32CallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFunc32Callback", reinterpret_cast(&__func)); + return __func(func); + } + + /** + * @function CallFunc33Callback + * @param func (function) + * @return string + */ + inline plg::string CallFunc33Callback(Func33 func) { + using CallFunc33CallbackFn = plg::string (*)(Func33); + static CallFunc33CallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFunc33Callback", reinterpret_cast(&__func)); + return __func(func); + } + + /** + * @function CallFuncEnumCallback + * @param func (function) + * @return string + */ + inline plg::string CallFuncEnumCallback(FuncEnum func) { + using CallFuncEnumCallbackFn = plg::string (*)(FuncEnum); + static CallFuncEnumCallbackFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CallFuncEnumCallback", reinterpret_cast(&__func)); + return __func(func); + } + } // namespace cross_call_master From 26dd5310591427657271fd27a513ea703d49bdf4 Mon Sep 17 00:00:00 2001 From: Nikita Ushakov Date: Fri, 21 Nov 2025 18:01:43 +0000 Subject: [PATCH 13/16] fix: add new class tests --- .../cross_call_master.pplugin | 4 +- test/cross_call_master/plugin.cpp | 108 +++- .../plugify/include/pps/cross_call_master.hpp | 569 +++++++++++++++++- test/cross_call_worker/plugin.cpp | 247 +++++++- 4 files changed, 920 insertions(+), 8 deletions(-) diff --git a/test/cross_call_master/cross_call_master.pplugin b/test/cross_call_master/cross_call_master.pplugin index e84f7ca..35a49d1 100644 --- a/test/cross_call_master/cross_call_master.pplugin +++ b/test/cross_call_master/cross_call_master.pplugin @@ -4635,7 +4635,7 @@ "ResourceHandleCreateDefault" ], "destructor": "ResourceHandleDestroy", - "methods": [ + "bindings": [ { "name": "GetId", "method": "ResourceHandleGetId", "bindSelf": true }, { "name": "GetName", "method": "ResourceHandleGetName", "bindSelf": true }, { "name": "SetName", "method": "ResourceHandleSetName", "bindSelf": true }, @@ -4656,7 +4656,7 @@ "CounterCreateZero" ], "destructor": null, - "methods": [ + "bindings": [ { "name": "GetValue", "method": "CounterGetValue", "bindSelf": true }, { "name": "SetValue", "method": "CounterSetValue", "bindSelf": true }, { "name": "Increment", "method": "CounterIncrement", "bindSelf": true }, diff --git a/test/cross_call_master/plugin.cpp b/test/cross_call_master/plugin.cpp index 3aadcd6..7d8bbe8 100644 --- a/test/cross_call_master/plugin.cpp +++ b/test/cross_call_master/plugin.cpp @@ -33,6 +33,7 @@ #define TEST_REVERSE_PARAMS_ALL_PRIMITIVES (1 << 23) #define TEST_REVERSE_PARAMS_VARIANTS (1 << 24) #define TEST_REVERSE_PARAMS_FUNCTIONS (1 << 25) +#define TEST_REVERSE_CLASSES_WRAPPERS (1 << 26) #define TEST_ALL 0xFFFFFFFF #ifndef TEST_CASES #define TEST_CASES TEST_ALL @@ -581,6 +582,7 @@ class CrossCallMaster final : public plg::IPluginEntry { ReverseParamsAllPrimitives(); ReverseParamsVariants(); ReverseParamsFunctions(); + ReverseClassesWrappers(); _tests.Run(); } @@ -3558,6 +3560,80 @@ class CrossCallMaster final : public plg::IPluginEntry { #endif// TEST_CASES & TEST_REVERSE_PARAMS_FUNCTIONS } + void ReverseClassesWrappers() { +#if TEST_CASES & TEST_REVERSE_CLASSES_WRAPPERS + _tests.Add("ReverseClassBasicLifecycle", [&](SimpleTests::Test &test) { + const plg::string returnExpected = "true"; + _reverseReturn.reset(); + cross_call_worker::ReverseCall("ClassBasicLifecycle"); + if (!_reverseReturn) { + test.Fail("Return not set"); + } else if (*_reverseReturn != returnExpected) { + test.Fail(std::format("Wrong return {}, expected {}", *_reverseReturn, returnExpected)); + } + }); + _tests.Add("ReverseClassStateManagement", [&](SimpleTests::Test &test) { + const plg::string returnExpected = "true"; + _reverseReturn.reset(); + cross_call_worker::ReverseCall("ClassStateManagement"); + if (!_reverseReturn) { + test.Fail("Return not set"); + } else if (*_reverseReturn != returnExpected) { + test.Fail(std::format("Wrong return {}, expected {}", *_reverseReturn, returnExpected)); + } + }); + _tests.Add("ReverseClassMultipleInstances", [&](SimpleTests::Test &test) { + const plg::string returnExpected = "true"; + _reverseReturn.reset(); + cross_call_worker::ReverseCall("ClassMultipleInstances"); + if (!_reverseReturn) { + test.Fail("Return not set"); + } else if (*_reverseReturn != returnExpected) { + test.Fail(std::format("Wrong return {}, expected {}", *_reverseReturn, returnExpected)); + } + }); + _tests.Add("ReverseClassCounterWithoutDestructor", [&](SimpleTests::Test &test) { + const plg::string returnExpected = "true"; + _reverseReturn.reset(); + cross_call_worker::ReverseCall("ClassCounterWithoutDestructor"); + if (!_reverseReturn) { + test.Fail("Return not set"); + } else if (*_reverseReturn != returnExpected) { + test.Fail(std::format("Wrong return {}, expected {}", *_reverseReturn, returnExpected)); + } + }); + _tests.Add("ReverseClassStaticMethods", [&](SimpleTests::Test &test) { + const plg::string returnExpected = "true"; + _reverseReturn.reset(); + cross_call_worker::ReverseCall("ClassStaticMethods"); + if (!_reverseReturn) { + test.Fail("Return not set"); + } else if (*_reverseReturn != returnExpected) { + test.Fail(std::format("Wrong return {}, expected {}", *_reverseReturn, returnExpected)); + } + }); + _tests.Add("ReverseClassMemoryLeakDetection", [&](SimpleTests::Test &test) { + const plg::string returnExpected = "true"; + _reverseReturn.reset(); + cross_call_worker::ReverseCall("ClassMemoryLeakDetection"); + if (!_reverseReturn) { + test.Fail("Return not set"); + } else if (*_reverseReturn != returnExpected) { + test.Fail(std::format("Wrong return {}, expected {}", *_reverseReturn, returnExpected)); + } + }); + _tests.Add("ReverseClassExceptionHandling", [&](SimpleTests::Test &test) { + const plg::string returnExpected = "true"; + _reverseReturn.reset(); + cross_call_worker::ReverseCall("ClassExceptionHandling"); + if (!_reverseReturn) { + test.Fail("Return not set"); + } else if (*_reverseReturn != returnExpected) { + test.Fail(std::format("Wrong return {}, expected {}", *_reverseReturn, returnExpected)); + } + }); +#endif// TEST_CASES & TEST_REVERSE_PARAMS_VARIANTS + } public: void ReverseReturn(const plg::string &returnString) { _reverseReturn = {returnString}; @@ -4900,6 +4976,7 @@ std::atomic ResourceHandle::s_totalDestroyed{0}; std::mutex ResourceHandle::s_mutex; // ResourceHandle exported functions +extern "C" PLUGIN_API void* ResourceHandleCreate(int32_t id, const plg::string& name) { try { return new ResourceHandle(id, name); @@ -4909,6 +4986,7 @@ PLUGIN_API void* ResourceHandleCreate(int32_t id, const plg::string& name) { } } +extern "C" PLUGIN_API void* ResourceHandleCreateDefault() { static std::atomic nextId{1000}; int32_t id = nextId++; @@ -4920,6 +4998,7 @@ PLUGIN_API void* ResourceHandleCreateDefault() { } } +extern "C" PLUGIN_API void ResourceHandleDestroy(void* handle) { if (handle) { delete static_cast(handle); @@ -4928,6 +5007,7 @@ PLUGIN_API void ResourceHandleDestroy(void* handle) { } } +extern "C" PLUGIN_API int32_t ResourceHandleGetId(void* handle) { if (!handle) { std::println("[ERROR] ResourceHandleGetId: handle is null"); @@ -4936,6 +5016,7 @@ PLUGIN_API int32_t ResourceHandleGetId(void* handle) { return static_cast(handle)->id; } +extern "C" PLUGIN_API plg::string ResourceHandleGetName(void* handle) { if (!handle) { std::println("[ERROR] ResourceHandleGetName: handle is null"); @@ -4944,6 +5025,7 @@ PLUGIN_API plg::string ResourceHandleGetName(void* handle) { return static_cast(handle)->name; } +extern "C" PLUGIN_API void ResourceHandleSetName(void* handle, const plg::string& name) { if (!handle) { std::println("[ERROR] ResourceHandleSetName: handle is null"); @@ -4955,6 +5037,7 @@ PLUGIN_API void ResourceHandleSetName(void* handle, const plg::string& name) { res->name = name; } +extern "C" PLUGIN_API void ResourceHandleIncrementCounter(void* handle) { if (!handle) { std::println("[ERROR] ResourceHandleIncrementCounter: handle is null"); @@ -4965,6 +5048,7 @@ PLUGIN_API void ResourceHandleIncrementCounter(void* handle) { std::println("[ACTION] ResourceHandle ID={}: Counter incremented to {}", res->id, res->counter); } +extern "C" PLUGIN_API int32_t ResourceHandleGetCounter(void* handle) { if (!handle) { std::println("[ERROR] ResourceHandleGetCounter: handle is null"); @@ -4973,6 +5057,7 @@ PLUGIN_API int32_t ResourceHandleGetCounter(void* handle) { return static_cast(handle)->counter; } +extern "C" PLUGIN_API void ResourceHandleAddData(void* handle, float value) { if (!handle) { std::println("[ERROR] ResourceHandleAddData: handle is null"); @@ -4984,6 +5069,7 @@ PLUGIN_API void ResourceHandleAddData(void* handle, float value) { res->id, value, res->data.size()); } +extern "C" PLUGIN_API plg::vector ResourceHandleGetData(void* handle) { if (!handle) { std::println("[ERROR] ResourceHandleGetData: handle is null"); @@ -4993,18 +5079,21 @@ PLUGIN_API plg::vector ResourceHandleGetData(void* handle) { return plg::vector(res->data.begin(), res->data.end()); } +extern "C" PLUGIN_API int32_t ResourceHandleGetAliveCount() { int32_t count = ResourceHandle::s_aliveCount.load(); std::println("[STATS] ResourceHandle: {} instances currently alive", count); return count; } +extern "C" PLUGIN_API int32_t ResourceHandleGetTotalCreated() { int32_t count = ResourceHandle::s_totalCreated.load(); std::println("[STATS] ResourceHandle: {} total instances created", count); return count; } +extern "C" PLUGIN_API int32_t ResourceHandleGetTotalDestroyed() { int32_t count = ResourceHandle::s_totalDestroyed.load(); std::println("[STATS] ResourceHandle: {} total instances destroyed", count); @@ -5021,29 +5110,32 @@ struct Counter { explicit Counter(int64_t val) : value(val) { std::println("[COUNTER] Counter created with value: {}", value); } - - // Note: No destructor logging since this is a lightweight wrapper }; +static std::vector> pool; + // Counter exported functions +extern "C" PLUGIN_API void* CounterCreate(int64_t initialValue) { try { - return new Counter(initialValue); + return pool.emplace_back(std::make_unique(initialValue)).get(); } catch (const std::exception& e) { std::println("[ERROR] CounterCreate failed: {}", e.what()); return nullptr; } } +extern "C" PLUGIN_API void* CounterCreateZero() { try { - return new Counter(0); + return pool.emplace_back(std::make_unique(0)).get(); } catch (const std::exception& e) { std::println("[ERROR] CounterCreateZero failed: {}", e.what()); return nullptr; } } +extern "C" PLUGIN_API int64_t CounterGetValue(void* counter) { if (!counter) { std::println("[ERROR] CounterGetValue: counter is null"); @@ -5052,6 +5144,7 @@ PLUGIN_API int64_t CounterGetValue(void* counter) { return static_cast(counter)->value; } +extern "C" PLUGIN_API void CounterSetValue(void* counter, int64_t value) { if (!counter) { std::println("[ERROR] CounterSetValue: counter is null"); @@ -5062,6 +5155,7 @@ PLUGIN_API void CounterSetValue(void* counter, int64_t value) { cnt->value = value; } +extern "C" PLUGIN_API void CounterIncrement(void* counter) { if (!counter) { std::println("[ERROR] CounterIncrement: counter is null"); @@ -5072,6 +5166,7 @@ PLUGIN_API void CounterIncrement(void* counter) { std::println("[COUNTER] Counter incremented to: {}", cnt->value); } +extern "C" PLUGIN_API void CounterDecrement(void* counter) { if (!counter) { std::println("[ERROR] CounterDecrement: counter is null"); @@ -5082,6 +5177,7 @@ PLUGIN_API void CounterDecrement(void* counter) { std::println("[COUNTER] Counter decremented to: {}", cnt->value); } +extern "C" PLUGIN_API void CounterAdd(void* counter, int64_t amount) { if (!counter) { std::println("[ERROR] CounterAdd: counter is null"); @@ -5092,6 +5188,7 @@ PLUGIN_API void CounterAdd(void* counter, int64_t amount) { std::println("[COUNTER] Counter added {}, new value: {}", amount, cnt->value); } +extern "C" PLUGIN_API void CounterReset(void* counter) { if (!counter) { std::println("[ERROR] CounterReset: counter is null"); @@ -5102,6 +5199,7 @@ PLUGIN_API void CounterReset(void* counter) { cnt->value = 0; } +extern "C" PLUGIN_API bool CounterIsPositive(void* counter) { if (!counter) { std::println("[ERROR] CounterIsPositive: counter is null"); @@ -5110,12 +5208,14 @@ PLUGIN_API bool CounterIsPositive(void* counter) { return static_cast(counter)->value > 0; } +extern "C" PLUGIN_API int32_t CounterCompare(int64_t value1, int64_t value2) { if (value1 < value2) return -1; if (value1 > value2) return 1; return 0; } +extern "C" PLUGIN_API int64_t CounterSum(const plg::vector& values) { return std::accumulate(values.begin(), values.end(), int64_t{0}); } diff --git a/test/cross_call_worker/external/plugify/include/pps/cross_call_master.hpp b/test/cross_call_worker/external/plugify/include/pps/cross_call_master.hpp index d287b43..376ac82 100644 --- a/test/cross_call_worker/external/plugify/include/pps/cross_call_master.hpp +++ b/test/cross_call_worker/external/plugify/include/pps/cross_call_master.hpp @@ -3,6 +3,7 @@ #include #include #include +#include // Generated from cross_call_master.pplugin @@ -167,7 +168,7 @@ namespace cross_call_master { using Func33 = void (*)(plg::any&); - using FuncEnum = plg::vector (*)(Example, plg::vector); + using FuncEnum = plg::vector (*)(Example, plg::vector&); /** @@ -1961,4 +1962,570 @@ namespace cross_call_master { return __func(func); } + /** + * @function ResourceHandleCreate + * @param id (int32) + * @param name (string) + * @return ptr64 + */ + inline void* ResourceHandleCreate(int32_t id, const plg::string& name) { + using ResourceHandleCreateFn = void* (*)(int32_t, const plg::string&); + static ResourceHandleCreateFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.ResourceHandleCreate", reinterpret_cast(&__func)); + return __func(id, name); + } + + /** + * @function ResourceHandleCreateDefault + * @return ptr64 + */ + inline void* ResourceHandleCreateDefault() { + using ResourceHandleCreateDefaultFn = void* (*)(); + static ResourceHandleCreateDefaultFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.ResourceHandleCreateDefault", reinterpret_cast(&__func)); + return __func(); + } + + /** + * @function ResourceHandleDestroy + * @param handle (ptr64) + */ + inline void ResourceHandleDestroy(void* handle) { + using ResourceHandleDestroyFn = void (*)(void*); + static ResourceHandleDestroyFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.ResourceHandleDestroy", reinterpret_cast(&__func)); + __func(handle); + } + + /** + * @function ResourceHandleGetId + * @param handle (ptr64) + * @return int32 + */ + inline int32_t ResourceHandleGetId(void* handle) { + using ResourceHandleGetIdFn = int32_t (*)(void*); + static ResourceHandleGetIdFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.ResourceHandleGetId", reinterpret_cast(&__func)); + return __func(handle); + } + + /** + * @function ResourceHandleGetName + * @param handle (ptr64) + * @return string + */ + inline plg::string ResourceHandleGetName(void* handle) { + using ResourceHandleGetNameFn = plg::string (*)(void*); + static ResourceHandleGetNameFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.ResourceHandleGetName", reinterpret_cast(&__func)); + return __func(handle); + } + + /** + * @function ResourceHandleSetName + * @param handle (ptr64) + * @param name (string) + */ + inline void ResourceHandleSetName(void* handle, const plg::string& name) { + using ResourceHandleSetNameFn = void (*)(void*, const plg::string&); + static ResourceHandleSetNameFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.ResourceHandleSetName", reinterpret_cast(&__func)); + __func(handle, name); + } + + /** + * @function ResourceHandleIncrementCounter + * @param handle (ptr64) + */ + inline void ResourceHandleIncrementCounter(void* handle) { + using ResourceHandleIncrementCounterFn = void (*)(void*); + static ResourceHandleIncrementCounterFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.ResourceHandleIncrementCounter", reinterpret_cast(&__func)); + __func(handle); + } + + /** + * @function ResourceHandleGetCounter + * @param handle (ptr64) + * @return int32 + */ + inline int32_t ResourceHandleGetCounter(void* handle) { + using ResourceHandleGetCounterFn = int32_t (*)(void*); + static ResourceHandleGetCounterFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.ResourceHandleGetCounter", reinterpret_cast(&__func)); + return __func(handle); + } + + /** + * @function ResourceHandleAddData + * @param handle (ptr64) + * @param value (float) + */ + inline void ResourceHandleAddData(void* handle, float value) { + using ResourceHandleAddDataFn = void (*)(void*, float); + static ResourceHandleAddDataFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.ResourceHandleAddData", reinterpret_cast(&__func)); + __func(handle, value); + } + + /** + * @function ResourceHandleGetData + * @param handle (ptr64) + * @return float[] + */ + inline plg::vector ResourceHandleGetData(void* handle) { + using ResourceHandleGetDataFn = plg::vector (*)(void*); + static ResourceHandleGetDataFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.ResourceHandleGetData", reinterpret_cast(&__func)); + return __func(handle); + } + + /** + * @function ResourceHandleGetAliveCount + * @return int32 + */ + inline int32_t ResourceHandleGetAliveCount() { + using ResourceHandleGetAliveCountFn = int32_t (*)(); + static ResourceHandleGetAliveCountFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.ResourceHandleGetAliveCount", reinterpret_cast(&__func)); + return __func(); + } + + /** + * @function ResourceHandleGetTotalCreated + * @return int32 + */ + inline int32_t ResourceHandleGetTotalCreated() { + using ResourceHandleGetTotalCreatedFn = int32_t (*)(); + static ResourceHandleGetTotalCreatedFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.ResourceHandleGetTotalCreated", reinterpret_cast(&__func)); + return __func(); + } + + /** + * @function ResourceHandleGetTotalDestroyed + * @return int32 + */ + inline int32_t ResourceHandleGetTotalDestroyed() { + using ResourceHandleGetTotalDestroyedFn = int32_t (*)(); + static ResourceHandleGetTotalDestroyedFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.ResourceHandleGetTotalDestroyed", reinterpret_cast(&__func)); + return __func(); + } + + /** + * @function CounterCreate + * @param initialValue (int64) + * @return ptr64 + */ + inline void* CounterCreate(int64_t initialValue) { + using CounterCreateFn = void* (*)(int64_t); + static CounterCreateFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CounterCreate", reinterpret_cast(&__func)); + return __func(initialValue); + } + + /** + * @function CounterCreateZero + * @return ptr64 + */ + inline void* CounterCreateZero() { + using CounterCreateZeroFn = void* (*)(); + static CounterCreateZeroFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CounterCreateZero", reinterpret_cast(&__func)); + return __func(); + } + + /** + * @function CounterGetValue + * @param counter (ptr64) + * @return int64 + */ + inline int64_t CounterGetValue(void* counter) { + using CounterGetValueFn = int64_t (*)(void*); + static CounterGetValueFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CounterGetValue", reinterpret_cast(&__func)); + return __func(counter); + } + + /** + * @function CounterSetValue + * @param counter (ptr64) + * @param value (int64) + */ + inline void CounterSetValue(void* counter, int64_t value) { + using CounterSetValueFn = void (*)(void*, int64_t); + static CounterSetValueFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CounterSetValue", reinterpret_cast(&__func)); + __func(counter, value); + } + + /** + * @function CounterIncrement + * @param counter (ptr64) + */ + inline void CounterIncrement(void* counter) { + using CounterIncrementFn = void (*)(void*); + static CounterIncrementFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CounterIncrement", reinterpret_cast(&__func)); + __func(counter); + } + + /** + * @function CounterDecrement + * @param counter (ptr64) + */ + inline void CounterDecrement(void* counter) { + using CounterDecrementFn = void (*)(void*); + static CounterDecrementFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CounterDecrement", reinterpret_cast(&__func)); + __func(counter); + } + + /** + * @function CounterAdd + * @param counter (ptr64) + * @param amount (int64) + */ + inline void CounterAdd(void* counter, int64_t amount) { + using CounterAddFn = void (*)(void*, int64_t); + static CounterAddFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CounterAdd", reinterpret_cast(&__func)); + __func(counter, amount); + } + + /** + * @function CounterReset + * @param counter (ptr64) + */ + inline void CounterReset(void* counter) { + using CounterResetFn = void (*)(void*); + static CounterResetFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CounterReset", reinterpret_cast(&__func)); + __func(counter); + } + + /** + * @function CounterIsPositive + * @param counter (ptr64) + * @return bool + */ + inline bool CounterIsPositive(void* counter) { + using CounterIsPositiveFn = bool (*)(void*); + static CounterIsPositiveFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CounterIsPositive", reinterpret_cast(&__func)); + return __func(counter); + } + + /** + * @function CounterCompare + * @param value1 (int64) + * @param value2 (int64) + * @return int32 + */ + inline int32_t CounterCompare(int64_t value1, int64_t value2) { + using CounterCompareFn = int32_t (*)(int64_t, int64_t); + static CounterCompareFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CounterCompare", reinterpret_cast(&__func)); + return __func(value1, value2); + } + + /** + * @function CounterSum + * @param values (int64[]) + * @return int64 + */ + inline int64_t CounterSum(const plg::vector& values) { + using CounterSumFn = int64_t (*)(const plg::vector&); + static CounterSumFn __func = nullptr; + if (__func == nullptr) plg::GetMethodPtr2("cross_call_master.CounterSum", reinterpret_cast(&__func)); + return __func(values); + } + + enum class Ownership : bool { Borrowed, Owned }; + + /** + * @brief RAII wrapper for ResourceHandle pointer + */ + class ResourceHandle final { + public: + //ResourceHandle() = default; + + /** + * @param id (int32) + * @param name (string) + */ + explicit ResourceHandle(int32_t id, const plg::string& name) + : ResourceHandle(ResourceHandleCreate(id, name), Ownership::Owned) {} + + /** + */ + explicit ResourceHandle() + : ResourceHandle(ResourceHandleCreateDefault(), Ownership::Owned) {} + + ~ResourceHandle() { + destroy(); + } + + ResourceHandle(const ResourceHandle&) = delete; + ResourceHandle& operator=(const ResourceHandle&) = delete; + + ResourceHandle(ResourceHandle&& other) noexcept + : _handle(other._handle) + , _ownership(other._ownership) { + other.nullify(); + } + + ResourceHandle& operator=(ResourceHandle&& other) noexcept { + if (this != &other) { + destroy(); + _handle = other._handle; + _ownership = other._ownership; + other.nullify(); + } + return *this; + } + + ResourceHandle(void* handle, Ownership ownership) : _handle(handle), _ownership(ownership) {} + + [[nodiscard]] auto get() const noexcept { return _handle; } + + [[nodiscard]] auto release() noexcept { + auto handle = _handle; + nullify(); + return handle; + } + + void reset() noexcept { + destroy(); + nullify(); + } + + void swap(ResourceHandle& other) noexcept { + using std::swap; + swap(_handle, other._handle); + swap(_ownership, other._ownership); + } + + friend void swap(ResourceHandle& lhs, ResourceHandle& rhs) noexcept { lhs.swap(rhs); } + + explicit operator bool() const noexcept { return _handle != nullptr; } + [[nodiscard]] auto operator<=>(const ResourceHandle& other) const noexcept { return _handle <=> other._handle; } + [[nodiscard]] bool operator==(const ResourceHandle& other) const noexcept { return _handle == other._handle; } + + /** + * @return int32 + */ + int32_t GetId() { + if (_handle == nullptr) throw std::runtime_error("ResourceHandle: Empty handle"); + return ResourceHandleGetId(_handle); + } + + /** + * @return string + */ + plg::string GetName() { + if (_handle == nullptr) throw std::runtime_error("ResourceHandle: Empty handle"); + return ResourceHandleGetName(_handle); + } + + /** + * @param name (string) + */ + void SetName(const plg::string& name) { + if (_handle == nullptr) throw std::runtime_error("ResourceHandle: Empty handle"); + ResourceHandleSetName(_handle, name); + } + + /** + */ + void IncrementCounter() { + if (_handle == nullptr) throw std::runtime_error("ResourceHandle: Empty handle"); + ResourceHandleIncrementCounter(_handle); + } + + /** + * @return int32 + */ + int32_t GetCounter() { + if (_handle == nullptr) throw std::runtime_error("ResourceHandle: Empty handle"); + return ResourceHandleGetCounter(_handle); + } + + /** + * @param value (float) + */ + void AddData(float value) { + if (_handle == nullptr) throw std::runtime_error("ResourceHandle: Empty handle"); + ResourceHandleAddData(_handle, value); + } + + /** + * @return float[] + */ + plg::vector GetData() { + if (_handle == nullptr) throw std::runtime_error("ResourceHandle: Empty handle"); + return ResourceHandleGetData(_handle); + } + + /** + * @return int32 + */ + static int32_t GetAliveCount() { + return ResourceHandleGetAliveCount(); + } + + /** + * @return int32 + */ + static int32_t GetTotalCreated() { + return ResourceHandleGetTotalCreated(); + } + + /** + * @return int32 + */ + static int32_t GetTotalDestroyed() { + return ResourceHandleGetTotalDestroyed(); + } + + private: + void destroy() const noexcept { + if (_handle != nullptr && _ownership == Ownership::Owned) { + ResourceHandleDestroy(_handle); + } + } + + void nullify() noexcept { + _handle = nullptr; + _ownership = Ownership::Borrowed; + } + + void* _handle{nullptr}; + Ownership _ownership{Ownership::Borrowed}; + }; + + + /** + */ + class Counter final { + public: + //Counter() = default; + + /** + * @param initialValue (int64) + */ + explicit Counter(int64_t initialValue) + : Counter(CounterCreate(initialValue), Ownership::Owned) {} + + /** + */ + explicit Counter() + : Counter(CounterCreateZero(), Ownership::Owned) {} + + Counter(const Counter&) = default; + Counter& operator=(const Counter&) = default; + Counter(Counter&&) noexcept = default; + Counter& operator=(Counter&&) noexcept = default; + ~Counter() = default; + + explicit Counter(void* handle, Ownership) : _handle(handle) {} + + [[nodiscard]] auto get() const noexcept { return _handle; } + + [[nodiscard]] auto release() noexcept { + auto handle = _handle; + _handle = nullptr; + return handle; + } + + void reset() noexcept { + _handle = nullptr; + } + + void swap(Counter& other) noexcept { + using std::swap; + swap(_handle, other._handle); + } + + friend void swap(Counter& lhs, Counter& rhs) noexcept { lhs.swap(rhs); } + + explicit operator bool() const noexcept { return _handle != nullptr; } + [[nodiscard]] auto operator<=>(const Counter& other) const noexcept { return _handle <=> other._handle; } + [[nodiscard]] bool operator==(const Counter& other) const noexcept { return _handle == other._handle; } + + /** + * @return int64 + */ + int64_t GetValue() { + if (_handle == nullptr) throw std::runtime_error("Counter: Empty handle"); + return CounterGetValue(_handle); + } + + /** + * @param value (int64) + */ + void SetValue(int64_t value) { + if (_handle == nullptr) throw std::runtime_error("Counter: Empty handle"); + CounterSetValue(_handle, value); + } + + /** + */ + void Increment() { + if (_handle == nullptr) throw std::runtime_error("Counter: Empty handle"); + CounterIncrement(_handle); + } + + /** + */ + void Decrement() { + if (_handle == nullptr) throw std::runtime_error("Counter: Empty handle"); + CounterDecrement(_handle); + } + + /** + * @param amount (int64) + */ + void Add(int64_t amount) { + if (_handle == nullptr) throw std::runtime_error("Counter: Empty handle"); + CounterAdd(_handle, amount); + } + + /** + */ + void Reset() { + if (_handle == nullptr) throw std::runtime_error("Counter: Empty handle"); + CounterReset(_handle); + } + + /** + * @return bool + */ + bool IsPositive() { + if (_handle == nullptr) throw std::runtime_error("Counter: Empty handle"); + return CounterIsPositive(_handle); + } + + /** + * @param value1 (int64) + * @param value2 (int64) + * @return int32 + */ + static int32_t Compare(int64_t value1, int64_t value2) { + return CounterCompare(value1, value2); + } + + /** + * @param values (int64[]) + * @return int64 + */ + static int64_t Sum(const plg::vector& values) { + return CounterSum(values); + } + + private: + void* _handle{nullptr}; + }; + } // namespace cross_call_master diff --git a/test/cross_call_worker/plugin.cpp b/test/cross_call_worker/plugin.cpp index e78151b..b4692d5 100644 --- a/test/cross_call_worker/plugin.cpp +++ b/test/cross_call_worker/plugin.cpp @@ -1837,6 +1837,209 @@ plg::vector MockFuncEnum(cross_call_master::Example return {p1, cross_call_master::Example::Forth}; } +class TestClass { +private: + // Conditional logging - only in debug builds + static void Log([[maybe_unused]] const plg::string& message) { +#ifdef DEBUG + std::println("{}", message); +#endif + } +public: + static plg::string BasicLifecycle() { + Log("TEST 1: Basic Lifecycle"); + Log("_______________________"); + + int32_t initialAlive = cross_call_master::ResourceHandle::GetAliveCount(); + int32_t initialCreated = cross_call_master::ResourceHandle::GetTotalCreated(); + + { + cross_call_master::ResourceHandle resource(1, "Test1"); + + Log(std::format("v Created ResourceHandle ID: {}", resource.GetId())); + Log(std::format("v Alive count increased: {}", cross_call_master::ResourceHandle::GetAliveCount())); + } + + int32_t finalAlive = cross_call_master::ResourceHandle::GetAliveCount(); + int32_t finalCreated = cross_call_master::ResourceHandle::GetTotalCreated(); + int32_t finalDestroyed = cross_call_master::ResourceHandle::GetTotalDestroyed(); + + Log(std::format("v Destructor called, alive count: {}", finalAlive)); + Log(std::format("v Total created: {}", finalCreated - initialCreated)); + Log(std::format("v Total destroyed: {}", finalDestroyed)); + + if (finalAlive == initialAlive && finalCreated == finalDestroyed) { + Log("v TEST 1 PASSED: Lifecycle working correctly\n"); + return "true"; + } else { + Log("x TEST 1 FAILED: Lifecycle mismatch!\n"); + return "false"; + } + } + + static plg::string StateManagement() { + Log("TEST 2: State Management"); + Log("________________________"); + + cross_call_master::ResourceHandle resource(2, "StateTest"); + + resource.IncrementCounter(); + resource.IncrementCounter(); + resource.IncrementCounter(); + int32_t counter = resource.GetCounter(); + Log(std::format("v Counter incremented 3 times: {}", counter)); + + resource.SetName("StateTestModified"); + plg::string newName = resource.GetName(); + Log(std::format("v Name changed to: {}", newName)); + + resource.AddData(1.1f); + resource.AddData(2.2f); + resource.AddData(3.3f); + plg::vector data = resource.GetData(); + Log(std::format("v Added {} data points", data.size())); + + if (counter == 3 && newName == "StateTestModified" && data.size() == 3) { + Log("v TEST 2 PASSED: State management working\n"); + return "true"; + } else { + Log("x TEST 2 FAILED: State not preserved!\n"); + return "false"; + } + } + + static plg::string MultipleInstances() { + Log("TEST 3: Multiple Instances"); + Log("__________________________"); + + int32_t beforeAlive = cross_call_master::ResourceHandle::GetAliveCount(); + + { + cross_call_master::ResourceHandle r1(10, "Instance1"); + cross_call_master::ResourceHandle r2(20, "Instance2"); + cross_call_master::ResourceHandle r3; + + int32_t duringAlive = cross_call_master::ResourceHandle::GetAliveCount(); + Log(std::format("v Created 3 instances, alive: {}", duringAlive)); + Log(std::format("v R1 ID: {}, R2 ID: {}, R3 ID: {}", r1.GetId(), r2.GetId(), r3.GetId())); + + if (duringAlive - beforeAlive == 3) { + Log("v All 3 instances tracked correctly"); + } + } + + int32_t afterAlive = cross_call_master::ResourceHandle::GetAliveCount(); + + if (afterAlive == beforeAlive) { + Log("v TEST 3 PASSED: All instances destroyed properly\n"); + return "true"; + } else { + Log(std::format("x TEST 3 FAILED: Leak detected! Before: {}, After: {}\n", beforeAlive, afterAlive)); + return "false"; + } + } + + static plg::string CounterWithoutDestructor() { + Log("TEST 4: Counter (No Destructor)"); + Log("________________________________"); + + cross_call_master::Counter counter(100); + Log(std::format("v Created Counter with value: {}", counter.GetValue())); + + counter.Increment(); + counter.Increment(); + counter.Add(50); + int64_t value = counter.GetValue(); + Log(std::format("v After operations, value: {}", value)); + + bool isPositive = counter.IsPositive(); + Log(std::format("v Is positive: {}", isPositive)); + + if (value == 152 && isPositive) { + Log("v TEST 4 PASSED: Counter operations working\n"); + return "true"; + } else { + Log("x TEST 4 FAILED: Counter operations incorrect\n"); + return "false"; + } + } + + static plg::string StaticMethods() { + Log("TEST 5: Static Methods"); + Log("______________________"); + + int32_t alive = cross_call_master::ResourceHandle::GetAliveCount(); + int32_t created = cross_call_master::ResourceHandle::GetTotalCreated(); + int32_t destroyed = cross_call_master::ResourceHandle::GetTotalDestroyed(); + Log(std::format("v ResourceHandle stats - Alive: {}, Created: {}, Destroyed: {}", alive, created, destroyed)); + + int32_t cmp1 = cross_call_master::Counter::Compare(100, 50); + int32_t cmp2 = cross_call_master::Counter::Compare(50, 100); + int32_t cmp3 = cross_call_master::Counter::Compare(50, 50); + Log(std::format("v Counter.Compare(100, 50) = {} (expected 1)", cmp1)); + Log(std::format("v Counter.Compare(50, 100) = {} (expected -1)", cmp2)); + Log(std::format("v Counter.Compare(50, 50) = {} (expected 0)", cmp3)); + + plg::vector values = {1, 2, 3, 4, 5}; + int64_t sum = cross_call_master::Counter::Sum(values); + Log(std::format("v Counter.Sum([1,2,3,4,5]) = {} (expected 15)", sum)); + + if (cmp1 == 1 && cmp2 == -1 && cmp3 == 0 && sum == 15) { + Log("v TEST 5 PASSED: Static methods working\n"); + return "true"; + } else { + Log("x TEST 5 FAILED: Static methods incorrect\n"); + return "false"; + } + } + + static plg::string MemoryLeakDetection() { + Log("TEST 6: Memory Leak Detection"); + Log("______________________________"); + + Log("! Creating resource and releasing ownership (intentional leak test)"); + + int32_t beforeAlive = cross_call_master::ResourceHandle::GetAliveCount(); + + { + cross_call_master::ResourceHandle leaked(999, "IntentionalLeak"); + Log(std::format("v Created resource ID: {}", leaked.GetId())); + } + + int32_t afterAlive = cross_call_master::ResourceHandle::GetAliveCount(); + + Log(std::format("v Before leak test: {} alive", beforeAlive)); + Log(std::format("v After release: {} alive", afterAlive)); + + if (afterAlive == beforeAlive + 1) { + Log("! TEST 6: Resource intentionally leaked\n"); + Log(" This is expected behavior - resource released without destruction\n"); + return "true"; + } else { + Log("x TEST 6 FAILED: Unexpected alive count\n"); + return "false"; + } + } + + static plg::string ExceptionHandling() { + Log("TEST 7: Exception Handling"); + Log("__________________________"); + + try { + cross_call_master::ResourceHandle resource(777, "ExceptionTest"); + resource.reset(); + resource.GetId(); + Log("x TEST 7 FAILED: No exception thrown!\n"); + return "false"; + } + catch (const std::runtime_error& ex) { + Log(std::format("v Caught expected exception: {}", ex.what())); + Log("v TEST 7 PASSED: Exception handling working\n"); + return "true"; + } + } +}; + extern "C" PLUGIN_API void ReverseCall(const plg::string &test) { static std::unordered_map tests{ @@ -2791,7 +2994,49 @@ PLUGIN_API void ReverseCall(const plg::string &test) { const auto result = cross_call_master::CallFuncEnumCallback(&MockFuncEnum); cross_call_master::ReverseReturn(result); } - } + }, + { + "ClassBasicLifecycle", []() { + const auto result = TestClass::BasicLifecycle(); + cross_call_master::ReverseReturn(result); + } + }, + { + "ClassStateManagement", []() { + const auto result = TestClass::StateManagement(); + cross_call_master::ReverseReturn(result); + } + }, + { + "ClassMultipleInstances", []() { + const auto result = TestClass::MultipleInstances(); + cross_call_master::ReverseReturn(result); + } + }, + { + "ClassCounterWithoutDestructor", []() { + const auto result = TestClass::CounterWithoutDestructor(); + cross_call_master::ReverseReturn(result); + } + }, + { + "ClassStaticMethods", []() { + const auto result = TestClass::StaticMethods(); + cross_call_master::ReverseReturn(result); + } + }, + { + "ClassMemoryLeakDetection", []() { + const auto result = TestClass::MemoryLeakDetection(); + cross_call_master::ReverseReturn(result); + } + }, + { + "ClassExceptionHandling", []() { + const auto result = TestClass::ExceptionHandling(); + cross_call_master::ReverseReturn(result); + } + } }; auto it = tests.find(test); if (it != tests.end()) { From bc3086b6943ad16230f321dc7e6d5799d93b4a55 Mon Sep 17 00:00:00 2001 From: qubka Date: Wed, 26 Nov 2025 00:25:32 +0000 Subject: [PATCH 14/16] fix: some improvements for test --- test/cross_call_master/plugin.cpp | 92 ++++++++++++++++++------------- test/cross_call_worker/plugin.cpp | 65 +++++++++++++++++++--- 2 files changed, 113 insertions(+), 44 deletions(-) diff --git a/test/cross_call_master/plugin.cpp b/test/cross_call_master/plugin.cpp index 7d8bbe8..49f1431 100644 --- a/test/cross_call_master/plugin.cpp +++ b/test/cross_call_master/plugin.cpp @@ -3632,6 +3632,16 @@ class CrossCallMaster final : public plg::IPluginEntry { test.Fail(std::format("Wrong return {}, expected {}", *_reverseReturn, returnExpected)); } }); + _tests.Add("ReverseClassOwnershipTransfer", [&](SimpleTests::Test &test) { + const plg::string returnExpected = "true"; + _reverseReturn.reset(); + cross_call_worker::ReverseCall("ClassOwnershipTransfer"); + if (!_reverseReturn) { + test.Fail("Return not set"); + } else if (*_reverseReturn != returnExpected) { + test.Fail(std::format("Wrong return {}, expected {}", *_reverseReturn, returnExpected)); + } + }); #endif// TEST_CASES & TEST_REVERSE_PARAMS_VARIANTS } public: @@ -4934,6 +4944,14 @@ PLUGIN_API plg::string CallFuncEnumCallback(cross_call_worker::FuncEnum func) { // classes +// Conditional logging - only in debug builds +template +void Log([[maybe_unused]] std::format_string fmt, [[maybe_unused]] Args&&... args) { +#if VERBOSE + std::println(fmt, std::forward(args)...); +#endif +} + class ResourceHandle { public: int32_t id; @@ -4949,18 +4967,18 @@ class ResourceHandle { ResourceHandle(int32_t id, const plg::string& name) : id(id), name(name), counter(0) { - s_aliveCount++; - s_totalCreated++; + ++s_aliveCount; + ++s_totalCreated; std::lock_guard lock(s_mutex); - std::println("[LIFECYCLE] ResourceHandle CREATED: ID={}, Name='{}', Alive={}, TotalCreated={}", + Log("[LIFECYCLE] ResourceHandle CREATED: ID={}, Name='{}', Alive={}, TotalCreated={}", id, name, s_aliveCount.load(), s_totalCreated.load()); } ~ResourceHandle() { - s_aliveCount--; - s_totalDestroyed++; + --s_aliveCount; + ++s_totalDestroyed; std::lock_guard lock(s_mutex); - std::println("[LIFECYCLE] ResourceHandle DESTROYED: ID={}, Name='{}', Counter={}, DataSize={}, Alive={}, TotalDestroyed={}", + Log("[LIFECYCLE] ResourceHandle DESTROYED: ID={}, Name='{}', Counter={}, DataSize={}, Alive={}, TotalDestroyed={}", id, name, counter, data.size(), s_aliveCount.load(), s_totalDestroyed.load()); } @@ -4981,7 +4999,7 @@ PLUGIN_API void* ResourceHandleCreate(int32_t id, const plg::string& name) { try { return new ResourceHandle(id, name); } catch (const std::exception& e) { - std::println("[ERROR] ResourceHandleCreate failed: {}", e.what()); + Log("[ERROR] ResourceHandleCreate failed: {}", e.what()); return nullptr; } } @@ -4993,7 +5011,7 @@ PLUGIN_API void* ResourceHandleCreateDefault() { try { return new ResourceHandle(id, std::format("Resource_{}", id)); } catch (const std::exception& e) { - std::println("[ERROR] ResourceHandleCreateDefault failed: {}", e.what()); + Log("[ERROR] ResourceHandleCreateDefault failed: {}", e.what()); return nullptr; } } @@ -5003,14 +5021,14 @@ PLUGIN_API void ResourceHandleDestroy(void* handle) { if (handle) { delete static_cast(handle); } else { - std::println("[WARNING] ResourceHandleDestroy called with nullptr"); + Log("[WARNING] ResourceHandleDestroy called with nullptr"); } } extern "C" PLUGIN_API int32_t ResourceHandleGetId(void* handle) { if (!handle) { - std::println("[ERROR] ResourceHandleGetId: handle is null"); + Log("[ERROR] ResourceHandleGetId: handle is null"); return -1; } return static_cast(handle)->id; @@ -5019,7 +5037,7 @@ PLUGIN_API int32_t ResourceHandleGetId(void* handle) { extern "C" PLUGIN_API plg::string ResourceHandleGetName(void* handle) { if (!handle) { - std::println("[ERROR] ResourceHandleGetName: handle is null"); + Log("[ERROR] ResourceHandleGetName: handle is null"); return ""; } return static_cast(handle)->name; @@ -5028,11 +5046,11 @@ PLUGIN_API plg::string ResourceHandleGetName(void* handle) { extern "C" PLUGIN_API void ResourceHandleSetName(void* handle, const plg::string& name) { if (!handle) { - std::println("[ERROR] ResourceHandleSetName: handle is null"); + Log("[ERROR] ResourceHandleSetName: handle is null"); return; } auto* res = static_cast(handle); - std::println("[ACTION] ResourceHandle ID={}: Name changed from '{}' to '{}'", + Log("[ACTION] ResourceHandle ID={}: Name changed from '{}' to '{}'", res->id, res->name, name); res->name = name; } @@ -5040,18 +5058,18 @@ PLUGIN_API void ResourceHandleSetName(void* handle, const plg::string& name) { extern "C" PLUGIN_API void ResourceHandleIncrementCounter(void* handle) { if (!handle) { - std::println("[ERROR] ResourceHandleIncrementCounter: handle is null"); + Log("[ERROR] ResourceHandleIncrementCounter: handle is null"); return; } auto* res = static_cast(handle); res->counter++; - std::println("[ACTION] ResourceHandle ID={}: Counter incremented to {}", res->id, res->counter); + Log("[ACTION] ResourceHandle ID={}: Counter incremented to {}", res->id, res->counter); } extern "C" PLUGIN_API int32_t ResourceHandleGetCounter(void* handle) { if (!handle) { - std::println("[ERROR] ResourceHandleGetCounter: handle is null"); + Log("[ERROR] ResourceHandleGetCounter: handle is null"); return -1; } return static_cast(handle)->counter; @@ -5060,19 +5078,19 @@ PLUGIN_API int32_t ResourceHandleGetCounter(void* handle) { extern "C" PLUGIN_API void ResourceHandleAddData(void* handle, float value) { if (!handle) { - std::println("[ERROR] ResourceHandleAddData: handle is null"); + Log("[ERROR] ResourceHandleAddData: handle is null"); return; } auto* res = static_cast(handle); res->data.push_back(value); - std::println("[ACTION] ResourceHandle ID={}: Added data value {}, total data points: {}", + Log("[ACTION] ResourceHandle ID={}: Added data value {}, total data points: {}", res->id, value, res->data.size()); } extern "C" PLUGIN_API plg::vector ResourceHandleGetData(void* handle) { if (!handle) { - std::println("[ERROR] ResourceHandleGetData: handle is null"); + Log("[ERROR] ResourceHandleGetData: handle is null"); return {}; } auto* res = static_cast(handle); @@ -5082,21 +5100,21 @@ PLUGIN_API plg::vector ResourceHandleGetData(void* handle) { extern "C" PLUGIN_API int32_t ResourceHandleGetAliveCount() { int32_t count = ResourceHandle::s_aliveCount.load(); - std::println("[STATS] ResourceHandle: {} instances currently alive", count); + Log("[STATS] ResourceHandle: {} instances currently alive", count); return count; } extern "C" PLUGIN_API int32_t ResourceHandleGetTotalCreated() { int32_t count = ResourceHandle::s_totalCreated.load(); - std::println("[STATS] ResourceHandle: {} total instances created", count); + Log("[STATS] ResourceHandle: {} total instances created", count); return count; } extern "C" PLUGIN_API int32_t ResourceHandleGetTotalDestroyed() { int32_t count = ResourceHandle::s_totalDestroyed.load(); - std::println("[STATS] ResourceHandle: {} total instances destroyed", count); + Log("[STATS] ResourceHandle: {} total instances destroyed", count); return count; } @@ -5108,7 +5126,7 @@ struct Counter { int64_t value; explicit Counter(int64_t val) : value(val) { - std::println("[COUNTER] Counter created with value: {}", value); + Log("[COUNTER] Counter created with value: {}", value); } }; @@ -5120,7 +5138,7 @@ PLUGIN_API void* CounterCreate(int64_t initialValue) { try { return pool.emplace_back(std::make_unique(initialValue)).get(); } catch (const std::exception& e) { - std::println("[ERROR] CounterCreate failed: {}", e.what()); + Log("[ERROR] CounterCreate failed: {}", e.what()); return nullptr; } } @@ -5130,7 +5148,7 @@ PLUGIN_API void* CounterCreateZero() { try { return pool.emplace_back(std::make_unique(0)).get(); } catch (const std::exception& e) { - std::println("[ERROR] CounterCreateZero failed: {}", e.what()); + Log("[ERROR] CounterCreateZero failed: {}", e.what()); return nullptr; } } @@ -5138,7 +5156,7 @@ PLUGIN_API void* CounterCreateZero() { extern "C" PLUGIN_API int64_t CounterGetValue(void* counter) { if (!counter) { - std::println("[ERROR] CounterGetValue: counter is null"); + Log("[ERROR] CounterGetValue: counter is null"); return 0; } return static_cast(counter)->value; @@ -5147,62 +5165,62 @@ PLUGIN_API int64_t CounterGetValue(void* counter) { extern "C" PLUGIN_API void CounterSetValue(void* counter, int64_t value) { if (!counter) { - std::println("[ERROR] CounterSetValue: counter is null"); + Log("[ERROR] CounterSetValue: counter is null"); return; } auto* cnt = static_cast(counter); - std::println("[COUNTER] Counter value changed: {} -> {}", cnt->value, value); + Log("[COUNTER] Counter value changed: {} -> {}", cnt->value, value); cnt->value = value; } extern "C" PLUGIN_API void CounterIncrement(void* counter) { if (!counter) { - std::println("[ERROR] CounterIncrement: counter is null"); + Log("[ERROR] CounterIncrement: counter is null"); return; } auto* cnt = static_cast(counter); cnt->value++; - std::println("[COUNTER] Counter incremented to: {}", cnt->value); + Log("[COUNTER] Counter incremented to: {}", cnt->value); } extern "C" PLUGIN_API void CounterDecrement(void* counter) { if (!counter) { - std::println("[ERROR] CounterDecrement: counter is null"); + Log("[ERROR] CounterDecrement: counter is null"); return; } auto* cnt = static_cast(counter); cnt->value--; - std::println("[COUNTER] Counter decremented to: {}", cnt->value); + Log("[COUNTER] Counter decremented to: {}", cnt->value); } extern "C" PLUGIN_API void CounterAdd(void* counter, int64_t amount) { if (!counter) { - std::println("[ERROR] CounterAdd: counter is null"); + Log("[ERROR] CounterAdd: counter is null"); return; } auto* cnt = static_cast(counter); cnt->value += amount; - std::println("[COUNTER] Counter added {}, new value: {}", amount, cnt->value); + Log("[COUNTER] Counter added {}, new value: {}", amount, cnt->value); } extern "C" PLUGIN_API void CounterReset(void* counter) { if (!counter) { - std::println("[ERROR] CounterReset: counter is null"); + Log("[ERROR] CounterReset: counter is null"); return; } auto* cnt = static_cast(counter); - std::println("[COUNTER] Counter reset from {} to 0", cnt->value); + Log("[COUNTER] Counter reset from {} to 0", cnt->value); cnt->value = 0; } extern "C" PLUGIN_API bool CounterIsPositive(void* counter) { if (!counter) { - std::println("[ERROR] CounterIsPositive: counter is null"); + Log("[ERROR] CounterIsPositive: counter is null"); return false; } return static_cast(counter)->value > 0; diff --git a/test/cross_call_worker/plugin.cpp b/test/cross_call_worker/plugin.cpp index b4692d5..3047ff5 100644 --- a/test/cross_call_worker/plugin.cpp +++ b/test/cross_call_worker/plugin.cpp @@ -1841,7 +1841,7 @@ class TestClass { private: // Conditional logging - only in debug builds static void Log([[maybe_unused]] const plg::string& message) { -#ifdef DEBUG +#ifdef VERBOSE std::println("{}", message); #endif } @@ -1997,8 +1997,6 @@ class TestClass { Log("TEST 6: Memory Leak Detection"); Log("______________________________"); - Log("! Creating resource and releasing ownership (intentional leak test)"); - int32_t beforeAlive = cross_call_master::ResourceHandle::GetAliveCount(); { @@ -2011,12 +2009,11 @@ class TestClass { Log(std::format("v Before leak test: {} alive", beforeAlive)); Log(std::format("v After release: {} alive", afterAlive)); - if (afterAlive == beforeAlive + 1) { - Log("! TEST 6: Resource intentionally leaked\n"); - Log(" This is expected behavior - resource released without destruction\n"); + if (afterAlive == beforeAlive) { + Log("v TEST 6 PASSED: Destructor cleaned up leaked resource\n"); return "true"; } else { - Log("x TEST 6 FAILED: Unexpected alive count\n"); + Log("x TEST 6 FAILED: Resource still alive (FATAL)\n"); return "false"; } } @@ -2038,6 +2035,54 @@ class TestClass { return "true"; } } + + static plg::string OwnershipTransfer() { + Log("TEST 7: Ownership Transfer (get + release)"); + Log("─────────────────────────────────────────"); + + int initial_alive = cross_call_master::ResourceHandle::GetAliveCount(); + int initial_created = cross_call_master::ResourceHandle::GetTotalCreated(); + + cross_call_master::ResourceHandle resource(42, "OwnershipTest"); + Log(std::format("✓ Created ResourceHandle ID: {}", resource.GetId())); + + // Get internal wrapper (simulate internal pointer access) + auto* wrapper = resource.get(); + Log(std::format("✓ get() returned internal wrapper: {}", + reinterpret_cast(wrapper))); + + // Release ownership + auto* handle = resource.release(); + Log(std::format("✓ release() returned handle: {}", + reinterpret_cast(handle))); + + if (wrapper != handle) { + Log("✗ TEST 7 FAILED: get() did not return internal wrapper"); + return "false"; + } + + try { + resource.GetId(); + Log("✗ TEST 7 FAILED: ResourceHandle still accessible after release()"); + return "false"; + } catch (const std::exception& e) { + Log("✓ ResourceHandle is invalid after release()"); + } + + // Check that handle is now owned externally and alive count updated correctly + int alive_after_release = cross_call_master::ResourceHandle::GetAliveCount(); + if (alive_after_release != initial_alive + 1) { + Log(std::format("✗ TEST 7 FAILED: Alive count mismatch after release. " + "Expected {}, got {}", + initial_alive + 1, alive_after_release)); + return "false"; + } + + cross_call_master::ResourceHandleDestroy(handle); + + Log("✓ TEST 7 PASSED: Ownership transfer working correctly\n"); + return "true"; + } }; extern "C" @@ -3036,6 +3081,12 @@ PLUGIN_API void ReverseCall(const plg::string &test) { const auto result = TestClass::ExceptionHandling(); cross_call_master::ReverseReturn(result); } + }, + { + "ClassOwnershipTransfer", []() { + const auto result = TestClass::OwnershipTransfer(); + cross_call_master::ReverseReturn(result); + } } }; auto it = tests.find(test); From 67d2ff739cc0cb809d08f3029f90bf3dd12a4e4a Mon Sep 17 00:00:00 2001 From: qubka Date: Thu, 27 Nov 2025 16:50:24 +0000 Subject: [PATCH 15/16] fix: change success/fail symbols --- external/plugify | 2 +- test/cross_call_worker/plugin.cpp | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/external/plugify b/external/plugify index f0b7aa9..d55fb6b 160000 --- a/external/plugify +++ b/external/plugify @@ -1 +1 @@ -Subproject commit f0b7aa9213b675d6122a52256e1bed42d8125ecf +Subproject commit d55fb6b3b88470de1b60ca558b60c91b05e0f78c diff --git a/test/cross_call_worker/plugin.cpp b/test/cross_call_worker/plugin.cpp index 3047ff5..3a62714 100644 --- a/test/cross_call_worker/plugin.cpp +++ b/test/cross_call_worker/plugin.cpp @@ -2044,35 +2044,35 @@ class TestClass { int initial_created = cross_call_master::ResourceHandle::GetTotalCreated(); cross_call_master::ResourceHandle resource(42, "OwnershipTest"); - Log(std::format("✓ Created ResourceHandle ID: {}", resource.GetId())); + Log(std::format("v Created ResourceHandle ID: {}", resource.GetId())); // Get internal wrapper (simulate internal pointer access) auto* wrapper = resource.get(); - Log(std::format("✓ get() returned internal wrapper: {}", + Log(std::format("v get() returned internal wrapper: {}", reinterpret_cast(wrapper))); // Release ownership auto* handle = resource.release(); - Log(std::format("✓ release() returned handle: {}", + Log(std::format("v release() returned handle: {}", reinterpret_cast(handle))); if (wrapper != handle) { - Log("✗ TEST 7 FAILED: get() did not return internal wrapper"); + Log("x TEST 7 FAILED: get() did not return internal wrapper"); return "false"; } try { resource.GetId(); - Log("✗ TEST 7 FAILED: ResourceHandle still accessible after release()"); + Log("x TEST 7 FAILED: ResourceHandle still accessible after release()"); return "false"; } catch (const std::exception& e) { - Log("✓ ResourceHandle is invalid after release()"); + Log("v ResourceHandle is invalid after release()"); } // Check that handle is now owned externally and alive count updated correctly int alive_after_release = cross_call_master::ResourceHandle::GetAliveCount(); if (alive_after_release != initial_alive + 1) { - Log(std::format("✗ TEST 7 FAILED: Alive count mismatch after release. " + Log(std::format("x TEST 7 FAILED: Alive count mismatch after release. " "Expected {}, got {}", initial_alive + 1, alive_after_release)); return "false"; @@ -2080,7 +2080,7 @@ class TestClass { cross_call_master::ResourceHandleDestroy(handle); - Log("✓ TEST 7 PASSED: Ownership transfer working correctly\n"); + Log("v TEST 7 PASSED: Ownership transfer working correctly\n"); return "true"; } }; From 0227f5564b9c98f89b70cc5c77abbc3e6ff377a1 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 27 Nov 2025 16:50:43 +0000 Subject: [PATCH 16/16] chore(main): release 2.1.5 --- .github/release-please-manifest.json | 2 +- CHANGELOG.md | 20 ++++++++++++++++++++ version.txt | 2 +- 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/.github/release-please-manifest.json b/.github/release-please-manifest.json index 38dc7f3..5c6af54 100644 --- a/.github/release-please-manifest.json +++ b/.github/release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "2.1.4" + ".": "2.1.5" } diff --git a/CHANGELOG.md b/CHANGELOG.md index 309ca05..5689741 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,25 @@ # Changelog +## [2.1.5](https://github.com/untrustedmodders/plugify-module-cpp/compare/v2.1.4...v2.1.5) (2025-11-27) + + +### Bug Fixes + +* add clang doc parser ([5b3ee8d](https://github.com/untrustedmodders/plugify-module-cpp/commit/5b3ee8d2114367317b4785e6ff0797dc3ac5f24f)) +* add clang doc parser ([95afaff](https://github.com/untrustedmodders/plugify-module-cpp/commit/95afaff4590ac1f73df5f14be9749559f6fe4f40)) +* add clang doc parser ([4248438](https://github.com/untrustedmodders/plugify-module-cpp/commit/4248438f85e2d6332527765c9723781547f26b07)) +* add initial class testing ([dd35f35](https://github.com/untrustedmodders/plugify-module-cpp/commit/dd35f352d44b86cb901873be1867f5b4e9aa8530)) +* add new class tests ([26dd531](https://github.com/untrustedmodders/plugify-module-cpp/commit/26dd5310591427657271fd27a513ea703d49bdf4)) +* change success/fail symbols ([67d2ff7](https://github.com/untrustedmodders/plugify-module-cpp/commit/67d2ff739cc0cb809d08f3029f90bf3dd12a4e4a)) +* move tools to separate folders ([cf9fdbf](https://github.com/untrustedmodders/plugify-module-cpp/commit/cf9fdbfe9f55c8f666f5c0664f1ee6b7313d22c9)) +* remove assume_valid from string ([f63b395](https://github.com/untrustedmodders/plugify-module-cpp/commit/f63b39504307fdc26267febc74578a81e6f33366)) +* some improvements for test ([bc3086b](https://github.com/untrustedmodders/plugify-module-cpp/commit/bc3086b6943ad16230f321dc7e6d5799d93b4a55)) +* update deps ([0bc30cb](https://github.com/untrustedmodders/plugify-module-cpp/commit/0bc30cbaf46f58a80aa18775a2728b3f4961a776)) +* update deps ([401ec2c](https://github.com/untrustedmodders/plugify-module-cpp/commit/401ec2caf368c5616fbb63908e9ddc09b2b13e1b)) +* update notify ([62f2bac](https://github.com/untrustedmodders/plugify-module-cpp/commit/62f2baca2affbfa530bcf4be2e7b7fdbf13bb8b4)) +* update plg includes ([1201020](https://github.com/untrustedmodders/plugify-module-cpp/commit/1201020e00ea55970749f8457b33d9d969f88e4f)) +* update test for classes ([e44e0dd](https://github.com/untrustedmodders/plugify-module-cpp/commit/e44e0dd752a4608f0822f8ebc3c9f2e9195ffe25)) + ## [2.1.4](https://github.com/untrustedmodders/plugify-module-cpp/compare/v2.1.3...v2.1.4) (2025-10-06) diff --git a/version.txt b/version.txt index 7d2ed7c..cd57a8b 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -2.1.4 +2.1.5