From cae5bccdeb28ba45e8cabed1a9b4d8e440a92272 Mon Sep 17 00:00:00 2001 From: Hideaki Tai Date: Wed, 4 Oct 2023 16:13:24 +0900 Subject: [PATCH] feat: add library dependencies --- .github/workflows/build.yml | 5 + README.md | 12 +- Tween/Timeline.h | 2 +- Tween/Transition.h | 2 +- Tween/Types.h | 6 +- Tween/util/ArxContainer/ArxContainer.h | 769 ------------------ .../ArxContainer/ArxContainer/has_include.h | 30 - .../ArxContainer/has_libstdcplusplus.h | 35 - .../ArxContainer/initializer_list.h | 32 - .../ArxContainer/replace_minmax_macros.h | 35 - Tween/util/ArxContainer/LICENSE | 21 - Tween/util/ArxContainer/README.md | 194 ----- Tween/util/ArxContainer/library.json | 18 - Tween/util/ArxContainer/library.properties | 9 - Tween/util/ArxSmartPtr/ArxSmartPtr.h | 46 -- .../ArxSmartPtr/ArxSmartPtr/LICENSE_1_0.txt | 23 - .../ArxSmartPtr/detail/has_include.h | 30 - .../ArxSmartPtr/detail/has_libstdcplusplus.h | 35 - .../detail/replace_minmax_macros.h | 35 - .../ArxSmartPtr/detail/shared_count.h | 159 ---- .../util/ArxSmartPtr/ArxSmartPtr/shared_ptr.h | 377 --------- Tween/util/ArxSmartPtr/LICENSE | 21 - Tween/util/ArxSmartPtr/README.md | 77 -- Tween/util/ArxSmartPtr/library.json | 18 - Tween/util/ArxSmartPtr/library.properties | 9 - Tween/util/ArxTypeTraits/ArxTypeTraits.h | 38 - .../ArxTypeTraits/ArxTypeTraits/functional.h | 165 ---- .../ArxTypeTraits/ArxTypeTraits/has_include.h | 30 - .../ArxTypeTraits/has_libstdcplusplus.h | 35 - .../ArxTypeTraits/initializer_list.h | 30 - .../ArxTypeTraits/replace_minmax_macros.h | 35 - .../util/ArxTypeTraits/ArxTypeTraits/tuple.h | 82 -- .../ArxTypeTraits/ArxTypeTraits/type_traits.h | 638 --------------- Tween/util/ArxTypeTraits/LICENSE | 21 - Tween/util/ArxTypeTraits/README.md | 117 --- Tween/util/ArxTypeTraits/library.json | 18 - Tween/util/ArxTypeTraits/library.properties | 9 - Tween/util/Easing/Easing.h | 30 - Tween/util/Easing/Easing/BackEase.h | 75 -- Tween/util/Easing/Easing/BounceEase.h | 79 -- Tween/util/Easing/Easing/CircularEase.h | 67 -- Tween/util/Easing/Easing/CubicEase.h | 67 -- Tween/util/Easing/Easing/EasingBase.h | 47 -- Tween/util/Easing/Easing/ElasticEase.h | 132 --- Tween/util/Easing/Easing/ExponentialEase.h | 67 -- Tween/util/Easing/Easing/LICENSE.txt | 8 - Tween/util/Easing/Easing/LinearEase.h | 62 -- Tween/util/Easing/Easing/QuadraticEase.h | 67 -- Tween/util/Easing/Easing/QuarticEase.h | 67 -- Tween/util/Easing/Easing/QuinticEase.h | 67 -- Tween/util/Easing/Easing/SineEase.h | 62 -- Tween/util/Easing/Easing/Types.h | 68 -- Tween/util/Easing/LICENSE | 21 - Tween/util/Easing/README.md | 100 --- Tween/util/Easing/library.json | 20 - Tween/util/Easing/library.properties | 9 - Tween/util/PollingTimer/FrameRateCounter.h | 92 --- Tween/util/PollingTimer/IntervalCounter.h | 183 ----- Tween/util/PollingTimer/LICENSE | 21 - Tween/util/PollingTimer/OneShotTimer.h | 25 - Tween/util/PollingTimer/PollingTimer.h | 298 ------- Tween/util/PollingTimer/README.md | 306 ------- Tween/util/PollingTimer/library.json | 18 - Tween/util/PollingTimer/library.properties | 9 - .../util/ArxTypeTraits/ArxTypeTraits.h | 38 - .../ArxTypeTraits/ArxTypeTraits/functional.h | 165 ---- .../ArxTypeTraits/ArxTypeTraits/has_include.h | 30 - .../ArxTypeTraits/has_libstdcplusplus.h | 35 - .../ArxTypeTraits/initializer_list.h | 30 - .../ArxTypeTraits/replace_minmax_macros.h | 35 - .../util/ArxTypeTraits/ArxTypeTraits/tuple.h | 82 -- .../ArxTypeTraits/ArxTypeTraits/type_traits.h | 638 --------------- .../PollingTimer/util/ArxTypeTraits/LICENSE | 21 - .../PollingTimer/util/ArxTypeTraits/README.md | 117 --- .../util/ArxTypeTraits/library.json | 18 - .../util/ArxTypeTraits/library.properties | 9 - .../util/TeensyDirtySTLErrorSolution/LICENSE | 21 - .../TeensyDirtySTLErrorSolution/README.md | 57 -- .../TeensyDirtySTLErrorSolution.h | 65 -- library.json | 10 +- library.properties | 1 + 81 files changed, 27 insertions(+), 6630 deletions(-) delete mode 100644 Tween/util/ArxContainer/ArxContainer.h delete mode 100644 Tween/util/ArxContainer/ArxContainer/has_include.h delete mode 100644 Tween/util/ArxContainer/ArxContainer/has_libstdcplusplus.h delete mode 100644 Tween/util/ArxContainer/ArxContainer/initializer_list.h delete mode 100644 Tween/util/ArxContainer/ArxContainer/replace_minmax_macros.h delete mode 100644 Tween/util/ArxContainer/LICENSE delete mode 100644 Tween/util/ArxContainer/README.md delete mode 100644 Tween/util/ArxContainer/library.json delete mode 100644 Tween/util/ArxContainer/library.properties delete mode 100644 Tween/util/ArxSmartPtr/ArxSmartPtr.h delete mode 100644 Tween/util/ArxSmartPtr/ArxSmartPtr/LICENSE_1_0.txt delete mode 100644 Tween/util/ArxSmartPtr/ArxSmartPtr/detail/has_include.h delete mode 100644 Tween/util/ArxSmartPtr/ArxSmartPtr/detail/has_libstdcplusplus.h delete mode 100644 Tween/util/ArxSmartPtr/ArxSmartPtr/detail/replace_minmax_macros.h delete mode 100644 Tween/util/ArxSmartPtr/ArxSmartPtr/detail/shared_count.h delete mode 100644 Tween/util/ArxSmartPtr/ArxSmartPtr/shared_ptr.h delete mode 100644 Tween/util/ArxSmartPtr/LICENSE delete mode 100644 Tween/util/ArxSmartPtr/README.md delete mode 100644 Tween/util/ArxSmartPtr/library.json delete mode 100644 Tween/util/ArxSmartPtr/library.properties delete mode 100644 Tween/util/ArxTypeTraits/ArxTypeTraits.h delete mode 100644 Tween/util/ArxTypeTraits/ArxTypeTraits/functional.h delete mode 100644 Tween/util/ArxTypeTraits/ArxTypeTraits/has_include.h delete mode 100644 Tween/util/ArxTypeTraits/ArxTypeTraits/has_libstdcplusplus.h delete mode 100644 Tween/util/ArxTypeTraits/ArxTypeTraits/initializer_list.h delete mode 100644 Tween/util/ArxTypeTraits/ArxTypeTraits/replace_minmax_macros.h delete mode 100644 Tween/util/ArxTypeTraits/ArxTypeTraits/tuple.h delete mode 100644 Tween/util/ArxTypeTraits/ArxTypeTraits/type_traits.h delete mode 100644 Tween/util/ArxTypeTraits/LICENSE delete mode 100644 Tween/util/ArxTypeTraits/README.md delete mode 100644 Tween/util/ArxTypeTraits/library.json delete mode 100644 Tween/util/ArxTypeTraits/library.properties delete mode 100644 Tween/util/Easing/Easing.h delete mode 100644 Tween/util/Easing/Easing/BackEase.h delete mode 100644 Tween/util/Easing/Easing/BounceEase.h delete mode 100644 Tween/util/Easing/Easing/CircularEase.h delete mode 100644 Tween/util/Easing/Easing/CubicEase.h delete mode 100644 Tween/util/Easing/Easing/EasingBase.h delete mode 100644 Tween/util/Easing/Easing/ElasticEase.h delete mode 100644 Tween/util/Easing/Easing/ExponentialEase.h delete mode 100644 Tween/util/Easing/Easing/LICENSE.txt delete mode 100644 Tween/util/Easing/Easing/LinearEase.h delete mode 100644 Tween/util/Easing/Easing/QuadraticEase.h delete mode 100644 Tween/util/Easing/Easing/QuarticEase.h delete mode 100644 Tween/util/Easing/Easing/QuinticEase.h delete mode 100644 Tween/util/Easing/Easing/SineEase.h delete mode 100644 Tween/util/Easing/Easing/Types.h delete mode 100644 Tween/util/Easing/LICENSE delete mode 100644 Tween/util/Easing/README.md delete mode 100644 Tween/util/Easing/library.json delete mode 100644 Tween/util/Easing/library.properties delete mode 100644 Tween/util/PollingTimer/FrameRateCounter.h delete mode 100644 Tween/util/PollingTimer/IntervalCounter.h delete mode 100644 Tween/util/PollingTimer/LICENSE delete mode 100644 Tween/util/PollingTimer/OneShotTimer.h delete mode 100644 Tween/util/PollingTimer/PollingTimer.h delete mode 100644 Tween/util/PollingTimer/README.md delete mode 100644 Tween/util/PollingTimer/library.json delete mode 100644 Tween/util/PollingTimer/library.properties delete mode 100644 Tween/util/PollingTimer/util/ArxTypeTraits/ArxTypeTraits.h delete mode 100644 Tween/util/PollingTimer/util/ArxTypeTraits/ArxTypeTraits/functional.h delete mode 100644 Tween/util/PollingTimer/util/ArxTypeTraits/ArxTypeTraits/has_include.h delete mode 100644 Tween/util/PollingTimer/util/ArxTypeTraits/ArxTypeTraits/has_libstdcplusplus.h delete mode 100644 Tween/util/PollingTimer/util/ArxTypeTraits/ArxTypeTraits/initializer_list.h delete mode 100644 Tween/util/PollingTimer/util/ArxTypeTraits/ArxTypeTraits/replace_minmax_macros.h delete mode 100644 Tween/util/PollingTimer/util/ArxTypeTraits/ArxTypeTraits/tuple.h delete mode 100644 Tween/util/PollingTimer/util/ArxTypeTraits/ArxTypeTraits/type_traits.h delete mode 100644 Tween/util/PollingTimer/util/ArxTypeTraits/LICENSE delete mode 100644 Tween/util/PollingTimer/util/ArxTypeTraits/README.md delete mode 100644 Tween/util/PollingTimer/util/ArxTypeTraits/library.json delete mode 100644 Tween/util/PollingTimer/util/ArxTypeTraits/library.properties delete mode 100644 Tween/util/PollingTimer/util/TeensyDirtySTLErrorSolution/LICENSE delete mode 100644 Tween/util/PollingTimer/util/TeensyDirtySTLErrorSolution/README.md delete mode 100644 Tween/util/PollingTimer/util/TeensyDirtySTLErrorSolution/TeensyDirtySTLErrorSolution.h diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4befdf4..8f9665c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -101,4 +101,9 @@ jobs: - examples/transition_callback libraries: | - source-path: ./ + - name: ArxContainer + - name: ArxSmartPtr + - name: ArxTypeTraits + - name: Easing + - name: PollingTimer verbose: true diff --git a/README.md b/README.md index 2d05c17..10967dc 100644 --- a/README.md +++ b/README.md @@ -287,13 +287,15 @@ Sequence& hold(const double in); Sequence& offset(const double ms); ``` +## Dependent Libraries + +- [Easing](https://github.com/hideakitai/Easing) +- [PollingTimer](https://github.com/hideakitai/PollingTimer) +- [ArxTypeTraits](https://github.com/hideakitai/ArxTypeTraits) +- [ArxContainer](https://github.com/hideakitai/ArxContainer) +- [ArxSmartPtr](https://github.com/hideakitai/ArxSmartPtr) ## Embedded Libraries -- [Easing v0.1.0](https://github.com/hideakitai/Easing) -- [PollingTimer v0.4.3](https://github.com/hideakitai/PollingTimer) -- [ArxTypeTraits v0.2.3](https://github.com/hideakitai/ArxTypeTraits) -- [ArxContainer v0.4.0](https://github.com/hideakitai/ArxContainer) -- [ArxSmartPtr v0.2.3](https://github.com/hideakitai/ArxSmartPtr) - [TeensyDirtySTLErrorSolution v0.1.0](https://github.com/hideakitai/TeensyDirtySTLErrorSolution) ## License diff --git a/Tween/Timeline.h b/Tween/Timeline.h index 8771951..5b50ab5 100644 --- a/Tween/Timeline.h +++ b/Tween/Timeline.h @@ -4,7 +4,7 @@ #include "Types.h" #include "Sequence.h" -#include "util/PollingTimer/FrameRateCounter.h" +#include namespace ht { namespace tween { diff --git a/Tween/Transition.h b/Tween/Transition.h index f3b26ea..7aab5f1 100644 --- a/Tween/Transition.h +++ b/Tween/Transition.h @@ -3,7 +3,7 @@ #define HT_TWEEN_TRANSITION_H #include "Types.h" -#include "util/Easing/Easing.h" +#include struct CRGB; struct CHSV; diff --git a/Tween/Types.h b/Tween/Types.h index 3cf3597..32a2243 100644 --- a/Tween/Types.h +++ b/Tween/Types.h @@ -8,9 +8,9 @@ #elif defined(OF_VERSION_MAJOR) #include "ofMain.h" #endif -#include "util/ArxTypeTraits/ArxTypeTraits.h" -#include "util/ArxSmartPtr/ArxSmartPtr.h" -#include "util/ArxContainer/ArxContainer.h" +#include +#include +#include namespace ht { namespace tween { diff --git a/Tween/util/ArxContainer/ArxContainer.h b/Tween/util/ArxContainer/ArxContainer.h deleted file mode 100644 index 9b9494f..0000000 --- a/Tween/util/ArxContainer/ArxContainer.h +++ /dev/null @@ -1,769 +0,0 @@ -#pragma once - -#ifndef ARX_RINGBUFFER_H -#define ARX_RINGBUFFER_H - -#include "ArxContainer/has_include.h" -#include "ArxContainer/has_libstdcplusplus.h" - -#ifdef ARDUINO -#include -#endif - -#include "ArxContainer/replace_minmax_macros.h" -#include "ArxContainer/initializer_list.h" - -#if ARX_HAVE_LIBSTDCPLUSPLUS >= 201103L // Have libstdc++11 - -#include -#include -#include -#include - -#else // Do not have libstdc++11 - -#include - -#ifndef ARX_VECTOR_DEFAULT_SIZE -#define ARX_VECTOR_DEFAULT_SIZE 16 -#endif // ARX_VECTOR_DEFAULT_SIZE - -#ifndef ARX_DEQUE_DEFAULT_SIZE -#define ARX_DEQUE_DEFAULT_SIZE 16 -#endif // ARX_DEQUE_DEFAULT_SIZE - -#ifndef ARX_MAP_DEFAULT_SIZE -#define ARX_MAP_DEFAULT_SIZE 16 -#endif // ARX_MAP_DEFAULT_SIZE - -namespace arx { - -namespace container { - namespace detail { - template - T&& move(T& t) { return static_cast(t); } - } // namespace detail -} // namespace container - -template -class RingBuffer { - class Iterator { - friend RingBuffer; - - T* ptr {nullptr}; // pointer to the first element - int pos {0}; - - Iterator() {} - Iterator(T* ptr, int pos) - : ptr(ptr), pos(pos) {} - - public: - Iterator(const Iterator& it) { - this->ptr = it.ptr; - this->pos = it.pos; - } - - Iterator(Iterator&& it) { - this->ptr = container::detail::move(it.ptr); - this->pos = container::detail::move(it.pos); - } - - int index() const { - if (pos >= 0) - return pos % N; - else - return N - (abs(pos) % (N + 1)); - } - - int index_with_offset(const int i) const { - const int p = pos + i; - if (p >= 0) - return p % N; - else - return N - (abs(p) % (N + 1)); - } - - T& operator*() { - return *(ptr + index()); - } - const T& operator*() const { - return *(ptr + index()); - } - T* operator->() { - return ptr + index(); - } - const T* operator->() const { - return ptr + index(); - } - - Iterator operator+(const Iterator& rhs) { - Iterator it(this->ptr, this->pos + rhs.pos); - return it; - } - Iterator operator+(const int n) { - Iterator it(this->ptr, this->pos + n); - return it; - } - Iterator operator-(const Iterator& rhs) { - Iterator it(this->ptr, this->pos - rhs.pos); - return it; - } - Iterator operator-(const int n) { - Iterator it(this->ptr, this->pos - n); - return it; - } - Iterator& operator+=(const Iterator& rhs) { - this->pos += rhs.pos; - return *this; - } - Iterator& operator+=(const int n) { - this->pos += n; - return *this; - } - Iterator& operator-=(const Iterator& rhs) { - this->pos -= rhs.pos; - return *this; - } - Iterator& operator-=(const int n) { - this->pos -= n; - return *this; - } - - // prefix increment/decrement - Iterator& operator++() { - ++pos; - return *this; - } - Iterator& operator--() { - --pos; - return *this; - } - // postfix increment/decrement - Iterator operator++(int) { - Iterator it = *this; - ++pos; - return it; - } - Iterator operator--(int) { - Iterator it = *this; - --pos; - return it; - } - - Iterator& operator=(const Iterator& rhs) { - this->ptr = rhs.ptr; - this->pos = rhs.pos; - return *this; - } - Iterator& operator=(Iterator&& rhs) { - this->ptr = container::detail::move(rhs.ptr); - this->pos = container::detail::move(rhs.pos); - return *this; - } - - bool operator==(const Iterator& rhs) const { - return (rhs.ptr == ptr) && (rhs.pos == pos); - } - bool operator!=(const Iterator& rhs) const { - return !(*this == rhs); - } - bool operator<(const Iterator& rhs) const { - return pos < rhs.pos; - } - bool operator<=(const Iterator& rhs) const { - return pos <= rhs.pos; - } - bool operator>(const Iterator& rhs) const { - return pos > rhs.pos; - } - bool operator>=(const Iterator& rhs) const { - return pos >= rhs.pos; - } - - private: - int raw_pos() const { - return pos; - } - - void set(const int i) { - pos = i; - } - - void reset() { - pos = 0; - } - }; - -protected: - friend class Iterator; - - T queue_[N]; - Iterator head_; - Iterator tail_; - -public: - using iterator = Iterator; - using const_iterator = const Iterator; - - RingBuffer() - : queue_() - , head_(queue_, 0) - , tail_(queue_, 0) { - } - - RingBuffer(std::initializer_list lst) - : queue_() - , head_(queue_, 0) - , tail_(queue_, 0) { - for (auto it = lst.begin(); it != lst.end(); ++it) { - push_back(*it); - } - } - - // copy - explicit RingBuffer(const RingBuffer& r) - : queue_() - , head_(r.head_) - , tail_(r.tail_) { - for (size_t i = 0; i < r.size(); ++i) - queue_[i] = r.queue_[i]; - } - RingBuffer& operator=(const RingBuffer& r) { - head_ = r.head_; - tail_ = r.tail_; - for (size_t i = 0; i < r.size(); ++i) - queue_[i] = r.queue_[i]; - return *this; - } - - // move - RingBuffer(RingBuffer&& r) { - head_ = container::detail::move(r.head_); - tail_ = container::detail::move(r.tail_); - for (size_t i = 0; i < r.size(); ++i) - queue_[i] = container::detail::move(r.queue_[i]); - } - - RingBuffer& operator=(RingBuffer&& r) { - head_ = container::detail::move(r.head_); - tail_ = container::detail::move(r.tail_); - for (size_t i = 0; i < r.size(); ++i) - queue_[i] = container::detail::move(r.queue_[i]); - return *this; - } - - virtual ~RingBuffer() {} - - size_t capacity() const { return N; }; - size_t size() const { return abs(tail_.raw_pos() - head_.raw_pos()); } - inline const T* data() const { return &(get(head_)); } - T* data() { return &(get(head_)); } - bool empty() const { return tail_ == head_; } - void clear() { - head_.reset(); - tail_.reset(); - } - - void pop() { - pop_front(); - } - void pop_front() { - if (size() == 0) return; - if (size() == 1) - clear(); - else - increment_head(); - } - void pop_back() { - if (size() == 0) return; - if (size() == 1) - clear(); - else - decrement_tail(); - } - - void push(const T& data) { - push_back(data); - } - void push(T&& data) { - push_back(data); - } - void push_back(const T& data) { - get(tail_) = data; - increment_tail(); - }; - void push_back(T&& data) { - get(tail_) = data; - increment_tail(); - }; - void push_front(const T& data) { - get(head_) = data; - decrement_head(); - }; - void push_front(T&& data) { - get(head_) = data; - decrement_head(); - }; - void emplace(const T& data) { push(data); } - void emplace(T&& data) { push(data); } - void emplace_back(const T& data) { push_back(data); } - void emplace_back(T&& data) { push_back(data); } - - const T& front() const { return get(head_); }; - T& front() { return get(head_); }; - - const T& back() const { return get(size() - 1); } - T& back() { return get(size() - 1); } - - const T& operator[](size_t index) const { return get((int)index); } - T& operator[](size_t index) { return get((int)index); } - - iterator begin() { return empty() ? Iterator() : head_; } - iterator end() { return empty() ? Iterator() : tail_; } - const_iterator begin() const { return empty() ? Iterator() : head_; } - const_iterator end() const { return empty() ? Iterator() : tail_; } - - iterator erase(const iterator& p) { - if (!is_valid(p)) return end(); - - iterator it_last = begin() + size() - 1; - for (iterator it = p; it != it_last; ++it) - *it = *(it + 1); - *it_last = T(); - decrement_tail(); - return empty() ? end() : p; - } - - void resize(size_t sz) { - size_t s = size(); - if (sz > size()) { - for (size_t i = 0; i < sz - s; ++i) push(T()); - } else if (sz < size()) { - for (size_t i = 0; i < s - sz; ++i) pop(); - } - } - - void assign(const_iterator first, const_iterator end) { - clear(); - while (first != end) push(*(first++)); - } - - void assign(const T* first, const T* end) { - clear(); - // T* it = first; - while (first != end) push(*(first++)); - } - - void shrink_to_fit() { - // dummy - } - - void reserve(size_t n) { - (void)n; - // dummy - } - - void fill(const T& v) { - iterator it = begin(); - while (it != end()) { - *it = v; - ++it; - } - } - - void insert(const_iterator pos, const_iterator first, const_iterator last) { - if (pos != end()) { - size_t sz = 0; - { - for (iterator it = first; it != last; ++it) ++sz; - } - iterator it = end() + sz - 1; - for (int i = sz; i > 0; --i, --it) - *it = *(it - sz); - it = pos; - for (size_t i = 0; i < sz; ++i) - *it = *(first + i); - } else { - for (iterator it = first; it != last; ++it) - push_back(*it); - } - } - - void insert(const_iterator pos, const T* first, const T* last) { - if (pos != end()) { - size_t sz = 0; - { - for (const T* it = first; it != last; ++it) ++sz; - } - iterator it = end() + sz - 1; - for (int i = sz; i > 0; --i, --it) - *it = *(it - sz); - it = pos; - for (size_t i = 0; i < sz; ++i) - *it = *(first + i); - } else { - for (const T* it = first; it != last; ++it) - push_back(*it); - } - } - -private: - T& get(const Iterator& it) { - return queue_[it.index()]; - } - const T& get(const Iterator& it) const { - return queue_[it.index()]; - } - T& get(const int index) { - return queue_[head_.index_with_offset(index)]; - } - const T& get(const int index) const { - return queue_[head_.index_with_offset(index)]; - } - - T* ptr(const Iterator& it) { - return (T*)(queue_ + it.index()); - } - const T* ptr(const Iterator& it) const { - return (T*)(queue_ + it.index()); - } - T* ptr(const int index) { - return (T*)(queue_ + head_.index_with_offset(index)); - } - const T* ptr(const int index) const { - return (T*)(queue_ + head_.index_with_offset(index)); - } - - void increment_head() { - ++head_; - resolve_overflow(); - } - void increment_tail() { - ++tail_; - resolve_overflow(); - if (size() > N) - increment_head(); - } - void decrement_head() { - --head_; - resolve_overflow(); - if (size() > N) - decrement_tail(); - } - void decrement_tail() { - --tail_; - resolve_overflow(); - } - - void resolve_overflow() { - if (empty()) - clear(); - else if (head_.raw_pos() > tail_.raw_pos()) { - // the same value will be obtained regardless of which of the head tail overflows - int len = (INT_MAX - head_.raw_pos()) + (tail_.raw_pos() - INT_MIN); - clear(); - tail_.set(len); - } - } - - bool is_valid(const iterator& it) { - return (it.raw_pos() >= head_.raw_pos()) && (it.raw_pos() < tail_.raw_pos()); - } -}; - -template -bool operator==(const RingBuffer& x, const RingBuffer& y) { - if (x.size() != y.size()) return false; - for (size_t i = 0; i < x.size(); ++i) - if (x[i] != y[i]) return false; - return true; -} - -template -bool operator!=(const RingBuffer& x, const RingBuffer& y) { - return !(x == y); -} - -template -struct vector : public RingBuffer { - using iterator = typename RingBuffer::iterator; - using const_iterator = typename RingBuffer::const_iterator; - - vector() - : RingBuffer() {} - vector(std::initializer_list lst) - : RingBuffer(lst) {} - - // copy - vector(const vector& r) - : RingBuffer(r) {} - - vector& operator=(const vector& r) { - RingBuffer::operator=(r); - return *this; - } - - // move - vector(vector&& r) - : RingBuffer(r) {} - - vector& operator=(vector&& r) { - RingBuffer::operator=(r); - return *this; - } - - virtual ~vector() {} - -private: - using RingBuffer::pop; - using RingBuffer::pop_front; - using RingBuffer::push; - using RingBuffer::push_front; - using RingBuffer::emplace; - using RingBuffer::fill; -}; - -template -struct array : public RingBuffer { - using iterator = typename RingBuffer::iterator; - using const_iterator = typename RingBuffer::const_iterator; - - array() - : RingBuffer() {} - array(std::initializer_list lst) - : RingBuffer(lst) {} - - // copy - array(const array& r) - : RingBuffer(r) {} - - array& operator=(const array& r) { - RingBuffer::operator=(r); - return *this; - } - - // move - array(array&& r) - : RingBuffer(r) {} - - array& operator=(array&& r) { - RingBuffer::operator=(r); - return *this; - } - - virtual ~array() {} - -private: - using RingBuffer::pop; - using RingBuffer::pop_front; - using RingBuffer::push; - using RingBuffer::push_front; - using RingBuffer::emplace; -}; - -template -struct deque : public RingBuffer { - using iterator = typename RingBuffer::iterator; - using const_iterator = typename RingBuffer::const_iterator; - - deque() - : RingBuffer() {} - deque(std::initializer_list lst) - : RingBuffer(lst) {} - - // copy - deque(const deque& r) - : RingBuffer(r) {} - - deque& operator=(const deque& r) { - RingBuffer::operator=(r); - return *this; - } - - // move - deque(deque&& r) - : RingBuffer(r) {} - - deque& operator=(deque&& r) { - RingBuffer::operator=(r); - return *this; - } - - virtual ~deque() {} - -private: - using RingBuffer::capacity; - using RingBuffer::pop; - using RingBuffer::push; - using RingBuffer::emplace; - using RingBuffer::assign; - using RingBuffer::begin; - using RingBuffer::end; - using RingBuffer::fill; -}; - -template -struct pair { - T1 first; - T2 second; -}; - -template -pair make_pair(const T1& t1, const T2& t2) { - return {t1, t2}; -}; - -template -bool operator==(const pair& x, const pair& y) { - return (x.first == y.first) && (x.second == y.second); -} - -template -bool operator!=(const pair& x, const pair& y) { - return !(x == y); -} - -template -struct map : public RingBuffer, N> { - using iterator = typename RingBuffer, N>::iterator; - using const_iterator = typename RingBuffer, N>::const_iterator; - using base = RingBuffer, N>; - - map() - : base() {} - map(std::initializer_list > lst) - : base(lst) {} - - // copy - map(const map& r) - : base(r) {} - - map& operator=(const map& r) { - base::operator=(r); - return *this; - } - - // move - map(map&& r) - : RingBuffer(r) {} - - map& operator=(map&& r) { - base::operator=(r); - return *this; - } - - virtual ~map() {} - - const_iterator find(const Key& key) const { - for (size_t i = 0; i < this->size(); ++i) { - const_iterator it = this->begin() + i; - if (key == it->first) - return it; - } - return this->end(); - } - - iterator find(const Key& key) { - for (size_t i = 0; i < this->size(); ++i) { - iterator it = this->begin() + i; - if (key == it->first) - return it; - } - return this->end(); - } - - pair insert(const Key& key, const T& t) { - bool b {false}; - iterator it = find(key); - if (it == this->end()) { - this->push(make_pair(key, t)); - b = true; - it = this->begin() + this->size() - 1; - } - return {it, b}; - } - - pair insert(const pair& p) { - bool b {false}; - iterator it = find(p.first); - if (it == this->end()) { - this->push(p); - b = true; - it = this->begin() + this->size() - 1; - } - return {it, b}; - } - - pair emplace(const Key& key, const T& t) { - return insert(key, t); - } - - pair emplace(const pair& p) { - return insert(p); - } - - const T& at(const Key& key) const { - // iterator it = find(key); - // if (it != this->end()) return it->second; - // return T(); - return find(key)->second; - } - - T& at(const Key& key) { - // iterator it = find(key); - // if (it != this->end()) return it->second; - // return T(); - return find(key)->second; - } - - iterator erase(const iterator& it) { - iterator i = (iterator)find(it->first); - return base::erase(i); - } - - iterator erase(const Key& key) { - iterator i = find(key); - return base::erase(i); - } - - iterator erase(const size_t index) { - if (index < this->size()) { - iterator it = this->begin() + index; - erase(it); - } - return this->end(); - } - - T& operator[](const Key& key) { - iterator it = find(key); - if (it != this->end()) return it->second; - - insert(::arx::make_pair(key, T())); - return this->back().second; - } - -private: - using base::assign; - using base::back; - using base::capacity; - using base::data; - using base::emplace_back; - using base::front; - using base::pop; - using base::pop_back; - using base::pop_front; - using base::push; - using base::push_back; - using base::push_front; - using base::resize; - using base::shrink_to_fit; - using base::fill; -}; - -} // namespace arx - -template -using ArxRingBuffer = arx::RingBuffer; - -#endif // Do not have libstdc++11 -#endif // ARX_RINGBUFFER_H diff --git a/Tween/util/ArxContainer/ArxContainer/has_include.h b/Tween/util/ArxContainer/ArxContainer/has_include.h deleted file mode 100644 index d605d71..0000000 --- a/Tween/util/ArxContainer/ArxContainer/has_include.h +++ /dev/null @@ -1,30 +0,0 @@ -#pragma once - -#ifndef ARX_TYPE_TRAITS_HAS_INCLUDE_H -#define ARX_TYPE_TRAITS_HAS_INCLUDE_H - - // Check whether __has_include is available, but also check the GCC - // version (__has_include was introduced in gcc 5) to catch - // environments (such as ESP8266) where gcc is old, but some system - // header provides a fake __has_include. We also need to check - // against __clang__ here, since clang pretends to be GCC - // 4.something and would otherwise be detected incorrectly here... - #if !defined(__has_include) || defined(__GNUC__) && __GNUC__ < 5 && !defined(__clang__) - #if defined(ARDUINO_ARCH_ESP8266) - // ESP8266 does not have a working __has_include, but we - // know it does have a working libstdc++ with all the - // headers we care about, so provide a fake has_include - #define ARX_SYSTEM_HAS_INCLUDE(x) 1 - #elif defined(ARDUINO_SAM_DUE) - // Arduino DUE's GCC version is 4.8.3 (GCC < 5.0). - // If libstdc++ is used, std::function causes error - // so currently we disable libstdc++ and use ArxTypeTraits - #define ARX_SYSTEM_HAS_INCLUDE(x) 0 - #else - #error "Compiler does not support __has_include, please report a bug against the ArxTypeTraits library about this." - #endif - #else - #define ARX_SYSTEM_HAS_INCLUDE(x) __has_include(x) - #endif - -#endif // ARX_TYPE_TRAITS_HAS_INCLUDE_H diff --git a/Tween/util/ArxContainer/ArxContainer/has_libstdcplusplus.h b/Tween/util/ArxContainer/ArxContainer/has_libstdcplusplus.h deleted file mode 100644 index 23f2b26..0000000 --- a/Tween/util/ArxContainer/ArxContainer/has_libstdcplusplus.h +++ /dev/null @@ -1,35 +0,0 @@ -#pragma once - -#ifndef ARX_TYPE_TRAITS_HAS_LIBSTDCPLUSPLUS_H -#define ARX_TYPE_TRAITS_HAS_LIBSTDCPLUSPLUS_H - -#if !defined(ARX_HAVE_LIBSTDCPLUSPLUS) - #if ARX_SYSTEM_HAS_INCLUDE() && !defined(ARDUINO_spresense_ast) - #include - #if defined(__GLIBCXX__) || defined(_LIBCPP_VERSION) - // For gcc's libstdc++ and clang's libc++, assume that - // __cplusplus tells us what the standard includes support - #define ARX_HAVE_LIBSTDCPLUSPLUS __cplusplus - #elif defined(_CPPLIB_VER) - #if _CPPLIB_VER > 650 - #define ARX_HAVE_LIBSTDCPLUSPLUS 201703L // C++17 - #elif _CPPLIB_VER == 650 - #define ARX_HAVE_LIBSTDCPLUSPLUS 201402L // C++14 - #elif _CPPLIB_VER >= 610 - #define ARX_HAVE_LIBSTDCPLUSPLUS 201103L // C++11 - #else - #define ARX_HAVE_LIBSTDCPLUSPLUS 199711L // C++98 - #endif - #elif defined(__UCLIBCXX_MAJOR__) - // For uclibc++, assume C++98 support only. - #define ARX_HAVE_LIBSTDCPLUSPLUS 199711L - #else - #error "Unknown C++ library found, please report a bug against the ArxTypeTraits library about this." - #endif - #else - // Assume no standard library is available at all (e.g. on AVR) - #define ARX_HAVE_LIBSTDCPLUSPLUS 0 - #endif -#endif - -#endif // ARX_TYPE_TRAITS_HAS_LIBSTDCPLUSPLUS_H diff --git a/Tween/util/ArxContainer/ArxContainer/initializer_list.h b/Tween/util/ArxContainer/ArxContainer/initializer_list.h deleted file mode 100644 index 374aa27..0000000 --- a/Tween/util/ArxContainer/ArxContainer/initializer_list.h +++ /dev/null @@ -1,32 +0,0 @@ -#pragma once - -#ifndef ARX_TYPE_TRAITS_INITIALIZER_H -#define ARX_TYPE_TRAITS_INITIALIZER_H - -// Initializer_list *must* be defined in std, so take extra care to only -// define it when is really not available (e.g. -// ArduinoSTL is C++98 but *does* define ) and not -// already defined (e.g. by ArxContainer). -#if ARX_SYSTEM_HAS_INCLUDE() -#include -#else -namespace std { -template -class initializer_list { -private: - const T* array; - size_t len; - initializer_list(const T* a, size_t l) - : array(a), len(l) {} - -public: - initializer_list() - : array(nullptr), len(0) {} - size_t size() const { return len; } - const T* begin() const { return array; } - const T* end() const { return array + len; } -}; -} // namespace std -#endif - -#endif // ARX_TYPE_TRAITS_INITIALIZER_LIST_H diff --git a/Tween/util/ArxContainer/ArxContainer/replace_minmax_macros.h b/Tween/util/ArxContainer/ArxContainer/replace_minmax_macros.h deleted file mode 100644 index f8ff86e..0000000 --- a/Tween/util/ArxContainer/ArxContainer/replace_minmax_macros.h +++ /dev/null @@ -1,35 +0,0 @@ -#pragma once - -#ifndef ARX_TYPE_TRAITS_REPLACE_MINMAX_MACROS_H -#define ARX_TYPE_TRAITS_REPLACE_MINMAX_MACROS_H - -// Make sure Arduino.h is actually included, since otherwise it might be -// included later and break *uses* of the min/max methods, rather than -// the declarations of it. -#ifdef ARDUINO - #include -#endif - -// These macros are defined by Arduino.h on some platforms, and conflict -// with min/max methods defined or included by ArxTypeTraits, so replace -// them with macros here. -#ifdef max - #undef max - template - constexpr auto max(T1 x, T2 y) - -> decltype(x + y) - { - return (x > y) ? x : y; - } -#endif -#ifdef min - #undef min - template - constexpr auto min(T1 x, T2 y) - -> decltype(x + y) - { - return (x < y) ? x : y; - } -#endif - -#endif // ARX_TYPE_TRAITS_REPLACE_MINMAX_MACROS_H diff --git a/Tween/util/ArxContainer/LICENSE b/Tween/util/ArxContainer/LICENSE deleted file mode 100644 index 8c86460..0000000 --- a/Tween/util/ArxContainer/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2019 Hideaki Tai - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/Tween/util/ArxContainer/README.md b/Tween/util/ArxContainer/README.md deleted file mode 100644 index c06c0b8..0000000 --- a/Tween/util/ArxContainer/README.md +++ /dev/null @@ -1,194 +0,0 @@ -# ArxContainer - -C++ container-like classes (`vector`, `array`, `deque`, `map` etc.) for Arduino which cannot use STL - -## Note - -- `ArxContainer` is C++ container-__like__ classes for Arduino - - Containers in this library is defined inside namespace `arx` instad of `std` (e.g. `arx::vector`) - - All of the functions is not supported currently -- If standard libraries are available, automatically use `std` version instead of `arx` version - - -## Supported Container Types - -- `vector` -- `array` -- `map` (`pair`) -- `deque` - - -## Supported Boards - -`arx` version of containers are enabled only if you use following architecture. -In other borads, `arx` version is disabled and standard libraries (`std` version) will be imported (because they can use them). - -- AVR (Uno, Nano, Mega, etc.) -- MEGAAVR (Uno WiFi, Nano Ecery, etc.) -- SAM (Due) - - -## Usage - -### vector - -```C++ -// initialize with initializer_list -arx::vector vs {1, 2, 3}; - -// add contents -for (size_t i = 4; i <= 5; ++i) - vs.push_back(i); - -// index access -for (size_t i = 0; i < vs.size(); ++i) - Serial.println(vs[i]); - -// range-based access -for (const auto& v : vs) - Serial.println(v); -``` - -### array - -```C++ -// initialize with initializer_list -arx::array arr {1, 2, 3}; - -// fill -arr.fill(123); - -// index access -for (size_t i = 0; i < arr.size(); ++i) - Serial.println(arr[i]); - -// range-based access -for (const auto& a : arr) - Serial.println(a); -``` - -### map - -``` C++ -// initialize with initializer_list -arx::map mp {{"one", 1}, {"two", 2}}; - -// add contents -mp.insert("three", 3); -mp["four"] = 4; - -// range based access -for (const auto& m : mp) -{ - Serial.print("{"); - Serial.print(m.first); Serial.print(","); - Serial.print(m.second); - Serial.println("}"); -} - -// key access -Serial.print("one = "); Serial.println(mp["one"]); -Serial.print("two = "); Serial.println(mp["two"]); -Serial.print("three = "); Serial.println(mp["three"]); -Serial.print("four = "); Serial.println(mp["four"]); -``` - -### deque - -```C++ -// initialize with initializer_list -arx::deque dq {1, 2, 3}; - -// add contents -for (int i = 4; i <= 5; ++i) - dq.push_back(i); - -// index access -for (int i = 0; i < dq.size(); ++i) - Serial.print(dq[i]); -``` - - -## Detail - -`ArxContainer` is C++ container-__like__ classes for Arduino. -This library is based on `arx::RingBuffer` and `arx::xxxx` is limited-size container. -`arx::RingBuffer` can be used as: - -```C++ -ArxRingBuffer buffer; - -buffer.push(1); -buffer.push(2); -buffer.push(3); - -for(size_t i = 0; i < buffer.size(); ++i) - Serial.println(buffer[i]); - -buffer.pop(); - -for(auto& b : buffer) - Serial.println(b); -``` - -`arx::xxxx` are derived from `RingBuffer` and defined as: - -``` C++ -namespace arx { - template - struct vector : public RingBuffer - - template - struct array : public RingBuffer - - template - struct map : public RingBuffer, N> - - template - struct deque : public RingBuffer -} -``` - -So range-based loop cannot be applyed to `arx::deque` (iterator is not continuous because it is based on `RingBuffer`). - - -### Manage Size Limit of Container - -Global default size of container can be changed by defining these macros before `#include `. - -``` C++ -#define ARX_VECTOR_DEFAULT_SIZE XX // default: 16 -#define ARX_MAP_DEFAULT_SIZE XX // default: 16 -#define ARX_DEQUE_DEFAULT_SIZE XX // default: 16 -``` - -Or you can change each container size by template argument. - -``` C++ -arx::vector vs; -arx::map ms; -arx::deque ds; -``` - -## Roadmap - -This library will be updated if I want to use more container interfaces on supported boards shown above. -PRs are welcome! - - -## Used Inside of - -- [Packetizer](https://github.com/hideakitai/Packetizer) -- [MsgPack](https://github.com/hideakitai/MsgPack) -- [ArduinoOSC](https://github.com/hideakitai/ArduinoOSC) -- [ArtNet](https://github.com/hideakitai/ArtNet) -- [Tween](https://github.com/hideakitai/Tween) -- [TimeProfiler](https://github.com/hideakitai/TimeProfiler) -- [TaskManager](https://github.com/hideakitai/TaskManager) -- [ArxStringUtils](https://github.com/hideakitai/ArxStringUtils) -- [Debouncer](https://github.com/hideakitai/Debouncer) - - -## License - -MIT diff --git a/Tween/util/ArxContainer/library.json b/Tween/util/ArxContainer/library.json deleted file mode 100644 index baf2512..0000000 --- a/Tween/util/ArxContainer/library.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "name": "ArxContainer", - "keywords": "ringbuffer, vector, deque, map", - "description": "C++ container-like classes (vector, map, etc.) for Arduino which cannot use STL", - "repository": { - "type": "git", - "url": "https://github.com/hideakitai/ArxContainer.git" - }, - "authors": { - "name": "Hideaki Tai", - "url": "https://github.com/hideakitai", - "maintainer": true - }, - "version": "0.4.0", - "license": "MIT", - "frameworks": "arduino", - "platforms": "*" -} diff --git a/Tween/util/ArxContainer/library.properties b/Tween/util/ArxContainer/library.properties deleted file mode 100644 index c04d569..0000000 --- a/Tween/util/ArxContainer/library.properties +++ /dev/null @@ -1,9 +0,0 @@ -name=ArxContainer -version=0.4.0 -author=hideakitai -maintainer=hideakitai -sentence=C++ container-like classes (vector, map, etc.) for Arduino which cannot use STL -paragraph=C++ container-like classes (vector, map, etc.) for Arduino which cannot use STL -category=Data Storage -url=https://github.com/hideakitai/ArxContainer -architectures=* diff --git a/Tween/util/ArxSmartPtr/ArxSmartPtr.h b/Tween/util/ArxSmartPtr/ArxSmartPtr.h deleted file mode 100644 index 6a0240b..0000000 --- a/Tween/util/ArxSmartPtr/ArxSmartPtr.h +++ /dev/null @@ -1,46 +0,0 @@ -#pragma once - -#ifndef ARX_SMART_PTR_H -#define ARX_SMART_PTR_H - -#ifdef ARDUINO - #include -#endif - -#include "ArxSmartPtr/detail/has_include.h" -#include "ArxSmartPtr/detail/has_libstdcplusplus.h" - -// Make sure std namespace exists -namespace std { } - -// Import everything from the std namespace into arx::std, so that -// anything we import rather than define is also available through -// arx::stdx. -// This includes everything yet to be defined, so we can do this early -// (and must do so, to allow e.g. the C++14 additions in the arx::std -// namespace to reference the C++11 stuff from the system headers. -namespace arx { - namespace stdx { - using namespace ::std; - } -} - -// Import everything from arx::std back into the normal std namespace. -// This ensures that you can just use `std::foo` everywhere and you get -// the standard library version if it is available, falling back to arx -// versions for things not supplied by the standard library. Only when -// you really need the arx version (e.g. for constexpr numeric_limits -// when also using ArduinoSTL), you need to qualify with arx::stdx:: -namespace std { - using namespace ::arx::stdx; -} - -#include "ArxSmartPtr/detail/replace_minmax_macros.h" - -#if ARX_HAVE_LIBSTDCPLUSPLUS >= 201103L // Have libstdc++11 - #include -#else - #include "ArxSmartPtr/shared_ptr.h" -#endif - -#endif // ARX_SMART_PTR_H diff --git a/Tween/util/ArxSmartPtr/ArxSmartPtr/LICENSE_1_0.txt b/Tween/util/ArxSmartPtr/ArxSmartPtr/LICENSE_1_0.txt deleted file mode 100644 index 127a5bc..0000000 --- a/Tween/util/ArxSmartPtr/ArxSmartPtr/LICENSE_1_0.txt +++ /dev/null @@ -1,23 +0,0 @@ -Boost Software License - Version 1.0 - August 17th, 2003 - -Permission is hereby granted, free of charge, to any person or organization -obtaining a copy of the software and accompanying documentation covered by -this license (the "Software") to use, reproduce, display, distribute, -execute, and transmit the Software, and to prepare derivative works of the -Software, and to permit third-parties to whom the Software is furnished to -do so, all subject to the following: - -The copyright notices in the Software and this entire statement, including -the above license grant, this restriction and the following disclaimer, -must be included in all copies of the Software, in whole or in part, and -all derivative works of the Software, unless such copies or derivative -works are solely in the form of machine-executable object code generated by -a source language processor. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT -SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE -FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, -ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/Tween/util/ArxSmartPtr/ArxSmartPtr/detail/has_include.h b/Tween/util/ArxSmartPtr/ArxSmartPtr/detail/has_include.h deleted file mode 100644 index d605d71..0000000 --- a/Tween/util/ArxSmartPtr/ArxSmartPtr/detail/has_include.h +++ /dev/null @@ -1,30 +0,0 @@ -#pragma once - -#ifndef ARX_TYPE_TRAITS_HAS_INCLUDE_H -#define ARX_TYPE_TRAITS_HAS_INCLUDE_H - - // Check whether __has_include is available, but also check the GCC - // version (__has_include was introduced in gcc 5) to catch - // environments (such as ESP8266) where gcc is old, but some system - // header provides a fake __has_include. We also need to check - // against __clang__ here, since clang pretends to be GCC - // 4.something and would otherwise be detected incorrectly here... - #if !defined(__has_include) || defined(__GNUC__) && __GNUC__ < 5 && !defined(__clang__) - #if defined(ARDUINO_ARCH_ESP8266) - // ESP8266 does not have a working __has_include, but we - // know it does have a working libstdc++ with all the - // headers we care about, so provide a fake has_include - #define ARX_SYSTEM_HAS_INCLUDE(x) 1 - #elif defined(ARDUINO_SAM_DUE) - // Arduino DUE's GCC version is 4.8.3 (GCC < 5.0). - // If libstdc++ is used, std::function causes error - // so currently we disable libstdc++ and use ArxTypeTraits - #define ARX_SYSTEM_HAS_INCLUDE(x) 0 - #else - #error "Compiler does not support __has_include, please report a bug against the ArxTypeTraits library about this." - #endif - #else - #define ARX_SYSTEM_HAS_INCLUDE(x) __has_include(x) - #endif - -#endif // ARX_TYPE_TRAITS_HAS_INCLUDE_H diff --git a/Tween/util/ArxSmartPtr/ArxSmartPtr/detail/has_libstdcplusplus.h b/Tween/util/ArxSmartPtr/ArxSmartPtr/detail/has_libstdcplusplus.h deleted file mode 100644 index 23f2b26..0000000 --- a/Tween/util/ArxSmartPtr/ArxSmartPtr/detail/has_libstdcplusplus.h +++ /dev/null @@ -1,35 +0,0 @@ -#pragma once - -#ifndef ARX_TYPE_TRAITS_HAS_LIBSTDCPLUSPLUS_H -#define ARX_TYPE_TRAITS_HAS_LIBSTDCPLUSPLUS_H - -#if !defined(ARX_HAVE_LIBSTDCPLUSPLUS) - #if ARX_SYSTEM_HAS_INCLUDE() && !defined(ARDUINO_spresense_ast) - #include - #if defined(__GLIBCXX__) || defined(_LIBCPP_VERSION) - // For gcc's libstdc++ and clang's libc++, assume that - // __cplusplus tells us what the standard includes support - #define ARX_HAVE_LIBSTDCPLUSPLUS __cplusplus - #elif defined(_CPPLIB_VER) - #if _CPPLIB_VER > 650 - #define ARX_HAVE_LIBSTDCPLUSPLUS 201703L // C++17 - #elif _CPPLIB_VER == 650 - #define ARX_HAVE_LIBSTDCPLUSPLUS 201402L // C++14 - #elif _CPPLIB_VER >= 610 - #define ARX_HAVE_LIBSTDCPLUSPLUS 201103L // C++11 - #else - #define ARX_HAVE_LIBSTDCPLUSPLUS 199711L // C++98 - #endif - #elif defined(__UCLIBCXX_MAJOR__) - // For uclibc++, assume C++98 support only. - #define ARX_HAVE_LIBSTDCPLUSPLUS 199711L - #else - #error "Unknown C++ library found, please report a bug against the ArxTypeTraits library about this." - #endif - #else - // Assume no standard library is available at all (e.g. on AVR) - #define ARX_HAVE_LIBSTDCPLUSPLUS 0 - #endif -#endif - -#endif // ARX_TYPE_TRAITS_HAS_LIBSTDCPLUSPLUS_H diff --git a/Tween/util/ArxSmartPtr/ArxSmartPtr/detail/replace_minmax_macros.h b/Tween/util/ArxSmartPtr/ArxSmartPtr/detail/replace_minmax_macros.h deleted file mode 100644 index f8ff86e..0000000 --- a/Tween/util/ArxSmartPtr/ArxSmartPtr/detail/replace_minmax_macros.h +++ /dev/null @@ -1,35 +0,0 @@ -#pragma once - -#ifndef ARX_TYPE_TRAITS_REPLACE_MINMAX_MACROS_H -#define ARX_TYPE_TRAITS_REPLACE_MINMAX_MACROS_H - -// Make sure Arduino.h is actually included, since otherwise it might be -// included later and break *uses* of the min/max methods, rather than -// the declarations of it. -#ifdef ARDUINO - #include -#endif - -// These macros are defined by Arduino.h on some platforms, and conflict -// with min/max methods defined or included by ArxTypeTraits, so replace -// them with macros here. -#ifdef max - #undef max - template - constexpr auto max(T1 x, T2 y) - -> decltype(x + y) - { - return (x > y) ? x : y; - } -#endif -#ifdef min - #undef min - template - constexpr auto min(T1 x, T2 y) - -> decltype(x + y) - { - return (x < y) ? x : y; - } -#endif - -#endif // ARX_TYPE_TRAITS_REPLACE_MINMAX_MACROS_H diff --git a/Tween/util/ArxSmartPtr/ArxSmartPtr/detail/shared_count.h b/Tween/util/ArxSmartPtr/ArxSmartPtr/detail/shared_count.h deleted file mode 100644 index a634a6d..0000000 --- a/Tween/util/ArxSmartPtr/ArxSmartPtr/detail/shared_count.h +++ /dev/null @@ -1,159 +0,0 @@ -#pragma once - -#ifndef ARX_SMART_PTR_DETAIL_SHARED_COUNT_H -#define ARX_SMART_PTR_DETAIL_SHARED_COUNT_H - -#ifdef ARDUINO - #include -#endif - -// imported and simplified from https://github.com/boostorg/smart_ptr - -namespace arx { namespace stdx { - - namespace detail - { - class sp_counted_base - { - sp_counted_base(const sp_counted_base&) = delete; - sp_counted_base& operator= (const sp_counted_base&) = delete; - - int use_count_; - - public: - - sp_counted_base() : use_count_(1) {} - virtual ~sp_counted_base() {} - - virtual void dispose() = 0; - - void add_ref() - { - ++use_count_; - } - - void release() - { - if (--use_count_ == 0) - dispose(); - } - - long use_count() const - { - return static_cast(use_count_); - } - }; - - - template - class sp_counted_impl : public sp_counted_base - { - T* ptr; - - sp_counted_impl(const sp_counted_impl&) = delete; - sp_counted_impl& operator= (const sp_counted_impl&) = delete; - - typedef sp_counted_impl this_type; - - public: - - sp_counted_impl(T* ptr) : ptr(ptr) {} - virtual ~sp_counted_impl() {} - - virtual void dispose() override - { - delete ptr; - } - }; - - - - class shared_count - { - private: - - sp_counted_base* pi_; - - public: - - shared_count() : pi_(0) - { - } - - explicit shared_count(sp_counted_base* p) : pi_(p) - { - } - - template - explicit shared_count(Y* p) : pi_(0) - { - pi_ = new sp_counted_impl(p); - - if(pi_ == 0) - { - delete p; - } - } - - ~shared_count() - { - if(pi_ != 0) pi_->release(); - } - - shared_count(const shared_count& r) : pi_(r.pi_) - { - if(pi_ != 0) pi_->add_ref(); - } - - shared_count(shared_count&& r) : pi_(r.pi_) - { - r.pi_ = 0; - } - - shared_count& operator= (const shared_count& r) - { - sp_counted_base* tmp = r.pi_; - if(tmp != pi_) - { - if(tmp != 0) tmp->add_ref(); - if(pi_ != 0) pi_->release(); - pi_ = tmp; - } - return *this; - } - - void swap(shared_count& r) - { - sp_counted_base* tmp = r.pi_; - r.pi_ = pi_; - pi_ = tmp; - } - - long use_count() const - { - return (pi_ != 0) ? pi_->use_count() : 0; - } - - bool unique() const - { - return use_count() == 1; - } - - bool empty() const - { - return pi_ == 0; - } - - friend inline bool operator== (const shared_count& a, const shared_count& b) - { - return a.pi_ == b.pi_; - } - }; - - } // namespace detail - -}} // namespace arx::stdx - - - -#endif // ARX_SMART_PTR_DETAIL_SHARED_COUNT_H diff --git a/Tween/util/ArxSmartPtr/ArxSmartPtr/shared_ptr.h b/Tween/util/ArxSmartPtr/ArxSmartPtr/shared_ptr.h deleted file mode 100644 index 34fd8ce..0000000 --- a/Tween/util/ArxSmartPtr/ArxSmartPtr/shared_ptr.h +++ /dev/null @@ -1,377 +0,0 @@ -#pragma once - -#ifndef ARX_SMART_PTR_SHARED_PTR_H -#define ARX_SMART_PTR_SHARED_PTR_H - -#ifdef ARDUINO - #include -#endif -#include "detail/shared_count.h" - -// imported and simplified from https://github.com/boostorg/smart_ptr - -namespace arx { namespace stdx -{ - template class shared_ptr; - - namespace sp - { - namespace detail - { - typedef decltype(nullptr) nullptr_t; - - template T&& move(T& t) { return static_cast(t); } - - template T forward(T t) { return t; } - - template - void swap(T& a, T& b) - { - T t = move(a); - a = move(b); - b = move(t); - } - } - - // element, element_type - - template struct element { typedef T type; }; - template struct element { typedef T type; }; - template struct element { typedef T type; }; - - // dereference, return type of operator* - - template struct dereference { typedef T& type; }; - template<> struct dereference { typedef void type; }; - template<> struct dereference { typedef void type; }; - template<> struct dereference { typedef void type; }; - template<> struct dereference { typedef void type; }; - template struct dereference { typedef void type; }; - template struct dereference { typedef void type; }; - - // member_access, return type of operator-> - - template struct member_access { typedef T* type; }; - template struct member_access { typedef void type; }; - template struct member_access { typedef void type; }; - - // array_access, return type of operator[] - - template struct array_access { typedef void type; }; - template struct array_access { typedef T& type; }; - template struct array_access { typedef T& type; }; - } - - - template class shared_ptr - { - public: - - typedef typename sp::element::type element_type; - - private: - - typedef shared_ptr this_type; - - template friend class shared_ptr; - - element_type* px; - detail::shared_count pn; - - public: - - shared_ptr() : px(0), pn() - { - } - - shared_ptr(sp::detail::nullptr_t) : px(0), pn() - { - } - - template - explicit shared_ptr(Y* p): px(p), pn() - { - detail::shared_count(p).swap(pn); - } - - shared_ptr(const shared_ptr& r) : px(r.px), pn(r.pn) - { - } - - template - shared_ptr(const shared_ptr& r) - : px(r.px), pn(r.pn) - { - } - - template - shared_ptr(const shared_ptr& r, element_type* p) : px(p), pn(r.pn) - { - } - - shared_ptr& operator= (const shared_ptr& r) - { - this_type(r).swap(*this); - return *this; - } - - template - shared_ptr& operator= (const shared_ptr& r) - { - this_type(r).swap(*this); - return *this; - } - - shared_ptr(shared_ptr&& r) : px(r.px), pn() - { - pn.swap(r.pn); - r.px = 0; - } - - template - shared_ptr(shared_ptr&& r) - : px(r.px), pn() - { - pn.swap( r.pn ); - r.px = 0; - } - - shared_ptr& operator= (shared_ptr&& r) - { - this_type(static_cast(r)).swap(*this); - return *this; - } - - template - shared_ptr & operator= (shared_ptr&& r) - { - this_type(static_cast&&>(r)).swap(*this); - return *this; - } - - template - shared_ptr(shared_ptr&& r, element_type* p) : px(p), pn() - { - pn.swap( r.pn ); - r.px = 0; - } - - shared_ptr& operator= (sp::detail::nullptr_t) - { - this_type().swap(*this); - return *this; - } - - void reset() - { - this_type().swap(*this); - } - - template - void reset(Y* p) - { - this_type(p).swap(*this); - } - - template - void reset(const shared_ptr& r, element_type* p) - { - this_type(r, p).swap(*this); - } - - template - void reset(shared_ptr&& r, element_type* p) - { - this_type(static_cast&&>(r), p).swap(*this); - } - - typename sp::dereference::type operator* () const - { - return *px; - } - - typename sp::member_access::type operator-> () const - { - return px; - } - - typename sp::array_access::type operator[] (size_t i) const - { - return static_cast::type>(px[i]); - } - - element_type* get() const - { - return px; - } - - explicit operator bool () const - { - return px != 0; - } - - bool operator! () const - { - return px == 0; - } - - bool unique() const - { - return pn.unique(); - } - - long use_count() const - { - return pn.use_count(); - } - - void swap(shared_ptr& other) - { - sp::detail::swap(px, other.px); - pn.swap(other.pn); - } - - }; // shared_ptr - - - - template - inline bool operator== (const shared_ptr& a, const shared_ptr& b) - { - return a.get() == b.get(); - } - - template - inline bool operator!= (const shared_ptr& a, const shared_ptr& b) - { - return a.get() != b.get(); - } - - template - inline bool operator== (const shared_ptr& p, sp::detail::nullptr_t) - { - return p.get() == 0; - } - - template - inline bool operator== (sp::detail::nullptr_t, const shared_ptr& p ) - { - return p.get() == 0; - } - - template - inline bool operator!= (const shared_ptr& p, sp::detail::nullptr_t) - { - return p.get() != 0; - } - - template - inline bool operator!= (sp::detail::nullptr_t, const shared_ptr& p ) - { - return p.get() != 0; - } - - template - inline void swap(const shared_ptr& a, const shared_ptr& b) - { - a.swap(b); - } - - template - shared_ptr static_pointer_cast(const shared_ptr& r) - { - (void)static_cast(static_cast(0)); - - typedef typename shared_ptr::element_type E; - E* p = static_cast(r.get()); - return shared_ptr(r, p); - } - - template - shared_ptr const_pointer_cast(const shared_ptr& r) - { - (void)const_cast(static_cast(0)); - - typedef typename shared_ptr::element_type E; - E* p = const_cast(r.get()); - return shared_ptr(r, p); - } - - template - shared_ptr dynamic_pointer_cast(const shared_ptr& r) - { - (void)dynamic_cast(static_cast(0)); - - typedef typename shared_ptr::element_type E; - E* p = dynamic_cast(r.get()); - return p ? shared_ptr(r, p): shared_ptr(); - } - - template - shared_ptr reinterpret_pointer_cast(const shared_ptr& r) - { - (void)reinterpret_cast(static_cast(0) ); - - typedef typename shared_ptr::element_type E; - E* p = reinterpret_cast(r.get()); - return shared_ptr(r, p); - } - - template - shared_ptr static_pointer_cast(shared_ptr&& r) - { - (void)static_cast(static_cast(0)); - - typedef typename shared_ptr::element_type E; - E* p = static_cast(r.get()); - return shared_ptr(sp::detail::move(r), p); - } - - template - shared_ptr const_pointer_cast(shared_ptr&& r) - { - (void)const_cast(static_cast(0)); - - typedef typename shared_ptr::element_type E; - E* p = const_cast(r.get()); - return shared_ptr(sp::detail::move(r), p); - } - - template - shared_ptr dynamic_pointer_cast(shared_ptr&& r) - { - (void)dynamic_cast(static_cast(0)); - - typedef typename shared_ptr::element_type E; - E* p = dynamic_cast(r.get()); - return p ? shared_ptr(sp::detail::move(r), p) : shared_ptr(); - } - - template - shared_ptr reinterpret_pointer_cast(shared_ptr&& r) - { - (void)reinterpret_cast(static_cast(0)); - - typedef typename shared_ptr::element_type E; - E* p = reinterpret_cast(r.get()); - return shared_ptr(sp::detail::move(r), p); - } - - - // make_shared : for compatibility, just an alias of constructor - - template - shared_ptr make_shared() - { - return shared_ptr(new T); - } - - template - shared_ptr make_shared(Args&&... args) - { - return shared_ptr(new T(sp::detail::forward(args)...)); - } - -}} // namespace arx::stdx - -#endif // ARX_SMART_PTR_SHARED_PTR_H diff --git a/Tween/util/ArxSmartPtr/LICENSE b/Tween/util/ArxSmartPtr/LICENSE deleted file mode 100644 index 6f5269b..0000000 --- a/Tween/util/ArxSmartPtr/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2020 Hideaki Tai - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/Tween/util/ArxSmartPtr/README.md b/Tween/util/ArxSmartPtr/README.md deleted file mode 100644 index c4d6007..0000000 --- a/Tween/util/ArxSmartPtr/README.md +++ /dev/null @@ -1,77 +0,0 @@ -# ArxSmartPtr - -C++ smart pointer-like classes for Arduino which can't use standard smart pointers - - -## Note - -- `ArxSmartPtr` is C++ smart pointer-__like__ classes for Arduino. -- Most of the functions are imported and simplified based on [Boost.SmartPtr](https://github.com/boostorg/smart_ptr). -- Automatically use standard library first if the boards can use them - - -## Supported SmartPtr - -- `shared_ptr` - - -### Limitations - -- Custom Deleter cannot be used -- Custom Allocater cannot be used -- `std::make_shared` is just an alias for constructor - - -## Supported Boards - -This library is currently enabled only if you use following architecture. - -- AVR (Uno, Nano, Mega, etc.) -- MEGAAVR (Uno WiFi, Nano Ecery, etc.) -- SAM (Due) - - -## Usage - -Please see example for more information. - -``` C++ -{ - Serial.println("start"); - std::shared_ptr t1(new Base(4)); - std::shared_ptr t2; - { - std::shared_ptr t3(new Base(5)); - std::shared_ptr t4(new Base(6)); - t2 = t3; - } - Serial.println("end"); -} -// start -// Base::Constructor 4 -// Base::Constructor 5 -// Base::Constructor 6 -// Base::Destructor 6 -// end -// Base::Destructor 5 -// Base::Destructor 4 -``` - -## Used Inside of - -- [Packetizer](https://github.com/hideakitai/Packetizer) -- [MsgPacketizer](https://github.com/hideakitai/MsgPacketizer) -- [ArduinoOSC](https://github.com/hideakitai/ArduinoOSC) -- [Tween](https://github.com/hideakitai/Tween) -- [SceneManager](https://github.com/hideakitai/SceneManager) -- [TaskManager](https://github.com/hideakitai/TaskManager) - - -## Roadmap - -This library will be updated if I want to use more smart pointer interfaces on supported boards shown above. -PRs are welcome! - -## License - -MIT diff --git a/Tween/util/ArxSmartPtr/library.json b/Tween/util/ArxSmartPtr/library.json deleted file mode 100644 index ab81328..0000000 --- a/Tween/util/ArxSmartPtr/library.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "name": "ArxSmartPtr", - "keywords": "smart ptr, shared ptr, stl", - "description": "C++ smart pointer-like classes for Arduino which cannot use standard smart pointers", - "repository": { - "type": "git", - "url": "https://github.com/hideakitai/ArxSmartPtr.git" - }, - "authors": { - "name": "Hideaki Tai", - "url": "https://github.com/hideakitai", - "maintainer": true - }, - "version": "0.2.3", - "license": "MIT", - "frameworks": "arduino", - "platforms": "*" -} diff --git a/Tween/util/ArxSmartPtr/library.properties b/Tween/util/ArxSmartPtr/library.properties deleted file mode 100644 index b0ddcdf..0000000 --- a/Tween/util/ArxSmartPtr/library.properties +++ /dev/null @@ -1,9 +0,0 @@ -name=ArxSmartPtr -version=0.2.3 -author=hideakitai -maintainer=hideakitai -sentence=C++ smart pointer-like classes for Arduino which cannot use standard smart pointers -paragraph=C++ smart pointer-like classes for Arduino which cannot use standard smart pointers -category=Data Storage -url=https://github.com/hideakitai/ArxSmartPtr -architectures=* diff --git a/Tween/util/ArxTypeTraits/ArxTypeTraits.h b/Tween/util/ArxTypeTraits/ArxTypeTraits.h deleted file mode 100644 index f963316..0000000 --- a/Tween/util/ArxTypeTraits/ArxTypeTraits.h +++ /dev/null @@ -1,38 +0,0 @@ -#pragma once - -#ifndef ARX_TYPE_TRAITS_H -#define ARX_TYPE_TRAITS_H - -#include "ArxTypeTraits/has_include.h" -#include "ArxTypeTraits/has_libstdcplusplus.h" - -// Make sure std namespace exists -namespace std { } - -// Import everything from the std namespace into arx::std, so that -// anything we import rather than define is also available through -// arx::stdx. -// This includes everything yet to be defined, so we can do this early -// (and must do so, to allow e.g. the C++14 additions in the arx::std -// namespace to reference the C++11 stuff from the system headers. -namespace arx { - namespace stdx { - using namespace ::std; - } -} - -// Import everything from arx::std back into the normal std namespace. -// This ensures that you can just use `std::foo` everywhere and you get -// the standard library version if it is available, falling back to arx -// versions for things not supplied by the standard library. Only when -// you really need the arx version (e.g. for constexpr numeric_limits -// when also using ArduinoSTL), you need to qualify with arx::stdx:: -namespace std { - using namespace ::arx::stdx; -} - -#include "ArxTypeTraits/replace_minmax_macros.h" - -#include "ArxTypeTraits/type_traits.h" - -#endif // ARX_TYPE_TRAITS_H diff --git a/Tween/util/ArxTypeTraits/ArxTypeTraits/functional.h b/Tween/util/ArxTypeTraits/ArxTypeTraits/functional.h deleted file mode 100644 index ed25943..0000000 --- a/Tween/util/ArxTypeTraits/ArxTypeTraits/functional.h +++ /dev/null @@ -1,165 +0,0 @@ -#pragma once - -#ifndef ARX_TYPE_TRAITS_FUNCTIONAL_H -#define ARX_TYPE_TRAITS_FUNCTIONAL_H - -#if ARX_HAVE_LIBSTDCPLUSPLUS >= 201103L // Have libstdc++11 - -#include - -#else // Do not have libstdc++11 - -// If we have a header, include it and assume it has placement new -// (for AVR this has always been true, MEGAAVR does not have placement -// new now, but will probably get it before is added). -// This also handles the case where ArduinoSTL is used, which defines an -// inline placement new which would conflict with the below definition. -#if ARX_SYSTEM_HAS_INCLUDE() -#include -#else -// When there is no header, there might be a header, but -// not all Arduino platform (versions) define a placement new operator -// in there. -// However, it is hard to detect whether it is or is not defined, but -// the versions that do define it, do not define it inline in the -// header, so we can just define it inline here without conflicts. -// Note that there is no need to include anything to declare the -// non-placement new operators, since those are implicit. -inline void* operator new (const size_t size, void* ptr) noexcept { (void)size; return ptr; } -#endif - -namespace arx { namespace stdx { - - // reference: - // stack overflow https://stackoverflow.com/questions/32074410/stdfunction-bind-like-type-erasure-without-standard-c-library - - template - class function; - - template - class function - { - struct vtable_t - { - void (*mover)(void* src, void* dest); - void (*destroyer)(void*); - R (*invoke)(void const* t, Args&&... args); - - template - static vtable_t const* get() - { - static const vtable_t table = - { - // mover - [] (void* src, void* dest) - { - new(dest) T(move(*static_cast(src))); - }, - // destroyer - [] (void* t) - { - static_cast(t)->~T(); - }, - // invoke - [] (void const* t, Args&&... args) -> R - { - return (*static_cast(t))(std::forward(args)...); - } - }; - return &table; - } - }; - - vtable_t const* table {nullptr}; - void* data {nullptr}; - - public: - - template < - class Func, - class dF = typename std::decay::type, - typename enable_if {}>::type* = nullptr, - typename enable_if ::type, R>{}>::type* = nullptr - > - function(const Func& f) - : table(vtable_t::template get()) - { - data = reinterpret_cast(new Func(f)); - } - function(const function& o) - : table(o.table) - { - data = o.data; - } - function(function&& o) - : table(o.table) - { - if (table) table->mover(o.data, data); - } - function() - { - } - ~function() - { - if (table) table->destroyer(data); - } - - function& operator= (const function& o) - { - this->~function(); - new(this) function(move(o)); - return *this; - } - function& operator= (function&& o) - { - this->~function(); - new(this) function(move(o)); - return *this; - } - function& operator= (std::nullptr_t p) - { - (void)p; - this->~function(); - return *this; - } - - explicit operator bool() const - { - return table; - } - - R operator()(Args...args) const - { - return table->invoke(data, forward(args)...); - } - }; - - template - inline bool operator== (const function& f, std::nullptr_t) - { - return !static_cast(f); - } - - template - inline bool operator== (std::nullptr_t, const function& f) - { - return !static_cast(f); - } - - template - inline bool operator!= (const function& f, std::nullptr_t) - { - return static_cast(f); - } - - template - inline bool operator!= (std::nullptr_t, const function& f) - { - return static_cast(f); - } - -} } // namespace arx::std - -#endif // Do not have libstdc++11 - -#endif // ARX_TYPE_TRAITS_FUNCTIONAL_H diff --git a/Tween/util/ArxTypeTraits/ArxTypeTraits/has_include.h b/Tween/util/ArxTypeTraits/ArxTypeTraits/has_include.h deleted file mode 100644 index d605d71..0000000 --- a/Tween/util/ArxTypeTraits/ArxTypeTraits/has_include.h +++ /dev/null @@ -1,30 +0,0 @@ -#pragma once - -#ifndef ARX_TYPE_TRAITS_HAS_INCLUDE_H -#define ARX_TYPE_TRAITS_HAS_INCLUDE_H - - // Check whether __has_include is available, but also check the GCC - // version (__has_include was introduced in gcc 5) to catch - // environments (such as ESP8266) where gcc is old, but some system - // header provides a fake __has_include. We also need to check - // against __clang__ here, since clang pretends to be GCC - // 4.something and would otherwise be detected incorrectly here... - #if !defined(__has_include) || defined(__GNUC__) && __GNUC__ < 5 && !defined(__clang__) - #if defined(ARDUINO_ARCH_ESP8266) - // ESP8266 does not have a working __has_include, but we - // know it does have a working libstdc++ with all the - // headers we care about, so provide a fake has_include - #define ARX_SYSTEM_HAS_INCLUDE(x) 1 - #elif defined(ARDUINO_SAM_DUE) - // Arduino DUE's GCC version is 4.8.3 (GCC < 5.0). - // If libstdc++ is used, std::function causes error - // so currently we disable libstdc++ and use ArxTypeTraits - #define ARX_SYSTEM_HAS_INCLUDE(x) 0 - #else - #error "Compiler does not support __has_include, please report a bug against the ArxTypeTraits library about this." - #endif - #else - #define ARX_SYSTEM_HAS_INCLUDE(x) __has_include(x) - #endif - -#endif // ARX_TYPE_TRAITS_HAS_INCLUDE_H diff --git a/Tween/util/ArxTypeTraits/ArxTypeTraits/has_libstdcplusplus.h b/Tween/util/ArxTypeTraits/ArxTypeTraits/has_libstdcplusplus.h deleted file mode 100644 index 23f2b26..0000000 --- a/Tween/util/ArxTypeTraits/ArxTypeTraits/has_libstdcplusplus.h +++ /dev/null @@ -1,35 +0,0 @@ -#pragma once - -#ifndef ARX_TYPE_TRAITS_HAS_LIBSTDCPLUSPLUS_H -#define ARX_TYPE_TRAITS_HAS_LIBSTDCPLUSPLUS_H - -#if !defined(ARX_HAVE_LIBSTDCPLUSPLUS) - #if ARX_SYSTEM_HAS_INCLUDE() && !defined(ARDUINO_spresense_ast) - #include - #if defined(__GLIBCXX__) || defined(_LIBCPP_VERSION) - // For gcc's libstdc++ and clang's libc++, assume that - // __cplusplus tells us what the standard includes support - #define ARX_HAVE_LIBSTDCPLUSPLUS __cplusplus - #elif defined(_CPPLIB_VER) - #if _CPPLIB_VER > 650 - #define ARX_HAVE_LIBSTDCPLUSPLUS 201703L // C++17 - #elif _CPPLIB_VER == 650 - #define ARX_HAVE_LIBSTDCPLUSPLUS 201402L // C++14 - #elif _CPPLIB_VER >= 610 - #define ARX_HAVE_LIBSTDCPLUSPLUS 201103L // C++11 - #else - #define ARX_HAVE_LIBSTDCPLUSPLUS 199711L // C++98 - #endif - #elif defined(__UCLIBCXX_MAJOR__) - // For uclibc++, assume C++98 support only. - #define ARX_HAVE_LIBSTDCPLUSPLUS 199711L - #else - #error "Unknown C++ library found, please report a bug against the ArxTypeTraits library about this." - #endif - #else - // Assume no standard library is available at all (e.g. on AVR) - #define ARX_HAVE_LIBSTDCPLUSPLUS 0 - #endif -#endif - -#endif // ARX_TYPE_TRAITS_HAS_LIBSTDCPLUSPLUS_H diff --git a/Tween/util/ArxTypeTraits/ArxTypeTraits/initializer_list.h b/Tween/util/ArxTypeTraits/ArxTypeTraits/initializer_list.h deleted file mode 100644 index b1cd74f..0000000 --- a/Tween/util/ArxTypeTraits/ArxTypeTraits/initializer_list.h +++ /dev/null @@ -1,30 +0,0 @@ -#pragma once - -#ifndef ARX_TYPE_TRAITS_INITIALIZER_H -#define ARX_TYPE_TRAITS_INITIALIZER_H - -// Initializer_list *must* be defined in std, so take extra care to only -// define it when is really not available (e.g. -// ArduinoSTL is C++98 but *does* define ) and not -// already defined (e.g. by ArxContainer). -#if ARX_SYSTEM_HAS_INCLUDE() -#include -#else -namespace std { - template - class initializer_list - { - private: - const T* array; - size_t len; - initializer_list(const T* a, size_t l) : array(a), len(l) {} - public: - initializer_list() : array(nullptr), len(0) {} - size_t size() const { return len; } - const T *begin() const { return array; } - const T *end() const { return array + len; } - }; -} // namespace std -#endif - -#endif // ARX_TYPE_TRAITS_INITIALIZER_LIST_H diff --git a/Tween/util/ArxTypeTraits/ArxTypeTraits/replace_minmax_macros.h b/Tween/util/ArxTypeTraits/ArxTypeTraits/replace_minmax_macros.h deleted file mode 100644 index f8ff86e..0000000 --- a/Tween/util/ArxTypeTraits/ArxTypeTraits/replace_minmax_macros.h +++ /dev/null @@ -1,35 +0,0 @@ -#pragma once - -#ifndef ARX_TYPE_TRAITS_REPLACE_MINMAX_MACROS_H -#define ARX_TYPE_TRAITS_REPLACE_MINMAX_MACROS_H - -// Make sure Arduino.h is actually included, since otherwise it might be -// included later and break *uses* of the min/max methods, rather than -// the declarations of it. -#ifdef ARDUINO - #include -#endif - -// These macros are defined by Arduino.h on some platforms, and conflict -// with min/max methods defined or included by ArxTypeTraits, so replace -// them with macros here. -#ifdef max - #undef max - template - constexpr auto max(T1 x, T2 y) - -> decltype(x + y) - { - return (x > y) ? x : y; - } -#endif -#ifdef min - #undef min - template - constexpr auto min(T1 x, T2 y) - -> decltype(x + y) - { - return (x < y) ? x : y; - } -#endif - -#endif // ARX_TYPE_TRAITS_REPLACE_MINMAX_MACROS_H diff --git a/Tween/util/ArxTypeTraits/ArxTypeTraits/tuple.h b/Tween/util/ArxTypeTraits/ArxTypeTraits/tuple.h deleted file mode 100644 index 2c13d95..0000000 --- a/Tween/util/ArxTypeTraits/ArxTypeTraits/tuple.h +++ /dev/null @@ -1,82 +0,0 @@ -#pragma once - -#ifndef ARX_TYPE_TRAITS_TUPLE_H -#define ARX_TYPE_TRAITS_TUPLE_H - -#if ARX_HAVE_LIBSTDCPLUSPLUS >= 201103L // Have libstdc++11 - -#include - -#else // Do not have libstdc++11 - -namespace arx { namespace stdx { - - // https://theolizer.com/cpp-school2/cpp-school2-15/ - // https://wandbox.org/permlink/C0BWIzjqg4iO3kKZ - - template - struct tuple - { - tuple() {} - }; - - template - class tuple : public tuple - { - template friend struct get_helper; - tFirst mMember; - public: - tuple(tFirst const& iFirst, tRest const&... iRest) - : tuple(iRest...) - , mMember(iFirst) - { } - constexpr tuple() {} - }; - - template - struct get_helper { }; - template - struct get_helper<0, tFirst, tRest...> - { - typedef tFirst type; - static type& get(tuple& iTuple) - { - return iTuple.mMember; - } - }; - template - struct get_helper - { - typedef typename get_helper::type type; - static type& get(tuple& iTuple) - { - return get_helper::get(iTuple); - } - }; - - template - typename get_helper::type& get(tuple& iTuple) - { - return get_helper::get(iTuple); - } - - template class tuple_size; - template class tuple_size; - template class tuple_size; - template class tuple_size; - template - class tuple_size > - : public integral_constant {}; - - template - auto make_tuple(Types&&... args) - -> std::tuple::type...> - { - return std::tuple::type...>(std::forward::type>(args)...); - } - -} } // namespace arx::std - -#endif // Do not have libstdc++11 - -#endif // ARX_TYPE_TRAITS_TUPLE_H diff --git a/Tween/util/ArxTypeTraits/ArxTypeTraits/type_traits.h b/Tween/util/ArxTypeTraits/ArxTypeTraits/type_traits.h deleted file mode 100644 index ff41693..0000000 --- a/Tween/util/ArxTypeTraits/ArxTypeTraits/type_traits.h +++ /dev/null @@ -1,638 +0,0 @@ -#pragma once - -#ifndef ARX_TYPE_TRAITS_TYPE_TRAITS_H -#define ARX_TYPE_TRAITS_TYPE_TRAITS_H - -#if ARX_HAVE_LIBSTDCPLUSPLUS >= 199711L // Have libstdc++98 - -#include - -#else // Do not have libstdc++98 - -namespace arx { namespace stdx { - - template - void swap(T& a, T& b) - { - T t = move(a); - a = move(b); - b = move(t); - } -} } // namespace arx::stdx - -#endif // Do not have libstdc++98 - - -#if ARX_HAVE_LIBSTDCPLUSPLUS >= 201103L // Have libstdc++11 - -#include -#include - -#else // Do not have libstdc++11 - -#include -#include -#include - -namespace arx { namespace stdx { - - using nullptr_t = decltype(nullptr); - - // numeric_limits - - template - struct numeric_limits - { - static constexpr T max() { return T(); } - static constexpr T min() { return T(); } - }; - template <> constexpr bool numeric_limits::max() { return true; } - template <> constexpr char numeric_limits::max() { return CHAR_MAX; } - template <> constexpr signed char numeric_limits::max() { return SCHAR_MAX; } - template <> constexpr unsigned char numeric_limits::max() { return UCHAR_MAX; } -#ifndef ARDUINO_spresense_ast - template <> constexpr wchar_t numeric_limits::max() { return WCHAR_MAX; } - // template <> constexpr char8_t numeric_limits::max() { return UCHAR_MAX; } -#endif - template <> constexpr char16_t numeric_limits::max() { return UINT_LEAST16_MAX; } - template <> constexpr char32_t numeric_limits::max() { return UINT_LEAST32_MAX; } - template <> constexpr short numeric_limits::max() { return SHRT_MAX; } - template <> constexpr unsigned short numeric_limits::max() { return USHRT_MAX; } - template <> constexpr int numeric_limits::max() { return INT_MAX; } - template <> constexpr unsigned int numeric_limits::max() { return UINT_MAX; } - template <> constexpr long numeric_limits::max() { return LONG_MAX; } - template <> constexpr unsigned long numeric_limits::max() { return ULONG_MAX; } - // template <> constexpr long long numeric_limits::max() { return LLONG_MAX; } - // template <> constexpr unsigned long long numeric_limits::max() { return ULLONG_MAX; } - template <> constexpr float numeric_limits::max() { return FLT_MAX; } - template <> constexpr double numeric_limits::max() { return DBL_MAX; } - template <> constexpr long double numeric_limits::max() { return LDBL_MAX; } - - template <> constexpr bool numeric_limits::min() { return false; } - template <> constexpr char numeric_limits::min() { return CHAR_MIN; } - template <> constexpr signed char numeric_limits::min() { return SCHAR_MIN; } - template <> constexpr unsigned char numeric_limits::min() { return 0; } -#ifndef ARDUINO_spresense_ast - template <> constexpr wchar_t numeric_limits::min() { return WCHAR_MIN; } - // template <> constexpr char8_t numeric_limits::min() { return 0; } -#endif - template <> constexpr char16_t numeric_limits::min() { return 0; } - template <> constexpr char32_t numeric_limits::min() { return 0; } - template <> constexpr short numeric_limits::min() { return SHRT_MIN; } - template <> constexpr unsigned short numeric_limits::min() { return 0; } - template <> constexpr int numeric_limits::min() { return INT_MIN; } - template <> constexpr unsigned int numeric_limits::min() { return 0; } - template <> constexpr long numeric_limits::min() { return LONG_MIN; } - template <> constexpr unsigned long numeric_limits::min() { return 0; } - // template <> constexpr long long numeric_limits::min() { return LLONG_MIN; } - // template <> constexpr unsigned long long numeric_limits::min() { return 0; } - template <> constexpr float numeric_limits::min() { return FLT_MIN; } - template <> constexpr double numeric_limits::min() { return DBL_MIN; } - template <> constexpr long double numeric_limits::min() { return LDBL_MIN; } - - - // integral_constant - - template - struct integral_constant - { - static constexpr T value = v; - using value_type = T; - using type = integral_constant; - constexpr operator value_type() const noexcept { return value; } - constexpr value_type operator()() const noexcept { return value; } - }; - - using true_type = integral_constant; - using false_type = integral_constant; - - - template - T declval(); // no implementation - - - template - struct enable_if; - template - struct enable_if { using type = T; }; - - - template - struct conditional { using type = T; }; - template - struct conditional { using type = F; }; - - - template struct remove_cv { using type = T; }; - template struct remove_cv { using type = T; }; - template struct remove_cv { using type = T; }; - template struct remove_cv { using type = T; }; - - template struct remove_const { using type = T; }; - template struct remove_const { using type = T; }; - - template struct remove_volatile { using type = T; }; - template struct remove_volatile { using type = T; }; - - template struct remove_pointer { using type = T; }; - template struct remove_pointer { using type = T; }; - template struct remove_pointer { using type = T; }; - template struct remove_pointer { using type = T; }; - template struct remove_pointer { using type = T; }; - - template struct remove_reference { using type = T; }; - template struct remove_reference { using type = T; }; - template struct remove_reference { using type = T; }; - - template struct remove_extent { typedef T type; }; - template struct remove_extent { typedef T type; }; - template struct remove_extent { typedef T type; }; - - - template - constexpr T&& forward(typename remove_reference::type& t) noexcept - { - return static_cast(t); - } - template - constexpr T&& forward(typename remove_reference::type&& t) noexcept - { - return static_cast(t); - } - - - namespace detail - { - template - struct type_identity { using type = T; }; - template - auto try_add_pointer(int) -> type_identity::type*>; - template - auto try_add_pointer(...) -> type_identity; - } - template - struct add_pointer : decltype(detail::try_add_pointer(0)) {}; - - - template - struct is_same : false_type {}; - template - struct is_same : true_type {}; - - - template - struct is_integral : false_type {}; - template <> struct is_integral : true_type {}; - template <> struct is_integral : true_type {}; - template <> struct is_integral : true_type {}; - template <> struct is_integral : true_type {}; - template <> struct is_integral : true_type {}; - template <> struct is_integral : true_type {}; - template <> struct is_integral : true_type {}; - template <> struct is_integral : true_type {}; - template <> struct is_integral : true_type {}; - template <> struct is_integral : true_type {}; - template <> struct is_integral : true_type {}; - template <> struct is_integral : true_type {}; - template <> struct is_integral : true_type {}; - template <> struct is_integral : true_type {}; - template <> struct is_integral : true_type {}; - - - template - struct is_floating_point : false_type {}; - template <> struct is_floating_point : true_type {}; - template <> struct is_floating_point : true_type {}; - template <> struct is_floating_point : true_type {}; - - - template - struct is_arithmetic - : conditional< - is_integral::value || is_floating_point::value, - true_type, - false_type - >::type - {}; - - - namespace detail - { - template ::value> - struct is_signed : integral_constant {}; - template - struct is_signed : false_type {}; - } - template - struct is_signed : detail::is_signed::type {}; - - - namespace detail - { - template::value> - struct is_unsigned : integral_constant {}; - template - struct is_unsigned : false_type {}; - } - template - struct is_unsigned : detail::is_unsigned::type {}; - - - template struct is_pointer_helper : false_type {}; - template struct is_pointer_helper : true_type {}; - template struct is_pointer : is_pointer_helper::type> {}; - - - template - struct is_array : false_type {}; - template - struct is_array : true_type {}; - template - struct is_array : true_type {}; - - - namespace details - { - template - struct Tester { using type = void; }; - template - using void_t = typename Tester::type; - templateclass Z, class, class...Ts> - struct can_apply : false_type{}; - templateclass Z, class...Ts> - struct can_apply>, Ts...> : true_type{}; - - template - using try_convert = decltype(To{declval()}); - } - templateclass Z, class...Ts> - using can_apply = details::can_apply; - - template - struct is_convertible - : conditional < - can_apply ::value - , true_type - , typename conditional < - is_arithmetic::value && is_arithmetic::value, - true_type, - false_type - >::type - >::type - {}; - - template<> - struct is_convertible : true_type{}; - - - // primary template - template - struct is_function : false_type { }; - // specialization for regular functions - template - struct is_function : true_type {}; - // specialization for variadic functions such as printf - template - struct is_function : true_type {}; - // specialization for function types that have cv-qualifiers - template - struct is_function : true_type {}; - template - struct is_function : true_type {}; - template - struct is_function : true_type {}; - template - struct is_function : true_type {}; - template - struct is_function : true_type {}; - template - struct is_function : true_type {}; - // specialization for function types that have ref-qualifiers - template - struct is_function : true_type {}; - template - struct is_function : true_type {}; - template - struct is_function : true_type {}; - template - struct is_function : true_type {}; - template - struct is_function : true_type {}; - template - struct is_function : true_type {}; - template - struct is_function : true_type {}; - template - struct is_function : true_type {}; - template - struct is_function : true_type {}; - template - struct is_function : true_type {}; - template - struct is_function : true_type {}; - template - struct is_function : true_type {}; - template - struct is_function : true_type {}; - template - struct is_function : true_type {}; - template - struct is_function : true_type {}; - template - struct is_function : true_type {}; - - - template - struct is_empty : public integral_constant { }; - - - template - class decay - { - typedef typename remove_reference::type U; - public: - typedef typename conditional< - is_array::value, - typename remove_extent::type*, - typename conditional< - is_function::value, - typename add_pointer::type, - typename remove_cv::type - >::type - >::type type; - }; - - - namespace details - { - template struct tag { using type=T; }; - template using type_t = typename Tag::type; - - template - using invoke_t = decltype( declval()(declval()...) ); - - template - struct result_of {}; - template - struct result_of>> - : tag > - {}; - } - template - using result_of = details::result_of; - -} } // namespace arx::stdx - -#endif // Do not have libstdc++11 - - -#if ARX_HAVE_LIBSTDCPLUSPLUS >= 201402L // Have libstdc++14 - -#else // Do not have libstdc++14 - -namespace arx { namespace stdx { - - // `move` must be declared before including `functional.h` - // C++14 constexpr version should be inside of C++14, - // but moved before `functional.h` - template - constexpr typename remove_reference::type&& move(T&& t) noexcept - { - return static_cast::type&&>(t); - } - -} } // namespace arx::stdx - -#endif // Do not have libstdc++14 - - -#include "initializer_list.h" -#include "tuple.h" -#include "functional.h" - -#if ARX_HAVE_LIBSTDCPLUSPLUS >= 201402L // Have libstdc++14 - // Nothing to include here, relevant header files were already included - // for C++11 above. -#else // Do not have libstdc++14 - -namespace arx { namespace stdx { - - template - using enable_if_t = typename enable_if::type; - - template - using decay_t = typename decay::type; - - template - using remove_cv_t = typename remove_cv::type; - template - using remove_const_t = typename remove_const::type; - template - using remove_volatile_t = typename remove_volatile::type; - template - using remove_reference_t = typename remove_reference::type; - template - using remove_pointer_t = typename remove_pointer::type; - - template - struct integer_sequence - { - using type = integer_sequence; - using value_type = T; - static constexpr size_t size() noexcept { return sizeof...(Ts); } - }; - template - using index_sequence = integer_sequence; - - // https://stackoverflow.com/questions/17424477/implementation-c14-make-integer-sequence - - template - struct concat_impl; - template - using concat = typename concat_impl::type; - - template - struct concat_impl , index_sequence> - : index_sequence {}; - template - struct make_index_sequence_impl; - template - using make_index_sequence = typename make_index_sequence_impl::type; - template - struct make_index_sequence_impl - : concat, make_index_sequence > {}; - template<> - struct make_index_sequence_impl <0> : index_sequence<>{}; - template<> - struct make_index_sequence_impl <1> : index_sequence<0>{}; - - template - using index_sequence_for = make_index_sequence; - -} } // namespace arx::stdx - -#endif // Do not have libstdc++14 - - -#if ARX_HAVE_LIBSTDCPLUSPLUS >= 201703L // Have libstdc++17 - // Nothing to include here, relevant header files were already included - // for C++11 above. -#else // Do not have libstdc++17 - -namespace arx { namespace stdx { - - template - struct Tester { using type = void; }; - template - using void_t = typename Tester::type; - - template - struct disjunction : false_type {}; - template - struct disjunction : Arg::type {}; - template - struct disjunction : conditional>::type {}; - - template - struct conjunction : true_type {}; - template - struct conjunction : Arg::type {}; - template - struct conjunction : conditional, Arg>::type {}; - - template - struct negation : integral_constant {}; - - // https://qiita.com/_EnumHack/items/92e6e135174f1f781dbb - // without decltype(auto) - - template - constexpr auto apply_impl(F&& f, Tuple&& t, index_sequence) - -> decltype(f(get(forward(t))...)) - { - return f(get(forward(t))...); - } - template - constexpr auto apply(F&& f, Tuple&& t) - -> decltype(apply_impl( - forward(f), - forward(t), - make_index_sequence>::value>{} - )) - { - return apply_impl( - forward(f), - forward(t), - make_index_sequence>::value>() - ); - } - -} } // namespace arx::stdx - -#endif // Do not have libstdc++17 - - -#if ARX_HAVE_LIBSTDCPLUSPLUS > 201703L // Have libstdc++2a - // Nothing to include here, relevant header files were already included - // for C++11 above. -#else // Do not have libstdc++2a - -namespace arx { namespace stdx { - - template - struct remove_cvref - { - typedef remove_cv_t> type; - }; - - template< class T > - using remove_cvref_t = typename remove_cvref::type; - -} } // namespace arx::stdx -#endif // Do not have libstdc++2a - - -namespace arx { // others - - template class Check, class... T> - struct is_detected_impl : std::false_type {}; - template