Skip to content

Commit

Permalink
update Packetizer
Browse files Browse the repository at this point in the history
  • Loading branch information
hideakitai committed Sep 30, 2020
1 parent f70bfd6 commit 135cd9a
Show file tree
Hide file tree
Showing 14 changed files with 59 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
#define ARX_SYSTEM_HAS_INCLUDE(x) 1
#elif defined(ARDUINO_SAM_DUE)
// Arduino DUE's GCC version is 4.8.3 (GCC < 5.0).
// And it has not libstdc++
// 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."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
// define it when <initializer_list> is really not available (e.g.
// ArduinoSTL is C++98 but *does* define <initializer_list>) and not
// already defined (e.g. by ArxContainer).
#if __has_include(<initializer_list>)
#if ARX_SYSTEM_HAS_INCLUDE(<initializer_list>)
#include <initializer_list>
#else
namespace std {
Expand Down
2 changes: 2 additions & 0 deletions util/Packetizer/Packetizer/util/ArxContainer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,8 @@ PRs are welcome!
- [ArtNet](https://github.com/hideakitai/ArtNet)
- [Tween](https://github.com/hideakitai/Tween)
- [TimeProfiler](https://github.com/hideakitai/TimeProfiler)
- [SceneManager](https://github.com/hideakitai/SceneManager)
- [TaskManager](https://github.com/hideakitai/TaskManager)


## License
Expand Down
8 changes: 4 additions & 4 deletions util/Packetizer/Packetizer/util/ArxSmartPtr/ArxSmartPtr.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ namespace std { }

// Import everything from the std namespace into arx::std, so that
// anything we import rather than define is also available through
// arx::arx_std.
// 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 arx_std {
namespace stdx {
using namespace ::std;
}
}
Expand All @@ -32,9 +32,9 @@ namespace arx {
// 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::arx_std::
// when also using ArduinoSTL), you need to qualify with arx::stdx::
namespace std {
using namespace ::arx::arx_std;
using namespace ::arx::stdx;
}

#include "ArxSmartPtr/detail/replace_minmax_macros.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
#define ARX_SYSTEM_HAS_INCLUDE(x) 1
#elif defined(ARDUINO_SAM_DUE)
// Arduino DUE's GCC version is 4.8.3 (GCC < 5.0).
// And it has not libstdc++
// 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."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

// imported and simplified from https://github.com/boostorg/smart_ptr

namespace arx { namespace arx_std {
namespace arx { namespace stdx {

namespace detail
{
Expand Down Expand Up @@ -150,7 +150,7 @@ namespace arx { namespace arx_std {

} // namespace detail

}} // namespace arx::arx_std
}} // namespace arx::stdx



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

// imported and simplified from https://github.com/boostorg/smart_ptr

namespace arx { namespace arx_std
namespace arx { namespace stdx
{
template<class T> class shared_ptr;

Expand Down Expand Up @@ -370,6 +370,6 @@ namespace arx { namespace arx_std
return shared_ptr<T>(new T(sp::detail::forward<Args>(args)...));
}

}} // namespace arx::arx_std
}} // namespace arx::stdx

#endif // ARX_SMART_PTR_SHARED_PTR_H
2 changes: 2 additions & 0 deletions util/Packetizer/Packetizer/util/ArxSmartPtr/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ Please see example for more information.
- [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
Expand Down
8 changes: 4 additions & 4 deletions util/Packetizer/Packetizer/util/ArxTypeTraits/ArxTypeTraits.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ namespace std { }

// Import everything from the std namespace into arx::std, so that
// anything we import rather than define is also available through
// arx::arx_std.
// 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 arx_std {
namespace stdx {
using namespace ::std;
}
}
Expand All @@ -30,9 +30,9 @@ namespace arx {
// 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::arx_std::
// when also using ArduinoSTL), you need to qualify with arx::stdx::
namespace std {
using namespace ::arx::arx_std;
using namespace ::arx::stdx;
}

#include "ArxTypeTraits/replace_minmax_macros.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
inline void* operator new (const size_t size, void* ptr) noexcept { (void)size; return ptr; }
#endif

namespace arx { namespace arx_std {
namespace arx { namespace stdx {

// reference:
// stack overflow https://stackoverflow.com/questions/32074410/stdfunction-bind-like-type-erasure-without-standard-c-library
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
#define ARX_SYSTEM_HAS_INCLUDE(x) 1
#elif defined(ARDUINO_SAM_DUE)
// Arduino DUE's GCC version is 4.8.3 (GCC < 5.0).
// And it has not libstdc++
// 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."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

#else // Do not have libstdc++11

namespace arx { namespace arx_std {
namespace arx { namespace stdx {

// https://theolizer.com/cpp-school2/cpp-school2-15/
// https://wandbox.org/permlink/C0BWIzjqg4iO3kKZ
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

#else // Do not have libstdc++98

namespace arx { namespace arx_std {
namespace arx { namespace stdx {

template <class T>
void swap(T& a, T& b)
Expand All @@ -18,7 +18,7 @@ namespace arx { namespace arx_std {
a = move(b);
b = move(t);
}
} } // namespace arx::arx_std
} } // namespace arx::stdx

#endif // Do not have libstdc++98

Expand All @@ -34,7 +34,7 @@ namespace arx { namespace arx_std {
#include <limits.h>
#include <stdint.h>

namespace arx { namespace arx_std {
namespace arx { namespace stdx {

using nullptr_t = decltype(nullptr);

Expand Down Expand Up @@ -145,10 +145,6 @@ namespace arx { namespace arx_std {
template<class T, size_t N> struct remove_extent<T[N]> { typedef T type; };


template<class T>
T&& move(T& t){ return static_cast<T&&>(t); }


template <class T>
constexpr T&& forward(typename remove_reference<T>::type& t) noexcept
{
Expand Down Expand Up @@ -381,10 +377,31 @@ namespace arx { namespace arx_std {
template<class Sig>
using result_of = details::result_of<Sig>;

} } // namespace arx::arx_std
} } // 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 <class T>
constexpr typename remove_reference<T>::type&& move(T&& t) noexcept
{
return static_cast<typename remove_reference<T>::type&&>(t);
}

} } // namespace arx::stdx

#endif // Do not have libstdc++14


#include "initializer_list.h"
#include "tuple.h"
#include "functional.h"
Expand All @@ -394,7 +411,7 @@ namespace arx { namespace arx_std {
// for C++11 above.
#else // Do not have libstdc++14

namespace arx { namespace arx_std {
namespace arx { namespace stdx {

template <bool B, typename T = void>
using enable_if_t = typename enable_if<B, T>::type;
Expand Down Expand Up @@ -448,7 +465,7 @@ namespace arx { namespace arx_std {
template<typename... Ts>
using index_sequence_for = make_index_sequence<sizeof...(Ts)>;

} } // namespace arx::arx_std
} } // namespace arx::stdx

#endif // Do not have libstdc++14

Expand All @@ -458,7 +475,7 @@ namespace arx { namespace arx_std {
// for C++11 above.
#else // Do not have libstdc++17

namespace arx { namespace arx_std {
namespace arx { namespace stdx {

template <class... Ts>
struct Tester { using type = void; };
Expand Down Expand Up @@ -506,7 +523,7 @@ namespace arx { namespace arx_std {
);
}

} } // namespace arx::arx_std
} } // namespace arx::stdx

#endif // Do not have libstdc++17

Expand All @@ -516,7 +533,7 @@ namespace arx { namespace arx_std {
// for C++11 above.
#else // Do not have libstdc++2a

namespace arx { namespace arx_std {
namespace arx { namespace stdx {

template<class T>
struct remove_cvref
Expand All @@ -527,7 +544,7 @@ namespace arx { namespace arx_std {
template< class T >
using remove_cvref_t = typename remove_cvref<T>::type;

} } // namespace arx::arx_std
} } // namespace arx::stdx
#endif // Do not have libstdc++2a


Expand Down
5 changes: 3 additions & 2 deletions util/Packetizer/Packetizer/util/ArxTypeTraits/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ C++ type_traits for Arduino which cannot use it as default
- automatically use standard library first if the boards can
- if standard library is not enough (e.g. only C++11 is available), add missing parts listed below
- works almost all Arduino platforms (Let me know if you have errors)
- compatible with [ArduinoSTL](https://github.com/mike-matera/ArduinoSTL) or other [uClibc++](https://www.uclibc.org/) libraries (include them before `ArxTypeTraits`)
- compatible with [ArduinoSTL](https://github.com/mike-matera/ArduinoSTL) or other [uClibc++](https://www.uclibc.org/) libraries
- thx @matthijskooijman


## Supported Class Templates

### C++11 (defined only for platforms above which cannot use `type_traits`)
### C++11 (defined only for boards before C++11)

- `std::integral_constant`
- `std::true_type`
Expand Down Expand Up @@ -102,6 +102,7 @@ C++ type_traits for Arduino which cannot use it as default
- [PollingTimer](https://github.com/hideakitai/PollingTimer)
- [Tween](https://github.com/hideakitai/Tween)
- [ArxStringUtils](https://github.com/hideakitai/ArxStringUtils)
- [Filters](https://github.com/hideakitai/Filters)


## Contributors
Expand Down

0 comments on commit 135cd9a

Please sign in to comment.