Updated generators

This commit is contained in:
John Wellbelove 2020-12-08 11:39:26 +00:00
parent e122383d7d
commit 8cf7ab2974
14 changed files with 114 additions and 30 deletions

View File

@ -235,7 +235,7 @@ namespace etl
template <typename TSize>
void set_states(etl::ifsm_state** p_states, TSize size)
{
state_list = p_states;
state_list = p_states;
number_of_states = etl::fsm_state_id_t(size);
ETL_ASSERT(number_of_states > 0, ETL_ERROR(etl::fsm_state_list_exception));
@ -281,7 +281,7 @@ namespace etl
//*******************************************
/// Top level message handler for the FSM.
//*******************************************
void receive(const etl::imessage& message)
void receive(const etl::imessage& message) ETL_OVERRIDE
{
static etl::null_message_router nmr;
receive(nmr, message);
@ -290,7 +290,7 @@ namespace etl
//*******************************************
/// Top level message handler for the FSM.
//*******************************************
void receive(imessage_router& source, etl::message_router_id_t destination_router_id, const etl::imessage& message)
void receive(imessage_router& source, etl::message_router_id_t destination_router_id, const etl::imessage& message) ETL_OVERRIDE
{
if ((destination_router_id == get_message_router_id()) || (destination_router_id == imessage_router::ALL_MESSAGE_ROUTERS))
{
@ -301,7 +301,7 @@ namespace etl
//*******************************************
/// Top level message handler for the FSM.
//*******************************************
void receive(etl::imessage_router& source, const etl::imessage& message)
void receive(etl::imessage_router& source, const etl::imessage& message) ETL_OVERRIDE
{
etl::fsm_state_id_t next_state_id = p_state->process_event(source, message);
ETL_ASSERT(next_state_id < number_of_states, ETL_ERROR(etl::fsm_state_id_exception));
@ -331,7 +331,7 @@ namespace etl
/// Does this FSM accept the message id?
/// Yes, it accepts everything!
//*******************************************
bool accepts(etl::message_id_t) const
bool accepts(etl::message_id_t) const ETL_OVERRIDE
{
return true;
}

View File

@ -293,7 +293,7 @@ namespace etl
//*******************************************
/// Top level message handler for the FSM.
//*******************************************
void receive(const etl::imessage& message)
void receive(const etl::imessage& message) ETL_OVERRIDE
{
static etl::null_message_router nmr;
receive(nmr, message);
@ -302,7 +302,7 @@ namespace etl
//*******************************************
/// Top level message handler for the FSM.
//*******************************************
void receive(imessage_router& source, etl::message_router_id_t destination_router_id, const etl::imessage& message)
void receive(imessage_router& source, etl::message_router_id_t destination_router_id, const etl::imessage& message) ETL_OVERRIDE
{
if ((destination_router_id == get_message_router_id()) || (destination_router_id == imessage_router::ALL_MESSAGE_ROUTERS))
{
@ -313,7 +313,7 @@ namespace etl
//*******************************************
/// Top level message handler for the FSM.
//*******************************************
void receive(etl::imessage_router& source, const etl::imessage& message)
void receive(etl::imessage_router& source, const etl::imessage& message) ETL_OVERRIDE
{
etl::fsm_state_id_t next_state_id = p_state->process_event(source, message);
ETL_ASSERT(next_state_id < number_of_states, ETL_ERROR(etl::fsm_state_id_exception));
@ -343,7 +343,7 @@ namespace etl
/// Does this FSM accept the message id?
/// Yes, it accepts everything!
//*******************************************
bool accepts(etl::message_id_t) const
bool accepts(etl::message_id_t) const ETL_OVERRIDE
{
return true;
}

View File

@ -121,6 +121,17 @@ namespace etl
size = etl::size_of<type>::value
};
};
#if ETL_CPP14_SUPPORTED
template <typename... T>
using largest_type_t = typename largest_type<T...>::type;
#endif
#if ETL_CPP17_SUPPORTED
template <typename... T>
constexpr size_t largest_type_v = largest_type<T...>::size;
#endif
#else
/*[[[cog
import cog
@ -225,6 +236,12 @@ namespace etl
value = etl::alignment_of<type>::value
};
};
#if ETL_CPP17_SUPPORTED
template <typename... T>
inline constexpr size_t largest_alignment_v = largest_alignment<T...>::value;
#endif
#else
/*[[[cog
import cog
@ -302,6 +319,11 @@ namespace etl
typedef typename etl::smallest_int_for_bits<etl::integral_limits<typename etl::make_signed<T>::type>::bits + 1>::type type;
};
#if ETL_CPP14_SUPPORTED
template <typename T>
using larger_int_type_t = typename larger_int_type<T>::type;
#endif
//***************************************************************************
/// Defines a type that is as larger or larger than the specified type.
/// Will return the specified type is there is not a larger type.
@ -315,6 +337,11 @@ namespace etl
typedef typename etl::smallest_uint_for_bits<etl::integral_limits<typename etl::make_unsigned<T>::type>::bits + 1>::type type;
};
#if ETL_CPP14_SUPPORTED
template <typename T>
using larger_uint_type_t = typename larger_uint_type<T>::type;
#endif
//***************************************************************************
/// Defines a type that is as larger or larger than the specified type.
/// Will return the specified type is there is not a larger type.
@ -340,6 +367,11 @@ namespace etl
typedef typename etl::smallest_int_for_bits<etl::integral_limits<T>::bits + 1>::type type;
};
#if ETL_CPP14_SUPPORTED
template <typename T>
using larger_type_t = typename larger_type<T>::type;
#endif
#if ETL_CPP11_SUPPORTED && !defined(ETL_LARGEST_FORCE_CPP03)
//***************************************************************************
/// Template to determine the largest type, size and alignment.
@ -357,6 +389,12 @@ namespace etl
alignment = etl::largest_alignment<T...>::value
};
};
#if ETL_CPP14_SUPPORTED
template <typename... T>
using largest_t = typename largest<T...>::type;
#endif
#else
/*[[[cog
import cog

View File

@ -121,6 +121,17 @@ namespace etl
size = etl::size_of<type>::value
};
};
#if ETL_CPP14_SUPPORTED
template <typename... T>
using smallest_type_t = typename smallest_type<T...>::type;
#endif
#if ETL_CPP17_SUPPORTED
template <typename... T>
constexpr size_t smallest_type_v = smallest_type<T...>::size;
#endif
#else
/*[[[cog
import cog
@ -303,7 +314,7 @@ namespace etl
/// Defines 'type' which is the type of the smallest unsigned integer.
///\ingroup smallest
//***************************************************************************
template <const size_t NBITS>
template <size_t NBITS>
struct smallest_uint_for_bits
{
private:
@ -318,13 +329,18 @@ namespace etl
typedef typename private_smallest::best_fit_uint_type<TYPE_INDEX>::type type;
};
#if ETL_CPP14_SUPPORTED
template <size_t NBITS>
using smallest_uint_for_bits_t = typename smallest_uint_for_bits<NBITS>::type;
#endif
//***************************************************************************
/// Template to determine the smallest signed int type that can contain a
/// value with the specified number of bits.
/// Defines 'type' which is the type of the smallest signed integer.
///\ingroup smallest
//***************************************************************************
template <const size_t NBITS>
template <size_t NBITS>
struct smallest_int_for_bits
{
private:
@ -339,13 +355,18 @@ namespace etl
typedef typename private_smallest::best_fit_int_type<TYPE_INDEX>::type type;
};
#if ETL_CPP14_SUPPORTED
template <size_t NBITS>
using smallest_int_for_bits_t = typename smallest_int_for_bits<NBITS>::type;
#endif
//***************************************************************************
/// Template to determine the smallest unsigned int type that can contain the
/// specified unsigned value.
/// Defines 'type' which is the type of the smallest unsigned integer.
///\ingroup smallest
//***************************************************************************
template <const uintmax_t VALUE>
template <uintmax_t VALUE>
struct smallest_uint_for_value
{
private:
@ -360,6 +381,11 @@ namespace etl
typedef typename private_smallest::best_fit_uint_type<TYPE_INDEX>::type type;
};
#if ETL_CPP14_SUPPORTED
template <uintmax_t VALUE>
using smallest_uint_for_value_t = typename smallest_uint_for_value<VALUE>::type;
#endif
//***************************************************************************
/// Template to determine the smallest int type that can contain the
/// specified signed value.
@ -372,14 +398,19 @@ namespace etl
private:
// Determines the index of the best signed type for the required value.
static const int TYPE_INDEX = (((VALUE > INT_LEAST8_MAX) || (VALUE < INT_LEAST8_MIN)) ? 1 : 0) +
(((VALUE > INT16_MAX) || (VALUE < INT16_MIN)) ? 1 : 0) +
(((VALUE > INT32_MAX) || (VALUE < INT32_MIN)) ? 1 : 0);
static const int TYPE_INDEX = (((VALUE > intmax_t(INT_LEAST8_MAX)) || (VALUE < intmax_t(INT_LEAST8_MIN))) ? 1 : 0) +
(((VALUE > intmax_t(INT16_MAX)) || (VALUE < intmax_t(INT16_MIN))) ? 1 : 0) +
(((VALUE > intmax_t(INT32_MAX)) || (VALUE < intmax_t(INT32_MIN))) ? 1 : 0);
public:
typedef typename private_smallest::best_fit_int_type<TYPE_INDEX>::type type;
};
#if ETL_CPP14_SUPPORTED
template <intmax_t VALUE>
using smallest_int_for_value_t = typename smallest_int_for_value<VALUE>::type;
#endif
}
#endif

View File

@ -129,8 +129,10 @@ namespace etl
static_assert(!(etl::is_same<nulltype, type>::value), "Invalid id");
};
#if ETL_CPP14_SUPPORTED
template <int ID>
using type_from_id_t = typename type_from_id<ID>::type;
#endif
private:
@ -165,7 +167,7 @@ namespace etl
#if ETL_CPP17_SUPPORTED
template <typename T>
static constexpr size_t id_from_type_v = id_from_type<T, TTypes...>::value;
static constexpr size_t id_from_type_v = id_from_type<T>::value;
#endif
//************************************
@ -223,9 +225,11 @@ namespace etl
static_assert(!etl::is_same<type, nulltype>::value, "Type match not found");
};
#if ETL_CPP14_SUPPORTED
// Template alias.
template <typename T>
using TypeFromType_t = typename type_from_type<T>::type;
using type_from_type_t = typename type_from_type<T>::type;
#endif
};
#else

View File

@ -73,8 +73,8 @@ namespace etl
struct type_select_helper
{
using type = typename etl::conditional<ID == N,
T1,
typename type_select_helper<ID, N + 1, TRest...>::type>::type;
T1,
typename type_select_helper<ID, N + 1, TRest...>::type>::type;
};
//***********************************
@ -94,8 +94,10 @@ namespace etl
using type = typename type_select_helper<ID, 0, TTypes...>::type;
};
#if ETL_CPP14_SUPPORTED
template <size_t ID>
using select_t = typename select<ID>::type;
#endif
};
#else

View File

@ -1088,7 +1088,13 @@ namespace etl
inline constexpr bool is_pod_v = std::is_standard_layout_v<T> && std::is_trivial_v<T>;
#endif
#if !defined(ARDUINO) && ETL_NOT_USING_STLPORT && !(defined(ETL_COMPILER_GCC) && ETL_COMPILER_VERSION < 5)
#if defined(ETL_COMPILER_GCC)
#if ETL_COMPILER_VERSION >= 5
#define ETL_GCC_V5_TYPE_TRAITS_SUPPORTED
#endif
#endif
#if !defined(ARDUINO) && ETL_NOT_USING_STLPORT && defined(ETL_GCC_V5_TYPE_TRAITS_SUPPORTED)
//***************************************************************************
/// is_trivially_constructible
///\ingroup type_traits

View File

@ -102,12 +102,10 @@ SOFTWARE.
// See if we can determine the OS we're compiling on, if haven't already done so in etl_profile.h
#include "profiles/determine_development_os.h"
#include <new.h>
// Figure out if we can use the standard library <new> header, if haven't already done so in etl_profile.h
#if !defined(ETL_USING_STD_NEW)
#if defined(__has_include)
#define ETL_USING_STD_NEW (__has_include(<new>) || __has_include(<new.h>))
#define ETL_USING_STD_NEW __has_include(<new>)
#elif ETL_NOT_USING_STL || (defined(ARDUINO) && defined(__AVR__))
#define ETL_USING_STD_NEW 0
#else

View File

@ -368,9 +368,9 @@ namespace etl
private:
// Determines the index of the best signed type for the required value.
static const int TYPE_INDEX = (((VALUE > intmax_t(INT_LEAST8_MAX)) || (VALUE < intmax_t(INT_LEAST8_MIN))) ? 1 : 0) +
(((VALUE > intmax_t(INT16_MAX)) || (VALUE < intmax_t(INT16_MIN))) ? 1 : 0) +
(((VALUE > intmax_t(INT32_MAX)) || (VALUE < intmax_t(INT32_MIN))) ? 1 : 0);
static const int TYPE_INDEX = (((VALUE > intmax_t(INT_LEAST8_MAX)) || (VALUE < intmax_t(INT_LEAST8_MIN))) ? 1 : 0) +
(((VALUE > intmax_t(INT16_MAX)) || (VALUE < intmax_t(INT16_MIN))) ? 1 : 0) +
(((VALUE > intmax_t(INT32_MAX)) || (VALUE < intmax_t(INT32_MIN))) ? 1 : 0);
public:

View File

@ -758,7 +758,7 @@ namespace etl
/// These require compiler specific intrinsics.
#if ETL_CPP11_SUPPORTED && !defined(ETL_COMPILER_ARM5)
template <typename T> struct alignment_of : integral_constant<size_t, alignof(T)> { };
#elif ETL_COMPILER_MICROSOFT
#elif defined(ETL_COMPILER_MICROSOFT)
template <typename T> struct alignment_of : integral_constant<size_t, size_t(__alignof(T))> {};
#elif defined(ETL_COMPILER_IAR) || defined(ETL_COMPILER_TI)
template <typename T> struct alignment_of : integral_constant<size_t, size_t(__ALIGNOF__(T))> {};

View File

@ -39,7 +39,7 @@ SOFTWARE.
#define ETL_VERSION_MAJOR 19
#define ETL_VERSION_MINOR 3
#define ETL_VERSION_PATCH 1
#define ETL_VERSION_PATCH 2
#define ETL_VERSION ETL_STRINGIFY(ETL_VERSION_MAJOR) "." ETL_STRINGIFY(ETL_VERSION_MINOR) "." ETL_STRINGIFY(ETL_VERSION_PATCH)
#define ETL_VERSION_W ETL_STRINGIFY(ETL_VERSION_MAJOR) L"." ETL_STRINGIFY(ETL_VERSION_MINOR) L"." ETL_STRINGIFY(ETL_VERSION_PATCH)
#define ETL_VERSION_U16 ETL_STRINGIFY(ETL_VERSION_MAJOR) u"." ETL_STRINGIFY(ETL_VERSION_MINOR) u"." ETL_STRINGIFY(ETL_VERSION_PATCH)

View File

@ -1,6 +1,6 @@
{
"name": "Embedded Template Library",
"version": "19.3.1",
"version": "19.3.2",
"author s": {
"name": "John Wellbelove",
"email": "john.wellbelove@etlcpp.com"

View File

@ -1,5 +1,5 @@
name=Embedded Template Library
version=19.3.1
version=19.3.2
author= John Wellbelove <john.wellbelove@etlcpp.com>
maintainer=John Wellbelove <john.wellbelove@etlcpp.com>
license=MIT

View File

@ -1,3 +1,8 @@
===============================================================================
19.3.2
Added check for existance of <new> in platform.h
Added placement_new.h which selects between <new> and ETL definitions.
===============================================================================
19.3.1
Fixed etl::format_spec constexpr compatibility with C++11.