mirror of
https://github.com/ETLCPP/etl.git
synced 2026-04-30 19:09:10 +08:00
Fix generators for clang-format compatibility
This commit is contained in:
parent
edacf74cd9
commit
2f5dccbe62
@ -27,7 +27,7 @@ SOFTWARE.
|
||||
******************************************************************************/
|
||||
|
||||
#if 0
|
||||
#error THIS HEADER IS A GENERATOR. DO NOT INCLUDE.
|
||||
#error THIS HEADER IS A GENERATOR. DO NOT INCLUDE.
|
||||
#endif
|
||||
|
||||
//***************************************************************************
|
||||
@ -49,24 +49,24 @@ SOFTWARE.
|
||||
//***************************************************************************
|
||||
|
||||
#ifndef ETL_FSM_INCLUDED
|
||||
#define ETL_FSM_INCLUDED
|
||||
#define ETL_FSM_INCLUDED
|
||||
|
||||
#include "platform.h"
|
||||
#include "array.h"
|
||||
#include "nullptr.h"
|
||||
#include "error_handler.h"
|
||||
#include "exception.h"
|
||||
#include "user_type.h"
|
||||
#include "message_router.h"
|
||||
#include "integral_limits.h"
|
||||
#include "largest.h"
|
||||
#if ETL_USING_CPP11
|
||||
#include "tuple.h"
|
||||
#endif
|
||||
#include "platform.h"
|
||||
#include "array.h"
|
||||
#include "error_handler.h"
|
||||
#include "exception.h"
|
||||
#include "integral_limits.h"
|
||||
#include "largest.h"
|
||||
#include "message_router.h"
|
||||
#include "nullptr.h"
|
||||
#include "user_type.h"
|
||||
#if ETL_USING_CPP11
|
||||
#include "tuple.h"
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "private/minmax_push.h"
|
||||
#include "private/minmax_push.h"
|
||||
|
||||
namespace etl
|
||||
{
|
||||
@ -74,26 +74,26 @@ namespace etl
|
||||
class hfsm;
|
||||
|
||||
/// Allow alternative type for state id.
|
||||
#if !defined(ETL_FSM_STATE_ID_TYPE)
|
||||
#if !defined(ETL_FSM_STATE_ID_TYPE)
|
||||
typedef uint_least8_t fsm_state_id_t;
|
||||
#else
|
||||
#else
|
||||
typedef ETL_FSM_STATE_ID_TYPE fsm_state_id_t;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// For internal FSM use.
|
||||
typedef typename etl::larger_type<etl::message_id_t>::type fsm_internal_id_t;
|
||||
|
||||
#if ETL_USING_CPP17 && !defined(ETL_FSM_FORCE_CPP03_IMPLEMENTATION) // For C++17 and above
|
||||
#if ETL_USING_CPP17 && !defined(ETL_FSM_FORCE_CPP03_IMPLEMENTATION) // For C++17 and above
|
||||
template <typename, typename, etl::fsm_state_id_t, typename...>
|
||||
class fsm_state;
|
||||
#else
|
||||
#else
|
||||
template <typename, typename, etl::fsm_state_id_t,
|
||||
typename, typename, typename, typename,
|
||||
typename, typename, typename, typename,
|
||||
typename, typename, typename, typename,
|
||||
typename, typename, typename, typename,
|
||||
typename, typename, typename, typename,
|
||||
typename, typename, typename, typename,
|
||||
typename, typename, typename, typename>
|
||||
class fsm_state;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//***************************************************************************
|
||||
/// Base exception class for FSM.
|
||||
@ -166,6 +166,7 @@ namespace etl
|
||||
class fsm_not_started : public etl::fsm_exception
|
||||
{
|
||||
public:
|
||||
|
||||
fsm_not_started(string_type file_name_, numeric_type line_number_)
|
||||
: etl::fsm_exception(ETL_ERROR_TEXT("fsm:not started", ETL_FSM_FILE_ID"F"), file_name_, line_number_)
|
||||
{
|
||||
@ -179,6 +180,7 @@ namespace etl
|
||||
class fsm_reentrant_transition_forbidden : public etl::fsm_exception
|
||||
{
|
||||
public:
|
||||
|
||||
fsm_reentrant_transition_forbidden(string_type file_name_, numeric_type line_number_)
|
||||
: etl::fsm_exception(ETL_ERROR_TEXT("fsm:reentrant calls to start/receive/etc. forbidden", ETL_FSM_FILE_ID"G"), file_name_, line_number_)
|
||||
{
|
||||
@ -195,7 +197,7 @@ namespace etl
|
||||
// Pass this whenever no state change is desired.
|
||||
// The highest unsigned value of fsm_state_id_t.
|
||||
static ETL_CONSTANT fsm_state_id_t No_State_Change = etl::integral_limits<fsm_state_id_t>::max;
|
||||
|
||||
|
||||
// Pass this when this event also needs to be passed to the parent.
|
||||
static ETL_CONSTANT fsm_state_id_t Pass_To_Parent = No_State_Change - 1U;
|
||||
|
||||
@ -213,15 +215,16 @@ namespace etl
|
||||
ETL_CONSTANT fsm_state_id_t ifsm_state_helper<T>::Self_Transition;
|
||||
|
||||
// Compile-time: TState::ID must equal its index in the type list (0..N-1)
|
||||
template <size_t Id, typename...> struct check_ids : etl::true_type
|
||||
template <size_t Id, typename...>
|
||||
struct check_ids : etl::true_type
|
||||
{
|
||||
};
|
||||
|
||||
template <size_t Id, typename TState0, typename... TRest>
|
||||
struct check_ids<Id, TState0, TRest...>
|
||||
: etl::integral_constant<bool, (TState0::STATE_ID == Id) && private_fsm::check_ids<Id + 1, TRest...>::value>
|
||||
: etl::integral_constant<bool, (TState0::STATE_ID == Id) && private_fsm::check_ids<Id + 1, TRest...>::value>
|
||||
{
|
||||
};
|
||||
};
|
||||
|
||||
//***************************************************************************
|
||||
/// RAII detection mechanism to catch reentrant calls to methods that might
|
||||
@ -231,6 +234,7 @@ namespace etl
|
||||
class fsm_reentrancy_guard
|
||||
{
|
||||
public:
|
||||
|
||||
//*******************************************
|
||||
/// Constructor.
|
||||
/// Checks if another method has locked reentrancy.
|
||||
@ -250,29 +254,30 @@ namespace etl
|
||||
{
|
||||
is_locked = false;
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
|
||||
// Reference to the flag signifying a lock on the state machine.
|
||||
bool& is_locked;
|
||||
|
||||
|
||||
// Copy & move semantics disabled since this is a guard.
|
||||
fsm_reentrancy_guard(fsm_reentrancy_guard const&) ETL_DELETE;
|
||||
fsm_reentrancy_guard& operator= (fsm_reentrancy_guard const&) ETL_DELETE;
|
||||
#if ETL_USING_CPP11
|
||||
fsm_reentrancy_guard& operator=(fsm_reentrancy_guard const&) ETL_DELETE;
|
||||
#if ETL_USING_CPP11
|
||||
fsm_reentrancy_guard(fsm_reentrancy_guard&&) ETL_DELETE;
|
||||
fsm_reentrancy_guard& operator= (fsm_reentrancy_guard&&) ETL_DELETE;
|
||||
#endif
|
||||
fsm_reentrancy_guard& operator=(fsm_reentrancy_guard&&) ETL_DELETE;
|
||||
#endif
|
||||
};
|
||||
}
|
||||
} // namespace private_fsm
|
||||
|
||||
class ifsm_state;
|
||||
|
||||
#if ETL_USING_CPP11
|
||||
#if ETL_USING_CPP11
|
||||
//***************************************************************************
|
||||
/// A class to store FSM states.
|
||||
//***************************************************************************
|
||||
template <typename... TStates>
|
||||
class fsm_state_pack
|
||||
class fsm_state_pack
|
||||
{
|
||||
public:
|
||||
|
||||
@ -294,18 +299,18 @@ namespace etl
|
||||
/// Gets a reference to the state.
|
||||
//*********************************
|
||||
template <typename TState>
|
||||
TState& get()
|
||||
{
|
||||
return etl::get<TState>(storage);
|
||||
TState& get()
|
||||
{
|
||||
return etl::get<TState>(storage);
|
||||
}
|
||||
|
||||
//*********************************
|
||||
/// Gets a const reference to the state.
|
||||
//*********************************
|
||||
template <typename TState>
|
||||
const TState& get() const
|
||||
{
|
||||
return etl::get<TState>(storage);
|
||||
const TState& get() const
|
||||
{
|
||||
return etl::get<TState>(storage);
|
||||
}
|
||||
|
||||
private:
|
||||
@ -322,9 +327,9 @@ namespace etl
|
||||
etl::tuple<TStates...> storage{};
|
||||
|
||||
/// Pointers to the states.
|
||||
etl::ifsm_state* states[sizeof...(TStates)]{ &etl::get<TStates>(storage)... };
|
||||
etl::ifsm_state* states[sizeof...(TStates)]{&etl::get<TStates>(storage)...};
|
||||
};
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//***************************************************************************
|
||||
/// Interface class for FSM states.
|
||||
@ -341,17 +346,17 @@ namespace etl
|
||||
using private_fsm::ifsm_state_helper<>::Pass_To_Parent;
|
||||
using private_fsm::ifsm_state_helper<>::Self_Transition;
|
||||
|
||||
#if ETL_USING_CPP17 && !defined(ETL_FSM_FORCE_CPP03_IMPLEMENTATION) // For C++17 and above
|
||||
#if ETL_USING_CPP17 && !defined(ETL_FSM_FORCE_CPP03_IMPLEMENTATION) // For C++17 and above
|
||||
template <typename, typename, etl::fsm_state_id_t, typename...>
|
||||
friend class fsm_state;
|
||||
#else
|
||||
#else
|
||||
template <typename, typename, etl::fsm_state_id_t,
|
||||
typename, typename, typename, typename,
|
||||
typename, typename, typename, typename,
|
||||
typename, typename, typename, typename,
|
||||
typename, typename, typename, typename,
|
||||
typename, typename, typename, typename,
|
||||
typename, typename, typename, typename,
|
||||
typename, typename, typename, typename>
|
||||
friend class etl::fsm_state;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//*******************************************
|
||||
/// Gets the id for this state.
|
||||
@ -383,7 +388,7 @@ namespace etl
|
||||
template <typename TSize>
|
||||
void set_child_states(etl::ifsm_state** state_list, TSize size)
|
||||
{
|
||||
p_active_child = ETL_NULLPTR;
|
||||
p_active_child = ETL_NULLPTR;
|
||||
p_default_child = ETL_NULLPTR;
|
||||
|
||||
for (TSize i = 0; i < size; ++i)
|
||||
@ -399,11 +404,11 @@ namespace etl
|
||||
/// Constructor.
|
||||
//*******************************************
|
||||
ifsm_state(etl::fsm_state_id_t state_id_)
|
||||
: state_id(state_id_),
|
||||
p_context(ETL_NULLPTR),
|
||||
p_parent(ETL_NULLPTR),
|
||||
p_active_child(ETL_NULLPTR),
|
||||
p_default_child(ETL_NULLPTR)
|
||||
: state_id(state_id_)
|
||||
, p_context(ETL_NULLPTR)
|
||||
, p_parent(ETL_NULLPTR)
|
||||
, p_active_child(ETL_NULLPTR)
|
||||
, p_default_child(ETL_NULLPTR)
|
||||
{
|
||||
}
|
||||
|
||||
@ -424,8 +429,11 @@ namespace etl
|
||||
|
||||
virtual fsm_state_id_t process_event(const etl::imessage& message) = 0;
|
||||
|
||||
virtual fsm_state_id_t on_enter_state() { return No_State_Change; } // By default, do nothing.
|
||||
virtual void on_exit_state() {} // By default, do nothing.
|
||||
virtual fsm_state_id_t on_enter_state()
|
||||
{
|
||||
return No_State_Change;
|
||||
} // By default, do nothing.
|
||||
virtual void on_exit_state() {} // By default, do nothing.
|
||||
|
||||
//*******************************************
|
||||
void set_fsm_context(etl::fsm& context)
|
||||
@ -450,7 +458,7 @@ namespace etl
|
||||
|
||||
// Disabled.
|
||||
ifsm_state(const ifsm_state&) ETL_DELETE;
|
||||
ifsm_state& operator =(const ifsm_state&) ETL_DELETE;
|
||||
ifsm_state& operator=(const ifsm_state&) ETL_DELETE;
|
||||
};
|
||||
|
||||
//***************************************************************************
|
||||
@ -482,7 +490,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));
|
||||
@ -496,7 +504,7 @@ namespace etl
|
||||
}
|
||||
}
|
||||
|
||||
#if ETL_USING_CPP11
|
||||
#if ETL_USING_CPP11
|
||||
//*******************************************
|
||||
/// Set the states for the FSM
|
||||
/// From an etl::fsm_state_pack.
|
||||
@ -504,7 +512,7 @@ namespace etl
|
||||
template <typename... TStates>
|
||||
void set_states(etl::fsm_state_pack<TStates...>& state_pack)
|
||||
{
|
||||
state_list = state_pack.get_state_list();
|
||||
state_list = state_pack.get_state_list();
|
||||
number_of_states = etl::fsm_state_id_t(state_pack.size());
|
||||
|
||||
for (etl::fsm_state_id_t i = 0; i < number_of_states; ++i)
|
||||
@ -512,7 +520,7 @@ namespace etl
|
||||
state_list[i]->set_fsm_context(*this);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//*******************************************
|
||||
/// Starts the FSM.
|
||||
@ -533,11 +541,11 @@ namespace etl
|
||||
if (call_on_enter_state)
|
||||
{
|
||||
etl::fsm_state_id_t next_state_id;
|
||||
etl::ifsm_state* p_last_state;
|
||||
etl::ifsm_state* p_last_state;
|
||||
|
||||
do
|
||||
{
|
||||
p_last_state = p_state;
|
||||
p_last_state = p_state;
|
||||
next_state_id = p_state->on_enter_state();
|
||||
if (next_state_id != ifsm_state::No_State_Change)
|
||||
{
|
||||
@ -560,7 +568,7 @@ namespace etl
|
||||
{
|
||||
etl::fsm_state_id_t next_state_id = p_state->process_event(message);
|
||||
|
||||
process_state_change(next_state_id);
|
||||
process_state_change(next_state_id);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -670,9 +678,7 @@ namespace etl
|
||||
//********************************************
|
||||
bool have_changed_state(etl::fsm_state_id_t next_state_id) const
|
||||
{
|
||||
return (next_state_id != p_state->get_state_id()) &&
|
||||
(next_state_id != ifsm_state::No_State_Change) &&
|
||||
(next_state_id != ifsm_state::Self_Transition);
|
||||
return (next_state_id != p_state->get_state_id()) && (next_state_id != ifsm_state::No_State_Change) && (next_state_id != ifsm_state::Self_Transition);
|
||||
}
|
||||
|
||||
//********************************************
|
||||
@ -691,7 +697,7 @@ namespace etl
|
||||
p_state->on_exit_state();
|
||||
next_state_id = p_state->on_enter_state();
|
||||
}
|
||||
|
||||
|
||||
if (have_changed_state(next_state_id))
|
||||
{
|
||||
ETL_ASSERT_OR_RETURN_VALUE(next_state_id < number_of_states, ETL_ERROR(etl::fsm_state_id_exception), p_state->get_state_id());
|
||||
@ -715,16 +721,16 @@ namespace etl
|
||||
return p_state->get_state_id();
|
||||
}
|
||||
|
||||
etl::ifsm_state* p_state; ///< A pointer to the current state.
|
||||
etl::ifsm_state** state_list; ///< The list of added states.
|
||||
etl::fsm_state_id_t number_of_states; ///< The number of states.
|
||||
bool is_processing_state_change; ///< Whether a method call that could potentially trigger a state change is active
|
||||
etl::ifsm_state* p_state; ///< A pointer to the current state.
|
||||
etl::ifsm_state** state_list; ///< The list of added states.
|
||||
etl::fsm_state_id_t number_of_states; ///< The number of states.
|
||||
bool is_processing_state_change; ///< Whether a method call that could potentially trigger a state change is active
|
||||
};
|
||||
|
||||
//*************************************************************************************************
|
||||
// For C++17 and above.
|
||||
//*************************************************************************************************
|
||||
#if ETL_USING_CPP17 && !defined(ETL_FSM_FORCE_CPP03_IMPLEMENTATION) // For C++17 and above
|
||||
#if ETL_USING_CPP17 && !defined(ETL_FSM_FORCE_CPP03_IMPLEMENTATION) // For C++17 and above
|
||||
//***************************************************************************
|
||||
// The definition for all types.
|
||||
//***************************************************************************
|
||||
@ -756,7 +762,7 @@ namespace etl
|
||||
//********************************************
|
||||
struct result_t
|
||||
{
|
||||
bool was_handled;
|
||||
bool was_handled;
|
||||
etl::fsm_state_id_t state_id;
|
||||
};
|
||||
|
||||
@ -795,17 +801,17 @@ namespace etl
|
||||
template <typename TContext, typename TDerived, etl::fsm_state_id_t STATE_ID_, typename... TMessageTypes>
|
||||
ETL_CONSTANT etl::fsm_state_id_t fsm_state<TContext, TDerived, STATE_ID_, TMessageTypes...>::STATE_ID;
|
||||
|
||||
#else
|
||||
//*************************************************************************************************
|
||||
// For C++14 and below.
|
||||
//*************************************************************************************************
|
||||
#else
|
||||
//*************************************************************************************************
|
||||
// For C++14 and below.
|
||||
//*************************************************************************************************
|
||||
//***************************************************************************
|
||||
// The definition for all 16 message types.
|
||||
//***************************************************************************
|
||||
template <typename TContext, typename TDerived, etl::fsm_state_id_t STATE_ID_,
|
||||
typename T1 = void, typename T2 = void, typename T3 = void, typename T4 = void,
|
||||
typename T5 = void, typename T6 = void, typename T7 = void, typename T8 = void,
|
||||
typename T9 = void, typename T10 = void, typename T11 = void, typename T12 = void,
|
||||
template <typename TContext, typename TDerived, etl::fsm_state_id_t STATE_ID_,
|
||||
typename T1 = void, typename T2 = void, typename T3 = void, typename T4 = void,
|
||||
typename T5 = void, typename T6 = void, typename T7 = void, typename T8 = void,
|
||||
typename T9 = void, typename T10 = void, typename T11 = void, typename T12 = void,
|
||||
typename T13 = void, typename T14 = void, typename T15 = void, typename T16 = void>
|
||||
class fsm_state : public ifsm_state
|
||||
{
|
||||
@ -834,7 +840,7 @@ namespace etl
|
||||
etl::fsm_state_id_t process_event(const etl::imessage& message)
|
||||
{
|
||||
etl::fsm_state_id_t new_state_id;
|
||||
etl::message_id_t event_id = message.get_message_id();
|
||||
etl::message_id_t event_id = message.get_message_id();
|
||||
|
||||
switch (event_id)
|
||||
{
|
||||
@ -864,10 +870,10 @@ namespace etl
|
||||
//***************************************************************************
|
||||
// Specialisation for 15 message types.
|
||||
//***************************************************************************
|
||||
template <typename TContext, typename TDerived, etl::fsm_state_id_t STATE_ID_,
|
||||
typename T1, typename T2, typename T3, typename T4,
|
||||
typename T5, typename T6, typename T7, typename T8,
|
||||
typename T9, typename T10, typename T11, typename T12,
|
||||
template <typename TContext, typename TDerived, etl::fsm_state_id_t STATE_ID_,
|
||||
typename T1, typename T2, typename T3, typename T4,
|
||||
typename T5, typename T6, typename T7, typename T8,
|
||||
typename T9, typename T10, typename T11, typename T12,
|
||||
typename T13, typename T14, typename T15>
|
||||
class fsm_state<TContext, TDerived, STATE_ID_, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, void> : public ifsm_state
|
||||
{
|
||||
@ -896,7 +902,7 @@ namespace etl
|
||||
etl::fsm_state_id_t process_event(const etl::imessage& message)
|
||||
{
|
||||
etl::fsm_state_id_t new_state_id;
|
||||
etl::message_id_t event_id = message.get_message_id();
|
||||
etl::message_id_t event_id = message.get_message_id();
|
||||
|
||||
switch (event_id)
|
||||
{
|
||||
@ -925,10 +931,10 @@ namespace etl
|
||||
//***************************************************************************
|
||||
// Specialisation for 14 message types.
|
||||
//***************************************************************************
|
||||
template <typename TContext, typename TDerived, etl::fsm_state_id_t STATE_ID_,
|
||||
typename T1, typename T2, typename T3, typename T4,
|
||||
typename T5, typename T6, typename T7, typename T8,
|
||||
typename T9, typename T10, typename T11, typename T12,
|
||||
template <typename TContext, typename TDerived, etl::fsm_state_id_t STATE_ID_,
|
||||
typename T1, typename T2, typename T3, typename T4,
|
||||
typename T5, typename T6, typename T7, typename T8,
|
||||
typename T9, typename T10, typename T11, typename T12,
|
||||
typename T13, typename T14>
|
||||
class fsm_state<TContext, TDerived, STATE_ID_, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, void, void> : public ifsm_state
|
||||
{
|
||||
@ -957,7 +963,7 @@ namespace etl
|
||||
etl::fsm_state_id_t process_event(const etl::imessage& message)
|
||||
{
|
||||
etl::fsm_state_id_t new_state_id;
|
||||
etl::message_id_t event_id = message.get_message_id();
|
||||
etl::message_id_t event_id = message.get_message_id();
|
||||
|
||||
switch (event_id)
|
||||
{
|
||||
@ -985,10 +991,10 @@ namespace etl
|
||||
//***************************************************************************
|
||||
// Specialisation for 13 message types.
|
||||
//***************************************************************************
|
||||
template <typename TContext, typename TDerived, etl::fsm_state_id_t STATE_ID_,
|
||||
typename T1, typename T2, typename T3, typename T4,
|
||||
typename T5, typename T6, typename T7, typename T8,
|
||||
typename T9, typename T10, typename T11, typename T12,
|
||||
template <typename TContext, typename TDerived, etl::fsm_state_id_t STATE_ID_,
|
||||
typename T1, typename T2, typename T3, typename T4,
|
||||
typename T5, typename T6, typename T7, typename T8,
|
||||
typename T9, typename T10, typename T11, typename T12,
|
||||
typename T13>
|
||||
class fsm_state<TContext, TDerived, STATE_ID_, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, void, void, void> : public ifsm_state
|
||||
{
|
||||
@ -1017,7 +1023,7 @@ namespace etl
|
||||
etl::fsm_state_id_t process_event(const etl::imessage& message)
|
||||
{
|
||||
etl::fsm_state_id_t new_state_id;
|
||||
etl::message_id_t event_id = message.get_message_id();
|
||||
etl::message_id_t event_id = message.get_message_id();
|
||||
|
||||
switch (event_id)
|
||||
{
|
||||
@ -1044,9 +1050,9 @@ namespace etl
|
||||
//***************************************************************************
|
||||
// Specialisation for 12 message types.
|
||||
//***************************************************************************
|
||||
template <typename TContext, typename TDerived, etl::fsm_state_id_t STATE_ID_,
|
||||
typename T1, typename T2, typename T3, typename T4,
|
||||
typename T5, typename T6, typename T7, typename T8,
|
||||
template <typename TContext, typename TDerived, etl::fsm_state_id_t STATE_ID_,
|
||||
typename T1, typename T2, typename T3, typename T4,
|
||||
typename T5, typename T6, typename T7, typename T8,
|
||||
typename T9, typename T10, typename T11, typename T12>
|
||||
class fsm_state<TContext, TDerived, STATE_ID_, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, void, void, void, void> : public ifsm_state
|
||||
{
|
||||
@ -1075,7 +1081,7 @@ namespace etl
|
||||
etl::fsm_state_id_t process_event(const etl::imessage& message)
|
||||
{
|
||||
etl::fsm_state_id_t new_state_id;
|
||||
etl::message_id_t event_id = message.get_message_id();
|
||||
etl::message_id_t event_id = message.get_message_id();
|
||||
|
||||
switch (event_id)
|
||||
{
|
||||
@ -1101,9 +1107,9 @@ namespace etl
|
||||
//***************************************************************************
|
||||
// Specialisation for 11 message types.
|
||||
//***************************************************************************
|
||||
template <typename TContext, typename TDerived, etl::fsm_state_id_t STATE_ID_,
|
||||
typename T1, typename T2, typename T3, typename T4,
|
||||
typename T5, typename T6, typename T7, typename T8,
|
||||
template <typename TContext, typename TDerived, etl::fsm_state_id_t STATE_ID_,
|
||||
typename T1, typename T2, typename T3, typename T4,
|
||||
typename T5, typename T6, typename T7, typename T8,
|
||||
typename T9, typename T10, typename T11>
|
||||
class fsm_state<TContext, TDerived, STATE_ID_, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, void, void, void, void, void> : public ifsm_state
|
||||
{
|
||||
@ -1132,7 +1138,7 @@ namespace etl
|
||||
etl::fsm_state_id_t process_event(const etl::imessage& message)
|
||||
{
|
||||
etl::fsm_state_id_t new_state_id;
|
||||
etl::message_id_t event_id = message.get_message_id();
|
||||
etl::message_id_t event_id = message.get_message_id();
|
||||
|
||||
switch (event_id)
|
||||
{
|
||||
@ -1157,9 +1163,9 @@ namespace etl
|
||||
//***************************************************************************
|
||||
// Specialisation for 10 message types.
|
||||
//***************************************************************************
|
||||
template <typename TContext, typename TDerived, etl::fsm_state_id_t STATE_ID_,
|
||||
typename T1, typename T2, typename T3, typename T4,
|
||||
typename T5, typename T6, typename T7, typename T8,
|
||||
template <typename TContext, typename TDerived, etl::fsm_state_id_t STATE_ID_,
|
||||
typename T1, typename T2, typename T3, typename T4,
|
||||
typename T5, typename T6, typename T7, typename T8,
|
||||
typename T9, typename T10>
|
||||
class fsm_state<TContext, TDerived, STATE_ID_, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, void, void, void, void, void, void> : public ifsm_state
|
||||
{
|
||||
@ -1188,7 +1194,7 @@ namespace etl
|
||||
etl::fsm_state_id_t process_event(const etl::imessage& message)
|
||||
{
|
||||
etl::fsm_state_id_t new_state_id;
|
||||
etl::message_id_t event_id = message.get_message_id();
|
||||
etl::message_id_t event_id = message.get_message_id();
|
||||
|
||||
switch (event_id)
|
||||
{
|
||||
@ -1212,9 +1218,9 @@ namespace etl
|
||||
//***************************************************************************
|
||||
// Specialisation for 9 message types.
|
||||
//***************************************************************************
|
||||
template <typename TContext, typename TDerived, etl::fsm_state_id_t STATE_ID_,
|
||||
typename T1, typename T2, typename T3, typename T4,
|
||||
typename T5, typename T6, typename T7, typename T8,
|
||||
template <typename TContext, typename TDerived, etl::fsm_state_id_t STATE_ID_,
|
||||
typename T1, typename T2, typename T3, typename T4,
|
||||
typename T5, typename T6, typename T7, typename T8,
|
||||
typename T9>
|
||||
class fsm_state<TContext, TDerived, STATE_ID_, T1, T2, T3, T4, T5, T6, T7, T8, T9, void, void, void, void, void, void, void> : public ifsm_state
|
||||
{
|
||||
@ -1243,7 +1249,7 @@ namespace etl
|
||||
etl::fsm_state_id_t process_event(const etl::imessage& message)
|
||||
{
|
||||
etl::fsm_state_id_t new_state_id;
|
||||
etl::message_id_t event_id = message.get_message_id();
|
||||
etl::message_id_t event_id = message.get_message_id();
|
||||
|
||||
switch (event_id)
|
||||
{
|
||||
@ -1266,8 +1272,8 @@ namespace etl
|
||||
//***************************************************************************
|
||||
// Specialisation for 8 message types.
|
||||
//***************************************************************************
|
||||
template <typename TContext, typename TDerived, etl::fsm_state_id_t STATE_ID_,
|
||||
typename T1, typename T2, typename T3, typename T4,
|
||||
template <typename TContext, typename TDerived, etl::fsm_state_id_t STATE_ID_,
|
||||
typename T1, typename T2, typename T3, typename T4,
|
||||
typename T5, typename T6, typename T7, typename T8>
|
||||
class fsm_state<TContext, TDerived, STATE_ID_, T1, T2, T3, T4, T5, T6, T7, T8, void, void, void, void, void, void, void, void> : public ifsm_state
|
||||
{
|
||||
@ -1296,7 +1302,7 @@ namespace etl
|
||||
etl::fsm_state_id_t process_event(const etl::imessage& message)
|
||||
{
|
||||
etl::fsm_state_id_t new_state_id;
|
||||
etl::message_id_t event_id = message.get_message_id();
|
||||
etl::message_id_t event_id = message.get_message_id();
|
||||
|
||||
switch (event_id)
|
||||
{
|
||||
@ -1318,8 +1324,8 @@ namespace etl
|
||||
//***************************************************************************
|
||||
// Specialisation for 7 message types.
|
||||
//***************************************************************************
|
||||
template <typename TContext, typename TDerived, etl::fsm_state_id_t STATE_ID_,
|
||||
typename T1, typename T2, typename T3, typename T4,
|
||||
template <typename TContext, typename TDerived, etl::fsm_state_id_t STATE_ID_,
|
||||
typename T1, typename T2, typename T3, typename T4,
|
||||
typename T5, typename T6, typename T7>
|
||||
class fsm_state<TContext, TDerived, STATE_ID_, T1, T2, T3, T4, T5, T6, T7, void, void, void, void, void, void, void, void, void> : public ifsm_state
|
||||
{
|
||||
@ -1348,7 +1354,7 @@ namespace etl
|
||||
etl::fsm_state_id_t process_event(const etl::imessage& message)
|
||||
{
|
||||
etl::fsm_state_id_t new_state_id;
|
||||
etl::message_id_t event_id = message.get_message_id();
|
||||
etl::message_id_t event_id = message.get_message_id();
|
||||
|
||||
switch (event_id)
|
||||
{
|
||||
@ -1369,8 +1375,8 @@ namespace etl
|
||||
//***************************************************************************
|
||||
// Specialisation for 6 message types.
|
||||
//***************************************************************************
|
||||
template <typename TContext, typename TDerived, etl::fsm_state_id_t STATE_ID_,
|
||||
typename T1, typename T2, typename T3, typename T4,
|
||||
template <typename TContext, typename TDerived, etl::fsm_state_id_t STATE_ID_,
|
||||
typename T1, typename T2, typename T3, typename T4,
|
||||
typename T5, typename T6>
|
||||
class fsm_state<TContext, TDerived, STATE_ID_, T1, T2, T3, T4, T5, T6, void, void, void, void, void, void, void, void, void, void> : public ifsm_state
|
||||
{
|
||||
@ -1399,7 +1405,7 @@ namespace etl
|
||||
etl::fsm_state_id_t process_event(const etl::imessage& message)
|
||||
{
|
||||
etl::fsm_state_id_t new_state_id;
|
||||
etl::message_id_t event_id = message.get_message_id();
|
||||
etl::message_id_t event_id = message.get_message_id();
|
||||
|
||||
switch (event_id)
|
||||
{
|
||||
@ -1419,8 +1425,8 @@ namespace etl
|
||||
//***************************************************************************
|
||||
// Specialisation for 5 message types.
|
||||
//***************************************************************************
|
||||
template <typename TContext, typename TDerived, etl::fsm_state_id_t STATE_ID_,
|
||||
typename T1, typename T2, typename T3, typename T4,
|
||||
template <typename TContext, typename TDerived, etl::fsm_state_id_t STATE_ID_,
|
||||
typename T1, typename T2, typename T3, typename T4,
|
||||
typename T5>
|
||||
class fsm_state<TContext, TDerived, STATE_ID_, T1, T2, T3, T4, T5, void, void, void, void, void, void, void, void, void, void, void> : public ifsm_state
|
||||
{
|
||||
@ -1449,7 +1455,7 @@ namespace etl
|
||||
etl::fsm_state_id_t process_event(const etl::imessage& message)
|
||||
{
|
||||
etl::fsm_state_id_t new_state_id;
|
||||
etl::message_id_t event_id = message.get_message_id();
|
||||
etl::message_id_t event_id = message.get_message_id();
|
||||
|
||||
switch (event_id)
|
||||
{
|
||||
@ -1468,7 +1474,7 @@ namespace etl
|
||||
//***************************************************************************
|
||||
// Specialisation for 4 message types.
|
||||
//***************************************************************************
|
||||
template <typename TContext, typename TDerived, etl::fsm_state_id_t STATE_ID_,
|
||||
template <typename TContext, typename TDerived, etl::fsm_state_id_t STATE_ID_,
|
||||
typename T1, typename T2, typename T3, typename T4>
|
||||
class fsm_state<TContext, TDerived, STATE_ID_, T1, T2, T3, T4, void, void, void, void, void, void, void, void, void, void, void, void> : public ifsm_state
|
||||
{
|
||||
@ -1497,7 +1503,7 @@ namespace etl
|
||||
etl::fsm_state_id_t process_event(const etl::imessage& message)
|
||||
{
|
||||
etl::fsm_state_id_t new_state_id;
|
||||
etl::message_id_t event_id = message.get_message_id();
|
||||
etl::message_id_t event_id = message.get_message_id();
|
||||
|
||||
switch (event_id)
|
||||
{
|
||||
@ -1515,7 +1521,7 @@ namespace etl
|
||||
//***************************************************************************
|
||||
// Specialisation for 3 message types.
|
||||
//***************************************************************************
|
||||
template <typename TContext, typename TDerived, etl::fsm_state_id_t STATE_ID_,
|
||||
template <typename TContext, typename TDerived, etl::fsm_state_id_t STATE_ID_,
|
||||
typename T1, typename T2, typename T3>
|
||||
class fsm_state<TContext, TDerived, STATE_ID_, T1, T2, T3, void, void, void, void, void, void, void, void, void, void, void, void, void> : public ifsm_state
|
||||
{
|
||||
@ -1544,7 +1550,7 @@ namespace etl
|
||||
etl::fsm_state_id_t process_event(const etl::imessage& message)
|
||||
{
|
||||
etl::fsm_state_id_t new_state_id;
|
||||
etl::message_id_t event_id = message.get_message_id();
|
||||
etl::message_id_t event_id = message.get_message_id();
|
||||
|
||||
switch (event_id)
|
||||
{
|
||||
@ -1561,7 +1567,7 @@ namespace etl
|
||||
//***************************************************************************
|
||||
// Specialisation for 2 message types.
|
||||
//***************************************************************************
|
||||
template <typename TContext, typename TDerived, etl::fsm_state_id_t STATE_ID_,
|
||||
template <typename TContext, typename TDerived, etl::fsm_state_id_t STATE_ID_,
|
||||
typename T1, typename T2>
|
||||
class fsm_state<TContext, TDerived, STATE_ID_, T1, T2, void, void, void, void, void, void, void, void, void, void, void, void, void, void> : public ifsm_state
|
||||
{
|
||||
@ -1590,7 +1596,7 @@ namespace etl
|
||||
etl::fsm_state_id_t process_event(const etl::imessage& message)
|
||||
{
|
||||
etl::fsm_state_id_t new_state_id;
|
||||
etl::message_id_t event_id = message.get_message_id();
|
||||
etl::message_id_t event_id = message.get_message_id();
|
||||
|
||||
switch (event_id)
|
||||
{
|
||||
@ -1606,7 +1612,7 @@ namespace etl
|
||||
//***************************************************************************
|
||||
// Specialisation for 1 message type.
|
||||
//***************************************************************************
|
||||
template <typename TContext, typename TDerived, etl::fsm_state_id_t STATE_ID_,
|
||||
template <typename TContext, typename TDerived, etl::fsm_state_id_t STATE_ID_,
|
||||
typename T1>
|
||||
class fsm_state<TContext, TDerived, STATE_ID_, T1, void, void, void, void, void, void, void, void, void, void, void, void, void, void, void> : public ifsm_state
|
||||
{
|
||||
@ -1635,7 +1641,7 @@ namespace etl
|
||||
etl::fsm_state_id_t process_event(const etl::imessage& message)
|
||||
{
|
||||
etl::fsm_state_id_t new_state_id;
|
||||
etl::message_id_t event_id = message.get_message_id();
|
||||
etl::message_id_t event_id = message.get_message_id();
|
||||
|
||||
switch (event_id)
|
||||
{
|
||||
@ -1672,6 +1678,7 @@ namespace etl
|
||||
{
|
||||
return static_cast<TContext&>(ifsm_state::get_fsm_context());
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
etl::fsm_state_id_t process_event(const etl::imessage& message)
|
||||
@ -1680,15 +1687,15 @@ namespace etl
|
||||
}
|
||||
};
|
||||
|
||||
template <typename TContext, typename TDerived, etl::fsm_state_id_t STATE_ID_,
|
||||
typename T1, typename T2, typename T3, typename T4,
|
||||
typename T5, typename T6, typename T7, typename T8,
|
||||
typename T9, typename T10, typename T11, typename T12,
|
||||
template <typename TContext, typename TDerived, etl::fsm_state_id_t STATE_ID_,
|
||||
typename T1, typename T2, typename T3, typename T4,
|
||||
typename T5, typename T6, typename T7, typename T8,
|
||||
typename T9, typename T10, typename T11, typename T12,
|
||||
typename T13, typename T14, typename T15, typename T16>
|
||||
ETL_CONSTANT etl::fsm_state_id_t fsm_state<TContext, TDerived, STATE_ID_, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>::STATE_ID;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
} // namespace etl
|
||||
|
||||
#include "private/minmax_pop.h"
|
||||
#include "private/minmax_pop.h"
|
||||
|
||||
#endif
|
||||
|
||||
@ -31,7 +31,7 @@ import cog
|
||||
cog.outl("#if 0")
|
||||
]]]*/
|
||||
/*[[[end]]]*/
|
||||
#error THIS HEADER IS A GENERATOR. DO NOT INCLUDE.
|
||||
#error THIS HEADER IS A GENERATOR. DO NOT INCLUDE.
|
||||
/*[[[cog
|
||||
import cog
|
||||
cog.outl("#endif")
|
||||
@ -61,24 +61,24 @@ cog.outl("//********************************************************************
|
||||
//***************************************************************************
|
||||
|
||||
#ifndef ETL_FSM_INCLUDED
|
||||
#define ETL_FSM_INCLUDED
|
||||
#define ETL_FSM_INCLUDED
|
||||
|
||||
#include "platform.h"
|
||||
#include "array.h"
|
||||
#include "nullptr.h"
|
||||
#include "error_handler.h"
|
||||
#include "exception.h"
|
||||
#include "user_type.h"
|
||||
#include "message_router.h"
|
||||
#include "integral_limits.h"
|
||||
#include "largest.h"
|
||||
#if ETL_USING_CPP11
|
||||
#include "tuple.h"
|
||||
#endif
|
||||
#include "platform.h"
|
||||
#include "array.h"
|
||||
#include "error_handler.h"
|
||||
#include "exception.h"
|
||||
#include "integral_limits.h"
|
||||
#include "largest.h"
|
||||
#include "message_router.h"
|
||||
#include "nullptr.h"
|
||||
#include "user_type.h"
|
||||
#if ETL_USING_CPP11
|
||||
#include "tuple.h"
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "private/minmax_push.h"
|
||||
#include "private/minmax_push.h"
|
||||
|
||||
namespace etl
|
||||
{
|
||||
@ -86,33 +86,33 @@ namespace etl
|
||||
class hfsm;
|
||||
|
||||
/// Allow alternative type for state id.
|
||||
#if !defined(ETL_FSM_STATE_ID_TYPE)
|
||||
#if !defined(ETL_FSM_STATE_ID_TYPE)
|
||||
typedef uint_least8_t fsm_state_id_t;
|
||||
#else
|
||||
#else
|
||||
typedef ETL_FSM_STATE_ID_TYPE fsm_state_id_t;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// For internal FSM use.
|
||||
typedef typename etl::larger_type<etl::message_id_t>::type fsm_internal_id_t;
|
||||
|
||||
#if ETL_USING_CPP17 && !defined(ETL_FSM_FORCE_CPP03_IMPLEMENTATION) // For C++17 and above
|
||||
#if ETL_USING_CPP17 && !defined(ETL_FSM_FORCE_CPP03_IMPLEMENTATION) // For C++17 and above
|
||||
template <typename, typename, etl::fsm_state_id_t, typename...>
|
||||
class fsm_state;
|
||||
#else
|
||||
/*[[[cog
|
||||
#else
|
||||
/*[[[cog
|
||||
import cog
|
||||
cog.outl("template <typename, typename, etl::fsm_state_id_t,")
|
||||
cog.out(" ")
|
||||
cog.out(" ")
|
||||
for n in range(1, int(Handlers)):
|
||||
cog.out("typename, ")
|
||||
cog.out(" typename,")
|
||||
if n % 4 == 0:
|
||||
cog.outl("")
|
||||
cog.out(" ")
|
||||
cog.outl("typename>")
|
||||
cog.out(" ")
|
||||
cog.outl(" typename>")
|
||||
cog.outl("class fsm_state;")
|
||||
]]]*/
|
||||
/*[[[end]]]*/
|
||||
#endif
|
||||
/*[[[end]]]*/
|
||||
#endif
|
||||
|
||||
//***************************************************************************
|
||||
/// Base exception class for FSM.
|
||||
@ -185,6 +185,7 @@ namespace etl
|
||||
class fsm_not_started : public etl::fsm_exception
|
||||
{
|
||||
public:
|
||||
|
||||
fsm_not_started(string_type file_name_, numeric_type line_number_)
|
||||
: etl::fsm_exception(ETL_ERROR_TEXT("fsm:not started", ETL_FSM_FILE_ID"F"), file_name_, line_number_)
|
||||
{
|
||||
@ -198,6 +199,7 @@ namespace etl
|
||||
class fsm_reentrant_transition_forbidden : public etl::fsm_exception
|
||||
{
|
||||
public:
|
||||
|
||||
fsm_reentrant_transition_forbidden(string_type file_name_, numeric_type line_number_)
|
||||
: etl::fsm_exception(ETL_ERROR_TEXT("fsm:reentrant calls to start/receive/etc. forbidden", ETL_FSM_FILE_ID"G"), file_name_, line_number_)
|
||||
{
|
||||
@ -214,7 +216,7 @@ namespace etl
|
||||
// Pass this whenever no state change is desired.
|
||||
// The highest unsigned value of fsm_state_id_t.
|
||||
static ETL_CONSTANT fsm_state_id_t No_State_Change = etl::integral_limits<fsm_state_id_t>::max;
|
||||
|
||||
|
||||
// Pass this when this event also needs to be passed to the parent.
|
||||
static ETL_CONSTANT fsm_state_id_t Pass_To_Parent = No_State_Change - 1U;
|
||||
|
||||
@ -232,15 +234,16 @@ namespace etl
|
||||
ETL_CONSTANT fsm_state_id_t ifsm_state_helper<T>::Self_Transition;
|
||||
|
||||
// Compile-time: TState::ID must equal its index in the type list (0..N-1)
|
||||
template <size_t Id, typename...> struct check_ids : etl::true_type
|
||||
template <size_t Id, typename...>
|
||||
struct check_ids : etl::true_type
|
||||
{
|
||||
};
|
||||
|
||||
template <size_t Id, typename TState0, typename... TRest>
|
||||
struct check_ids<Id, TState0, TRest...>
|
||||
: etl::integral_constant<bool, (TState0::STATE_ID == Id) && private_fsm::check_ids<Id + 1, TRest...>::value>
|
||||
: etl::integral_constant<bool, (TState0::STATE_ID == Id) && private_fsm::check_ids<Id + 1, TRest...>::value>
|
||||
{
|
||||
};
|
||||
};
|
||||
|
||||
//***************************************************************************
|
||||
/// RAII detection mechanism to catch reentrant calls to methods that might
|
||||
@ -250,6 +253,7 @@ namespace etl
|
||||
class fsm_reentrancy_guard
|
||||
{
|
||||
public:
|
||||
|
||||
//*******************************************
|
||||
/// Constructor.
|
||||
/// Checks if another method has locked reentrancy.
|
||||
@ -269,29 +273,30 @@ namespace etl
|
||||
{
|
||||
is_locked = false;
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
|
||||
// Reference to the flag signifying a lock on the state machine.
|
||||
bool& is_locked;
|
||||
|
||||
|
||||
// Copy & move semantics disabled since this is a guard.
|
||||
fsm_reentrancy_guard(fsm_reentrancy_guard const&) ETL_DELETE;
|
||||
fsm_reentrancy_guard& operator= (fsm_reentrancy_guard const&) ETL_DELETE;
|
||||
#if ETL_USING_CPP11
|
||||
fsm_reentrancy_guard& operator=(fsm_reentrancy_guard const&) ETL_DELETE;
|
||||
#if ETL_USING_CPP11
|
||||
fsm_reentrancy_guard(fsm_reentrancy_guard&&) ETL_DELETE;
|
||||
fsm_reentrancy_guard& operator= (fsm_reentrancy_guard&&) ETL_DELETE;
|
||||
#endif
|
||||
fsm_reentrancy_guard& operator=(fsm_reentrancy_guard&&) ETL_DELETE;
|
||||
#endif
|
||||
};
|
||||
}
|
||||
} // namespace private_fsm
|
||||
|
||||
class ifsm_state;
|
||||
|
||||
#if ETL_USING_CPP11
|
||||
#if ETL_USING_CPP11
|
||||
//***************************************************************************
|
||||
/// A class to store FSM states.
|
||||
//***************************************************************************
|
||||
template <typename... TStates>
|
||||
class fsm_state_pack
|
||||
class fsm_state_pack
|
||||
{
|
||||
public:
|
||||
|
||||
@ -313,18 +318,18 @@ namespace etl
|
||||
/// Gets a reference to the state.
|
||||
//*********************************
|
||||
template <typename TState>
|
||||
TState& get()
|
||||
{
|
||||
return etl::get<TState>(storage);
|
||||
TState& get()
|
||||
{
|
||||
return etl::get<TState>(storage);
|
||||
}
|
||||
|
||||
//*********************************
|
||||
/// Gets a const reference to the state.
|
||||
//*********************************
|
||||
template <typename TState>
|
||||
const TState& get() const
|
||||
{
|
||||
return etl::get<TState>(storage);
|
||||
const TState& get() const
|
||||
{
|
||||
return etl::get<TState>(storage);
|
||||
}
|
||||
|
||||
private:
|
||||
@ -341,9 +346,9 @@ namespace etl
|
||||
etl::tuple<TStates...> storage{};
|
||||
|
||||
/// Pointers to the states.
|
||||
etl::ifsm_state* states[sizeof...(TStates)]{ &etl::get<TStates>(storage)... };
|
||||
etl::ifsm_state* states[sizeof...(TStates)]{&etl::get<TStates>(storage)...};
|
||||
};
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//***************************************************************************
|
||||
/// Interface class for FSM states.
|
||||
@ -360,24 +365,24 @@ namespace etl
|
||||
using private_fsm::ifsm_state_helper<>::Pass_To_Parent;
|
||||
using private_fsm::ifsm_state_helper<>::Self_Transition;
|
||||
|
||||
#if ETL_USING_CPP17 && !defined(ETL_FSM_FORCE_CPP03_IMPLEMENTATION) // For C++17 and above
|
||||
#if ETL_USING_CPP17 && !defined(ETL_FSM_FORCE_CPP03_IMPLEMENTATION) // For C++17 and above
|
||||
template <typename, typename, etl::fsm_state_id_t, typename...>
|
||||
friend class fsm_state;
|
||||
#else
|
||||
#else
|
||||
/*[[[cog
|
||||
import cog
|
||||
cog.outl(" template <typename, typename, etl::fsm_state_id_t,")
|
||||
cog.out(" ")
|
||||
cog.out(" ")
|
||||
for n in range(1, int(Handlers)):
|
||||
cog.out("typename, ")
|
||||
cog.out(" typename,")
|
||||
if n % 4 == 0:
|
||||
cog.outl("")
|
||||
cog.out(" ")
|
||||
cog.outl("typename>")
|
||||
cog.out(" ")
|
||||
cog.outl(" typename>")
|
||||
]]]*/
|
||||
/*[[[end]]]*/
|
||||
friend class etl::fsm_state;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//*******************************************
|
||||
/// Gets the id for this state.
|
||||
@ -409,7 +414,7 @@ namespace etl
|
||||
template <typename TSize>
|
||||
void set_child_states(etl::ifsm_state** state_list, TSize size)
|
||||
{
|
||||
p_active_child = ETL_NULLPTR;
|
||||
p_active_child = ETL_NULLPTR;
|
||||
p_default_child = ETL_NULLPTR;
|
||||
|
||||
for (TSize i = 0; i < size; ++i)
|
||||
@ -425,11 +430,11 @@ namespace etl
|
||||
/// Constructor.
|
||||
//*******************************************
|
||||
ifsm_state(etl::fsm_state_id_t state_id_)
|
||||
: state_id(state_id_),
|
||||
p_context(ETL_NULLPTR),
|
||||
p_parent(ETL_NULLPTR),
|
||||
p_active_child(ETL_NULLPTR),
|
||||
p_default_child(ETL_NULLPTR)
|
||||
: state_id(state_id_)
|
||||
, p_context(ETL_NULLPTR)
|
||||
, p_parent(ETL_NULLPTR)
|
||||
, p_active_child(ETL_NULLPTR)
|
||||
, p_default_child(ETL_NULLPTR)
|
||||
{
|
||||
}
|
||||
|
||||
@ -450,8 +455,11 @@ namespace etl
|
||||
|
||||
virtual fsm_state_id_t process_event(const etl::imessage& message) = 0;
|
||||
|
||||
virtual fsm_state_id_t on_enter_state() { return No_State_Change; } // By default, do nothing.
|
||||
virtual void on_exit_state() {} // By default, do nothing.
|
||||
virtual fsm_state_id_t on_enter_state()
|
||||
{
|
||||
return No_State_Change;
|
||||
} // By default, do nothing.
|
||||
virtual void on_exit_state() {} // By default, do nothing.
|
||||
|
||||
//*******************************************
|
||||
void set_fsm_context(etl::fsm& context)
|
||||
@ -476,7 +484,7 @@ namespace etl
|
||||
|
||||
// Disabled.
|
||||
ifsm_state(const ifsm_state&) ETL_DELETE;
|
||||
ifsm_state& operator =(const ifsm_state&) ETL_DELETE;
|
||||
ifsm_state& operator=(const ifsm_state&) ETL_DELETE;
|
||||
};
|
||||
|
||||
//***************************************************************************
|
||||
@ -508,7 +516,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));
|
||||
@ -522,7 +530,7 @@ namespace etl
|
||||
}
|
||||
}
|
||||
|
||||
#if ETL_USING_CPP11
|
||||
#if ETL_USING_CPP11
|
||||
//*******************************************
|
||||
/// Set the states for the FSM
|
||||
/// From an etl::fsm_state_pack.
|
||||
@ -530,7 +538,7 @@ namespace etl
|
||||
template <typename... TStates>
|
||||
void set_states(etl::fsm_state_pack<TStates...>& state_pack)
|
||||
{
|
||||
state_list = state_pack.get_state_list();
|
||||
state_list = state_pack.get_state_list();
|
||||
number_of_states = etl::fsm_state_id_t(state_pack.size());
|
||||
|
||||
for (etl::fsm_state_id_t i = 0; i < number_of_states; ++i)
|
||||
@ -538,7 +546,7 @@ namespace etl
|
||||
state_list[i]->set_fsm_context(*this);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//*******************************************
|
||||
/// Starts the FSM.
|
||||
@ -559,11 +567,11 @@ namespace etl
|
||||
if (call_on_enter_state)
|
||||
{
|
||||
etl::fsm_state_id_t next_state_id;
|
||||
etl::ifsm_state* p_last_state;
|
||||
etl::ifsm_state* p_last_state;
|
||||
|
||||
do
|
||||
{
|
||||
p_last_state = p_state;
|
||||
p_last_state = p_state;
|
||||
next_state_id = p_state->on_enter_state();
|
||||
if (next_state_id != ifsm_state::No_State_Change)
|
||||
{
|
||||
@ -586,7 +594,7 @@ namespace etl
|
||||
{
|
||||
etl::fsm_state_id_t next_state_id = p_state->process_event(message);
|
||||
|
||||
process_state_change(next_state_id);
|
||||
process_state_change(next_state_id);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -696,9 +704,7 @@ namespace etl
|
||||
//********************************************
|
||||
bool have_changed_state(etl::fsm_state_id_t next_state_id) const
|
||||
{
|
||||
return (next_state_id != p_state->get_state_id()) &&
|
||||
(next_state_id != ifsm_state::No_State_Change) &&
|
||||
(next_state_id != ifsm_state::Self_Transition);
|
||||
return (next_state_id != p_state->get_state_id()) && (next_state_id != ifsm_state::No_State_Change) && (next_state_id != ifsm_state::Self_Transition);
|
||||
}
|
||||
|
||||
//********************************************
|
||||
@ -717,7 +723,7 @@ namespace etl
|
||||
p_state->on_exit_state();
|
||||
next_state_id = p_state->on_enter_state();
|
||||
}
|
||||
|
||||
|
||||
if (have_changed_state(next_state_id))
|
||||
{
|
||||
ETL_ASSERT_OR_RETURN_VALUE(next_state_id < number_of_states, ETL_ERROR(etl::fsm_state_id_exception), p_state->get_state_id());
|
||||
@ -741,16 +747,16 @@ namespace etl
|
||||
return p_state->get_state_id();
|
||||
}
|
||||
|
||||
etl::ifsm_state* p_state; ///< A pointer to the current state.
|
||||
etl::ifsm_state** state_list; ///< The list of added states.
|
||||
etl::fsm_state_id_t number_of_states; ///< The number of states.
|
||||
bool is_processing_state_change; ///< Whether a method call that could potentially trigger a state change is active
|
||||
etl::ifsm_state* p_state; ///< A pointer to the current state.
|
||||
etl::ifsm_state** state_list; ///< The list of added states.
|
||||
etl::fsm_state_id_t number_of_states; ///< The number of states.
|
||||
bool is_processing_state_change; ///< Whether a method call that could potentially trigger a state change is active
|
||||
};
|
||||
|
||||
//*************************************************************************************************
|
||||
// For C++17 and above.
|
||||
//*************************************************************************************************
|
||||
#if ETL_USING_CPP17 && !defined(ETL_FSM_FORCE_CPP03_IMPLEMENTATION) // For C++17 and above
|
||||
#if ETL_USING_CPP17 && !defined(ETL_FSM_FORCE_CPP03_IMPLEMENTATION) // For C++17 and above
|
||||
//***************************************************************************
|
||||
// The definition for all types.
|
||||
//***************************************************************************
|
||||
@ -782,7 +788,7 @@ namespace etl
|
||||
//********************************************
|
||||
struct result_t
|
||||
{
|
||||
bool was_handled;
|
||||
bool was_handled;
|
||||
etl::fsm_state_id_t state_id;
|
||||
};
|
||||
|
||||
@ -821,11 +827,11 @@ namespace etl
|
||||
template <typename TContext, typename TDerived, etl::fsm_state_id_t STATE_ID_, typename... TMessageTypes>
|
||||
ETL_CONSTANT etl::fsm_state_id_t fsm_state<TContext, TDerived, STATE_ID_, TMessageTypes...>::STATE_ID;
|
||||
|
||||
#else
|
||||
//*************************************************************************************************
|
||||
// For C++14 and below.
|
||||
//*************************************************************************************************
|
||||
/*[[[cog
|
||||
#else
|
||||
//*************************************************************************************************
|
||||
// For C++14 and below.
|
||||
//*************************************************************************************************
|
||||
/*[[[cog
|
||||
import cog
|
||||
################################################
|
||||
# The first definition for all of the events.
|
||||
@ -833,14 +839,14 @@ namespace etl
|
||||
cog.outl("//***************************************************************************")
|
||||
cog.outl("// The definition for all %s message types." % Handlers)
|
||||
cog.outl("//***************************************************************************")
|
||||
cog.outl("template <typename TContext, typename TDerived, etl::fsm_state_id_t STATE_ID_, ")
|
||||
cog.out(" ")
|
||||
cog.outl("template <typename TContext, typename TDerived, etl::fsm_state_id_t STATE_ID_,")
|
||||
cog.out(" ")
|
||||
for n in range(1, int(Handlers)):
|
||||
cog.out("typename T%s = void, " % n)
|
||||
cog.out(" typename T%s = void," % n)
|
||||
if n % 4 == 0:
|
||||
cog.outl("")
|
||||
cog.out(" ")
|
||||
cog.outl("typename T%s = void>" % Handlers)
|
||||
cog.out(" ")
|
||||
cog.outl(" typename T%s = void>" % Handlers)
|
||||
cog.outl("class fsm_state : public ifsm_state")
|
||||
cog.outl("{")
|
||||
cog.outl("public:")
|
||||
@ -868,7 +874,7 @@ namespace etl
|
||||
cog.outl(" etl::fsm_state_id_t process_event(const etl::imessage& message)")
|
||||
cog.outl(" {")
|
||||
cog.outl(" etl::fsm_state_id_t new_state_id;")
|
||||
cog.outl(" etl::message_id_t event_id = message.get_message_id();")
|
||||
cog.outl(" etl::message_id_t event_id = message.get_message_id();")
|
||||
cog.outl("")
|
||||
cog.outl(" switch (event_id)")
|
||||
cog.outl(" {")
|
||||
@ -896,14 +902,14 @@ namespace etl
|
||||
else:
|
||||
cog.outl("// Specialisation for %d message types." % n)
|
||||
cog.outl("//***************************************************************************")
|
||||
cog.outl("template <typename TContext, typename TDerived, etl::fsm_state_id_t STATE_ID_, ")
|
||||
cog.out(" ")
|
||||
cog.outl("template <typename TContext, typename TDerived, etl::fsm_state_id_t STATE_ID_,")
|
||||
cog.out(" ")
|
||||
for t in range(1, n):
|
||||
cog.out("typename T%d, " % t)
|
||||
cog.out(" typename T%d," % t)
|
||||
if t % 4 == 0:
|
||||
cog.outl("")
|
||||
cog.out(" ")
|
||||
cog.outl("typename T%d>" % n)
|
||||
cog.out(" ")
|
||||
cog.outl(" typename T%d>" % n)
|
||||
cog.out("class fsm_state<TContext, TDerived, STATE_ID_, ")
|
||||
for t in range(1, n + 1):
|
||||
cog.out("T%d, " % t)
|
||||
@ -942,7 +948,7 @@ namespace etl
|
||||
cog.outl(" etl::fsm_state_id_t process_event(const etl::imessage& message)")
|
||||
cog.outl(" {")
|
||||
cog.outl(" etl::fsm_state_id_t new_state_id;")
|
||||
cog.outl(" etl::message_id_t event_id = message.get_message_id();")
|
||||
cog.outl(" etl::message_id_t event_id = message.get_message_id();")
|
||||
cog.outl("")
|
||||
cog.outl(" switch (event_id)")
|
||||
cog.outl(" {")
|
||||
@ -993,6 +999,7 @@ namespace etl
|
||||
cog.outl(" {")
|
||||
cog.outl(" return static_cast<TContext&>(ifsm_state::get_fsm_context());")
|
||||
cog.outl(" }")
|
||||
cog.outl("")
|
||||
cog.outl("private:")
|
||||
cog.outl("")
|
||||
cog.outl(" etl::fsm_state_id_t process_event(const etl::imessage& message)")
|
||||
@ -1002,23 +1009,23 @@ namespace etl
|
||||
cog.outl("};")
|
||||
|
||||
cog.outl("")
|
||||
cog.outl("template <typename TContext, typename TDerived, etl::fsm_state_id_t STATE_ID_, ")
|
||||
cog.out(" ")
|
||||
cog.outl("template <typename TContext, typename TDerived, etl::fsm_state_id_t STATE_ID_,")
|
||||
cog.out(" ")
|
||||
for n in range(1, int(Handlers)):
|
||||
cog.out("typename T%s, " % n)
|
||||
cog.out(" typename T%s," % n)
|
||||
if n % 4 == 0:
|
||||
cog.outl("")
|
||||
cog.out(" ")
|
||||
cog.outl("typename T%s>" % Handlers)
|
||||
cog.out(" ")
|
||||
cog.outl(" typename T%s>" % Handlers)
|
||||
cog.out("ETL_CONSTANT etl::fsm_state_id_t fsm_state<TContext, TDerived, STATE_ID_, ")
|
||||
for n in range(1, int(Handlers)):
|
||||
cog.out("T%s, " % n)
|
||||
cog.outl("T%s>::STATE_ID;" % Handlers)
|
||||
]]]*/
|
||||
/*[[[end]]]*/
|
||||
#endif
|
||||
}
|
||||
/*[[[end]]]*/
|
||||
#endif
|
||||
} // namespace etl
|
||||
|
||||
#include "private/minmax_pop.h"
|
||||
#include "private/minmax_pop.h"
|
||||
|
||||
#endif
|
||||
|
||||
@ -33,7 +33,7 @@ import cog
|
||||
cog.outl("#if 0")
|
||||
]]]*/
|
||||
/*[[[end]]]*/
|
||||
#error THIS HEADER IS A GENERATOR. DO NOT INCLUDE.
|
||||
#error THIS HEADER IS A GENERATOR. DO NOT INCLUDE.
|
||||
/*[[[cog
|
||||
import cog
|
||||
cog.outl("#endif")
|
||||
@ -63,19 +63,19 @@ cog.outl("//********************************************************************
|
||||
//***************************************************************************
|
||||
|
||||
#ifndef ETL_LARGEST_INCLUDED
|
||||
#define ETL_LARGEST_INCLUDED
|
||||
#define ETL_LARGEST_INCLUDED
|
||||
|
||||
///\defgroup largest largest
|
||||
///\ingroup utilities
|
||||
|
||||
#include "platform.h"
|
||||
#include "type_traits.h"
|
||||
#include "smallest.h"
|
||||
#include "static_assert.h"
|
||||
#include "platform.h"
|
||||
#include "smallest.h"
|
||||
#include "static_assert.h"
|
||||
#include "type_traits.h"
|
||||
|
||||
namespace etl
|
||||
{
|
||||
#if ETL_USING_CPP11 && !defined(ETL_LARGEST_TYPE_FORCE_CPP03_IMPLEMENTATION)
|
||||
#if ETL_USING_CPP11 && !defined(ETL_LARGEST_TYPE_FORCE_CPP03_IMPLEMENTATION)
|
||||
//***************************************************************************
|
||||
/// Template to determine the largest type and size.
|
||||
/// Defines 'value_type' which is the type of the largest parameter.
|
||||
@ -94,10 +94,10 @@ namespace etl
|
||||
|
||||
// Set 'type' to be the largest of the first parameter and any of the others.
|
||||
// This is recursive.
|
||||
using type = typename etl::conditional<(etl::size_of<T1>::value > etl::size_of<largest_other>::value), // Boolean
|
||||
T1, // TrueType
|
||||
largest_other> // FalseType
|
||||
::type; // The largest type of the two.
|
||||
using type = typename etl::conditional<(etl::size_of<T1>::value > etl::size_of<largest_other>::value), // Boolean
|
||||
T1, // TrueType
|
||||
largest_other> // FalseType
|
||||
::type; // The largest type of the two.
|
||||
|
||||
// The size of the largest type.
|
||||
enum
|
||||
@ -122,18 +122,18 @@ namespace etl
|
||||
};
|
||||
};
|
||||
|
||||
#if ETL_USING_CPP11
|
||||
#if ETL_USING_CPP11
|
||||
template <typename... T>
|
||||
using largest_type_t = typename largest_type<T...>::type;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if ETL_USING_CPP17
|
||||
#if ETL_USING_CPP17
|
||||
template <typename... T>
|
||||
constexpr size_t largest_type_v = largest_type<T...>::size;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#else
|
||||
/*[[[cog
|
||||
#else
|
||||
/*[[[cog
|
||||
import cog
|
||||
cog.outl("//***************************************************************************")
|
||||
cog.outl("/// Template to determine the largest type and size.")
|
||||
@ -142,16 +142,16 @@ namespace etl
|
||||
cog.outl("/// Defines 'size' which is the size of the largest parameter.")
|
||||
cog.outl("///\\ingroup largest")
|
||||
cog.outl("//***************************************************************************")
|
||||
cog.out("template <typename T1, ")
|
||||
cog.out("template <typename T1,")
|
||||
for n in range(2, int(NTypes)):
|
||||
cog.out("typename T%s = void, " % n)
|
||||
cog.out(" typename T%s = void," % n)
|
||||
if n % 4 == 0:
|
||||
cog.outl("")
|
||||
cog.out(" ")
|
||||
cog.outl("typename T%s = void>" % int(NTypes))
|
||||
cog.out(" ")
|
||||
cog.outl(" typename T%s = void>" % int(NTypes))
|
||||
cog.outl("struct largest_type")
|
||||
cog.outl("{")
|
||||
cog.outl(" // Define 'largest_other' as 'largest_type' with all but the first parameter. ")
|
||||
cog.outl(" // Define 'largest_other' as 'largest_type' with all but the first parameter.")
|
||||
cog.out(" typedef typename largest_type<")
|
||||
for n in range(2, int(NTypes)):
|
||||
cog.out("T%s, " % n)
|
||||
@ -163,9 +163,9 @@ namespace etl
|
||||
cog.outl(" // Set 'type' to be the largest of the first parameter and any of the others.")
|
||||
cog.outl(" // This is recursive.")
|
||||
cog.outl(" typedef typename etl::conditional<(sizeof(T1) > sizeof(largest_other)), // Boolean")
|
||||
cog.outl(" T1, // TrueType")
|
||||
cog.outl(" largest_other> // FalseType")
|
||||
cog.outl(" ::type type; // The largest type of the two.")
|
||||
cog.outl(" T1, // TrueType")
|
||||
cog.outl(" largest_other> // FalseType")
|
||||
cog.outl(" ::type type; // The largest type of the two.")
|
||||
cog.outl("")
|
||||
cog.outl(" // The size of the largest type.")
|
||||
cog.outl(" enum")
|
||||
@ -178,13 +178,13 @@ namespace etl
|
||||
cog.outl("// Specialisation for one template parameter.")
|
||||
cog.outl("//***************************************************************************")
|
||||
cog.outl("template <typename T1>")
|
||||
cog.out("struct largest_type<T1, ")
|
||||
cog.out("struct largest_type<T1,")
|
||||
for n in range(2, int(NTypes)):
|
||||
cog.out("void, ")
|
||||
cog.out(" void,")
|
||||
if n % 8 == 0:
|
||||
cog.outl("")
|
||||
cog.out(" ")
|
||||
cog.outl("void>")
|
||||
cog.out(" ")
|
||||
cog.outl(" void>")
|
||||
cog.outl("{")
|
||||
cog.outl(" typedef T1 type;")
|
||||
cog.outl("")
|
||||
@ -194,10 +194,10 @@ namespace etl
|
||||
cog.outl(" };")
|
||||
cog.outl("};")
|
||||
]]]*/
|
||||
/*[[[end]]]*/
|
||||
#endif
|
||||
/*[[[end]]]*/
|
||||
#endif
|
||||
|
||||
#if ETL_USING_CPP11 && !defined(ETL_LARGEST_ALIGNMENT_FORCE_CPP03_IMPLEMENTATION)
|
||||
#if ETL_USING_CPP11 && !defined(ETL_LARGEST_ALIGNMENT_FORCE_CPP03_IMPLEMENTATION)
|
||||
//***************************************************************************
|
||||
/// Template to determine the largest alignment.
|
||||
/// Defines <b>value</b> which is the largest alignment of all the parameters.
|
||||
@ -212,9 +212,9 @@ namespace etl
|
||||
// Set 'type' to be the largest of the first parameter and any of the others.
|
||||
// This is recursive.
|
||||
using type = typename etl::conditional<(etl::alignment_of<T1>::value > etl::alignment_of<largest_other>::value), // Boolean
|
||||
T1, // TrueType
|
||||
largest_other> // FalseType
|
||||
::type; // The largest type of the two.
|
||||
T1, // TrueType
|
||||
largest_other> // FalseType
|
||||
::type; // The largest type of the two.
|
||||
|
||||
// The largest alignment.
|
||||
enum
|
||||
@ -237,13 +237,13 @@ namespace etl
|
||||
};
|
||||
};
|
||||
|
||||
#if ETL_USING_CPP17
|
||||
#if ETL_USING_CPP17
|
||||
template <typename... T>
|
||||
inline constexpr size_t largest_alignment_v = largest_alignment<T...>::value;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#else
|
||||
/*[[[cog
|
||||
#else
|
||||
/*[[[cog
|
||||
import cog
|
||||
cog.outl("//***************************************************************************")
|
||||
cog.outl("/// Template to determine the largest alignment.")
|
||||
@ -251,16 +251,16 @@ namespace etl
|
||||
cog.outl("/// Defines <b>value</b> which is the largest alignment of all the parameters.")
|
||||
cog.outl("///\\ingroup largest")
|
||||
cog.outl("//***************************************************************************")
|
||||
cog.out("template <typename T1, ")
|
||||
cog.out("template <typename T1,")
|
||||
for n in range(2, int(NTypes)):
|
||||
cog.out("typename T%s = void, " % n)
|
||||
cog.out(" typename T%s = void," % n)
|
||||
if n % 4 == 0:
|
||||
cog.outl("")
|
||||
cog.out(" ")
|
||||
cog.outl("typename T%s = void>" % int(NTypes))
|
||||
cog.out(" ")
|
||||
cog.outl(" typename T%s = void>" % int(NTypes))
|
||||
cog.outl("struct largest_alignment")
|
||||
cog.outl("{")
|
||||
cog.outl(" // Define 'largest_other' as 'largest_type' with all but the first parameter. ")
|
||||
cog.outl(" // Define 'largest_other' as 'largest_type' with all but the first parameter.")
|
||||
cog.out(" typedef typename largest_alignment<")
|
||||
for n in range(2, int(NTypes)):
|
||||
cog.out("T%s, " % n)
|
||||
@ -272,9 +272,9 @@ namespace etl
|
||||
cog.outl(" // Set 'type' to be the largest of the first parameter and any of the others.")
|
||||
cog.outl(" // This is recursive.")
|
||||
cog.outl(" typedef typename etl::conditional<(etl::alignment_of<T1>::value > etl::alignment_of<largest_other>::value), // Boolean")
|
||||
cog.outl(" T1, // TrueType")
|
||||
cog.outl(" largest_other> // FalseType")
|
||||
cog.outl(" ::type type; // The largest type of the two.")
|
||||
cog.outl(" T1, // TrueType")
|
||||
cog.outl(" largest_other> // FalseType")
|
||||
cog.outl(" ::type type; // The largest type of the two.")
|
||||
cog.outl("")
|
||||
cog.outl(" // The largest alignment.")
|
||||
cog.outl(" enum")
|
||||
@ -287,13 +287,13 @@ namespace etl
|
||||
cog.outl("// Specialisation for one template parameter.")
|
||||
cog.outl("//***************************************************************************")
|
||||
cog.outl("template <typename T1>")
|
||||
cog.out("struct largest_alignment<T1, ")
|
||||
cog.out("struct largest_alignment<T1,")
|
||||
for n in range(2, int(NTypes)):
|
||||
cog.out("void, ")
|
||||
cog.out(" void,")
|
||||
if n % 8 == 0:
|
||||
cog.outl("")
|
||||
cog.out(" ")
|
||||
cog.outl("void>")
|
||||
cog.out(" ")
|
||||
cog.outl(" void>")
|
||||
cog.outl("{")
|
||||
cog.outl(" typedef T1 type;")
|
||||
cog.outl("")
|
||||
@ -303,8 +303,8 @@ namespace etl
|
||||
cog.outl(" };")
|
||||
cog.outl("};")
|
||||
]]]*/
|
||||
/*[[[end]]]*/
|
||||
#endif
|
||||
/*[[[end]]]*/
|
||||
#endif
|
||||
|
||||
//***************************************************************************
|
||||
/// Defines a type that is as larger or larger than the specified type.
|
||||
@ -319,10 +319,10 @@ namespace etl
|
||||
typedef typename etl::smallest_int_for_bits<etl::integral_limits<typename etl::make_signed<T>::type>::bits + 1>::type type;
|
||||
};
|
||||
|
||||
#if ETL_USING_CPP11
|
||||
#if ETL_USING_CPP11
|
||||
template <typename T>
|
||||
using larger_int_type_t = typename larger_int_type<T>::type;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//***************************************************************************
|
||||
/// Defines a type that is as larger or larger than the specified type.
|
||||
@ -337,10 +337,10 @@ namespace etl
|
||||
typedef typename etl::smallest_uint_for_bits<etl::integral_limits<typename etl::make_unsigned<T>::type>::bits + 1>::type type;
|
||||
};
|
||||
|
||||
#if ETL_USING_CPP11
|
||||
#if ETL_USING_CPP11
|
||||
template <typename T>
|
||||
using larger_uint_type_t = typename larger_uint_type<T>::type;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//***************************************************************************
|
||||
/// Defines a type that is as larger or larger than the specified type.
|
||||
@ -367,12 +367,12 @@ namespace etl
|
||||
typedef typename etl::smallest_int_for_bits<etl::integral_limits<T>::bits + 1>::type type;
|
||||
};
|
||||
|
||||
#if ETL_USING_CPP11
|
||||
#if ETL_USING_CPP11
|
||||
template <typename T>
|
||||
using larger_type_t = typename larger_type<T>::type;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if ETL_USING_CPP11 && !defined(ETL_LARGEST_FORCE_CPP03_IMPLEMENTATION)
|
||||
#if ETL_USING_CPP11 && !defined(ETL_LARGEST_FORCE_CPP03_IMPLEMENTATION)
|
||||
//***************************************************************************
|
||||
/// Template to determine the largest type, size and alignment.
|
||||
/// Defines <b>value</b> which is the largest type, size and alignment of all the parameters.
|
||||
@ -390,18 +390,18 @@ namespace etl
|
||||
};
|
||||
};
|
||||
|
||||
#if ETL_USING_CPP11
|
||||
template <typename... T>
|
||||
using largest_t = typename largest<T...>::type;
|
||||
#endif
|
||||
#if ETL_USING_CPP11
|
||||
template <typename... T>
|
||||
using largest_t = typename largest<T...>::type;
|
||||
#endif
|
||||
|
||||
#if ETL_USING_CPP17
|
||||
template <typename... T>
|
||||
inline constexpr size_t largest_size = largest<T...>::size;
|
||||
#endif
|
||||
#if ETL_USING_CPP17
|
||||
template <typename... T>
|
||||
inline constexpr size_t largest_size = largest<T...>::size;
|
||||
#endif
|
||||
|
||||
#else
|
||||
/*[[[cog
|
||||
#else
|
||||
/*[[[cog
|
||||
import cog
|
||||
cog.outl("//***************************************************************************")
|
||||
cog.outl("/// Template to determine the largest type, size and alignment.")
|
||||
@ -409,13 +409,13 @@ namespace etl
|
||||
cog.outl("/// Defines <b>value</b> which is the largest type, size and alignment of all the parameters.")
|
||||
cog.outl("///\\ingroup largest")
|
||||
cog.outl("//***************************************************************************")
|
||||
cog.out("template <typename T1, ")
|
||||
cog.out("template <typename T1,")
|
||||
for n in range(2, int(NTypes)):
|
||||
cog.out("typename T%s = void, " % n)
|
||||
cog.out(" typename T%s = void," % n)
|
||||
if n % 4 == 0:
|
||||
cog.outl("")
|
||||
cog.out(" ")
|
||||
cog.outl("typename T%s = void>" % NTypes)
|
||||
cog.out(" ")
|
||||
cog.outl(" typename T%s = void>" % NTypes)
|
||||
cog.outl("struct largest")
|
||||
cog.outl("{")
|
||||
cog.out(" typedef typename etl::largest_type<")
|
||||
@ -445,8 +445,8 @@ namespace etl
|
||||
cog.outl(" };")
|
||||
cog.outl("};")
|
||||
]]]*/
|
||||
/*[[[end]]]*/
|
||||
#endif
|
||||
}
|
||||
/*[[[end]]]*/
|
||||
#endif
|
||||
} // namespace etl
|
||||
|
||||
#endif
|
||||
|
||||
@ -31,7 +31,7 @@ import cog
|
||||
cog.outl("#if 0")
|
||||
]]]*/
|
||||
/*[[[end]]]*/
|
||||
#error THIS HEADER IS A GENERATOR. DO NOT INCLUDE.
|
||||
#error THIS HEADER IS A GENERATOR. DO NOT INCLUDE.
|
||||
/*[[[cog
|
||||
import cog
|
||||
cog.outl("#endif")
|
||||
@ -61,30 +61,29 @@ cog.outl("//********************************************************************
|
||||
//***************************************************************************
|
||||
|
||||
#ifndef ETL_MESSAGE_PACKET_INCLUDED
|
||||
#define ETL_MESSAGE_PACKET_INCLUDED
|
||||
#define ETL_MESSAGE_PACKET_INCLUDED
|
||||
|
||||
#include "platform.h"
|
||||
#include "platform.h"
|
||||
|
||||
#include "message.h"
|
||||
#include "error_handler.h"
|
||||
#include "static_assert.h"
|
||||
#include "largest.h"
|
||||
#include "alignment.h"
|
||||
#include "utility.h"
|
||||
#include "type_list.h"
|
||||
#include "alignment.h"
|
||||
#include "error_handler.h"
|
||||
#include "largest.h"
|
||||
#include "message.h"
|
||||
#include "static_assert.h"
|
||||
#include "type_list.h"
|
||||
#include "utility.h"
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdint.h>
|
||||
|
||||
namespace etl
|
||||
{
|
||||
#if ETL_USING_CPP17 && !defined(ETL_MESSAGE_PACKET_FORCE_CPP03_IMPLEMENTATION)
|
||||
#if ETL_USING_CPP17 && !defined(ETL_MESSAGE_PACKET_FORCE_CPP03_IMPLEMENTATION)
|
||||
//***************************************************************************
|
||||
// The definition for all message types.
|
||||
//***************************************************************************
|
||||
template <typename... TMessageTypes>
|
||||
class message_packet
|
||||
{
|
||||
|
||||
private:
|
||||
|
||||
template <typename T>
|
||||
@ -100,18 +99,18 @@ namespace etl
|
||||
|
||||
using message_types = etl::type_list<TMessageTypes...>;
|
||||
|
||||
//********************************************
|
||||
#include "private/diagnostic_uninitialized_push.h"
|
||||
//********************************************
|
||||
#include "private/diagnostic_uninitialized_push.h"
|
||||
constexpr message_packet() noexcept
|
||||
: valid(false)
|
||||
{
|
||||
}
|
||||
#include "private/diagnostic_pop.h"
|
||||
#include "private/diagnostic_pop.h"
|
||||
|
||||
//********************************************
|
||||
///
|
||||
//********************************************
|
||||
#include "private/diagnostic_uninitialized_push.h"
|
||||
//********************************************
|
||||
///
|
||||
//********************************************
|
||||
#include "private/diagnostic_uninitialized_push.h"
|
||||
template <typename T, typename = typename etl::enable_if<IsIMessage<T> || IsInMessageList<T>, int>::type>
|
||||
explicit message_packet(T&& msg)
|
||||
: valid(true)
|
||||
@ -139,7 +138,7 @@ namespace etl
|
||||
ETL_STATIC_ASSERT(IsInMessageList<T>, "Message not in packet type list");
|
||||
}
|
||||
}
|
||||
#include "private/diagnostic_pop.h"
|
||||
#include "private/diagnostic_pop.h"
|
||||
|
||||
//**********************************************
|
||||
message_packet(const message_packet& other)
|
||||
@ -152,7 +151,7 @@ namespace etl
|
||||
}
|
||||
}
|
||||
|
||||
#if ETL_USING_CPP11
|
||||
#if ETL_USING_CPP11
|
||||
//**********************************************
|
||||
message_packet(message_packet&& other)
|
||||
{
|
||||
@ -163,7 +162,7 @@ namespace etl
|
||||
add_new_message(etl::move(other.get()));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//**********************************************
|
||||
void copy(const message_packet& other)
|
||||
@ -187,9 +186,9 @@ namespace etl
|
||||
}
|
||||
}
|
||||
|
||||
//**********************************************
|
||||
#include "private/diagnostic_uninitialized_push.h"
|
||||
message_packet& operator =(const message_packet& rhs)
|
||||
//**********************************************
|
||||
#include "private/diagnostic_uninitialized_push.h"
|
||||
message_packet& operator=(const message_packet& rhs)
|
||||
{
|
||||
delete_current_message();
|
||||
valid = rhs.is_valid();
|
||||
@ -200,11 +199,11 @@ namespace etl
|
||||
|
||||
return *this;
|
||||
}
|
||||
#include "private/diagnostic_pop.h"
|
||||
#include "private/diagnostic_pop.h"
|
||||
|
||||
//**********************************************
|
||||
#include "private/diagnostic_uninitialized_push.h"
|
||||
message_packet& operator =(message_packet&& rhs)
|
||||
//**********************************************
|
||||
#include "private/diagnostic_uninitialized_push.h"
|
||||
message_packet& operator=(message_packet&& rhs)
|
||||
{
|
||||
delete_current_message();
|
||||
valid = rhs.is_valid();
|
||||
@ -215,7 +214,7 @@ namespace etl
|
||||
|
||||
return *this;
|
||||
}
|
||||
#include "private/diagnostic_pop.h"
|
||||
#include "private/diagnostic_pop.h"
|
||||
|
||||
//********************************************
|
||||
~message_packet()
|
||||
@ -263,7 +262,7 @@ namespace etl
|
||||
//**********************************************
|
||||
template <typename TMessage>
|
||||
static ETL_CONSTEXPR
|
||||
typename etl::enable_if<etl::is_base_of<etl::imessage, TMessage>::value, bool>::type
|
||||
typename etl::enable_if<etl::is_base_of<etl::imessage, TMessage>::value, bool>::type
|
||||
accepts()
|
||||
{
|
||||
return accepts<TMessage::ID>();
|
||||
@ -271,7 +270,7 @@ namespace etl
|
||||
|
||||
enum
|
||||
{
|
||||
SIZE = etl::largest<TMessageTypes...>::size,
|
||||
SIZE = etl::largest<TMessageTypes...>::size,
|
||||
ALIGNMENT = etl::largest<TMessageTypes...>::alignment
|
||||
};
|
||||
|
||||
@ -291,24 +290,24 @@ namespace etl
|
||||
return Id1 == id2;
|
||||
}
|
||||
|
||||
//********************************************
|
||||
#include "private/diagnostic_uninitialized_push.h"
|
||||
//********************************************
|
||||
#include "private/diagnostic_uninitialized_push.h"
|
||||
void delete_current_message()
|
||||
{
|
||||
if (valid)
|
||||
{
|
||||
etl::imessage* pmsg = static_cast<etl::imessage*>(data);
|
||||
|
||||
#if ETL_HAS_VIRTUAL_MESSAGES
|
||||
#if ETL_HAS_VIRTUAL_MESSAGES
|
||||
pmsg->~imessage();
|
||||
#else
|
||||
#else
|
||||
delete_message(pmsg);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#include "private/diagnostic_pop.h"
|
||||
#include "private/diagnostic_pop.h"
|
||||
|
||||
#if !ETL_HAS_VIRTUAL_MESSAGES
|
||||
#if !ETL_HAS_VIRTUAL_MESSAGES
|
||||
//********************************************
|
||||
void delete_message(etl::imessage* pmsg)
|
||||
{
|
||||
@ -330,7 +329,7 @@ namespace etl
|
||||
return false;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//********************************************
|
||||
void add_new_message(const etl::imessage& msg)
|
||||
@ -344,7 +343,7 @@ namespace etl
|
||||
(add_new_message_type<TMessageTypes>(etl::move(msg)) || ...);
|
||||
}
|
||||
|
||||
#include "private/diagnostic_uninitialized_push.h"
|
||||
#include "private/diagnostic_uninitialized_push.h"
|
||||
//********************************************
|
||||
/// Only enabled for types that are in the typelist.
|
||||
//********************************************
|
||||
@ -355,9 +354,9 @@ namespace etl
|
||||
void* p = data;
|
||||
new (p) etl::remove_reference_t<TMessage>((etl::forward<TMessage>(msg)));
|
||||
}
|
||||
#include "private/diagnostic_pop.h"
|
||||
#include "private/diagnostic_pop.h"
|
||||
|
||||
#include "private/diagnostic_uninitialized_push.h"
|
||||
#include "private/diagnostic_uninitialized_push.h"
|
||||
//********************************************
|
||||
template <typename TType>
|
||||
bool add_new_message_type(const etl::imessage& msg)
|
||||
@ -373,7 +372,7 @@ namespace etl
|
||||
return false;
|
||||
}
|
||||
}
|
||||
#include "private/diagnostic_pop.h"
|
||||
#include "private/diagnostic_pop.h"
|
||||
|
||||
//********************************************
|
||||
template <typename TType>
|
||||
@ -392,7 +391,7 @@ namespace etl
|
||||
}
|
||||
|
||||
typename etl::aligned_storage<SIZE, ALIGNMENT>::type data;
|
||||
bool valid;
|
||||
bool valid;
|
||||
};
|
||||
|
||||
//***************************************************************************
|
||||
@ -416,24 +415,24 @@ namespace etl
|
||||
|
||||
using message_types = etl::type_list<>;
|
||||
|
||||
//********************************************
|
||||
#include "private/diagnostic_uninitialized_push.h"
|
||||
//********************************************
|
||||
#include "private/diagnostic_uninitialized_push.h"
|
||||
constexpr message_packet() noexcept
|
||||
{
|
||||
}
|
||||
#include "private/diagnostic_pop.h"
|
||||
#include "private/diagnostic_pop.h"
|
||||
|
||||
//**********************************************
|
||||
message_packet(const message_packet& /*other*/)
|
||||
{
|
||||
}
|
||||
|
||||
#if ETL_USING_CPP11
|
||||
#if ETL_USING_CPP11
|
||||
//**********************************************
|
||||
message_packet(message_packet&& /*other*/)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//**********************************************
|
||||
void copy(const message_packet& /*other*/)
|
||||
@ -445,21 +444,21 @@ namespace etl
|
||||
{
|
||||
}
|
||||
|
||||
//**********************************************
|
||||
#include "private/diagnostic_uninitialized_push.h"
|
||||
message_packet& operator =(const message_packet& /*rhs*/)
|
||||
//**********************************************
|
||||
#include "private/diagnostic_uninitialized_push.h"
|
||||
message_packet& operator=(const message_packet& /*rhs*/)
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
#include "private/diagnostic_pop.h"
|
||||
#include "private/diagnostic_pop.h"
|
||||
|
||||
//**********************************************
|
||||
#include "private/diagnostic_uninitialized_push.h"
|
||||
message_packet& operator =(message_packet&& /*rhs*/)
|
||||
//**********************************************
|
||||
#include "private/diagnostic_uninitialized_push.h"
|
||||
message_packet& operator=(message_packet&& /*rhs*/)
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
#include "private/diagnostic_pop.h"
|
||||
#include "private/diagnostic_pop.h"
|
||||
|
||||
//********************************************
|
||||
~message_packet()
|
||||
@ -502,7 +501,7 @@ namespace etl
|
||||
|
||||
enum
|
||||
{
|
||||
SIZE = 0,
|
||||
SIZE = 0,
|
||||
ALIGNMENT = 1
|
||||
};
|
||||
};
|
||||
@ -521,7 +520,7 @@ namespace etl
|
||||
template <typename TTypeList>
|
||||
using message_packet_from_type_list_t = typename message_packet_from_type_list<TTypeList>::type;
|
||||
|
||||
#else
|
||||
#else
|
||||
|
||||
/*[[[cog
|
||||
import cog
|
||||
@ -532,10 +531,11 @@ namespace etl
|
||||
for i in range(1, n + 1):
|
||||
cog.out(" T%d::ID == id" % i)
|
||||
if i < n:
|
||||
cog.out(" ||")
|
||||
if i % 4 == 0:
|
||||
cog.outl("")
|
||||
cog.out(" ")
|
||||
cog.out(" ||")
|
||||
else:
|
||||
cog.out(" ||")
|
||||
cog.outl(";")
|
||||
|
||||
################################################
|
||||
@ -544,10 +544,11 @@ namespace etl
|
||||
for i in range(1, n + 1):
|
||||
cog.out(" T%d::ID == Id" % i)
|
||||
if i < n:
|
||||
cog.out(" ||")
|
||||
if i % 4 == 0:
|
||||
cog.outl("")
|
||||
cog.out(" ")
|
||||
cog.out(" ||")
|
||||
else:
|
||||
cog.out(" ||")
|
||||
cog.outl(";")
|
||||
|
||||
################################################
|
||||
@ -556,10 +557,11 @@ namespace etl
|
||||
for i in range(1, n + 1):
|
||||
cog.out(" T%d::ID == TMessage::ID" % i)
|
||||
if i < n:
|
||||
cog.out(" ||")
|
||||
if i % 4 == 0:
|
||||
cog.outl("")
|
||||
cog.out(" ")
|
||||
cog.out(" ||")
|
||||
else:
|
||||
cog.out(" ||")
|
||||
cog.outl(";")
|
||||
|
||||
################################################
|
||||
@ -568,9 +570,9 @@ namespace etl
|
||||
cog.out(" static const bool Enabled = (!etl::is_same<typename etl::remove_cvref<TMessage>::type, etl::message_packet<")
|
||||
for i in range(1, n):
|
||||
cog.out("T%d, " % i)
|
||||
cog.outl("T%s> >::value &&" % n)
|
||||
cog.outl(" !etl::is_same<typename etl::remove_cvref<TMessage>::type, etl::imessage>::value &&")
|
||||
cog.out(" etl::is_one_of<typename etl::remove_cvref<TMessage>::type,")
|
||||
cog.outl("T%s> >::value" % n)
|
||||
cog.outl(" && !etl::is_same<typename etl::remove_cvref<TMessage>::type, etl::imessage>::value")
|
||||
cog.out(" && etl::is_one_of<typename etl::remove_cvref<TMessage>::type, ")
|
||||
for i in range(1, n):
|
||||
cog.out("T%d, " % i)
|
||||
cog.outl("T%s>::value);" % n)
|
||||
@ -583,9 +585,9 @@ namespace etl
|
||||
cog.out(" static constexpr bool Enabled = (!etl::is_same<typename etl::remove_cvref<TMessage>::type, etl::message_packet<")
|
||||
for i in range(1, n):
|
||||
cog.out("T%d, " % i)
|
||||
cog.outl("T%s> >::value &&" % n)
|
||||
cog.outl(" !etl::is_same<typename etl::remove_cvref<TMessage>::type, etl::imessage>::value &&")
|
||||
cog.out(" etl::is_one_of<typename etl::remove_cvref<TMessage>::type,")
|
||||
cog.outl("T%s> >::value" % n)
|
||||
cog.outl(" && !etl::is_same<typename etl::remove_cvref<TMessage>::type, etl::imessage>::value")
|
||||
cog.out(" && etl::is_one_of<typename etl::remove_cvref<TMessage>::type, ")
|
||||
for i in range(1, n):
|
||||
cog.out("T%d, " % i)
|
||||
cog.outl("T%s>::value);" % n)
|
||||
@ -598,36 +600,36 @@ namespace etl
|
||||
cog.outl("//***************************************************************************")
|
||||
cog.outl("// The definition for all %s message types." % Handlers)
|
||||
cog.outl("//***************************************************************************")
|
||||
cog.out("template <")
|
||||
for n in range(1, int(Handlers)):
|
||||
cog.out("typename T%s = void, " % n)
|
||||
cog.out("template <typename T1 = void,")
|
||||
for n in range(2, int(Handlers)):
|
||||
cog.out(" typename T%s = void," % n)
|
||||
if n % 4 == 0:
|
||||
cog.outl("")
|
||||
cog.out(" ")
|
||||
cog.outl("typename T%s = void>" % int(Handlers))
|
||||
cog.out(" ")
|
||||
cog.outl(" typename T%s = void>" % int(Handlers))
|
||||
cog.outl("class message_packet")
|
||||
cog.outl("{")
|
||||
cog.outl("public:")
|
||||
cog.outl("")
|
||||
|
||||
cog.outl("#if ETL_USING_CPP11")
|
||||
cog.outl(" #if ETL_USING_CPP11")
|
||||
cog.out(" using message_types = etl::type_list<")
|
||||
for n in range(1, int(Handlers)):
|
||||
cog.out("T%s, " % n)
|
||||
cog.outl("T%s>;" % int(Handlers))
|
||||
cog.outl("#endif")
|
||||
cog.outl(" #endif")
|
||||
cog.outl("")
|
||||
|
||||
cog.outl(" //********************************************")
|
||||
cog.outl("#include \"private/diagnostic_uninitialized_push.h\"")
|
||||
cog.outl(" //********************************************")
|
||||
cog.outl(" #include \"private/diagnostic_uninitialized_push.h\"")
|
||||
cog.outl(" ETL_CONSTEXPR message_packet() ETL_NOEXCEPT")
|
||||
cog.outl(" : valid(false)")
|
||||
cog.outl(" {")
|
||||
cog.outl(" }")
|
||||
cog.outl("#include \"private/diagnostic_pop.h\"")
|
||||
cog.outl(" #include \"private/diagnostic_pop.h\"")
|
||||
cog.outl("")
|
||||
cog.outl(" //********************************************")
|
||||
cog.outl("#include \"private/diagnostic_uninitialized_push.h\"")
|
||||
cog.outl(" //********************************************")
|
||||
cog.outl(" #include \"private/diagnostic_uninitialized_push.h\"")
|
||||
cog.outl(" explicit message_packet(const etl::imessage& msg)")
|
||||
cog.outl(" {")
|
||||
cog.outl(" if (accepts(msg))")
|
||||
@ -642,11 +644,11 @@ namespace etl
|
||||
cog.outl("")
|
||||
cog.outl(" ETL_ASSERT(valid, ETL_ERROR(unhandled_message_exception));")
|
||||
cog.outl(" }")
|
||||
cog.outl("#include \"private/diagnostic_pop.h\"")
|
||||
cog.outl(" #include \"private/diagnostic_pop.h\"")
|
||||
cog.outl("")
|
||||
cog.outl("#if ETL_USING_CPP11 && !defined(ETL_MESSAGE_PACKET_FORCE_CPP03_IMPLEMENTATION)")
|
||||
cog.outl(" //********************************************")
|
||||
cog.outl("#include \"private/diagnostic_uninitialized_push.h\"")
|
||||
cog.outl(" #if ETL_USING_CPP11 && !defined(ETL_MESSAGE_PACKET_FORCE_CPP03_IMPLEMENTATION)")
|
||||
cog.outl(" //********************************************")
|
||||
cog.outl(" #include \"private/diagnostic_uninitialized_push.h\"")
|
||||
cog.outl(" explicit message_packet(etl::imessage&& msg)")
|
||||
cog.outl(" {")
|
||||
cog.outl(" if (accepts(msg))")
|
||||
@ -661,49 +663,51 @@ namespace etl
|
||||
cog.outl("")
|
||||
cog.outl(" ETL_ASSERT(valid, ETL_ERROR(unhandled_message_exception));")
|
||||
cog.outl(" }")
|
||||
cog.outl("#include \"private/diagnostic_pop.h\"")
|
||||
cog.outl("#endif")
|
||||
cog.outl(" #include \"private/diagnostic_pop.h\"")
|
||||
cog.outl(" #endif")
|
||||
cog.outl("")
|
||||
cog.outl("#if ETL_USING_CPP11 && !defined(ETL_MESSAGE_PACKET_FORCE_CPP03_IMPLEMENTATION) && !defined(ETL_COMPILER_GREEN_HILLS)")
|
||||
cog.outl(" //********************************************")
|
||||
cog.outl("#include \"private/diagnostic_uninitialized_push.h\"")
|
||||
cog.outl(" #if ETL_USING_CPP11 && !defined(ETL_MESSAGE_PACKET_FORCE_CPP03_IMPLEMENTATION) && !defined(ETL_COMPILER_GREEN_HILLS)")
|
||||
cog.outl(" //********************************************")
|
||||
cog.outl(" #include \"private/diagnostic_uninitialized_push.h\"")
|
||||
cog.out(" template <typename TMessage, typename = typename etl::enable_if<!etl::is_same<typename etl::remove_cvref<TMessage>::type, etl::message_packet<")
|
||||
for n in range(1, int(Handlers)):
|
||||
cog.out("T%s, " % n)
|
||||
cog.outl("T%s> >::value &&" % int(Handlers))
|
||||
cog.outl(" !etl::is_same<typename etl::remove_cvref<TMessage>::type, etl::imessage>::value &&")
|
||||
cog.out(" !etl::is_one_of<typename etl::remove_cvref<TMessage>::type, ")
|
||||
cog.outl("T%s> >::value" % int(Handlers))
|
||||
cog.outl(" && !etl::is_same<typename etl::remove_cvref<TMessage>::type, etl::imessage>::value")
|
||||
cog.out(" && !etl::is_one_of<typename etl::remove_cvref<TMessage>::type, ")
|
||||
for n in range(1, int(Handlers)):
|
||||
cog.out("T%s, " % n)
|
||||
cog.outl("T%s>::value, int>::type>" % int(Handlers))
|
||||
cog.outl("T%s>::value," % int(Handlers))
|
||||
cog.outl(" int>::type>")
|
||||
cog.outl(" explicit message_packet(TMessage&& /*msg*/)")
|
||||
cog.outl(" : valid(true)")
|
||||
cog.outl(" {")
|
||||
generate_static_assert_cpp11(int(Handlers))
|
||||
cog.outl(" }")
|
||||
cog.outl("#include \"private/diagnostic_pop.h\"")
|
||||
cog.outl("#else")
|
||||
cog.outl(" //********************************************")
|
||||
cog.outl("#include \"private/diagnostic_uninitialized_push.h\"")
|
||||
cog.outl(" #include \"private/diagnostic_pop.h\"")
|
||||
cog.outl(" #else")
|
||||
cog.outl(" //********************************************")
|
||||
cog.outl(" #include \"private/diagnostic_uninitialized_push.h\"")
|
||||
cog.outl(" template <typename TMessage>")
|
||||
cog.out(" explicit message_packet(const TMessage& /*msg*/, typename etl::enable_if<!etl::is_same<typename etl::remove_cvref<TMessage>::type, etl::message_packet<")
|
||||
for n in range(1, int(Handlers)):
|
||||
cog.out("T%s, " % n)
|
||||
cog.outl("T%s> >::value &&" % int(Handlers))
|
||||
cog.outl(" !etl::is_same<typename etl::remove_cvref<TMessage>::type, etl::imessage>::value &&")
|
||||
cog.out(" !etl::is_one_of<typename etl::remove_cvref<TMessage>::type, ")
|
||||
cog.outl("T%s> >::value" % int(Handlers))
|
||||
cog.outl(" && !etl::is_same<typename etl::remove_cvref<TMessage>::type, etl::imessage>::value")
|
||||
cog.out(" && !etl::is_one_of<typename etl::remove_cvref<TMessage>::type, ")
|
||||
for n in range(1, int(Handlers)):
|
||||
cog.out("T%s, " % n)
|
||||
cog.outl("T%s>::value, int>::type = 0)" % int(Handlers))
|
||||
cog.outl("T%s>::value," % int(Handlers))
|
||||
cog.outl(" int>::type = 0)")
|
||||
cog.outl(" : valid(true)")
|
||||
cog.outl(" {")
|
||||
generate_static_assert_cpp03(int(Handlers))
|
||||
cog.outl(" }")
|
||||
cog.outl("#include \"private/diagnostic_pop.h\"")
|
||||
cog.outl("#endif")
|
||||
cog.outl(" #include \"private/diagnostic_pop.h\"")
|
||||
cog.outl(" #endif")
|
||||
cog.outl("")
|
||||
cog.outl(" //**********************************************")
|
||||
cog.outl("#include \"private/diagnostic_uninitialized_push.h\"")
|
||||
cog.outl(" //**********************************************")
|
||||
cog.outl(" #include \"private/diagnostic_uninitialized_push.h\"")
|
||||
cog.outl(" message_packet(const message_packet& other)")
|
||||
cog.outl(" : valid(other.is_valid())")
|
||||
cog.outl(" {")
|
||||
@ -712,11 +716,11 @@ namespace etl
|
||||
cog.outl(" add_new_message(other.get());")
|
||||
cog.outl(" }")
|
||||
cog.outl(" }")
|
||||
cog.outl("#include \"private/diagnostic_pop.h\"")
|
||||
cog.outl(" #include \"private/diagnostic_pop.h\"")
|
||||
cog.outl("")
|
||||
cog.outl("#if ETL_USING_CPP11 && !defined(ETL_MESSAGE_PACKET_FORCE_CPP03_IMPLEMENTATION)")
|
||||
cog.outl(" //**********************************************")
|
||||
cog.outl("#include \"private/diagnostic_uninitialized_push.h\"")
|
||||
cog.outl(" #if ETL_USING_CPP11 && !defined(ETL_MESSAGE_PACKET_FORCE_CPP03_IMPLEMENTATION)")
|
||||
cog.outl(" //**********************************************")
|
||||
cog.outl(" #include \"private/diagnostic_uninitialized_push.h\"")
|
||||
cog.outl(" message_packet(message_packet&& other)")
|
||||
cog.outl(" : valid(other.is_valid())")
|
||||
cog.outl(" {")
|
||||
@ -725,12 +729,12 @@ namespace etl
|
||||
cog.outl(" add_new_message(etl::move(other.get()));")
|
||||
cog.outl(" }")
|
||||
cog.outl(" }")
|
||||
cog.outl("#include \"private/diagnostic_pop.h\"")
|
||||
cog.outl("#endif")
|
||||
cog.outl(" #include \"private/diagnostic_pop.h\"")
|
||||
cog.outl(" #endif")
|
||||
cog.outl("")
|
||||
cog.outl(" //**********************************************")
|
||||
cog.outl("#include \"private/diagnostic_uninitialized_push.h\"")
|
||||
cog.outl(" message_packet& operator =(const message_packet& rhs)")
|
||||
cog.outl(" //**********************************************")
|
||||
cog.outl(" #include \"private/diagnostic_uninitialized_push.h\"")
|
||||
cog.outl(" message_packet& operator=(const message_packet& rhs)")
|
||||
cog.outl(" {")
|
||||
cog.outl(" delete_current_message();")
|
||||
cog.outl(" valid = rhs.is_valid();")
|
||||
@ -741,12 +745,12 @@ namespace etl
|
||||
cog.outl("")
|
||||
cog.outl(" return *this;")
|
||||
cog.outl(" }")
|
||||
cog.outl("#include \"private/diagnostic_pop.h\"")
|
||||
cog.outl(" #include \"private/diagnostic_pop.h\"")
|
||||
cog.outl("")
|
||||
cog.outl("#if ETL_USING_CPP11 && !defined(ETL_MESSAGE_PACKET_FORCE_CPP03_IMPLEMENTATION)")
|
||||
cog.outl(" //**********************************************")
|
||||
cog.outl("#include \"private/diagnostic_uninitialized_push.h\"")
|
||||
cog.outl(" message_packet& operator =(message_packet&& rhs)")
|
||||
cog.outl(" #if ETL_USING_CPP11 && !defined(ETL_MESSAGE_PACKET_FORCE_CPP03_IMPLEMENTATION)")
|
||||
cog.outl(" //**********************************************")
|
||||
cog.outl(" #include \"private/diagnostic_uninitialized_push.h\"")
|
||||
cog.outl(" message_packet& operator=(message_packet&& rhs)")
|
||||
cog.outl(" {")
|
||||
cog.outl(" delete_current_message();")
|
||||
cog.outl(" valid = rhs.is_valid();")
|
||||
@ -757,8 +761,8 @@ namespace etl
|
||||
cog.outl("")
|
||||
cog.outl(" return *this;")
|
||||
cog.outl(" }")
|
||||
cog.outl("#include \"private/diagnostic_pop.h\"")
|
||||
cog.outl("#endif")
|
||||
cog.outl(" #include \"private/diagnostic_pop.h\"")
|
||||
cog.outl(" #endif")
|
||||
cog.outl("")
|
||||
cog.outl(" //********************************************")
|
||||
cog.outl(" ~message_packet()")
|
||||
@ -806,7 +810,7 @@ namespace etl
|
||||
cog.outl(" //**********************************************")
|
||||
cog.outl(" template <typename TMessage>")
|
||||
cog.outl(" static ETL_CONSTEXPR")
|
||||
cog.outl(" typename etl::enable_if<etl::is_base_of<etl::imessage, TMessage>::value, bool>::type")
|
||||
cog.outl(" typename etl::enable_if<etl::is_base_of<etl::imessage, TMessage>::value, bool>::type")
|
||||
cog.outl(" accepts()")
|
||||
cog.outl(" {")
|
||||
generate_accepts_return_compile_time_TMessage(int(Handlers))
|
||||
@ -834,11 +838,11 @@ namespace etl
|
||||
cog.outl(" {")
|
||||
cog.outl(" etl::imessage* pmsg = static_cast<etl::imessage*>(data);")
|
||||
cog.outl("")
|
||||
cog.outl("#if ETL_HAS_VIRTUAL_MESSAGES")
|
||||
cog.outl(" #if ETL_HAS_VIRTUAL_MESSAGES")
|
||||
cog.outl(" pmsg->~imessage();")
|
||||
cog.outl("#else")
|
||||
cog.outl(" #else")
|
||||
cog.outl(" delete_message(pmsg);")
|
||||
cog.outl("#endif")
|
||||
cog.outl(" #endif")
|
||||
cog.outl(" }")
|
||||
cog.outl(" }")
|
||||
cog.outl(" #include \"private/diagnostic_pop.h\"")
|
||||
@ -859,7 +863,7 @@ namespace etl
|
||||
cog.outl(" void add_new_message(const etl::imessage& msg)")
|
||||
cog.outl(" {")
|
||||
cog.outl(" const size_t id = msg.get_message_id();")
|
||||
cog.outl(" void* p = data;")
|
||||
cog.outl(" void* p = data;")
|
||||
cog.outl("")
|
||||
cog.outl(" switch (id)")
|
||||
cog.outl(" {")
|
||||
@ -869,12 +873,12 @@ namespace etl
|
||||
cog.outl(" }")
|
||||
cog.outl(" }")
|
||||
cog.outl("")
|
||||
cog.outl("#if ETL_USING_CPP11 && !defined(ETL_MESSAGE_PACKET_FORCE_CPP03_IMPLEMENTATION)")
|
||||
cog.outl(" #if ETL_USING_CPP11 && !defined(ETL_MESSAGE_PACKET_FORCE_CPP03_IMPLEMENTATION)")
|
||||
cog.outl(" //********************************************")
|
||||
cog.outl(" void add_new_message(etl::imessage&& msg)")
|
||||
cog.outl(" {")
|
||||
cog.outl(" const size_t id = msg.get_message_id();")
|
||||
cog.outl(" void* p = data;")
|
||||
cog.outl(" void* p = data;")
|
||||
cog.outl("")
|
||||
cog.outl(" switch (id)")
|
||||
cog.outl(" {")
|
||||
@ -883,14 +887,14 @@ namespace etl
|
||||
cog.outl(" default: ETL_ASSERT_FAIL(ETL_ERROR(unhandled_message_exception)); break;")
|
||||
cog.outl(" }")
|
||||
cog.outl(" }")
|
||||
cog.outl("#endif")
|
||||
cog.outl(" #endif")
|
||||
cog.outl("")
|
||||
cog.outl(" typename etl::aligned_storage<SIZE, ALIGNMENT>::type data;")
|
||||
cog.outl(" bool valid;")
|
||||
cog.outl(" bool valid;")
|
||||
cog.outl("};")
|
||||
|
||||
####################################
|
||||
# All of the other specialisations.
|
||||
#All of the other specialisations.
|
||||
####################################
|
||||
for n in range(int(Handlers) - 1, 0, -1):
|
||||
cog.outl("")
|
||||
@ -900,13 +904,16 @@ namespace etl
|
||||
else:
|
||||
cog.outl("// Specialisation for %d message types." % n)
|
||||
cog.outl("//***************************************************************************")
|
||||
cog.out("template <")
|
||||
for t in range(1, n):
|
||||
cog.out("typename T%s, " % t)
|
||||
if t % 4 == 0:
|
||||
cog.outl("")
|
||||
cog.out(" ")
|
||||
cog.outl("typename T%s>" % n)
|
||||
if n == 1:
|
||||
cog.outl("template <typename T1>")
|
||||
else:
|
||||
cog.out("template <typename T1,")
|
||||
for t in range(2, n):
|
||||
cog.out(" typename T%s," % t)
|
||||
if t % 4 == 0:
|
||||
cog.outl("")
|
||||
cog.out(" ")
|
||||
cog.outl(" typename T%s>" % n)
|
||||
cog.out("class message_packet<")
|
||||
for t in range(1, n + 1):
|
||||
cog.out("T%d, " % t)
|
||||
@ -923,25 +930,25 @@ namespace etl
|
||||
cog.outl("public:")
|
||||
cog.outl("")
|
||||
|
||||
cog.out("#if ETL_USING_CPP11")
|
||||
cog.out(" #if ETL_USING_CPP11")
|
||||
cog.outl("")
|
||||
cog.out(" using message_types = etl::type_list<")
|
||||
for t in range(1, int(n)):
|
||||
cog.out("T%s, " % t)
|
||||
cog.outl("T%s>;" % int(n))
|
||||
cog.outl("#endif")
|
||||
cog.outl(" #endif")
|
||||
cog.outl("")
|
||||
|
||||
cog.outl(" //********************************************")
|
||||
cog.outl("#include \"private/diagnostic_uninitialized_push.h\"")
|
||||
cog.outl(" //********************************************")
|
||||
cog.outl(" #include \"private/diagnostic_uninitialized_push.h\"")
|
||||
cog.outl(" ETL_CONSTEXPR message_packet() ETL_NOEXCEPT")
|
||||
cog.outl(" : valid(false)")
|
||||
cog.outl(" {")
|
||||
cog.outl(" }")
|
||||
cog.outl("#include \"private/diagnostic_pop.h\"")
|
||||
cog.outl(" #include \"private/diagnostic_pop.h\"")
|
||||
cog.outl("")
|
||||
cog.outl(" //********************************************")
|
||||
cog.outl("#include \"private/diagnostic_uninitialized_push.h\"")
|
||||
cog.outl(" //********************************************")
|
||||
cog.outl(" #include \"private/diagnostic_uninitialized_push.h\"")
|
||||
cog.outl(" explicit message_packet(const etl::imessage& msg)")
|
||||
cog.outl(" {")
|
||||
cog.outl(" if (accepts(msg))")
|
||||
@ -956,11 +963,11 @@ namespace etl
|
||||
cog.outl("")
|
||||
cog.outl(" ETL_ASSERT(valid, ETL_ERROR(unhandled_message_exception));")
|
||||
cog.outl(" }")
|
||||
cog.outl("#include \"private/diagnostic_pop.h\"")
|
||||
cog.outl(" #include \"private/diagnostic_pop.h\"")
|
||||
cog.outl("")
|
||||
cog.outl("#if ETL_USING_CPP11 && !defined(ETL_MESSAGE_PACKET_FORCE_CPP03_IMPLEMENTATION)")
|
||||
cog.outl(" //********************************************")
|
||||
cog.outl("#include \"private/diagnostic_uninitialized_push.h\"")
|
||||
cog.outl(" #if ETL_USING_CPP11 && !defined(ETL_MESSAGE_PACKET_FORCE_CPP03_IMPLEMENTATION)")
|
||||
cog.outl(" //********************************************")
|
||||
cog.outl(" #include \"private/diagnostic_uninitialized_push.h\"")
|
||||
cog.outl(" explicit message_packet(etl::imessage&& msg)")
|
||||
cog.outl(" {")
|
||||
cog.outl(" if (accepts(msg))")
|
||||
@ -975,49 +982,51 @@ namespace etl
|
||||
cog.outl("")
|
||||
cog.outl(" ETL_ASSERT(valid, ETL_ERROR(unhandled_message_exception));")
|
||||
cog.outl(" }")
|
||||
cog.outl("#include \"private/diagnostic_pop.h\"")
|
||||
cog.outl("#endif")
|
||||
cog.outl(" #include \"private/diagnostic_pop.h\"")
|
||||
cog.outl(" #endif")
|
||||
cog.outl("")
|
||||
cog.outl("#if ETL_USING_CPP11 && !defined(ETL_MESSAGE_PACKET_FORCE_CPP03_IMPLEMENTATION) && !defined(ETL_COMPILER_GREEN_HILLS)")
|
||||
cog.outl(" //********************************************")
|
||||
cog.outl("#include \"private/diagnostic_uninitialized_push.h\"")
|
||||
cog.outl(" #if ETL_USING_CPP11 && !defined(ETL_MESSAGE_PACKET_FORCE_CPP03_IMPLEMENTATION) && !defined(ETL_COMPILER_GREEN_HILLS)")
|
||||
cog.outl(" //********************************************")
|
||||
cog.outl(" #include \"private/diagnostic_uninitialized_push.h\"")
|
||||
cog.out(" template <typename TMessage, typename = typename etl::enable_if<!etl::is_same<typename etl::remove_cvref<TMessage>::type, etl::message_packet<")
|
||||
for t in range(1, n):
|
||||
cog.out("T%s, " % t)
|
||||
cog.outl("T%s> >::value &&" % n)
|
||||
cog.outl(" !etl::is_same<typename etl::remove_cvref<TMessage>::type, etl::imessage>::value &&")
|
||||
cog.out(" !etl::is_one_of<typename etl::remove_cvref<TMessage>::type, ")
|
||||
cog.outl("T%s> >::value" % n)
|
||||
cog.outl(" && !etl::is_same<typename etl::remove_cvref<TMessage>::type, etl::imessage>::value")
|
||||
cog.out(" && !etl::is_one_of<typename etl::remove_cvref<TMessage>::type, ")
|
||||
for t in range(1, n):
|
||||
cog.out("T%s, " % t)
|
||||
cog.outl("T%s>::value, int>::type>" % n)
|
||||
cog.outl("T%s>::value," % n)
|
||||
cog.outl(" int>::type>")
|
||||
cog.outl(" explicit message_packet(TMessage&& /*msg*/)")
|
||||
cog.outl(" : valid(true)")
|
||||
cog.outl(" {")
|
||||
generate_static_assert_cpp11(n)
|
||||
cog.outl(" }")
|
||||
cog.outl("#include \"private/diagnostic_pop.h\"")
|
||||
cog.outl("#else")
|
||||
cog.outl(" //********************************************")
|
||||
cog.outl("#include \"private/diagnostic_uninitialized_push.h\"")
|
||||
cog.outl(" #include \"private/diagnostic_pop.h\"")
|
||||
cog.outl(" #else")
|
||||
cog.outl(" //********************************************")
|
||||
cog.outl(" #include \"private/diagnostic_uninitialized_push.h\"")
|
||||
cog.outl(" template <typename TMessage>")
|
||||
cog.out(" explicit message_packet(const TMessage& /*msg*/, typename etl::enable_if<!etl::is_same<typename etl::remove_cvref<TMessage>::type, etl::message_packet<")
|
||||
for t in range(1, n):
|
||||
cog.out("T%s, " % t)
|
||||
cog.outl("T%s> >::value &&" % n)
|
||||
cog.outl(" !etl::is_same<typename etl::remove_cvref<TMessage>::type, etl::imessage>::value &&")
|
||||
cog.out(" !etl::is_one_of<typename etl::remove_cvref<TMessage>::type, ")
|
||||
cog.outl("T%s> >::value" % n)
|
||||
cog.outl(" && !etl::is_same<typename etl::remove_cvref<TMessage>::type, etl::imessage>::value")
|
||||
cog.out(" && !etl::is_one_of<typename etl::remove_cvref<TMessage>::type, ")
|
||||
for t in range(1, n):
|
||||
cog.out("T%s, " % t)
|
||||
cog.outl("T%s>::value, int>::type = 0)" % n)
|
||||
cog.outl("T%s>::value," % n)
|
||||
cog.outl(" int>::type = 0)")
|
||||
cog.outl(" : valid(true)")
|
||||
cog.outl(" {")
|
||||
generate_static_assert_cpp03(n)
|
||||
cog.outl(" }")
|
||||
cog.outl("#include \"private/diagnostic_pop.h\"")
|
||||
cog.outl("#endif")
|
||||
cog.outl(" #include \"private/diagnostic_pop.h\"")
|
||||
cog.outl(" #endif")
|
||||
cog.outl("")
|
||||
cog.outl(" //**********************************************")
|
||||
cog.outl("#include \"private/diagnostic_uninitialized_push.h\"")
|
||||
cog.outl(" //**********************************************")
|
||||
cog.outl(" #include \"private/diagnostic_uninitialized_push.h\"")
|
||||
cog.outl(" message_packet(const message_packet& other)")
|
||||
cog.outl(" : valid(other.is_valid())")
|
||||
cog.outl(" {")
|
||||
@ -1026,11 +1035,11 @@ namespace etl
|
||||
cog.outl(" add_new_message(other.get());")
|
||||
cog.outl(" }")
|
||||
cog.outl(" }")
|
||||
cog.outl("#include \"private/diagnostic_pop.h\"")
|
||||
cog.outl(" #include \"private/diagnostic_pop.h\"")
|
||||
cog.outl("")
|
||||
cog.outl("#if ETL_USING_CPP11 && !defined(ETL_MESSAGE_PACKET_FORCE_CPP03_IMPLEMENTATION)")
|
||||
cog.outl(" //**********************************************")
|
||||
cog.outl("#include \"private/diagnostic_uninitialized_push.h\"")
|
||||
cog.outl(" #if ETL_USING_CPP11 && !defined(ETL_MESSAGE_PACKET_FORCE_CPP03_IMPLEMENTATION)")
|
||||
cog.outl(" //**********************************************")
|
||||
cog.outl(" #include \"private/diagnostic_uninitialized_push.h\"")
|
||||
cog.outl(" message_packet(message_packet&& other)")
|
||||
cog.outl(" : valid(other.is_valid())")
|
||||
cog.outl(" {")
|
||||
@ -1039,12 +1048,12 @@ namespace etl
|
||||
cog.outl(" add_new_message(etl::move(other.get()));")
|
||||
cog.outl(" }")
|
||||
cog.outl(" }")
|
||||
cog.outl("#include \"private/diagnostic_pop.h\"")
|
||||
cog.outl("#endif")
|
||||
cog.outl(" #include \"private/diagnostic_pop.h\"")
|
||||
cog.outl(" #endif")
|
||||
cog.outl("")
|
||||
cog.outl(" //**********************************************")
|
||||
cog.outl("#include \"private/diagnostic_uninitialized_push.h\"")
|
||||
cog.outl(" message_packet& operator =(const message_packet& rhs)")
|
||||
cog.outl(" //**********************************************")
|
||||
cog.outl(" #include \"private/diagnostic_uninitialized_push.h\"")
|
||||
cog.outl(" message_packet& operator=(const message_packet& rhs)")
|
||||
cog.outl(" {")
|
||||
cog.outl(" delete_current_message();")
|
||||
cog.outl(" valid = rhs.is_valid();")
|
||||
@ -1055,12 +1064,12 @@ namespace etl
|
||||
cog.outl("")
|
||||
cog.outl(" return *this;")
|
||||
cog.outl(" }")
|
||||
cog.outl("#include \"private/diagnostic_pop.h\"")
|
||||
cog.outl(" #include \"private/diagnostic_pop.h\"")
|
||||
cog.outl("")
|
||||
cog.outl("#if ETL_USING_CPP11 && !defined(ETL_MESSAGE_PACKET_FORCE_CPP03_IMPLEMENTATION)")
|
||||
cog.outl(" //**********************************************")
|
||||
cog.outl("#include \"private/diagnostic_uninitialized_push.h\"")
|
||||
cog.outl(" message_packet& operator =(message_packet&& rhs)")
|
||||
cog.outl(" #if ETL_USING_CPP11 && !defined(ETL_MESSAGE_PACKET_FORCE_CPP03_IMPLEMENTATION)")
|
||||
cog.outl(" //**********************************************")
|
||||
cog.outl(" #include \"private/diagnostic_uninitialized_push.h\"")
|
||||
cog.outl(" message_packet& operator=(message_packet&& rhs)")
|
||||
cog.outl(" {")
|
||||
cog.outl(" delete_current_message();")
|
||||
cog.outl(" valid = rhs.is_valid();")
|
||||
@ -1071,8 +1080,8 @@ namespace etl
|
||||
cog.outl("")
|
||||
cog.outl(" return *this;")
|
||||
cog.outl(" }")
|
||||
cog.outl("#include \"private/diagnostic_pop.h\"")
|
||||
cog.outl("#endif")
|
||||
cog.outl(" #include \"private/diagnostic_pop.h\"")
|
||||
cog.outl(" #endif")
|
||||
cog.outl("")
|
||||
cog.outl(" //********************************************")
|
||||
cog.outl(" ~message_packet()")
|
||||
@ -1120,7 +1129,7 @@ namespace etl
|
||||
cog.outl(" //**********************************************")
|
||||
cog.outl(" template <typename TMessage>")
|
||||
cog.outl(" static ETL_CONSTEXPR")
|
||||
cog.outl(" typename etl::enable_if<etl::is_base_of<etl::imessage, TMessage>::value, bool>::type")
|
||||
cog.outl(" typename etl::enable_if<etl::is_base_of<etl::imessage, TMessage>::value, bool>::type")
|
||||
cog.outl(" accepts()")
|
||||
cog.outl(" {")
|
||||
generate_accepts_return_compile_time_TMessage(n)
|
||||
@ -1148,12 +1157,11 @@ namespace etl
|
||||
cog.outl(" {")
|
||||
cog.outl(" etl::imessage* pmsg = static_cast<etl::imessage*>(data);")
|
||||
cog.outl("")
|
||||
cog.outl("")
|
||||
cog.outl("#if ETL_HAS_VIRTUAL_MESSAGES")
|
||||
cog.outl(" #if ETL_HAS_VIRTUAL_MESSAGES")
|
||||
cog.outl(" pmsg->~imessage();")
|
||||
cog.outl("#else")
|
||||
cog.outl(" #else")
|
||||
cog.outl(" delete_message(pmsg);")
|
||||
cog.outl("#endif")
|
||||
cog.outl(" #endif")
|
||||
cog.outl(" }")
|
||||
cog.outl(" }")
|
||||
cog.outl(" #include \"private/diagnostic_pop.h\"")
|
||||
@ -1174,7 +1182,7 @@ namespace etl
|
||||
cog.outl(" void add_new_message(const etl::imessage& msg)")
|
||||
cog.outl(" {")
|
||||
cog.outl(" const size_t id = msg.get_message_id();")
|
||||
cog.outl(" void* p = data;")
|
||||
cog.outl(" void* p = data;")
|
||||
cog.outl("")
|
||||
cog.outl(" switch (id)")
|
||||
cog.outl(" {")
|
||||
@ -1184,12 +1192,12 @@ namespace etl
|
||||
cog.outl(" }")
|
||||
cog.outl(" }")
|
||||
cog.outl("")
|
||||
cog.outl("#if ETL_USING_CPP11 && !defined(ETL_MESSAGE_PACKET_FORCE_CPP03_IMPLEMENTATION)")
|
||||
cog.outl(" #if ETL_USING_CPP11 && !defined(ETL_MESSAGE_PACKET_FORCE_CPP03_IMPLEMENTATION)")
|
||||
cog.outl(" //********************************************")
|
||||
cog.outl(" void add_new_message(etl::imessage&& msg)")
|
||||
cog.outl(" {")
|
||||
cog.outl(" const size_t id = msg.get_message_id();")
|
||||
cog.outl(" void* p = data;")
|
||||
cog.outl(" void* p = data;")
|
||||
cog.outl("")
|
||||
cog.outl(" switch (id)")
|
||||
cog.outl(" {")
|
||||
@ -1198,10 +1206,10 @@ namespace etl
|
||||
cog.outl(" default: break;")
|
||||
cog.outl(" }")
|
||||
cog.outl(" }")
|
||||
cog.outl("#endif")
|
||||
cog.outl(" #endif")
|
||||
cog.outl("")
|
||||
cog.outl(" typename etl::aligned_storage<SIZE, ALIGNMENT>::type data;")
|
||||
cog.outl(" bool valid;")
|
||||
cog.outl(" bool valid;")
|
||||
cog.outl("};")
|
||||
]]]*/
|
||||
/*[[[end]]]*/
|
||||
@ -1215,9 +1223,9 @@ namespace etl
|
||||
{
|
||||
public:
|
||||
|
||||
#if ETL_USING_CPP11
|
||||
#if ETL_USING_CPP11
|
||||
using message_types = etl::type_list<>;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
ETL_CONSTEXPR message_packet() ETL_NOEXCEPT
|
||||
: valid(false)
|
||||
@ -1253,7 +1261,7 @@ namespace etl
|
||||
|
||||
enum
|
||||
{
|
||||
SIZE = 0U,
|
||||
SIZE = 0U,
|
||||
ALIGNMENT = 1U
|
||||
};
|
||||
|
||||
@ -1261,7 +1269,7 @@ namespace etl
|
||||
|
||||
bool valid;
|
||||
};
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
} // namespace etl
|
||||
|
||||
#endif
|
||||
|
||||
@ -31,7 +31,7 @@ import cog
|
||||
cog.outl("#if 0")
|
||||
]]]*/
|
||||
/*[[[end]]]*/
|
||||
#error THIS HEADER IS A GENERATOR. DO NOT INCLUDE.
|
||||
#error THIS HEADER IS A GENERATOR. DO NOT INCLUDE.
|
||||
/*[[[cog
|
||||
import cog
|
||||
cog.outl("#endif")
|
||||
@ -61,25 +61,25 @@ cog.outl("//********************************************************************
|
||||
//***************************************************************************
|
||||
|
||||
#ifndef ETL_MESSAGE_ROUTER_INCLUDED
|
||||
#define ETL_MESSAGE_ROUTER_INCLUDED
|
||||
#define ETL_MESSAGE_ROUTER_INCLUDED
|
||||
|
||||
#include "platform.h"
|
||||
#include "message.h"
|
||||
#include "shared_message.h"
|
||||
#include "message_packet.h"
|
||||
#include "message_types.h"
|
||||
#include "alignment.h"
|
||||
#include "error_handler.h"
|
||||
#include "exception.h"
|
||||
#include "largest.h"
|
||||
#include "nullptr.h"
|
||||
#include "placement_new.h"
|
||||
#include "successor.h"
|
||||
#include "type_traits.h"
|
||||
#include "type_list.h"
|
||||
#include "array.h"
|
||||
#include "platform.h"
|
||||
#include "alignment.h"
|
||||
#include "array.h"
|
||||
#include "error_handler.h"
|
||||
#include "exception.h"
|
||||
#include "largest.h"
|
||||
#include "message.h"
|
||||
#include "message_packet.h"
|
||||
#include "message_types.h"
|
||||
#include "nullptr.h"
|
||||
#include "placement_new.h"
|
||||
#include "shared_message.h"
|
||||
#include "successor.h"
|
||||
#include "type_list.h"
|
||||
#include "type_traits.h"
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdint.h>
|
||||
|
||||
namespace etl
|
||||
{
|
||||
@ -120,7 +120,8 @@ namespace etl
|
||||
template <typename... TMessageTypes>
|
||||
class traits
|
||||
{
|
||||
#if ETL_USING_CPP11
|
||||
#if ETL_USING_CPP11
|
||||
|
||||
private:
|
||||
|
||||
using message_id_sequence = etl::index_sequence<TMessageTypes::ID...>;
|
||||
@ -131,10 +132,10 @@ namespace etl
|
||||
using message_types = etl::type_list<TMessageTypes...>;
|
||||
using sorted_message_types = etl::type_list_sort_t<message_types, etl::compare_message_id_less>;
|
||||
|
||||
static_assert(etl::type_list_is_unique<message_types>::value, "All TMessageTypes must be unique");
|
||||
static_assert(etl::type_list_is_unique<message_types>::value, "All TMessageTypes must be unique");
|
||||
static_assert(etl::type_list_all_of<message_types, etl::is_message_type>::value, "All TMessageTypes must satisfy the condition etl::is_message_type");
|
||||
static_assert(etl::index_sequence_is_unique<message_id_sequence>::value, "All message IDs must be unique");
|
||||
#endif
|
||||
static_assert(etl::index_sequence_is_unique<message_id_sequence>::value, "All message IDs must be unique");
|
||||
#endif
|
||||
};
|
||||
|
||||
//***************************************************************************
|
||||
@ -148,13 +149,13 @@ namespace etl
|
||||
{
|
||||
public:
|
||||
|
||||
#if ETL_USING_CPP11
|
||||
using message_packet = etl::message_packet<>;
|
||||
using message_types = etl::type_list<>;
|
||||
#if ETL_USING_CPP11
|
||||
using message_packet = etl::message_packet<>;
|
||||
using message_types = etl::type_list<>;
|
||||
using sorted_message_types = etl::type_list<>;
|
||||
#endif
|
||||
#endif
|
||||
};
|
||||
}
|
||||
} // namespace private_message_router
|
||||
|
||||
//***************************************************************************
|
||||
/// Forward declare null message router functionality.
|
||||
@ -171,11 +172,11 @@ namespace etl
|
||||
public:
|
||||
|
||||
virtual ~imessage_router() {}
|
||||
virtual void receive(const etl::imessage&) = 0;
|
||||
virtual void receive(const etl::imessage&) = 0;
|
||||
virtual bool accepts(etl::message_id_t) const = 0;
|
||||
virtual bool is_null_router() const = 0;
|
||||
virtual bool is_producer() const = 0;
|
||||
virtual bool is_consumer() const = 0;
|
||||
virtual bool is_null_router() const = 0;
|
||||
virtual bool is_producer() const = 0;
|
||||
virtual bool is_consumer() const = 0;
|
||||
|
||||
//********************************************
|
||||
virtual void receive(etl::message_router_id_t destination_router_id, const etl::imessage& message)
|
||||
@ -240,16 +241,16 @@ namespace etl
|
||||
|
||||
// Disabled.
|
||||
imessage_router(const imessage_router&);
|
||||
imessage_router& operator =(const imessage_router&);
|
||||
imessage_router& operator=(const imessage_router&);
|
||||
|
||||
etl::message_router_id_t message_router_id;
|
||||
etl::message_router_id_t message_router_id;
|
||||
};
|
||||
|
||||
//***************************************************************************
|
||||
/// This router can be used as a sink for messages or a 'null source' router.
|
||||
//***************************************************************************
|
||||
class null_message_router : public imessage_router
|
||||
, public private_message_router::traits<>
|
||||
, public private_message_router::traits<>
|
||||
{
|
||||
public:
|
||||
|
||||
@ -328,7 +329,7 @@ namespace etl
|
||||
/// This router can be used as a producer-only of messages, such an interrupt routine.
|
||||
//***************************************************************************
|
||||
class message_producer : public imessage_router
|
||||
, public private_message_router::traits<>
|
||||
, public private_message_router::traits<>
|
||||
{
|
||||
public:
|
||||
|
||||
@ -416,7 +417,7 @@ namespace etl
|
||||
//***************************************************************************
|
||||
template <typename TRouter, typename TMessage>
|
||||
static
|
||||
typename etl::enable_if<etl::is_message_router<TRouter>::value && etl::is_message<TMessage>::value, void>::type
|
||||
typename etl::enable_if<etl::is_message_router<TRouter>::value && etl::is_message<TMessage>::value, void>::type
|
||||
send_message(TRouter& destination,
|
||||
const TMessage& message)
|
||||
{
|
||||
@ -428,7 +429,7 @@ namespace etl
|
||||
//***************************************************************************
|
||||
template <typename TRouter>
|
||||
static
|
||||
typename etl::enable_if<etl::is_message_router<TRouter>::value, void>::type
|
||||
typename etl::enable_if<etl::is_message_router<TRouter>::value, void>::type
|
||||
send_message(TRouter& destination,
|
||||
etl::shared_message message)
|
||||
{
|
||||
@ -440,7 +441,7 @@ namespace etl
|
||||
//***************************************************************************
|
||||
template <typename TRouter, typename TMessage>
|
||||
static
|
||||
typename etl::enable_if<etl::is_message_router<TRouter>::value && etl::is_message<TMessage>::value, void>::type
|
||||
typename etl::enable_if<etl::is_message_router<TRouter>::value && etl::is_message<TMessage>::value, void>::type
|
||||
send_message(TRouter& destination,
|
||||
etl::message_router_id_t id,
|
||||
const TMessage& message)
|
||||
@ -453,7 +454,7 @@ namespace etl
|
||||
//***************************************************************************
|
||||
template <typename TRouter>
|
||||
static
|
||||
typename etl::enable_if<etl::is_message_router<TRouter>::value, void>::type
|
||||
typename etl::enable_if<etl::is_message_router<TRouter>::value, void>::type
|
||||
send_message(TRouter& destination,
|
||||
etl::message_router_id_t id,
|
||||
etl::shared_message message)
|
||||
@ -464,13 +465,13 @@ namespace etl
|
||||
//*************************************************************************************************
|
||||
// For C++11 and above.
|
||||
//*************************************************************************************************
|
||||
#if ETL_USING_CPP11 && !defined(ETL_MESSAGE_ROUTER_FORCE_CPP03_IMPLEMENTATION)
|
||||
#if ETL_USING_CPP11 && !defined(ETL_MESSAGE_ROUTER_FORCE_CPP03_IMPLEMENTATION)
|
||||
//***************************************************************************
|
||||
// The definition for all message types.
|
||||
//***************************************************************************
|
||||
template <typename TDerived, typename... TMessageTypes>
|
||||
class message_router : public imessage_router
|
||||
, public private_message_router::traits<TMessageTypes...>
|
||||
, public private_message_router::traits<TMessageTypes...>
|
||||
{
|
||||
public:
|
||||
|
||||
@ -525,8 +526,8 @@ namespace etl
|
||||
//***********************************************
|
||||
void receive(const etl::imessage& msg) ETL_OVERRIDE
|
||||
{
|
||||
etl::message_id_t id = msg.get_message_id();
|
||||
size_t index = Number_Of_Messages;
|
||||
etl::message_id_t id = msg.get_message_id();
|
||||
size_t index = Number_Of_Messages;
|
||||
|
||||
// The IDs are sorted, so an ID less than the first is not handled by this router.
|
||||
if (id >= Message_Id_Start)
|
||||
@ -548,9 +549,9 @@ namespace etl
|
||||
}
|
||||
else
|
||||
{
|
||||
#include "etl/private/diagnostic_array_bounds_push.h"
|
||||
#include "etl/private/diagnostic_array_bounds_push.h"
|
||||
static_cast<TDerived*>(this)->on_receive_unknown(msg);
|
||||
#include "etl/private/diagnostic_pop.h"
|
||||
#include "etl/private/diagnostic_pop.h"
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -564,9 +565,9 @@ namespace etl
|
||||
template <typename TMessage, typename etl::enable_if<etl::is_one_of<TMessage, TMessageTypes...>::value, int>::type = 0>
|
||||
void receive(const TMessage& msg)
|
||||
{
|
||||
#include "etl/private/diagnostic_array_bounds_push.h"
|
||||
#include "etl/private/diagnostic_array_bounds_push.h"
|
||||
static_cast<TDerived*>(this)->on_receive(msg);
|
||||
#include "etl/private/diagnostic_pop.h"
|
||||
#include "etl/private/diagnostic_pop.h"
|
||||
}
|
||||
|
||||
//**********************************************
|
||||
@ -575,8 +576,7 @@ namespace etl
|
||||
/// \param msg The message.
|
||||
/// Enabled if TMessage is a message type, but not in the message type list.
|
||||
//**********************************************
|
||||
template <typename TMessage, typename etl::enable_if<etl::is_message<TMessage>::value &&
|
||||
!etl::is_one_of<TMessage, TMessageTypes...>::value, int>::type = 0>
|
||||
template <typename TMessage, typename etl::enable_if<etl::is_message<TMessage>::value && !etl::is_one_of<TMessage, TMessageTypes...>::value, int>::type = 0>
|
||||
void receive(const TMessage& msg)
|
||||
{
|
||||
if (has_successor())
|
||||
@ -585,9 +585,9 @@ namespace etl
|
||||
}
|
||||
else
|
||||
{
|
||||
#include "etl/private/diagnostic_array_bounds_push.h"
|
||||
#include "etl/private/diagnostic_array_bounds_push.h"
|
||||
static_cast<TDerived*>(this)->on_receive_unknown(msg);
|
||||
#include "etl/private/diagnostic_pop.h"
|
||||
#include "etl/private/diagnostic_pop.h"
|
||||
}
|
||||
}
|
||||
|
||||
@ -662,9 +662,7 @@ namespace etl
|
||||
|
||||
template <size_t Index>
|
||||
struct contiguous_impl<Index, false>
|
||||
: etl::bool_constant<(etl::type_list_type_at_index_t<sorted_message_types, Index>::ID + 1U ==
|
||||
etl::type_list_type_at_index_t<sorted_message_types, Index + 1U>::ID) &&
|
||||
contiguous_impl<Index + 1U>::value>
|
||||
: etl::bool_constant<(etl::type_list_type_at_index_t<sorted_message_types, Index>::ID + 1U == etl::type_list_type_at_index_t<sorted_message_types, Index + 1U>::ID) && contiguous_impl<Index + 1U>::value>
|
||||
{
|
||||
};
|
||||
|
||||
@ -701,7 +699,7 @@ namespace etl
|
||||
template <size_t... Indices>
|
||||
static constexpr message_dispatch_table_t make_message_dispatch_table(etl::index_sequence<Indices...>)
|
||||
{
|
||||
return message_dispatch_table_t{ { get_message_handler<Indices>()... } };
|
||||
return message_dispatch_table_t{{get_message_handler<Indices>()...}};
|
||||
}
|
||||
|
||||
//**********************************************
|
||||
@ -721,7 +719,7 @@ namespace etl
|
||||
template <size_t... Indices>
|
||||
static constexpr message_id_table_t make_message_id_table(etl::index_sequence<Indices...>)
|
||||
{
|
||||
return message_id_table_t{ { get_message_id_from_index<Indices>()... } };
|
||||
return message_id_table_t{{get_message_id_from_index<Indices>()...}};
|
||||
}
|
||||
|
||||
//**********************************************
|
||||
@ -732,7 +730,7 @@ namespace etl
|
||||
//**********************************************
|
||||
static size_t get_dispatch_index_from_message_id(etl::message_id_t id)
|
||||
{
|
||||
if ETL_IF_CONSTEXPR(Message_Ids_Are_Contiguous)
|
||||
if ETL_IF_CONSTEXPR (Message_Ids_Are_Contiguous)
|
||||
{
|
||||
// The IDs are contiguous, so we can calculate the index directly.
|
||||
return static_cast<size_t>(id - Message_Id_Start);
|
||||
@ -786,7 +784,7 @@ namespace etl
|
||||
etl::message_router<TDerived, TMessageTypes...>::make_message_id_table(etl::make_index_sequence<etl::message_router<TDerived, TMessageTypes...>::Number_Of_Messages>{});
|
||||
};
|
||||
|
||||
#if ETL_USING_CPP11 && !ETL_USING_CPP17
|
||||
#if ETL_USING_CPP11 && !ETL_USING_CPP17
|
||||
template <typename TDerived, typename... TMessageTypes>
|
||||
constexpr const typename etl::message_router<TDerived, TMessageTypes...>::message_dispatch_table_t
|
||||
etl::message_router<TDerived, TMessageTypes...>::message_dispatch_table;
|
||||
@ -794,14 +792,14 @@ namespace etl
|
||||
template <typename TDerived, typename... TMessageTypes>
|
||||
constexpr const typename etl::message_router<TDerived, TMessageTypes...>::message_id_table_t
|
||||
etl::message_router<TDerived, TMessageTypes...>::message_id_table;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//***************************************************************************
|
||||
// The definition of a message_router for zero message types.
|
||||
//***************************************************************************
|
||||
template <typename TDerived>
|
||||
class message_router<TDerived> : public imessage_router
|
||||
, public private_message_router::traits<>
|
||||
, public private_message_router::traits<>
|
||||
{
|
||||
public:
|
||||
|
||||
@ -850,12 +848,12 @@ namespace etl
|
||||
//***********************************************
|
||||
void receive(const etl::imessage& msg) ETL_OVERRIDE
|
||||
{
|
||||
#include "etl/private/diagnostic_array_bounds_push.h"
|
||||
#include "etl/private/diagnostic_array_bounds_push.h"
|
||||
if (has_successor())
|
||||
{
|
||||
get_successor().receive(msg);
|
||||
}
|
||||
#include "etl/private/diagnostic_pop.h"
|
||||
#include "etl/private/diagnostic_pop.h"
|
||||
}
|
||||
|
||||
//**********************************************
|
||||
@ -912,7 +910,7 @@ namespace etl
|
||||
template <typename TDerived, typename TTypeList>
|
||||
using message_router_from_type_list_t = typename message_router_from_type_list<TDerived, TTypeList>::type;
|
||||
|
||||
#else
|
||||
#else
|
||||
//*************************************************************************************************
|
||||
// For C++03/98.
|
||||
//*************************************************************************************************
|
||||
@ -935,7 +933,7 @@ namespace etl
|
||||
cog.out(" ")
|
||||
cog.outl("typename T%s = void>" % int(Handlers))
|
||||
cog.out("class message_router")
|
||||
cog.outl(" : public imessage_router")
|
||||
cog.outl(" : public imessage_router")
|
||||
cog.outl("{")
|
||||
cog.outl("public:")
|
||||
cog.outl("")
|
||||
@ -945,12 +943,12 @@ namespace etl
|
||||
cog.outl("T%s> message_packet;" % int(Handlers))
|
||||
cog.outl("")
|
||||
|
||||
cog.outl("#if ETL_USING_CPP11")
|
||||
cog.outl(" #if ETL_USING_CPP11")
|
||||
cog.out(" using message_types = etl::type_list<")
|
||||
for n in range(1, int(Handlers)):
|
||||
cog.out("T%s, " % n)
|
||||
cog.outl("T%s>;" % int(Handlers))
|
||||
cog.outl("#endif")
|
||||
cog.outl(" #endif")
|
||||
cog.outl("")
|
||||
|
||||
cog.outl(" //**********************************************")
|
||||
@ -986,7 +984,7 @@ namespace etl
|
||||
cog.outl(" {")
|
||||
cog.outl(" const etl::message_id_t id = msg.get_message_id();")
|
||||
cog.outl("")
|
||||
cog.outl("#include \"etl/private/diagnostic_array_bounds_push.h\"")
|
||||
cog.outl(" #include \"etl/private/diagnostic_array_bounds_push.h\"")
|
||||
cog.outl(" switch (id)")
|
||||
cog.outl(" {")
|
||||
for n in range(1, int(Handlers) + 1):
|
||||
@ -994,19 +992,19 @@ namespace etl
|
||||
cog.out(" static_cast<TDerived*>(this)->on_receive(static_cast<const T%d&>(msg));" % n)
|
||||
cog.outl(" break;")
|
||||
cog.outl(" default:")
|
||||
cog.outl(" {")
|
||||
cog.outl(" if (has_successor())")
|
||||
cog.outl(" {")
|
||||
cog.outl(" get_successor().receive(msg);")
|
||||
cog.outl(" }")
|
||||
cog.outl(" else")
|
||||
cog.outl(" {")
|
||||
cog.outl(" static_cast<TDerived*>(this)->on_receive_unknown(msg);")
|
||||
cog.outl(" }")
|
||||
cog.outl(" break;")
|
||||
cog.outl(" }")
|
||||
cog.outl(" {")
|
||||
cog.outl(" if (has_successor())")
|
||||
cog.outl(" {")
|
||||
cog.outl(" get_successor().receive(msg);")
|
||||
cog.outl(" }")
|
||||
cog.outl(" else")
|
||||
cog.outl(" {")
|
||||
cog.outl(" static_cast<TDerived*>(this)->on_receive_unknown(msg);")
|
||||
cog.outl(" }")
|
||||
cog.outl(" break;")
|
||||
cog.outl(" }")
|
||||
cog.outl(" }")
|
||||
cog.outl("#include \"etl/private/diagnostic_pop.h\"")
|
||||
cog.outl(" #include \"etl/private/diagnostic_pop.h\"")
|
||||
cog.outl(" }")
|
||||
cog.outl("")
|
||||
cog.outl(" template <typename TMessage>")
|
||||
@ -1016,9 +1014,9 @@ namespace etl
|
||||
cog.outl("T%s>::value, void>::type" % int(Handlers))
|
||||
cog.outl(" receive(const TMessage& msg)")
|
||||
cog.outl(" {")
|
||||
cog.outl("#include \"etl/private/diagnostic_array_bounds_push.h\"")
|
||||
cog.outl(" #include \"etl/private/diagnostic_array_bounds_push.h\"")
|
||||
cog.outl(" static_cast<TDerived*>(this)->on_receive(msg);")
|
||||
cog.outl("#include \"etl/private/diagnostic_pop.h\"")
|
||||
cog.outl(" #include \"etl/private/diagnostic_pop.h\"")
|
||||
cog.outl(" }")
|
||||
cog.outl("")
|
||||
cog.outl(" template <typename TMessage>")
|
||||
@ -1034,9 +1032,9 @@ namespace etl
|
||||
cog.outl(" }")
|
||||
cog.outl(" else")
|
||||
cog.outl(" {")
|
||||
cog.outl("#include \"etl/private/diagnostic_array_bounds_push.h\"")
|
||||
cog.outl(" #include \"etl/private/diagnostic_array_bounds_push.h\"")
|
||||
cog.outl(" static_cast<TDerived*>(this)->on_receive_unknown(msg);")
|
||||
cog.outl("#include \"etl/private/diagnostic_pop.h\"")
|
||||
cog.outl(" #include \"etl/private/diagnostic_pop.h\"")
|
||||
cog.outl(" }")
|
||||
cog.outl(" }")
|
||||
cog.outl("")
|
||||
@ -1047,24 +1045,20 @@ namespace etl
|
||||
cog.outl(" {")
|
||||
cog.outl(" switch (id)")
|
||||
cog.outl(" {")
|
||||
cog.out(" ")
|
||||
for n in range(1, int(Handlers) + 1):
|
||||
cog.out(" case T%d::ID:" % n)
|
||||
if n % 8 == 0:
|
||||
cog.outl("")
|
||||
cog.out(" ")
|
||||
cog.outl(" return true;")
|
||||
cog.outl(" case T%d::ID:" % n)
|
||||
cog.outl(" return true;")
|
||||
cog.outl(" default:")
|
||||
cog.outl(" {")
|
||||
cog.outl(" if (has_successor())")
|
||||
cog.outl(" {")
|
||||
cog.outl(" return get_successor().accepts(id);")
|
||||
cog.outl(" if (has_successor())")
|
||||
cog.outl(" {")
|
||||
cog.outl(" return get_successor().accepts(id);")
|
||||
cog.outl(" }")
|
||||
cog.outl(" else")
|
||||
cog.outl(" {")
|
||||
cog.outl(" return false;")
|
||||
cog.outl(" }")
|
||||
cog.outl(" }")
|
||||
cog.outl(" else")
|
||||
cog.outl(" {")
|
||||
cog.outl(" return false;")
|
||||
cog.outl(" }")
|
||||
cog.outl(" }")
|
||||
cog.outl(" }")
|
||||
cog.outl(" }")
|
||||
cog.outl("")
|
||||
@ -1120,22 +1114,22 @@ namespace etl
|
||||
cog.outl("")
|
||||
cog.out(" ")
|
||||
cog.outl("void>")
|
||||
cog.outl(" : public imessage_router")
|
||||
cog.outl(" : public imessage_router")
|
||||
cog.outl("{")
|
||||
cog.outl("public:")
|
||||
cog.outl("")
|
||||
cog.out(" typedef etl::message_packet<")
|
||||
for t in range(1, n):
|
||||
cog.out("T%s, " % t)
|
||||
cog.outl(" T%s> message_packet;" % n)
|
||||
cog.outl("T%s> message_packet;" % n)
|
||||
cog.outl("")
|
||||
|
||||
cog.outl("#if ETL_USING_CPP11")
|
||||
cog.outl(" #if ETL_USING_CPP11")
|
||||
cog.out(" using message_types = etl::type_list<")
|
||||
for t in range(1, n):
|
||||
cog.out("T%s, " % t)
|
||||
cog.outl("T%s>;" % n)
|
||||
cog.outl("#endif")
|
||||
cog.outl(" #endif")
|
||||
cog.outl("")
|
||||
|
||||
cog.outl(" //**********************************************")
|
||||
@ -1171,7 +1165,7 @@ namespace etl
|
||||
cog.outl(" {")
|
||||
cog.outl(" const size_t id = msg.get_message_id();")
|
||||
cog.outl("")
|
||||
cog.outl("#include \"etl/private/diagnostic_array_bounds_push.h\"")
|
||||
cog.outl(" #include \"etl/private/diagnostic_array_bounds_push.h\"")
|
||||
cog.outl(" switch (id)")
|
||||
cog.outl(" {")
|
||||
for t in range(1, n + 1):
|
||||
@ -1179,19 +1173,19 @@ namespace etl
|
||||
cog.out(" static_cast<TDerived*>(this)->on_receive(static_cast<const T%d&>(msg));" % t)
|
||||
cog.outl(" break;")
|
||||
cog.outl(" default:")
|
||||
cog.outl(" {")
|
||||
cog.outl(" if (has_successor())")
|
||||
cog.outl(" {")
|
||||
cog.outl(" get_successor().receive(msg);")
|
||||
cog.outl(" }")
|
||||
cog.outl(" else")
|
||||
cog.outl(" {")
|
||||
cog.outl(" static_cast<TDerived*>(this)->on_receive_unknown(msg);")
|
||||
cog.outl(" }")
|
||||
cog.outl(" break;")
|
||||
cog.outl(" }")
|
||||
cog.outl(" {")
|
||||
cog.outl(" if (has_successor())")
|
||||
cog.outl(" {")
|
||||
cog.outl(" get_successor().receive(msg);")
|
||||
cog.outl(" }")
|
||||
cog.outl(" else")
|
||||
cog.outl(" {")
|
||||
cog.outl(" static_cast<TDerived*>(this)->on_receive_unknown(msg);")
|
||||
cog.outl(" }")
|
||||
cog.outl(" break;")
|
||||
cog.outl(" }")
|
||||
cog.outl(" }")
|
||||
cog.outl("#include \"etl/private/diagnostic_pop.h\"")
|
||||
cog.outl(" #include \"etl/private/diagnostic_pop.h\"")
|
||||
cog.outl(" }")
|
||||
cog.outl("")
|
||||
cog.outl(" template <typename TMessage>")
|
||||
@ -1201,9 +1195,9 @@ namespace etl
|
||||
cog.outl("T%s>::value, void>::type" % n)
|
||||
cog.outl(" receive(const TMessage& msg)")
|
||||
cog.outl(" {")
|
||||
cog.outl("#include \"etl/private/diagnostic_array_bounds_push.h\"")
|
||||
cog.outl(" #include \"etl/private/diagnostic_array_bounds_push.h\"")
|
||||
cog.outl(" static_cast<TDerived*>(this)->on_receive(msg);")
|
||||
cog.outl("#include \"etl/private/diagnostic_pop.h\"")
|
||||
cog.outl(" #include \"etl/private/diagnostic_pop.h\"")
|
||||
cog.outl(" }")
|
||||
cog.outl("")
|
||||
cog.outl(" template <typename TMessage>")
|
||||
@ -1219,13 +1213,12 @@ namespace etl
|
||||
cog.outl(" }")
|
||||
cog.outl(" else")
|
||||
cog.outl(" {")
|
||||
cog.outl("#include \"etl/private/diagnostic_array_bounds_push.h\"")
|
||||
cog.outl(" #include \"etl/private/diagnostic_array_bounds_push.h\"")
|
||||
cog.outl(" static_cast<TDerived*>(this)->on_receive_unknown(msg);")
|
||||
cog.outl("#include \"etl/private/diagnostic_pop.h\"")
|
||||
cog.outl(" #include \"etl/private/diagnostic_pop.h\"")
|
||||
cog.outl(" }")
|
||||
cog.outl(" }")
|
||||
cog.outl("")
|
||||
cog.outl("")
|
||||
cog.outl(" //**********************************************")
|
||||
cog.outl(" using imessage_router::accepts;")
|
||||
cog.outl("")
|
||||
@ -1233,26 +1226,20 @@ namespace etl
|
||||
cog.outl(" {")
|
||||
cog.outl(" switch (id)")
|
||||
cog.outl(" {")
|
||||
cog.out(" ")
|
||||
for t in range(1, n + 1):
|
||||
cog.out(" case T%d::ID:" % t)
|
||||
if t % 8 == 0:
|
||||
cog.outl("")
|
||||
if t != n:
|
||||
cog.out(" ")
|
||||
cog.outl("")
|
||||
cog.outl(" case T%d::ID:" % t)
|
||||
cog.outl(" return true;")
|
||||
cog.outl(" default:")
|
||||
cog.outl(" {")
|
||||
cog.outl(" if (has_successor())")
|
||||
cog.outl(" {")
|
||||
cog.outl(" return get_successor().accepts(id);")
|
||||
cog.outl(" if (has_successor())")
|
||||
cog.outl(" {")
|
||||
cog.outl(" return get_successor().accepts(id);")
|
||||
cog.outl(" }")
|
||||
cog.outl(" else")
|
||||
cog.outl(" {")
|
||||
cog.outl(" return false;")
|
||||
cog.outl(" }")
|
||||
cog.outl(" }")
|
||||
cog.outl(" else")
|
||||
cog.outl(" {")
|
||||
cog.outl(" return false;")
|
||||
cog.outl(" }")
|
||||
cog.outl(" }")
|
||||
cog.outl(" }")
|
||||
cog.outl(" }")
|
||||
cog.outl("")
|
||||
@ -1288,9 +1275,9 @@ namespace etl
|
||||
|
||||
typedef etl::message_packet<> message_packet;
|
||||
|
||||
#if ETL_USING_CPP11
|
||||
#if ETL_USING_CPP11
|
||||
using message_types = etl::type_list<>;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//**********************************************
|
||||
message_router(etl::message_router_id_t id_)
|
||||
@ -1323,12 +1310,12 @@ namespace etl
|
||||
|
||||
void receive(const etl::imessage& msg) ETL_OVERRIDE
|
||||
{
|
||||
#include "etl/private/diagnostic_array_bounds_push.h"
|
||||
#include "etl/private/diagnostic_array_bounds_push.h"
|
||||
if (has_successor())
|
||||
{
|
||||
get_successor().receive(msg);
|
||||
}
|
||||
#include "etl/private/diagnostic_pop.h"
|
||||
#include "etl/private/diagnostic_pop.h"
|
||||
}
|
||||
|
||||
//**********************************************
|
||||
@ -1364,7 +1351,7 @@ namespace etl
|
||||
return true;
|
||||
}
|
||||
};
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
} // namespace etl
|
||||
|
||||
#endif
|
||||
|
||||
@ -33,7 +33,7 @@ import cog
|
||||
cog.outl("#if 0")
|
||||
]]]*/
|
||||
/*[[[end]]]*/
|
||||
#error THIS HEADER IS A GENERATOR. DO NOT INCLUDE.
|
||||
#error THIS HEADER IS A GENERATOR. DO NOT INCLUDE.
|
||||
/*[[[cog
|
||||
import cog
|
||||
cog.outl("#endif")
|
||||
@ -63,19 +63,19 @@ cog.outl("//********************************************************************
|
||||
//***************************************************************************
|
||||
|
||||
#ifndef ETL_SMALLEST_INCLUDED
|
||||
#define ETL_SMALLEST_INCLUDED
|
||||
#define ETL_SMALLEST_INCLUDED
|
||||
|
||||
#include "platform.h"
|
||||
#include "integral_limits.h"
|
||||
#include "platform.h"
|
||||
#include "integral_limits.h"
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdint.h>
|
||||
|
||||
///\defgroup smallest smallest
|
||||
///\ingroup utilities
|
||||
|
||||
namespace etl
|
||||
{
|
||||
#if ETL_USING_CPP11 && !defined(ETL_SMALLEST_TYPE_FORCE_CPP03_IMPLEMENTATION)
|
||||
#if ETL_USING_CPP11 && !defined(ETL_SMALLEST_TYPE_FORCE_CPP03_IMPLEMENTATION)
|
||||
//***************************************************************************
|
||||
/// Template to determine the largest type and size.
|
||||
/// Defines 'value_type' which is the type of the largest parameter.
|
||||
@ -95,9 +95,9 @@ namespace etl
|
||||
// Set 'type' to be the smallest of the first parameter and any of the others.
|
||||
// This is recursive.
|
||||
using type = typename etl::conditional<(etl::size_of<T1>::value < etl::size_of<smallest_other>::value), // Boolean
|
||||
T1, // TrueType
|
||||
smallest_other> // FalseType
|
||||
::type; // The smallest type of the two.
|
||||
T1, // TrueType
|
||||
smallest_other> // FalseType
|
||||
::type; // The smallest type of the two.
|
||||
|
||||
// The size of the smallest type.
|
||||
enum
|
||||
@ -122,18 +122,18 @@ namespace etl
|
||||
};
|
||||
};
|
||||
|
||||
#if ETL_USING_CPP11
|
||||
#if ETL_USING_CPP11
|
||||
template <typename... T>
|
||||
using smallest_type_t = typename smallest_type<T...>::type;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if ETL_USING_CPP17
|
||||
#if ETL_USING_CPP17
|
||||
template <typename... T>
|
||||
constexpr size_t smallest_type_v = smallest_type<T...>::size;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#else
|
||||
/*[[[cog
|
||||
#else
|
||||
/*[[[cog
|
||||
import cog
|
||||
cog.outl("//***************************************************************************")
|
||||
cog.outl("/// Template to determine the smallest type and size.")
|
||||
@ -142,13 +142,13 @@ namespace etl
|
||||
cog.outl("/// Defines 'size' which is the size of the smallest parameter.")
|
||||
cog.outl("///\\ingroup smallest")
|
||||
cog.outl("//***************************************************************************")
|
||||
cog.out("template <typename T1, ")
|
||||
cog.out("template <typename T1,")
|
||||
for n in range(2, int(NTypes)):
|
||||
cog.out("typename T%s = void, " % n)
|
||||
cog.out(" typename T%s = void," % n)
|
||||
if n % 4 == 0:
|
||||
cog.outl("")
|
||||
cog.out(" ")
|
||||
cog.outl("typename T%s = void>" % int(NTypes))
|
||||
cog.out(" ")
|
||||
cog.outl(" typename T%s = void>" % int(NTypes))
|
||||
cog.outl("struct smallest_type")
|
||||
cog.outl("{")
|
||||
cog.outl("private:")
|
||||
@ -165,7 +165,7 @@ namespace etl
|
||||
cog.outl(" typedef TrueType type;")
|
||||
cog.outl(" };")
|
||||
cog.outl("")
|
||||
cog.outl(" // Specialisation for 'false'. ")
|
||||
cog.outl(" // Specialisation for 'false'.")
|
||||
cog.outl(" // Defines 'type' as 'FalseType'.")
|
||||
cog.outl(" template <typename TrueType, typename FalseType>")
|
||||
cog.outl(" struct choose_type<false, TrueType, FalseType>")
|
||||
@ -175,21 +175,21 @@ namespace etl
|
||||
cog.outl("")
|
||||
cog.outl("public:")
|
||||
cog.outl("")
|
||||
cog.outl(" // Define 'smallest_other' as 'smallest_type' with all but the first parameter. ")
|
||||
cog.out(" typedef typename smallest_type<")
|
||||
for n in range(2, int(NTypes)):
|
||||
cog.out("T%s, " % n)
|
||||
cog.outl(" // Define 'smallest_other' as 'smallest_type' with all but the first parameter.")
|
||||
cog.out(" typedef typename smallest_type<T2,")
|
||||
for n in range(3, int(NTypes)):
|
||||
cog.out(" T%s," % n)
|
||||
if n % 16 == 0:
|
||||
cog.outl("")
|
||||
cog.out(" ")
|
||||
cog.outl("T%s>::type smallest_other;" % int(NTypes))
|
||||
cog.outl(" T%s>::type smallest_other;" % int(NTypes))
|
||||
cog.outl("")
|
||||
cog.outl(" // Set 'type' to be the smallest of the first parameter and any of the others.")
|
||||
cog.outl(" // This is recursive.")
|
||||
cog.outl(" typedef typename choose_type<(sizeof(T1) < sizeof(smallest_other)), // Boolean")
|
||||
cog.outl(" T1, // TrueType")
|
||||
cog.outl(" smallest_other> // FalseType")
|
||||
cog.outl(" ::type type; // The smallest type of the two.")
|
||||
cog.outl(" T1, // TrueType")
|
||||
cog.outl(" smallest_other> // FalseType")
|
||||
cog.outl(" ::type type; // The smallest type of the two.")
|
||||
cog.outl("")
|
||||
cog.outl(" // The size of the smallest type.")
|
||||
cog.outl(" enum")
|
||||
@ -202,13 +202,13 @@ namespace etl
|
||||
cog.outl("// Specialisation for one template parameter.")
|
||||
cog.outl("//***************************************************************************")
|
||||
cog.outl("template <typename T1>")
|
||||
cog.out("struct smallest_type<T1, ")
|
||||
cog.out("struct smallest_type<T1,")
|
||||
for n in range(2, int(NTypes)):
|
||||
cog.out("void, ")
|
||||
cog.out(" void,")
|
||||
if n % 8 == 0:
|
||||
cog.outl("")
|
||||
cog.out(" ")
|
||||
cog.outl("void>")
|
||||
cog.out(" ")
|
||||
cog.outl(" void>")
|
||||
cog.outl("{")
|
||||
cog.outl(" typedef T1 type;")
|
||||
cog.outl("")
|
||||
@ -218,8 +218,8 @@ namespace etl
|
||||
cog.outl(" };")
|
||||
cog.outl("};")
|
||||
]]]*/
|
||||
/*[[[end]]]*/
|
||||
#endif
|
||||
/*[[[end]]]*/
|
||||
#endif
|
||||
|
||||
namespace private_smallest
|
||||
{
|
||||
@ -256,7 +256,7 @@ namespace etl
|
||||
typedef uint_least32_t type;
|
||||
};
|
||||
|
||||
#if ETL_USING_64BIT_TYPES
|
||||
#if ETL_USING_64BIT_TYPES
|
||||
//*************************************************************************
|
||||
// Greater than 32 bits.
|
||||
//*************************************************************************
|
||||
@ -265,7 +265,7 @@ namespace etl
|
||||
{
|
||||
typedef uint_least64_t type;
|
||||
};
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
// Determine the type to hold the number of bits based on the index.
|
||||
@ -300,7 +300,7 @@ namespace etl
|
||||
typedef int_least32_t type;
|
||||
};
|
||||
|
||||
#if ETL_USING_64BIT_TYPES
|
||||
#if ETL_USING_64BIT_TYPES
|
||||
//*************************************************************************
|
||||
// Greater than 32 bits.
|
||||
//*************************************************************************
|
||||
@ -309,8 +309,8 @@ namespace etl
|
||||
{
|
||||
typedef int_least64_t type;
|
||||
};
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
} // namespace private_smallest
|
||||
|
||||
//***************************************************************************
|
||||
/// Template to determine the smallest unsigned int type that can contain a
|
||||
@ -324,9 +324,7 @@ namespace etl
|
||||
private:
|
||||
|
||||
// Determines the index of the best unsigned type for the required number of bits.
|
||||
static ETL_CONSTANT int TYPE_INDEX = ((NBITS > 8) ? 1 : 0) +
|
||||
((NBITS > 16) ? 1 : 0) +
|
||||
((NBITS > 32) ? 1 : 0);
|
||||
static ETL_CONSTANT int TYPE_INDEX = ((NBITS > 8) ? 1 : 0) + ((NBITS > 16) ? 1 : 0) + ((NBITS > 32) ? 1 : 0);
|
||||
|
||||
public:
|
||||
|
||||
@ -336,10 +334,10 @@ namespace etl
|
||||
template <size_t NBITS>
|
||||
ETL_CONSTANT int smallest_uint_for_bits<NBITS>::TYPE_INDEX;
|
||||
|
||||
#if ETL_USING_CPP11
|
||||
#if ETL_USING_CPP11
|
||||
template <size_t NBITS>
|
||||
using smallest_uint_for_bits_t = typename smallest_uint_for_bits<NBITS>::type;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//***************************************************************************
|
||||
/// Template to determine the smallest signed int type that can contain a
|
||||
@ -353,9 +351,7 @@ namespace etl
|
||||
private:
|
||||
|
||||
// Determines the index of the best unsigned type for the required number of bits.
|
||||
static ETL_CONSTANT int TYPE_INDEX = ((NBITS > 8) ? 1 : 0) +
|
||||
((NBITS > 16) ? 1 : 0) +
|
||||
((NBITS > 32) ? 1 : 0);
|
||||
static ETL_CONSTANT int TYPE_INDEX = ((NBITS > 8) ? 1 : 0) + ((NBITS > 16) ? 1 : 0) + ((NBITS > 32) ? 1 : 0);
|
||||
|
||||
public:
|
||||
|
||||
@ -365,10 +361,10 @@ namespace etl
|
||||
template <size_t NBITS>
|
||||
ETL_CONSTANT int smallest_int_for_bits<NBITS>::TYPE_INDEX;
|
||||
|
||||
#if ETL_USING_CPP11
|
||||
#if ETL_USING_CPP11
|
||||
template <size_t NBITS>
|
||||
using smallest_int_for_bits_t = typename smallest_int_for_bits<NBITS>::type;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//***************************************************************************
|
||||
/// Template to determine the smallest unsigned int type that can contain the
|
||||
@ -382,9 +378,7 @@ namespace etl
|
||||
private:
|
||||
|
||||
// Determines the index of the best unsigned type for the required value.
|
||||
static ETL_CONSTANT int TYPE_INDEX = ((VALUE > UINT_LEAST8_MAX) ? 1 : 0) +
|
||||
((VALUE > UINT16_MAX) ? 1 : 0) +
|
||||
((VALUE > UINT32_MAX) ? 1 : 0);
|
||||
static ETL_CONSTANT int TYPE_INDEX = ((VALUE > UINT_LEAST8_MAX) ? 1 : 0) + ((VALUE > UINT16_MAX) ? 1 : 0) + ((VALUE > UINT32_MAX) ? 1 : 0);
|
||||
|
||||
public:
|
||||
|
||||
@ -394,10 +388,10 @@ namespace etl
|
||||
template <uintmax_t VALUE>
|
||||
ETL_CONSTANT int smallest_uint_for_value<VALUE>::TYPE_INDEX;
|
||||
|
||||
#if ETL_USING_CPP11
|
||||
#if ETL_USING_CPP11
|
||||
template <uintmax_t VALUE>
|
||||
using smallest_uint_for_value_t = typename smallest_uint_for_value<VALUE>::type;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//***************************************************************************
|
||||
/// Template to determine the smallest int type that can contain the
|
||||
@ -411,9 +405,7 @@ namespace etl
|
||||
private:
|
||||
|
||||
// Determines the index of the best signed type for the required value.
|
||||
static ETL_CONSTANT 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 ETL_CONSTANT 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:
|
||||
|
||||
@ -423,10 +415,10 @@ namespace etl
|
||||
template <intmax_t VALUE>
|
||||
ETL_CONSTANT int smallest_int_for_value<VALUE>::TYPE_INDEX;
|
||||
|
||||
#if ETL_USING_CPP11
|
||||
#if ETL_USING_CPP11
|
||||
template <intmax_t VALUE>
|
||||
using smallest_int_for_value_t = typename smallest_int_for_value<VALUE>::type;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
} // namespace etl
|
||||
|
||||
#endif
|
||||
|
||||
@ -30,10 +30,10 @@ SOFTWARE.
|
||||
#define ETL_TYPE_LOOKUP_INCLUDED
|
||||
|
||||
#include "platform.h"
|
||||
#include "type_traits.h"
|
||||
#include "static_assert.h"
|
||||
#include "integral_limits.h"
|
||||
#include "null_type.h"
|
||||
#include "static_assert.h"
|
||||
#include "type_traits.h"
|
||||
|
||||
#include <limits.h>
|
||||
|
||||
@ -42,7 +42,7 @@ import cog
|
||||
cog.outl("#if 0")
|
||||
]]]*/
|
||||
/*[[[end]]]*/
|
||||
#error THIS HEADER IS A GENERATOR. DO NOT INCLUDE.
|
||||
#error THIS HEADER IS A GENERATOR. DO NOT INCLUDE.
|
||||
/*[[[cog
|
||||
import cog
|
||||
cog.outl("#endif")
|
||||
@ -85,7 +85,7 @@ namespace etl
|
||||
|
||||
#if ETL_USING_CPP11 && !defined(ETL_TYPE_SELECT_FORCE_CPP03_IMPLEMENTATION)
|
||||
//***************************************************************************
|
||||
// type_id_lookup
|
||||
// type_id_lookup
|
||||
//***************************************************************************
|
||||
template <typename... TTypes>
|
||||
struct type_id_lookup
|
||||
@ -93,7 +93,9 @@ namespace etl
|
||||
private:
|
||||
|
||||
// The type for no match.
|
||||
struct nulltype {};
|
||||
struct nulltype
|
||||
{
|
||||
};
|
||||
|
||||
// For N type pairs.
|
||||
template <size_t Id, typename T1, typename... TRest>
|
||||
@ -160,10 +162,10 @@ namespace etl
|
||||
static_assert(value != UNKNOWN, "Invalid type");
|
||||
};
|
||||
|
||||
#if ETL_USING_CPP17
|
||||
#if ETL_USING_CPP17
|
||||
template <typename T>
|
||||
static constexpr size_t id_from_type_v = id_from_type<T>::value;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//************************************
|
||||
template <typename T>
|
||||
@ -171,7 +173,7 @@ namespace etl
|
||||
{
|
||||
return get_id_from_type<T>();
|
||||
}
|
||||
|
||||
|
||||
//************************************
|
||||
template <typename T>
|
||||
static unsigned int get_id_from_type()
|
||||
@ -189,7 +191,9 @@ namespace etl
|
||||
private:
|
||||
|
||||
// The type for no match.
|
||||
struct nulltype {};
|
||||
struct nulltype
|
||||
{
|
||||
};
|
||||
|
||||
template <typename T, typename T1, typename... TRest>
|
||||
struct type_from_type_helper
|
||||
@ -227,14 +231,17 @@ namespace etl
|
||||
|
||||
#else
|
||||
|
||||
/*[[[cog
|
||||
/*[[[cog
|
||||
import cog
|
||||
cog.outl("//***************************************************************************")
|
||||
cog.outl("// For %s types." % int(NTypes))
|
||||
cog.outl("//***************************************************************************")
|
||||
max_w = len(str(int(NTypes)))
|
||||
cog.outl("template <typename T1,")
|
||||
for n in range(2, int(NTypes)):
|
||||
cog.outl(" typename T%s = etl::type_id_pair<etl::null_type<0>, -%s>," %(n, n))
|
||||
pad = " " * (max_w - len(str(n)))
|
||||
cog.outl(" typename T%s%s = etl::type_id_pair<etl::null_type<0>, -%s>," %(n, pad, n))
|
||||
|
||||
cog.outl(" typename T%s = etl::type_id_pair<etl::null_type<0>, -%s> >" %(NTypes, NTypes))
|
||||
cog.outl("struct type_id_lookup")
|
||||
cog.outl("{")
|
||||
@ -244,7 +251,8 @@ namespace etl
|
||||
cog.outl(" template <int Id>")
|
||||
cog.outl(" struct type_from_id")
|
||||
cog.outl(" {")
|
||||
cog.outl(" typedef ")
|
||||
cog.outl(" // clang-format off")
|
||||
cog.outl(" typedef")
|
||||
for n in range(1, int(NTypes) + 1):
|
||||
cog.outl(" typename etl::conditional<Id == T%s::Id, typename T%s::type," %(n, n))
|
||||
cog.out(" etl::null_type<0> >")
|
||||
@ -257,6 +265,7 @@ namespace etl
|
||||
if n != int(NTypes):
|
||||
cog.outl("")
|
||||
cog.out(" ")
|
||||
cog.outl(" // clang-format on")
|
||||
cog.outl("")
|
||||
cog.outl(" ETL_STATIC_ASSERT(!(etl::is_same<etl::null_type<0>, type>::value), \"Invalid id\");")
|
||||
cog.outl(" };")
|
||||
@ -272,10 +281,12 @@ namespace etl
|
||||
cog.outl(" {")
|
||||
cog.outl(" enum")
|
||||
cog.outl(" {")
|
||||
cog.outl(" value =")
|
||||
for n in range(1, int(NTypes) + 1) :
|
||||
cog.outl(" (unsigned int) etl::is_same<T, typename T%s::type>::value ? (unsigned int)T%s::Id :" % (n, n))
|
||||
cog.outl(" (unsigned int) UNKNOWN")
|
||||
first_pad = " " * (max_w - 1 + 3)
|
||||
cog.outl(" value = (unsigned int)etl::is_same<T, typename T1::type>::value%s? (unsigned int)T1::Id" % first_pad)
|
||||
for n in range(2, int(NTypes) + 1) :
|
||||
pad = " " * (max_w - len(str(n)) + 1)
|
||||
cog.outl(" : (unsigned int)etl::is_same<T, typename T%s::type>::value%s? (unsigned int)T%s::Id" % (n, pad, n))
|
||||
cog.outl(" : (unsigned int)UNKNOWN")
|
||||
cog.outl(" };")
|
||||
cog.outl("")
|
||||
cog.outl(" ETL_STATIC_ASSERT(((unsigned int)value != (unsigned int)UNKNOWN), \"Invalid type\");")
|
||||
@ -301,13 +312,15 @@ namespace etl
|
||||
cog.outl("//***************************************************************************")
|
||||
cog.outl("template <typename T1,")
|
||||
for n in range(2, int(NTypes)):
|
||||
cog.outl(" typename T%s = etl::type_type_pair<etl::null_type<0>, etl::null_type<0> >," %n)
|
||||
pad = " " * (max_w - len(str(n)))
|
||||
cog.outl(" typename T%s%s = etl::type_type_pair<etl::null_type<0>, etl::null_type<0> >," %(n, pad))
|
||||
cog.outl(" typename T%s = etl::type_type_pair<etl::null_type<0>, etl::null_type<0> > >" %NTypes)
|
||||
cog.outl("struct type_type_lookup")
|
||||
cog.outl("{")
|
||||
cog.outl("public:")
|
||||
cog.outl("")
|
||||
cog.outl(" //************************************")
|
||||
cog.outl(" // clang-format off")
|
||||
cog.outl(" template <typename T>")
|
||||
cog.outl(" struct type_from_type")
|
||||
cog.outl(" {")
|
||||
@ -327,11 +340,12 @@ namespace etl
|
||||
cog.outl("")
|
||||
cog.outl(" ETL_STATIC_ASSERT(!(etl::is_same<etl::null_type<0>, type>::value), \"Invalid type\");")
|
||||
cog.outl(" };")
|
||||
cog.outl(" // clang-format on")
|
||||
cog.outl("};")
|
||||
]]]*/
|
||||
/*[[[end]]]*/
|
||||
/*[[[end]]]*/
|
||||
|
||||
#endif
|
||||
}
|
||||
} // namespace etl
|
||||
|
||||
#endif
|
||||
|
||||
@ -30,16 +30,16 @@ SOFTWARE.
|
||||
#define ETL_TYPE_SELECT_INCLUDED
|
||||
|
||||
#include "platform.h"
|
||||
#include "null_type.h"
|
||||
#include "static_assert.h"
|
||||
#include "type_traits.h"
|
||||
#include "null_type.h"
|
||||
|
||||
/*[[[cog
|
||||
import cog
|
||||
cog.outl("#if 0")
|
||||
]]]*/
|
||||
/*[[[end]]]*/
|
||||
#error THIS HEADER IS A GENERATOR. DO NOT INCLUDE.
|
||||
#error THIS HEADER IS A GENERATOR. DO NOT INCLUDE.
|
||||
/*[[[cog
|
||||
import cog
|
||||
cog.outl("#endif")
|
||||
@ -99,19 +99,22 @@ namespace etl
|
||||
// Select type alias
|
||||
//***************************************************************************
|
||||
template <size_t Index, typename... TTypes>
|
||||
using type_select_t = typename etl::type_select<TTypes...>:: template select_t<Index>;
|
||||
using type_select_t = typename etl::type_select<TTypes...>::template select_t<Index>;
|
||||
|
||||
#else
|
||||
|
||||
/*[[[cog
|
||||
/*[[[cog
|
||||
import cog
|
||||
cog.outl("//***************************************************************************")
|
||||
cog.outl("// For %s types." % int(NTypes))
|
||||
cog.outl("//***************************************************************************")
|
||||
max_w = len(str(int(NTypes) - 1))
|
||||
cog.outl("template <typename T0,")
|
||||
for n in range(1, int(NTypes) - 1):
|
||||
cog.outl(" typename T%s = void," % n)
|
||||
cog.outl(" typename T%s = void>" %(int(NTypes) - 1))
|
||||
pad = " " * (max_w - len(str(n)))
|
||||
cog.outl(" typename T%s%s = void," % (n, pad))
|
||||
pad = " " * (max_w - len(str(int(NTypes) - 1)))
|
||||
cog.outl(" typename T%s%s = void>" %(int(NTypes) - 1, pad))
|
||||
cog.outl("struct type_select")
|
||||
cog.outl("{")
|
||||
cog.outl("public:")
|
||||
@ -119,6 +122,7 @@ namespace etl
|
||||
cog.outl(" template <size_t Id>")
|
||||
cog.outl(" struct select")
|
||||
cog.outl(" {")
|
||||
cog.outl(" // clang-format off")
|
||||
cog.outl(" typedef typename etl::conditional<Id == 0, T0,")
|
||||
for n in range(1, int(NTypes)) :
|
||||
cog.outl(" typename etl::conditional<Id == %s, T%s," % (n, n))
|
||||
@ -130,6 +134,7 @@ namespace etl
|
||||
cog.outl("")
|
||||
cog.out(" ")
|
||||
cog.outl("::type type;")
|
||||
cog.outl(" // clang-format on")
|
||||
cog.outl("");
|
||||
cog.outl(" ETL_STATIC_ASSERT(Id < %s, \"Invalid Id\");" % int(NTypes));
|
||||
cog.outl(" };")
|
||||
@ -142,7 +147,7 @@ namespace etl
|
||||
cog.outl("//***************************************************************************")
|
||||
cog.out("template <")
|
||||
for n in range(0, s - 1):
|
||||
cog.outl("typename T%s, " % n)
|
||||
cog.outl("typename T%s," % n)
|
||||
cog.out(" ")
|
||||
cog.outl("typename T%s>" % (s - 1))
|
||||
cog.out("struct type_select<")
|
||||
@ -151,9 +156,11 @@ namespace etl
|
||||
cog.outl("T%s>" % (s - 1))
|
||||
cog.outl("{")
|
||||
cog.outl("public:")
|
||||
cog.outl("")
|
||||
cog.outl(" template <size_t Id>")
|
||||
cog.outl(" struct select")
|
||||
cog.outl(" {")
|
||||
cog.outl(" // clang-format off")
|
||||
cog.outl(" typedef typename etl::conditional<Id == 0, T0,")
|
||||
for n in range(1, s) :
|
||||
cog.outl(" typename etl::conditional<Id == %s, T%s," % (n, n))
|
||||
@ -165,13 +172,14 @@ namespace etl
|
||||
cog.outl("")
|
||||
cog.out(" ")
|
||||
cog.outl("::type type;")
|
||||
cog.outl(" // clang-format on")
|
||||
cog.outl("");
|
||||
cog.outl(" ETL_STATIC_ASSERT(Id < %s, \"Invalid Id\");" % s);
|
||||
cog.outl(" };")
|
||||
cog.outl("};")
|
||||
]]]*/
|
||||
/*[[[end]]]*/
|
||||
/*[[[end]]]*/
|
||||
#endif
|
||||
}
|
||||
} // namespace etl
|
||||
|
||||
#endif
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -31,7 +31,7 @@ import cog
|
||||
cog.outl("#if 0")
|
||||
]]]*/
|
||||
/*[[[end]]]*/
|
||||
#error THIS HEADER IS A GENERATOR. DO NOT INCLUDE.
|
||||
#error THIS HEADER IS A GENERATOR. DO NOT INCLUDE.
|
||||
/*[[[cog
|
||||
import cog
|
||||
cog.outl("#endif")
|
||||
@ -61,21 +61,21 @@ cog.outl("//********************************************************************
|
||||
//***************************************************************************
|
||||
|
||||
#ifndef ETL_VARIANT_POOL_INCLUDED
|
||||
#define ETL_VARIANT_POOL_INCLUDED
|
||||
#define ETL_VARIANT_POOL_INCLUDED
|
||||
|
||||
#include "platform.h"
|
||||
#include "pool.h"
|
||||
#include "type_traits.h"
|
||||
#include "static_assert.h"
|
||||
#include "largest.h"
|
||||
#include "platform.h"
|
||||
#include "largest.h"
|
||||
#include "pool.h"
|
||||
#include "static_assert.h"
|
||||
#include "type_traits.h"
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdint.h>
|
||||
|
||||
namespace etl
|
||||
{
|
||||
#if ETL_USING_CPP11 && !defined(ETL_VARIANT_POOL_FORCE_CPP03_IMPLEMENTATION)
|
||||
#if ETL_USING_CPP11 && !defined(ETL_VARIANT_POOL_FORCE_CPP03_IMPLEMENTATION)
|
||||
//***************************************************************************
|
||||
template <size_t MAX_SIZE_, typename ... Ts>
|
||||
template <size_t MAX_SIZE_, typename... Ts>
|
||||
class variant_pool
|
||||
: public etl::generic_pool<etl::largest<Ts...>::size,
|
||||
etl::largest<Ts...>::alignment,
|
||||
@ -85,7 +85,8 @@ namespace etl
|
||||
|
||||
typedef etl::generic_pool<etl::largest<Ts...>::size,
|
||||
etl::largest<Ts...>::alignment,
|
||||
MAX_SIZE_> base_t;
|
||||
MAX_SIZE_>
|
||||
base_t;
|
||||
|
||||
static const size_t MAX_SIZE = MAX_SIZE_;
|
||||
|
||||
@ -129,11 +130,11 @@ namespace etl
|
||||
private:
|
||||
|
||||
variant_pool(const variant_pool&) ETL_DELETE;
|
||||
variant_pool& operator =(const variant_pool&) ETL_DELETE;
|
||||
variant_pool& operator=(const variant_pool&) ETL_DELETE;
|
||||
};
|
||||
|
||||
//***************************************************************************
|
||||
template <typename ... Ts>
|
||||
template <typename... Ts>
|
||||
class variant_pool_ext
|
||||
: public etl::generic_pool_ext<etl::largest<Ts...>::size,
|
||||
etl::largest<Ts...>::alignment>
|
||||
@ -141,7 +142,8 @@ namespace etl
|
||||
public:
|
||||
|
||||
typedef etl::generic_pool_ext<etl::largest<Ts...>::size,
|
||||
etl::largest<Ts...>::alignment> base_t;
|
||||
etl::largest<Ts...>::alignment>
|
||||
base_t;
|
||||
|
||||
//*************************************************************************
|
||||
/// Default constructor.
|
||||
@ -184,16 +186,18 @@ namespace etl
|
||||
private:
|
||||
|
||||
variant_pool_ext(const variant_pool_ext&) ETL_DELETE;
|
||||
variant_pool_ext& operator =(const variant_pool_ext&) ETL_DELETE;
|
||||
variant_pool_ext& operator=(const variant_pool_ext&) ETL_DELETE;
|
||||
};
|
||||
#else
|
||||
#else
|
||||
//***************************************************************************
|
||||
/*[[[cog
|
||||
import cog
|
||||
max_w = len(str(int(NTypes)))
|
||||
cog.outl("template <size_t MAX_SIZE_,")
|
||||
cog.outl(" typename T1,")
|
||||
for n in range(2, int(NTypes)):
|
||||
cog.outl(" typename T%s = void," % n)
|
||||
pad = " " * (max_w - len(str(n)))
|
||||
cog.outl(" typename T%s%s = void," % (n, pad))
|
||||
cog.outl(" typename T%s = void>" % int(NTypes))
|
||||
cog.outl("class variant_pool")
|
||||
cog.out(" : public etl::generic_pool<")
|
||||
@ -222,7 +226,8 @@ namespace etl
|
||||
for n in range(1, int(NTypes)):
|
||||
cog.out("T%s, " % n)
|
||||
cog.outl("T%s>::alignment," % int(NTypes))
|
||||
cog.outl(" MAX_SIZE_> base_t;")
|
||||
cog.outl(" MAX_SIZE_>")
|
||||
cog.outl(" base_t;")
|
||||
]]]*/
|
||||
/*[[[end]]]*/
|
||||
|
||||
@ -235,7 +240,7 @@ namespace etl
|
||||
{
|
||||
}
|
||||
|
||||
#if ETL_CPP11_NOT_SUPPORTED || ETL_USING_STLPORT
|
||||
#if ETL_CPP11_NOT_SUPPORTED || ETL_USING_STLPORT
|
||||
//*************************************************************************
|
||||
/// Creates the object. Default constructor.
|
||||
//*************************************************************************
|
||||
@ -340,7 +345,7 @@ namespace etl
|
||||
|
||||
return base_t::template create<T>(p1, p2, p3, p4);
|
||||
}
|
||||
#else
|
||||
#else
|
||||
//*************************************************************************
|
||||
/// Creates the object from a type. Variadic parameter constructor.
|
||||
//*************************************************************************
|
||||
@ -361,7 +366,7 @@ namespace etl
|
||||
|
||||
return base_t::template create<T>(etl::forward<Args>(args)...);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
/// Destroys the object.
|
||||
@ -374,15 +379,17 @@ namespace etl
|
||||
cog.out("ETL_STATIC_ASSERT((etl::is_one_of<T, ")
|
||||
for n in range(1, int(NTypes)):
|
||||
cog.out("T%s, " % n)
|
||||
if n % 16 == 0:
|
||||
cog.outl("T%s>::value" % int(NTypes))
|
||||
for n in range(1, int(NTypes) + 1):
|
||||
if (n - 1) % 4 == 0:
|
||||
cog.out(" || etl::is_base_of<T, T%s>::value" % n)
|
||||
else:
|
||||
cog.out(" || etl::is_base_of<T, T%s>::value" % n)
|
||||
if n == int(NTypes):
|
||||
cog.outl("),")
|
||||
elif n % 4 == 0:
|
||||
cog.outl("")
|
||||
cog.out(" ")
|
||||
cog.outl("T%s>::value ||" % int(NTypes))
|
||||
|
||||
for n in range(1, int(NTypes)):
|
||||
cog.outl(" etl::is_base_of<T, T%s>::value ||" % n)
|
||||
cog.outl(" etl::is_base_of<T, T%s>::value), \"Invalid type\");" % int(NTypes))
|
||||
|
||||
cog.outl(' "Invalid type");')
|
||||
]]]*/
|
||||
/*[[[end]]]*/
|
||||
|
||||
@ -400,7 +407,7 @@ namespace etl
|
||||
private:
|
||||
|
||||
variant_pool(const variant_pool&) ETL_DELETE;
|
||||
variant_pool& operator =(const variant_pool&) ETL_DELETE;
|
||||
variant_pool& operator=(const variant_pool&) ETL_DELETE;
|
||||
};
|
||||
|
||||
//***************************************************************************
|
||||
@ -408,7 +415,8 @@ namespace etl
|
||||
import cog
|
||||
cog.outl("template <typename T1,")
|
||||
for n in range(2, int(NTypes)):
|
||||
cog.outl(" typename T%s = void," % n)
|
||||
pad = " " * (max_w - len(str(n)))
|
||||
cog.outl(" typename T%s%s = void," % (n, pad))
|
||||
cog.outl(" typename T%s = void>" % int(NTypes))
|
||||
cog.outl("class variant_pool_ext")
|
||||
cog.out(" : public etl::generic_pool_ext<")
|
||||
@ -435,7 +443,8 @@ namespace etl
|
||||
cog.out(" etl::largest<")
|
||||
for n in range(1, int(NTypes)):
|
||||
cog.out("T%s, " % n)
|
||||
cog.outl("T%s>::alignment> base_t;" % int(NTypes))
|
||||
cog.outl("T%s>::alignment>" % int(NTypes))
|
||||
cog.outl(" base_t;")
|
||||
]]]*/
|
||||
/*[[[end]]]*/
|
||||
|
||||
@ -443,11 +452,11 @@ namespace etl
|
||||
/// Default constructor.
|
||||
//*************************************************************************
|
||||
variant_pool_ext(typename base_t::element* buffer, size_t size)
|
||||
: base_t(buffer, size)
|
||||
: base_t(buffer, size)
|
||||
{
|
||||
}
|
||||
|
||||
#if ETL_CPP11_NOT_SUPPORTED || ETL_USING_STLPORT
|
||||
#if ETL_CPP11_NOT_SUPPORTED || ETL_USING_STLPORT
|
||||
//*************************************************************************
|
||||
/// Creates the object. Default constructor.
|
||||
//*************************************************************************
|
||||
@ -552,7 +561,7 @@ namespace etl
|
||||
|
||||
return base_t::template create<T>(p1, p2, p3, p4);
|
||||
}
|
||||
#else
|
||||
#else
|
||||
//*************************************************************************
|
||||
/// Creates the object from a type. Variadic parameter constructor.
|
||||
//*************************************************************************
|
||||
@ -573,7 +582,7 @@ namespace etl
|
||||
|
||||
return base_t::template create<T>(etl::forward<Args>(args)...);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
/// Destroys the object.
|
||||
@ -586,15 +595,17 @@ namespace etl
|
||||
cog.out("ETL_STATIC_ASSERT((etl::is_one_of<T, ")
|
||||
for n in range(1, int(NTypes)):
|
||||
cog.out("T%s, " % n)
|
||||
if n % 16 == 0:
|
||||
cog.outl("T%s>::value" % int(NTypes))
|
||||
for n in range(1, int(NTypes) + 1):
|
||||
if (n - 1) % 4 == 0:
|
||||
cog.out(" || etl::is_base_of<T, T%s>::value" % n)
|
||||
else:
|
||||
cog.out(" || etl::is_base_of<T, T%s>::value" % n)
|
||||
if n == int(NTypes):
|
||||
cog.outl("),")
|
||||
elif n % 4 == 0:
|
||||
cog.outl("")
|
||||
cog.out(" ")
|
||||
cog.outl("T%s>::value ||" % int(NTypes))
|
||||
|
||||
for n in range(1, int(NTypes)):
|
||||
cog.outl(" etl::is_base_of<T, T%s>::value ||" % n)
|
||||
cog.outl(" etl::is_base_of<T, T%s>::value), \"Invalid type\");" % int(NTypes))
|
||||
|
||||
cog.outl(' "Invalid type");')
|
||||
]]]*/
|
||||
/*[[[end]]]*/
|
||||
|
||||
@ -604,17 +615,17 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Returns the maximum number of items in the variant_pool.
|
||||
//*************************************************************************
|
||||
size_t max_size() const
|
||||
{
|
||||
return base_t::max_size();
|
||||
size_t max_size() const
|
||||
{
|
||||
return base_t::max_size();
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
variant_pool_ext(const variant_pool_ext&) ETL_DELETE;
|
||||
variant_pool_ext& operator =(const variant_pool_ext&) ETL_DELETE;
|
||||
variant_pool_ext& operator=(const variant_pool_ext&) ETL_DELETE;
|
||||
};
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
} // namespace etl
|
||||
|
||||
#endif
|
||||
|
||||
@ -29,7 +29,7 @@ SOFTWARE.
|
||||
******************************************************************************/
|
||||
|
||||
#if 0
|
||||
#error THIS HEADER IS A GENERATOR. DO NOT INCLUDE.
|
||||
#error THIS HEADER IS A GENERATOR. DO NOT INCLUDE.
|
||||
#endif
|
||||
|
||||
//***************************************************************************
|
||||
@ -51,19 +51,19 @@ SOFTWARE.
|
||||
//***************************************************************************
|
||||
|
||||
#ifndef ETL_LARGEST_INCLUDED
|
||||
#define ETL_LARGEST_INCLUDED
|
||||
#define ETL_LARGEST_INCLUDED
|
||||
|
||||
///\defgroup largest largest
|
||||
///\ingroup utilities
|
||||
|
||||
#include "platform.h"
|
||||
#include "type_traits.h"
|
||||
#include "smallest.h"
|
||||
#include "static_assert.h"
|
||||
#include "platform.h"
|
||||
#include "smallest.h"
|
||||
#include "static_assert.h"
|
||||
#include "type_traits.h"
|
||||
|
||||
namespace etl
|
||||
{
|
||||
#if ETL_USING_CPP11 && !defined(ETL_LARGEST_TYPE_FORCE_CPP03_IMPLEMENTATION)
|
||||
#if ETL_USING_CPP11 && !defined(ETL_LARGEST_TYPE_FORCE_CPP03_IMPLEMENTATION)
|
||||
//***************************************************************************
|
||||
/// Template to determine the largest type and size.
|
||||
/// Defines 'value_type' which is the type of the largest parameter.
|
||||
@ -82,10 +82,10 @@ namespace etl
|
||||
|
||||
// Set 'type' to be the largest of the first parameter and any of the others.
|
||||
// This is recursive.
|
||||
using type = typename etl::conditional<(etl::size_of<T1>::value > etl::size_of<largest_other>::value), // Boolean
|
||||
T1, // TrueType
|
||||
largest_other> // FalseType
|
||||
::type; // The largest type of the two.
|
||||
using type = typename etl::conditional<(etl::size_of<T1>::value > etl::size_of<largest_other>::value), // Boolean
|
||||
T1, // TrueType
|
||||
largest_other> // FalseType
|
||||
::type; // The largest type of the two.
|
||||
|
||||
// The size of the largest type.
|
||||
enum
|
||||
@ -110,17 +110,17 @@ namespace etl
|
||||
};
|
||||
};
|
||||
|
||||
#if ETL_USING_CPP11
|
||||
#if ETL_USING_CPP11
|
||||
template <typename... T>
|
||||
using largest_type_t = typename largest_type<T...>::type;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if ETL_USING_CPP17
|
||||
#if ETL_USING_CPP17
|
||||
template <typename... T>
|
||||
constexpr size_t largest_type_v = largest_type<T...>::size;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#else
|
||||
#else
|
||||
//***************************************************************************
|
||||
/// Template to determine the largest type and size.
|
||||
/// Supports up to 16 types.
|
||||
@ -128,21 +128,21 @@ namespace etl
|
||||
/// Defines 'size' which is the size of the largest parameter.
|
||||
///\ingroup largest
|
||||
//***************************************************************************
|
||||
template <typename T1, typename T2 = void, typename T3 = void, typename T4 = void,
|
||||
typename T5 = void, typename T6 = void, typename T7 = void, typename T8 = void,
|
||||
typename T9 = void, typename T10 = void, typename T11 = void, typename T12 = void,
|
||||
template <typename T1, typename T2 = void, typename T3 = void, typename T4 = void,
|
||||
typename T5 = void, typename T6 = void, typename T7 = void, typename T8 = void,
|
||||
typename T9 = void, typename T10 = void, typename T11 = void, typename T12 = void,
|
||||
typename T13 = void, typename T14 = void, typename T15 = void, typename T16 = void>
|
||||
struct largest_type
|
||||
{
|
||||
// Define 'largest_other' as 'largest_type' with all but the first parameter.
|
||||
// Define 'largest_other' as 'largest_type' with all but the first parameter.
|
||||
typedef typename largest_type<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>::type largest_other;
|
||||
|
||||
// Set 'type' to be the largest of the first parameter and any of the others.
|
||||
// This is recursive.
|
||||
typedef typename etl::conditional<(sizeof(T1) > sizeof(largest_other)), // Boolean
|
||||
T1, // TrueType
|
||||
largest_other> // FalseType
|
||||
::type type; // The largest type of the two.
|
||||
T1, // TrueType
|
||||
largest_other> // FalseType
|
||||
::type type; // The largest type of the two.
|
||||
|
||||
// The size of the largest type.
|
||||
enum
|
||||
@ -155,7 +155,7 @@ namespace etl
|
||||
// Specialisation for one template parameter.
|
||||
//***************************************************************************
|
||||
template <typename T1>
|
||||
struct largest_type<T1, void, void, void, void, void, void, void,
|
||||
struct largest_type<T1, void, void, void, void, void, void, void,
|
||||
void, void, void, void, void, void, void, void>
|
||||
{
|
||||
typedef T1 type;
|
||||
@ -165,9 +165,9 @@ namespace etl
|
||||
size = sizeof(type)
|
||||
};
|
||||
};
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if ETL_USING_CPP11 && !defined(ETL_LARGEST_ALIGNMENT_FORCE_CPP03_IMPLEMENTATION)
|
||||
#if ETL_USING_CPP11 && !defined(ETL_LARGEST_ALIGNMENT_FORCE_CPP03_IMPLEMENTATION)
|
||||
//***************************************************************************
|
||||
/// Template to determine the largest alignment.
|
||||
/// Defines <b>value</b> which is the largest alignment of all the parameters.
|
||||
@ -182,9 +182,9 @@ namespace etl
|
||||
// Set 'type' to be the largest of the first parameter and any of the others.
|
||||
// This is recursive.
|
||||
using type = typename etl::conditional<(etl::alignment_of<T1>::value > etl::alignment_of<largest_other>::value), // Boolean
|
||||
T1, // TrueType
|
||||
largest_other> // FalseType
|
||||
::type; // The largest type of the two.
|
||||
T1, // TrueType
|
||||
largest_other> // FalseType
|
||||
::type; // The largest type of the two.
|
||||
|
||||
// The largest alignment.
|
||||
enum
|
||||
@ -207,33 +207,33 @@ namespace etl
|
||||
};
|
||||
};
|
||||
|
||||
#if ETL_USING_CPP17
|
||||
#if ETL_USING_CPP17
|
||||
template <typename... T>
|
||||
inline constexpr size_t largest_alignment_v = largest_alignment<T...>::value;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#else
|
||||
#else
|
||||
//***************************************************************************
|
||||
/// Template to determine the largest alignment.
|
||||
/// Supports up to 16 types.
|
||||
/// Defines <b>value</b> which is the largest alignment of all the parameters.
|
||||
///\ingroup largest
|
||||
//***************************************************************************
|
||||
template <typename T1, typename T2 = void, typename T3 = void, typename T4 = void,
|
||||
typename T5 = void, typename T6 = void, typename T7 = void, typename T8 = void,
|
||||
typename T9 = void, typename T10 = void, typename T11 = void, typename T12 = void,
|
||||
template <typename T1, typename T2 = void, typename T3 = void, typename T4 = void,
|
||||
typename T5 = void, typename T6 = void, typename T7 = void, typename T8 = void,
|
||||
typename T9 = void, typename T10 = void, typename T11 = void, typename T12 = void,
|
||||
typename T13 = void, typename T14 = void, typename T15 = void, typename T16 = void>
|
||||
struct largest_alignment
|
||||
{
|
||||
// Define 'largest_other' as 'largest_type' with all but the first parameter.
|
||||
// Define 'largest_other' as 'largest_type' with all but the first parameter.
|
||||
typedef typename largest_alignment<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>::type largest_other;
|
||||
|
||||
// Set 'type' to be the largest of the first parameter and any of the others.
|
||||
// This is recursive.
|
||||
typedef typename etl::conditional<(etl::alignment_of<T1>::value > etl::alignment_of<largest_other>::value), // Boolean
|
||||
T1, // TrueType
|
||||
largest_other> // FalseType
|
||||
::type type; // The largest type of the two.
|
||||
T1, // TrueType
|
||||
largest_other> // FalseType
|
||||
::type type; // The largest type of the two.
|
||||
|
||||
// The largest alignment.
|
||||
enum
|
||||
@ -246,7 +246,7 @@ namespace etl
|
||||
// Specialisation for one template parameter.
|
||||
//***************************************************************************
|
||||
template <typename T1>
|
||||
struct largest_alignment<T1, void, void, void, void, void, void, void,
|
||||
struct largest_alignment<T1, void, void, void, void, void, void, void,
|
||||
void, void, void, void, void, void, void, void>
|
||||
{
|
||||
typedef T1 type;
|
||||
@ -256,7 +256,7 @@ namespace etl
|
||||
value = etl::alignment_of<type>::value
|
||||
};
|
||||
};
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//***************************************************************************
|
||||
/// Defines a type that is as larger or larger than the specified type.
|
||||
@ -271,10 +271,10 @@ namespace etl
|
||||
typedef typename etl::smallest_int_for_bits<etl::integral_limits<typename etl::make_signed<T>::type>::bits + 1>::type type;
|
||||
};
|
||||
|
||||
#if ETL_USING_CPP11
|
||||
#if ETL_USING_CPP11
|
||||
template <typename T>
|
||||
using larger_int_type_t = typename larger_int_type<T>::type;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//***************************************************************************
|
||||
/// Defines a type that is as larger or larger than the specified type.
|
||||
@ -289,10 +289,10 @@ namespace etl
|
||||
typedef typename etl::smallest_uint_for_bits<etl::integral_limits<typename etl::make_unsigned<T>::type>::bits + 1>::type type;
|
||||
};
|
||||
|
||||
#if ETL_USING_CPP11
|
||||
#if ETL_USING_CPP11
|
||||
template <typename T>
|
||||
using larger_uint_type_t = typename larger_uint_type<T>::type;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//***************************************************************************
|
||||
/// Defines a type that is as larger or larger than the specified type.
|
||||
@ -319,12 +319,12 @@ namespace etl
|
||||
typedef typename etl::smallest_int_for_bits<etl::integral_limits<T>::bits + 1>::type type;
|
||||
};
|
||||
|
||||
#if ETL_USING_CPP11
|
||||
#if ETL_USING_CPP11
|
||||
template <typename T>
|
||||
using larger_type_t = typename larger_type<T>::type;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if ETL_USING_CPP11 && !defined(ETL_LARGEST_FORCE_CPP03_IMPLEMENTATION)
|
||||
#if ETL_USING_CPP11 && !defined(ETL_LARGEST_FORCE_CPP03_IMPLEMENTATION)
|
||||
//***************************************************************************
|
||||
/// Template to determine the largest type, size and alignment.
|
||||
/// Defines <b>value</b> which is the largest type, size and alignment of all the parameters.
|
||||
@ -342,26 +342,26 @@ namespace etl
|
||||
};
|
||||
};
|
||||
|
||||
#if ETL_USING_CPP11
|
||||
template <typename... T>
|
||||
using largest_t = typename largest<T...>::type;
|
||||
#endif
|
||||
#if ETL_USING_CPP11
|
||||
template <typename... T>
|
||||
using largest_t = typename largest<T...>::type;
|
||||
#endif
|
||||
|
||||
#if ETL_USING_CPP17
|
||||
template <typename... T>
|
||||
inline constexpr size_t largest_size = largest<T...>::size;
|
||||
#endif
|
||||
#if ETL_USING_CPP17
|
||||
template <typename... T>
|
||||
inline constexpr size_t largest_size = largest<T...>::size;
|
||||
#endif
|
||||
|
||||
#else
|
||||
#else
|
||||
//***************************************************************************
|
||||
/// Template to determine the largest type, size and alignment.
|
||||
/// Supports up to 16 types.
|
||||
/// Defines <b>value</b> which is the largest type, size and alignment of all the parameters.
|
||||
///\ingroup largest
|
||||
//***************************************************************************
|
||||
template <typename T1, typename T2 = void, typename T3 = void, typename T4 = void,
|
||||
typename T5 = void, typename T6 = void, typename T7 = void, typename T8 = void,
|
||||
typename T9 = void, typename T10 = void, typename T11 = void, typename T12 = void,
|
||||
template <typename T1, typename T2 = void, typename T3 = void, typename T4 = void,
|
||||
typename T5 = void, typename T6 = void, typename T7 = void, typename T8 = void,
|
||||
typename T9 = void, typename T10 = void, typename T11 = void, typename T12 = void,
|
||||
typename T13 = void, typename T14 = void, typename T15 = void, typename T16 = void>
|
||||
struct largest
|
||||
{
|
||||
@ -373,7 +373,7 @@ namespace etl
|
||||
alignment = etl::largest_alignment<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>::value
|
||||
};
|
||||
};
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
} // namespace etl
|
||||
|
||||
#endif
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -29,7 +29,7 @@ SOFTWARE.
|
||||
******************************************************************************/
|
||||
|
||||
#if 0
|
||||
#error THIS HEADER IS A GENERATOR. DO NOT INCLUDE.
|
||||
#error THIS HEADER IS A GENERATOR. DO NOT INCLUDE.
|
||||
#endif
|
||||
|
||||
//***************************************************************************
|
||||
@ -51,19 +51,19 @@ SOFTWARE.
|
||||
//***************************************************************************
|
||||
|
||||
#ifndef ETL_SMALLEST_INCLUDED
|
||||
#define ETL_SMALLEST_INCLUDED
|
||||
#define ETL_SMALLEST_INCLUDED
|
||||
|
||||
#include "platform.h"
|
||||
#include "integral_limits.h"
|
||||
#include "platform.h"
|
||||
#include "integral_limits.h"
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdint.h>
|
||||
|
||||
///\defgroup smallest smallest
|
||||
///\ingroup utilities
|
||||
|
||||
namespace etl
|
||||
{
|
||||
#if ETL_USING_CPP11 && !defined(ETL_SMALLEST_TYPE_FORCE_CPP03_IMPLEMENTATION)
|
||||
#if ETL_USING_CPP11 && !defined(ETL_SMALLEST_TYPE_FORCE_CPP03_IMPLEMENTATION)
|
||||
//***************************************************************************
|
||||
/// Template to determine the largest type and size.
|
||||
/// Defines 'value_type' which is the type of the largest parameter.
|
||||
@ -83,9 +83,9 @@ namespace etl
|
||||
// Set 'type' to be the smallest of the first parameter and any of the others.
|
||||
// This is recursive.
|
||||
using type = typename etl::conditional<(etl::size_of<T1>::value < etl::size_of<smallest_other>::value), // Boolean
|
||||
T1, // TrueType
|
||||
smallest_other> // FalseType
|
||||
::type; // The smallest type of the two.
|
||||
T1, // TrueType
|
||||
smallest_other> // FalseType
|
||||
::type; // The smallest type of the two.
|
||||
|
||||
// The size of the smallest type.
|
||||
enum
|
||||
@ -110,17 +110,17 @@ namespace etl
|
||||
};
|
||||
};
|
||||
|
||||
#if ETL_USING_CPP11
|
||||
#if ETL_USING_CPP11
|
||||
template <typename... T>
|
||||
using smallest_type_t = typename smallest_type<T...>::type;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if ETL_USING_CPP17
|
||||
#if ETL_USING_CPP17
|
||||
template <typename... T>
|
||||
constexpr size_t smallest_type_v = smallest_type<T...>::size;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#else
|
||||
#else
|
||||
//***************************************************************************
|
||||
/// Template to determine the smallest type and size.
|
||||
/// Supports up to 16 types.
|
||||
@ -128,9 +128,9 @@ namespace etl
|
||||
/// Defines 'size' which is the size of the smallest parameter.
|
||||
///\ingroup smallest
|
||||
//***************************************************************************
|
||||
template <typename T1, typename T2 = void, typename T3 = void, typename T4 = void,
|
||||
typename T5 = void, typename T6 = void, typename T7 = void, typename T8 = void,
|
||||
typename T9 = void, typename T10 = void, typename T11 = void, typename T12 = void,
|
||||
template <typename T1, typename T2 = void, typename T3 = void, typename T4 = void,
|
||||
typename T5 = void, typename T6 = void, typename T7 = void, typename T8 = void,
|
||||
typename T9 = void, typename T10 = void, typename T11 = void, typename T12 = void,
|
||||
typename T13 = void, typename T14 = void, typename T15 = void, typename T16 = void>
|
||||
struct smallest_type
|
||||
{
|
||||
@ -148,7 +148,7 @@ namespace etl
|
||||
typedef TrueType type;
|
||||
};
|
||||
|
||||
// Specialisation for 'false'.
|
||||
// Specialisation for 'false'.
|
||||
// Defines 'type' as 'FalseType'.
|
||||
template <typename TrueType, typename FalseType>
|
||||
struct choose_type<false, TrueType, FalseType>
|
||||
@ -158,15 +158,15 @@ namespace etl
|
||||
|
||||
public:
|
||||
|
||||
// Define 'smallest_other' as 'smallest_type' with all but the first parameter.
|
||||
// Define 'smallest_other' as 'smallest_type' with all but the first parameter.
|
||||
typedef typename smallest_type<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>::type smallest_other;
|
||||
|
||||
// Set 'type' to be the smallest of the first parameter and any of the others.
|
||||
// This is recursive.
|
||||
typedef typename choose_type<(sizeof(T1) < sizeof(smallest_other)), // Boolean
|
||||
T1, // TrueType
|
||||
smallest_other> // FalseType
|
||||
::type type; // The smallest type of the two.
|
||||
T1, // TrueType
|
||||
smallest_other> // FalseType
|
||||
::type type; // The smallest type of the two.
|
||||
|
||||
// The size of the smallest type.
|
||||
enum
|
||||
@ -179,7 +179,7 @@ namespace etl
|
||||
// Specialisation for one template parameter.
|
||||
//***************************************************************************
|
||||
template <typename T1>
|
||||
struct smallest_type<T1, void, void, void, void, void, void, void,
|
||||
struct smallest_type<T1, void, void, void, void, void, void, void,
|
||||
void, void, void, void, void, void, void, void>
|
||||
{
|
||||
typedef T1 type;
|
||||
@ -189,7 +189,7 @@ namespace etl
|
||||
size = sizeof(type)
|
||||
};
|
||||
};
|
||||
#endif
|
||||
#endif
|
||||
|
||||
namespace private_smallest
|
||||
{
|
||||
@ -226,7 +226,7 @@ namespace etl
|
||||
typedef uint_least32_t type;
|
||||
};
|
||||
|
||||
#if ETL_USING_64BIT_TYPES
|
||||
#if ETL_USING_64BIT_TYPES
|
||||
//*************************************************************************
|
||||
// Greater than 32 bits.
|
||||
//*************************************************************************
|
||||
@ -235,7 +235,7 @@ namespace etl
|
||||
{
|
||||
typedef uint_least64_t type;
|
||||
};
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
// Determine the type to hold the number of bits based on the index.
|
||||
@ -270,7 +270,7 @@ namespace etl
|
||||
typedef int_least32_t type;
|
||||
};
|
||||
|
||||
#if ETL_USING_64BIT_TYPES
|
||||
#if ETL_USING_64BIT_TYPES
|
||||
//*************************************************************************
|
||||
// Greater than 32 bits.
|
||||
//*************************************************************************
|
||||
@ -279,8 +279,8 @@ namespace etl
|
||||
{
|
||||
typedef int_least64_t type;
|
||||
};
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
} // namespace private_smallest
|
||||
|
||||
//***************************************************************************
|
||||
/// Template to determine the smallest unsigned int type that can contain a
|
||||
@ -294,9 +294,7 @@ namespace etl
|
||||
private:
|
||||
|
||||
// Determines the index of the best unsigned type for the required number of bits.
|
||||
static ETL_CONSTANT int TYPE_INDEX = ((NBITS > 8) ? 1 : 0) +
|
||||
((NBITS > 16) ? 1 : 0) +
|
||||
((NBITS > 32) ? 1 : 0);
|
||||
static ETL_CONSTANT int TYPE_INDEX = ((NBITS > 8) ? 1 : 0) + ((NBITS > 16) ? 1 : 0) + ((NBITS > 32) ? 1 : 0);
|
||||
|
||||
public:
|
||||
|
||||
@ -306,10 +304,10 @@ namespace etl
|
||||
template <size_t NBITS>
|
||||
ETL_CONSTANT int smallest_uint_for_bits<NBITS>::TYPE_INDEX;
|
||||
|
||||
#if ETL_USING_CPP11
|
||||
#if ETL_USING_CPP11
|
||||
template <size_t NBITS>
|
||||
using smallest_uint_for_bits_t = typename smallest_uint_for_bits<NBITS>::type;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//***************************************************************************
|
||||
/// Template to determine the smallest signed int type that can contain a
|
||||
@ -323,9 +321,7 @@ namespace etl
|
||||
private:
|
||||
|
||||
// Determines the index of the best unsigned type for the required number of bits.
|
||||
static ETL_CONSTANT int TYPE_INDEX = ((NBITS > 8) ? 1 : 0) +
|
||||
((NBITS > 16) ? 1 : 0) +
|
||||
((NBITS > 32) ? 1 : 0);
|
||||
static ETL_CONSTANT int TYPE_INDEX = ((NBITS > 8) ? 1 : 0) + ((NBITS > 16) ? 1 : 0) + ((NBITS > 32) ? 1 : 0);
|
||||
|
||||
public:
|
||||
|
||||
@ -335,10 +331,10 @@ namespace etl
|
||||
template <size_t NBITS>
|
||||
ETL_CONSTANT int smallest_int_for_bits<NBITS>::TYPE_INDEX;
|
||||
|
||||
#if ETL_USING_CPP11
|
||||
#if ETL_USING_CPP11
|
||||
template <size_t NBITS>
|
||||
using smallest_int_for_bits_t = typename smallest_int_for_bits<NBITS>::type;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//***************************************************************************
|
||||
/// Template to determine the smallest unsigned int type that can contain the
|
||||
@ -352,9 +348,7 @@ namespace etl
|
||||
private:
|
||||
|
||||
// Determines the index of the best unsigned type for the required value.
|
||||
static ETL_CONSTANT int TYPE_INDEX = ((VALUE > UINT_LEAST8_MAX) ? 1 : 0) +
|
||||
((VALUE > UINT16_MAX) ? 1 : 0) +
|
||||
((VALUE > UINT32_MAX) ? 1 : 0);
|
||||
static ETL_CONSTANT int TYPE_INDEX = ((VALUE > UINT_LEAST8_MAX) ? 1 : 0) + ((VALUE > UINT16_MAX) ? 1 : 0) + ((VALUE > UINT32_MAX) ? 1 : 0);
|
||||
|
||||
public:
|
||||
|
||||
@ -364,10 +358,10 @@ namespace etl
|
||||
template <uintmax_t VALUE>
|
||||
ETL_CONSTANT int smallest_uint_for_value<VALUE>::TYPE_INDEX;
|
||||
|
||||
#if ETL_USING_CPP11
|
||||
#if ETL_USING_CPP11
|
||||
template <uintmax_t VALUE>
|
||||
using smallest_uint_for_value_t = typename smallest_uint_for_value<VALUE>::type;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//***************************************************************************
|
||||
/// Template to determine the smallest int type that can contain the
|
||||
@ -381,9 +375,7 @@ namespace etl
|
||||
private:
|
||||
|
||||
// Determines the index of the best signed type for the required value.
|
||||
static ETL_CONSTANT 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 ETL_CONSTANT 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:
|
||||
|
||||
@ -393,10 +385,10 @@ namespace etl
|
||||
template <intmax_t VALUE>
|
||||
ETL_CONSTANT int smallest_int_for_value<VALUE>::TYPE_INDEX;
|
||||
|
||||
#if ETL_USING_CPP11
|
||||
#if ETL_USING_CPP11
|
||||
template <intmax_t VALUE>
|
||||
using smallest_int_for_value_t = typename smallest_int_for_value<VALUE>::type;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
} // namespace etl
|
||||
|
||||
#endif
|
||||
|
||||
@ -30,15 +30,15 @@ SOFTWARE.
|
||||
#define ETL_TYPE_LOOKUP_INCLUDED
|
||||
|
||||
#include "platform.h"
|
||||
#include "type_traits.h"
|
||||
#include "static_assert.h"
|
||||
#include "integral_limits.h"
|
||||
#include "null_type.h"
|
||||
#include "static_assert.h"
|
||||
#include "type_traits.h"
|
||||
|
||||
#include <limits.h>
|
||||
|
||||
#if 0
|
||||
#error THIS HEADER IS A GENERATOR. DO NOT INCLUDE.
|
||||
#error THIS HEADER IS A GENERATOR. DO NOT INCLUDE.
|
||||
#endif
|
||||
|
||||
//***************************************************************************
|
||||
@ -73,7 +73,7 @@ namespace etl
|
||||
|
||||
#if ETL_USING_CPP11 && !defined(ETL_TYPE_SELECT_FORCE_CPP03_IMPLEMENTATION)
|
||||
//***************************************************************************
|
||||
// type_id_lookup
|
||||
// type_id_lookup
|
||||
//***************************************************************************
|
||||
template <typename... TTypes>
|
||||
struct type_id_lookup
|
||||
@ -81,7 +81,9 @@ namespace etl
|
||||
private:
|
||||
|
||||
// The type for no match.
|
||||
struct nulltype {};
|
||||
struct nulltype
|
||||
{
|
||||
};
|
||||
|
||||
// For N type pairs.
|
||||
template <size_t Id, typename T1, typename... TRest>
|
||||
@ -148,10 +150,10 @@ namespace etl
|
||||
static_assert(value != UNKNOWN, "Invalid type");
|
||||
};
|
||||
|
||||
#if ETL_USING_CPP17
|
||||
#if ETL_USING_CPP17
|
||||
template <typename T>
|
||||
static constexpr size_t id_from_type_v = id_from_type<T>::value;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//************************************
|
||||
template <typename T>
|
||||
@ -159,7 +161,7 @@ namespace etl
|
||||
{
|
||||
return get_id_from_type<T>();
|
||||
}
|
||||
|
||||
|
||||
//************************************
|
||||
template <typename T>
|
||||
static unsigned int get_id_from_type()
|
||||
@ -177,7 +179,9 @@ namespace etl
|
||||
private:
|
||||
|
||||
// The type for no match.
|
||||
struct nulltype {};
|
||||
struct nulltype
|
||||
{
|
||||
};
|
||||
|
||||
template <typename T, typename T1, typename... TRest>
|
||||
struct type_from_type_helper
|
||||
@ -219,14 +223,14 @@ namespace etl
|
||||
// For 16 types.
|
||||
//***************************************************************************
|
||||
template <typename T1,
|
||||
typename T2 = etl::type_id_pair<etl::null_type<0>, -2>,
|
||||
typename T3 = etl::type_id_pair<etl::null_type<0>, -3>,
|
||||
typename T4 = etl::type_id_pair<etl::null_type<0>, -4>,
|
||||
typename T5 = etl::type_id_pair<etl::null_type<0>, -5>,
|
||||
typename T6 = etl::type_id_pair<etl::null_type<0>, -6>,
|
||||
typename T7 = etl::type_id_pair<etl::null_type<0>, -7>,
|
||||
typename T8 = etl::type_id_pair<etl::null_type<0>, -8>,
|
||||
typename T9 = etl::type_id_pair<etl::null_type<0>, -9>,
|
||||
typename T2 = etl::type_id_pair<etl::null_type<0>, -2>,
|
||||
typename T3 = etl::type_id_pair<etl::null_type<0>, -3>,
|
||||
typename T4 = etl::type_id_pair<etl::null_type<0>, -4>,
|
||||
typename T5 = etl::type_id_pair<etl::null_type<0>, -5>,
|
||||
typename T6 = etl::type_id_pair<etl::null_type<0>, -6>,
|
||||
typename T7 = etl::type_id_pair<etl::null_type<0>, -7>,
|
||||
typename T8 = etl::type_id_pair<etl::null_type<0>, -8>,
|
||||
typename T9 = etl::type_id_pair<etl::null_type<0>, -9>,
|
||||
typename T10 = etl::type_id_pair<etl::null_type<0>, -10>,
|
||||
typename T11 = etl::type_id_pair<etl::null_type<0>, -11>,
|
||||
typename T12 = etl::type_id_pair<etl::null_type<0>, -12>,
|
||||
@ -242,7 +246,8 @@ namespace etl
|
||||
template <int Id>
|
||||
struct type_from_id
|
||||
{
|
||||
typedef
|
||||
// clang-format off
|
||||
typedef
|
||||
typename etl::conditional<Id == T1::Id, typename T1::type,
|
||||
typename etl::conditional<Id == T2::Id, typename T2::type,
|
||||
typename etl::conditional<Id == T3::Id, typename T3::type,
|
||||
@ -263,6 +268,7 @@ namespace etl
|
||||
::type>::type>::type>::type>
|
||||
::type>::type>::type>::type>
|
||||
::type>::type>::type>::type type;
|
||||
// clang-format on
|
||||
|
||||
ETL_STATIC_ASSERT(!(etl::is_same<etl::null_type<0>, type>::value), "Invalid id");
|
||||
};
|
||||
@ -278,24 +284,23 @@ namespace etl
|
||||
{
|
||||
enum
|
||||
{
|
||||
value =
|
||||
(unsigned int) etl::is_same<T, typename T1::type>::value ? (unsigned int)T1::Id :
|
||||
(unsigned int) etl::is_same<T, typename T2::type>::value ? (unsigned int)T2::Id :
|
||||
(unsigned int) etl::is_same<T, typename T3::type>::value ? (unsigned int)T3::Id :
|
||||
(unsigned int) etl::is_same<T, typename T4::type>::value ? (unsigned int)T4::Id :
|
||||
(unsigned int) etl::is_same<T, typename T5::type>::value ? (unsigned int)T5::Id :
|
||||
(unsigned int) etl::is_same<T, typename T6::type>::value ? (unsigned int)T6::Id :
|
||||
(unsigned int) etl::is_same<T, typename T7::type>::value ? (unsigned int)T7::Id :
|
||||
(unsigned int) etl::is_same<T, typename T8::type>::value ? (unsigned int)T8::Id :
|
||||
(unsigned int) etl::is_same<T, typename T9::type>::value ? (unsigned int)T9::Id :
|
||||
(unsigned int) etl::is_same<T, typename T10::type>::value ? (unsigned int)T10::Id :
|
||||
(unsigned int) etl::is_same<T, typename T11::type>::value ? (unsigned int)T11::Id :
|
||||
(unsigned int) etl::is_same<T, typename T12::type>::value ? (unsigned int)T12::Id :
|
||||
(unsigned int) etl::is_same<T, typename T13::type>::value ? (unsigned int)T13::Id :
|
||||
(unsigned int) etl::is_same<T, typename T14::type>::value ? (unsigned int)T14::Id :
|
||||
(unsigned int) etl::is_same<T, typename T15::type>::value ? (unsigned int)T15::Id :
|
||||
(unsigned int) etl::is_same<T, typename T16::type>::value ? (unsigned int)T16::Id :
|
||||
(unsigned int) UNKNOWN
|
||||
value = (unsigned int)etl::is_same<T, typename T1::type>::value ? (unsigned int)T1::Id
|
||||
: (unsigned int)etl::is_same<T, typename T2::type>::value ? (unsigned int)T2::Id
|
||||
: (unsigned int)etl::is_same<T, typename T3::type>::value ? (unsigned int)T3::Id
|
||||
: (unsigned int)etl::is_same<T, typename T4::type>::value ? (unsigned int)T4::Id
|
||||
: (unsigned int)etl::is_same<T, typename T5::type>::value ? (unsigned int)T5::Id
|
||||
: (unsigned int)etl::is_same<T, typename T6::type>::value ? (unsigned int)T6::Id
|
||||
: (unsigned int)etl::is_same<T, typename T7::type>::value ? (unsigned int)T7::Id
|
||||
: (unsigned int)etl::is_same<T, typename T8::type>::value ? (unsigned int)T8::Id
|
||||
: (unsigned int)etl::is_same<T, typename T9::type>::value ? (unsigned int)T9::Id
|
||||
: (unsigned int)etl::is_same<T, typename T10::type>::value ? (unsigned int)T10::Id
|
||||
: (unsigned int)etl::is_same<T, typename T11::type>::value ? (unsigned int)T11::Id
|
||||
: (unsigned int)etl::is_same<T, typename T12::type>::value ? (unsigned int)T12::Id
|
||||
: (unsigned int)etl::is_same<T, typename T13::type>::value ? (unsigned int)T13::Id
|
||||
: (unsigned int)etl::is_same<T, typename T14::type>::value ? (unsigned int)T14::Id
|
||||
: (unsigned int)etl::is_same<T, typename T15::type>::value ? (unsigned int)T15::Id
|
||||
: (unsigned int)etl::is_same<T, typename T16::type>::value ? (unsigned int)T16::Id
|
||||
: (unsigned int)UNKNOWN
|
||||
};
|
||||
|
||||
ETL_STATIC_ASSERT(((unsigned int)value != (unsigned int)UNKNOWN), "Invalid type");
|
||||
@ -320,14 +325,14 @@ namespace etl
|
||||
// For 16 types.
|
||||
//***************************************************************************
|
||||
template <typename T1,
|
||||
typename T2 = etl::type_type_pair<etl::null_type<0>, etl::null_type<0> >,
|
||||
typename T3 = etl::type_type_pair<etl::null_type<0>, etl::null_type<0> >,
|
||||
typename T4 = etl::type_type_pair<etl::null_type<0>, etl::null_type<0> >,
|
||||
typename T5 = etl::type_type_pair<etl::null_type<0>, etl::null_type<0> >,
|
||||
typename T6 = etl::type_type_pair<etl::null_type<0>, etl::null_type<0> >,
|
||||
typename T7 = etl::type_type_pair<etl::null_type<0>, etl::null_type<0> >,
|
||||
typename T8 = etl::type_type_pair<etl::null_type<0>, etl::null_type<0> >,
|
||||
typename T9 = etl::type_type_pair<etl::null_type<0>, etl::null_type<0> >,
|
||||
typename T2 = etl::type_type_pair<etl::null_type<0>, etl::null_type<0> >,
|
||||
typename T3 = etl::type_type_pair<etl::null_type<0>, etl::null_type<0> >,
|
||||
typename T4 = etl::type_type_pair<etl::null_type<0>, etl::null_type<0> >,
|
||||
typename T5 = etl::type_type_pair<etl::null_type<0>, etl::null_type<0> >,
|
||||
typename T6 = etl::type_type_pair<etl::null_type<0>, etl::null_type<0> >,
|
||||
typename T7 = etl::type_type_pair<etl::null_type<0>, etl::null_type<0> >,
|
||||
typename T8 = etl::type_type_pair<etl::null_type<0>, etl::null_type<0> >,
|
||||
typename T9 = etl::type_type_pair<etl::null_type<0>, etl::null_type<0> >,
|
||||
typename T10 = etl::type_type_pair<etl::null_type<0>, etl::null_type<0> >,
|
||||
typename T11 = etl::type_type_pair<etl::null_type<0>, etl::null_type<0> >,
|
||||
typename T12 = etl::type_type_pair<etl::null_type<0>, etl::null_type<0> >,
|
||||
@ -340,6 +345,7 @@ namespace etl
|
||||
public:
|
||||
|
||||
//************************************
|
||||
// clang-format off
|
||||
template <typename T>
|
||||
struct type_from_type
|
||||
{
|
||||
@ -365,9 +371,10 @@ namespace etl
|
||||
|
||||
ETL_STATIC_ASSERT(!(etl::is_same<etl::null_type<0>, type>::value), "Invalid type");
|
||||
};
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
#endif
|
||||
}
|
||||
} // namespace etl
|
||||
|
||||
#endif
|
||||
|
||||
@ -30,12 +30,12 @@ SOFTWARE.
|
||||
#define ETL_TYPE_SELECT_INCLUDED
|
||||
|
||||
#include "platform.h"
|
||||
#include "null_type.h"
|
||||
#include "static_assert.h"
|
||||
#include "type_traits.h"
|
||||
#include "null_type.h"
|
||||
|
||||
#if 0
|
||||
#error THIS HEADER IS A GENERATOR. DO NOT INCLUDE.
|
||||
#error THIS HEADER IS A GENERATOR. DO NOT INCLUDE.
|
||||
#endif
|
||||
|
||||
//***************************************************************************
|
||||
@ -87,7 +87,7 @@ namespace etl
|
||||
// Select type alias
|
||||
//***************************************************************************
|
||||
template <size_t Index, typename... TTypes>
|
||||
using type_select_t = typename etl::type_select<TTypes...>:: template select_t<Index>;
|
||||
using type_select_t = typename etl::type_select<TTypes...>::template select_t<Index>;
|
||||
|
||||
#else
|
||||
|
||||
@ -95,15 +95,15 @@ namespace etl
|
||||
// For 16 types.
|
||||
//***************************************************************************
|
||||
template <typename T0,
|
||||
typename T1 = void,
|
||||
typename T2 = void,
|
||||
typename T3 = void,
|
||||
typename T4 = void,
|
||||
typename T5 = void,
|
||||
typename T6 = void,
|
||||
typename T7 = void,
|
||||
typename T8 = void,
|
||||
typename T9 = void,
|
||||
typename T1 = void,
|
||||
typename T2 = void,
|
||||
typename T3 = void,
|
||||
typename T4 = void,
|
||||
typename T5 = void,
|
||||
typename T6 = void,
|
||||
typename T7 = void,
|
||||
typename T8 = void,
|
||||
typename T9 = void,
|
||||
typename T10 = void,
|
||||
typename T11 = void,
|
||||
typename T12 = void,
|
||||
@ -117,6 +117,7 @@ namespace etl
|
||||
template <size_t Id>
|
||||
struct select
|
||||
{
|
||||
// clang-format off
|
||||
typedef typename etl::conditional<Id == 0, T0,
|
||||
typename etl::conditional<Id == 1, T1,
|
||||
typename etl::conditional<Id == 2, T2,
|
||||
@ -136,6 +137,7 @@ namespace etl
|
||||
etl::null_type<0> >
|
||||
::type>::type>::type>::type>::type>::type>::type>::type>
|
||||
::type>::type>::type>::type>::type>::type>::type>::type type;
|
||||
// clang-format on
|
||||
|
||||
ETL_STATIC_ASSERT(Id < 16, "Invalid Id");
|
||||
};
|
||||
@ -144,27 +146,29 @@ namespace etl
|
||||
//***************************************************************************
|
||||
// For 15 types.
|
||||
//***************************************************************************
|
||||
template <typename T0,
|
||||
typename T1,
|
||||
typename T2,
|
||||
typename T3,
|
||||
typename T4,
|
||||
typename T5,
|
||||
typename T6,
|
||||
typename T7,
|
||||
typename T8,
|
||||
typename T9,
|
||||
typename T10,
|
||||
typename T11,
|
||||
typename T12,
|
||||
typename T13,
|
||||
template <typename T0,
|
||||
typename T1,
|
||||
typename T2,
|
||||
typename T3,
|
||||
typename T4,
|
||||
typename T5,
|
||||
typename T6,
|
||||
typename T7,
|
||||
typename T8,
|
||||
typename T9,
|
||||
typename T10,
|
||||
typename T11,
|
||||
typename T12,
|
||||
typename T13,
|
||||
typename T14>
|
||||
struct type_select<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14>
|
||||
{
|
||||
public:
|
||||
|
||||
template <size_t Id>
|
||||
struct select
|
||||
{
|
||||
// clang-format off
|
||||
typedef typename etl::conditional<Id == 0, T0,
|
||||
typename etl::conditional<Id == 1, T1,
|
||||
typename etl::conditional<Id == 2, T2,
|
||||
@ -183,6 +187,7 @@ namespace etl
|
||||
etl::null_type<0> >
|
||||
::type>::type>::type>::type>::type>::type>::type>::type>
|
||||
::type>::type>::type>::type>::type>::type>::type type;
|
||||
// clang-format on
|
||||
|
||||
ETL_STATIC_ASSERT(Id < 15, "Invalid Id");
|
||||
};
|
||||
@ -191,26 +196,28 @@ namespace etl
|
||||
//***************************************************************************
|
||||
// For 14 types.
|
||||
//***************************************************************************
|
||||
template <typename T0,
|
||||
typename T1,
|
||||
typename T2,
|
||||
typename T3,
|
||||
typename T4,
|
||||
typename T5,
|
||||
typename T6,
|
||||
typename T7,
|
||||
typename T8,
|
||||
typename T9,
|
||||
typename T10,
|
||||
typename T11,
|
||||
typename T12,
|
||||
template <typename T0,
|
||||
typename T1,
|
||||
typename T2,
|
||||
typename T3,
|
||||
typename T4,
|
||||
typename T5,
|
||||
typename T6,
|
||||
typename T7,
|
||||
typename T8,
|
||||
typename T9,
|
||||
typename T10,
|
||||
typename T11,
|
||||
typename T12,
|
||||
typename T13>
|
||||
struct type_select<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13>
|
||||
{
|
||||
public:
|
||||
|
||||
template <size_t Id>
|
||||
struct select
|
||||
{
|
||||
// clang-format off
|
||||
typedef typename etl::conditional<Id == 0, T0,
|
||||
typename etl::conditional<Id == 1, T1,
|
||||
typename etl::conditional<Id == 2, T2,
|
||||
@ -228,6 +235,7 @@ namespace etl
|
||||
etl::null_type<0> >
|
||||
::type>::type>::type>::type>::type>::type>::type>::type>
|
||||
::type>::type>::type>::type>::type>::type type;
|
||||
// clang-format on
|
||||
|
||||
ETL_STATIC_ASSERT(Id < 14, "Invalid Id");
|
||||
};
|
||||
@ -236,25 +244,27 @@ namespace etl
|
||||
//***************************************************************************
|
||||
// For 13 types.
|
||||
//***************************************************************************
|
||||
template <typename T0,
|
||||
typename T1,
|
||||
typename T2,
|
||||
typename T3,
|
||||
typename T4,
|
||||
typename T5,
|
||||
typename T6,
|
||||
typename T7,
|
||||
typename T8,
|
||||
typename T9,
|
||||
typename T10,
|
||||
typename T11,
|
||||
template <typename T0,
|
||||
typename T1,
|
||||
typename T2,
|
||||
typename T3,
|
||||
typename T4,
|
||||
typename T5,
|
||||
typename T6,
|
||||
typename T7,
|
||||
typename T8,
|
||||
typename T9,
|
||||
typename T10,
|
||||
typename T11,
|
||||
typename T12>
|
||||
struct type_select<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>
|
||||
{
|
||||
public:
|
||||
|
||||
template <size_t Id>
|
||||
struct select
|
||||
{
|
||||
// clang-format off
|
||||
typedef typename etl::conditional<Id == 0, T0,
|
||||
typename etl::conditional<Id == 1, T1,
|
||||
typename etl::conditional<Id == 2, T2,
|
||||
@ -271,6 +281,7 @@ namespace etl
|
||||
etl::null_type<0> >
|
||||
::type>::type>::type>::type>::type>::type>::type>::type>
|
||||
::type>::type>::type>::type>::type type;
|
||||
// clang-format on
|
||||
|
||||
ETL_STATIC_ASSERT(Id < 13, "Invalid Id");
|
||||
};
|
||||
@ -279,24 +290,26 @@ namespace etl
|
||||
//***************************************************************************
|
||||
// For 12 types.
|
||||
//***************************************************************************
|
||||
template <typename T0,
|
||||
typename T1,
|
||||
typename T2,
|
||||
typename T3,
|
||||
typename T4,
|
||||
typename T5,
|
||||
typename T6,
|
||||
typename T7,
|
||||
typename T8,
|
||||
typename T9,
|
||||
typename T10,
|
||||
template <typename T0,
|
||||
typename T1,
|
||||
typename T2,
|
||||
typename T3,
|
||||
typename T4,
|
||||
typename T5,
|
||||
typename T6,
|
||||
typename T7,
|
||||
typename T8,
|
||||
typename T9,
|
||||
typename T10,
|
||||
typename T11>
|
||||
struct type_select<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>
|
||||
{
|
||||
public:
|
||||
|
||||
template <size_t Id>
|
||||
struct select
|
||||
{
|
||||
// clang-format off
|
||||
typedef typename etl::conditional<Id == 0, T0,
|
||||
typename etl::conditional<Id == 1, T1,
|
||||
typename etl::conditional<Id == 2, T2,
|
||||
@ -312,6 +325,7 @@ namespace etl
|
||||
etl::null_type<0> >
|
||||
::type>::type>::type>::type>::type>::type>::type>::type>
|
||||
::type>::type>::type>::type type;
|
||||
// clang-format on
|
||||
|
||||
ETL_STATIC_ASSERT(Id < 12, "Invalid Id");
|
||||
};
|
||||
@ -320,23 +334,25 @@ namespace etl
|
||||
//***************************************************************************
|
||||
// For 11 types.
|
||||
//***************************************************************************
|
||||
template <typename T0,
|
||||
typename T1,
|
||||
typename T2,
|
||||
typename T3,
|
||||
typename T4,
|
||||
typename T5,
|
||||
typename T6,
|
||||
typename T7,
|
||||
typename T8,
|
||||
typename T9,
|
||||
template <typename T0,
|
||||
typename T1,
|
||||
typename T2,
|
||||
typename T3,
|
||||
typename T4,
|
||||
typename T5,
|
||||
typename T6,
|
||||
typename T7,
|
||||
typename T8,
|
||||
typename T9,
|
||||
typename T10>
|
||||
struct type_select<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>
|
||||
{
|
||||
public:
|
||||
|
||||
template <size_t Id>
|
||||
struct select
|
||||
{
|
||||
// clang-format off
|
||||
typedef typename etl::conditional<Id == 0, T0,
|
||||
typename etl::conditional<Id == 1, T1,
|
||||
typename etl::conditional<Id == 2, T2,
|
||||
@ -351,6 +367,7 @@ namespace etl
|
||||
etl::null_type<0> >
|
||||
::type>::type>::type>::type>::type>::type>::type>::type>
|
||||
::type>::type>::type type;
|
||||
// clang-format on
|
||||
|
||||
ETL_STATIC_ASSERT(Id < 11, "Invalid Id");
|
||||
};
|
||||
@ -359,22 +376,24 @@ namespace etl
|
||||
//***************************************************************************
|
||||
// For 10 types.
|
||||
//***************************************************************************
|
||||
template <typename T0,
|
||||
typename T1,
|
||||
typename T2,
|
||||
typename T3,
|
||||
typename T4,
|
||||
typename T5,
|
||||
typename T6,
|
||||
typename T7,
|
||||
typename T8,
|
||||
template <typename T0,
|
||||
typename T1,
|
||||
typename T2,
|
||||
typename T3,
|
||||
typename T4,
|
||||
typename T5,
|
||||
typename T6,
|
||||
typename T7,
|
||||
typename T8,
|
||||
typename T9>
|
||||
struct type_select<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9>
|
||||
{
|
||||
public:
|
||||
|
||||
template <size_t Id>
|
||||
struct select
|
||||
{
|
||||
// clang-format off
|
||||
typedef typename etl::conditional<Id == 0, T0,
|
||||
typename etl::conditional<Id == 1, T1,
|
||||
typename etl::conditional<Id == 2, T2,
|
||||
@ -388,6 +407,7 @@ namespace etl
|
||||
etl::null_type<0> >
|
||||
::type>::type>::type>::type>::type>::type>::type>::type>
|
||||
::type>::type type;
|
||||
// clang-format on
|
||||
|
||||
ETL_STATIC_ASSERT(Id < 10, "Invalid Id");
|
||||
};
|
||||
@ -396,21 +416,23 @@ namespace etl
|
||||
//***************************************************************************
|
||||
// For 9 types.
|
||||
//***************************************************************************
|
||||
template <typename T0,
|
||||
typename T1,
|
||||
typename T2,
|
||||
typename T3,
|
||||
typename T4,
|
||||
typename T5,
|
||||
typename T6,
|
||||
typename T7,
|
||||
template <typename T0,
|
||||
typename T1,
|
||||
typename T2,
|
||||
typename T3,
|
||||
typename T4,
|
||||
typename T5,
|
||||
typename T6,
|
||||
typename T7,
|
||||
typename T8>
|
||||
struct type_select<T0, T1, T2, T3, T4, T5, T6, T7, T8>
|
||||
{
|
||||
public:
|
||||
|
||||
template <size_t Id>
|
||||
struct select
|
||||
{
|
||||
// clang-format off
|
||||
typedef typename etl::conditional<Id == 0, T0,
|
||||
typename etl::conditional<Id == 1, T1,
|
||||
typename etl::conditional<Id == 2, T2,
|
||||
@ -423,6 +445,7 @@ namespace etl
|
||||
etl::null_type<0> >
|
||||
::type>::type>::type>::type>::type>::type>::type>::type>
|
||||
::type type;
|
||||
// clang-format on
|
||||
|
||||
ETL_STATIC_ASSERT(Id < 9, "Invalid Id");
|
||||
};
|
||||
@ -431,20 +454,22 @@ namespace etl
|
||||
//***************************************************************************
|
||||
// For 8 types.
|
||||
//***************************************************************************
|
||||
template <typename T0,
|
||||
typename T1,
|
||||
typename T2,
|
||||
typename T3,
|
||||
typename T4,
|
||||
typename T5,
|
||||
typename T6,
|
||||
template <typename T0,
|
||||
typename T1,
|
||||
typename T2,
|
||||
typename T3,
|
||||
typename T4,
|
||||
typename T5,
|
||||
typename T6,
|
||||
typename T7>
|
||||
struct type_select<T0, T1, T2, T3, T4, T5, T6, T7>
|
||||
{
|
||||
public:
|
||||
|
||||
template <size_t Id>
|
||||
struct select
|
||||
{
|
||||
// clang-format off
|
||||
typedef typename etl::conditional<Id == 0, T0,
|
||||
typename etl::conditional<Id == 1, T1,
|
||||
typename etl::conditional<Id == 2, T2,
|
||||
@ -455,6 +480,7 @@ namespace etl
|
||||
typename etl::conditional<Id == 7, T7,
|
||||
etl::null_type<0> >
|
||||
::type>::type>::type>::type>::type>::type>::type>::type type;
|
||||
// clang-format on
|
||||
|
||||
ETL_STATIC_ASSERT(Id < 8, "Invalid Id");
|
||||
};
|
||||
@ -463,19 +489,21 @@ namespace etl
|
||||
//***************************************************************************
|
||||
// For 7 types.
|
||||
//***************************************************************************
|
||||
template <typename T0,
|
||||
typename T1,
|
||||
typename T2,
|
||||
typename T3,
|
||||
typename T4,
|
||||
typename T5,
|
||||
template <typename T0,
|
||||
typename T1,
|
||||
typename T2,
|
||||
typename T3,
|
||||
typename T4,
|
||||
typename T5,
|
||||
typename T6>
|
||||
struct type_select<T0, T1, T2, T3, T4, T5, T6>
|
||||
{
|
||||
public:
|
||||
|
||||
template <size_t Id>
|
||||
struct select
|
||||
{
|
||||
// clang-format off
|
||||
typedef typename etl::conditional<Id == 0, T0,
|
||||
typename etl::conditional<Id == 1, T1,
|
||||
typename etl::conditional<Id == 2, T2,
|
||||
@ -485,6 +513,7 @@ namespace etl
|
||||
typename etl::conditional<Id == 6, T6,
|
||||
etl::null_type<0> >
|
||||
::type>::type>::type>::type>::type>::type>::type type;
|
||||
// clang-format on
|
||||
|
||||
ETL_STATIC_ASSERT(Id < 7, "Invalid Id");
|
||||
};
|
||||
@ -493,18 +522,20 @@ namespace etl
|
||||
//***************************************************************************
|
||||
// For 6 types.
|
||||
//***************************************************************************
|
||||
template <typename T0,
|
||||
typename T1,
|
||||
typename T2,
|
||||
typename T3,
|
||||
typename T4,
|
||||
template <typename T0,
|
||||
typename T1,
|
||||
typename T2,
|
||||
typename T3,
|
||||
typename T4,
|
||||
typename T5>
|
||||
struct type_select<T0, T1, T2, T3, T4, T5>
|
||||
{
|
||||
public:
|
||||
|
||||
template <size_t Id>
|
||||
struct select
|
||||
{
|
||||
// clang-format off
|
||||
typedef typename etl::conditional<Id == 0, T0,
|
||||
typename etl::conditional<Id == 1, T1,
|
||||
typename etl::conditional<Id == 2, T2,
|
||||
@ -513,6 +544,7 @@ namespace etl
|
||||
typename etl::conditional<Id == 5, T5,
|
||||
etl::null_type<0> >
|
||||
::type>::type>::type>::type>::type>::type type;
|
||||
// clang-format on
|
||||
|
||||
ETL_STATIC_ASSERT(Id < 6, "Invalid Id");
|
||||
};
|
||||
@ -521,17 +553,19 @@ namespace etl
|
||||
//***************************************************************************
|
||||
// For 5 types.
|
||||
//***************************************************************************
|
||||
template <typename T0,
|
||||
typename T1,
|
||||
typename T2,
|
||||
typename T3,
|
||||
template <typename T0,
|
||||
typename T1,
|
||||
typename T2,
|
||||
typename T3,
|
||||
typename T4>
|
||||
struct type_select<T0, T1, T2, T3, T4>
|
||||
{
|
||||
public:
|
||||
|
||||
template <size_t Id>
|
||||
struct select
|
||||
{
|
||||
// clang-format off
|
||||
typedef typename etl::conditional<Id == 0, T0,
|
||||
typename etl::conditional<Id == 1, T1,
|
||||
typename etl::conditional<Id == 2, T2,
|
||||
@ -539,6 +573,7 @@ namespace etl
|
||||
typename etl::conditional<Id == 4, T4,
|
||||
etl::null_type<0> >
|
||||
::type>::type>::type>::type>::type type;
|
||||
// clang-format on
|
||||
|
||||
ETL_STATIC_ASSERT(Id < 5, "Invalid Id");
|
||||
};
|
||||
@ -547,22 +582,25 @@ namespace etl
|
||||
//***************************************************************************
|
||||
// For 4 types.
|
||||
//***************************************************************************
|
||||
template <typename T0,
|
||||
typename T1,
|
||||
typename T2,
|
||||
template <typename T0,
|
||||
typename T1,
|
||||
typename T2,
|
||||
typename T3>
|
||||
struct type_select<T0, T1, T2, T3>
|
||||
{
|
||||
public:
|
||||
|
||||
template <size_t Id>
|
||||
struct select
|
||||
{
|
||||
// clang-format off
|
||||
typedef typename etl::conditional<Id == 0, T0,
|
||||
typename etl::conditional<Id == 1, T1,
|
||||
typename etl::conditional<Id == 2, T2,
|
||||
typename etl::conditional<Id == 3, T3,
|
||||
etl::null_type<0> >
|
||||
::type>::type>::type>::type type;
|
||||
// clang-format on
|
||||
|
||||
ETL_STATIC_ASSERT(Id < 4, "Invalid Id");
|
||||
};
|
||||
@ -571,20 +609,23 @@ namespace etl
|
||||
//***************************************************************************
|
||||
// For 3 types.
|
||||
//***************************************************************************
|
||||
template <typename T0,
|
||||
typename T1,
|
||||
template <typename T0,
|
||||
typename T1,
|
||||
typename T2>
|
||||
struct type_select<T0, T1, T2>
|
||||
{
|
||||
public:
|
||||
|
||||
template <size_t Id>
|
||||
struct select
|
||||
{
|
||||
// clang-format off
|
||||
typedef typename etl::conditional<Id == 0, T0,
|
||||
typename etl::conditional<Id == 1, T1,
|
||||
typename etl::conditional<Id == 2, T2,
|
||||
etl::null_type<0> >
|
||||
::type>::type>::type type;
|
||||
// clang-format on
|
||||
|
||||
ETL_STATIC_ASSERT(Id < 3, "Invalid Id");
|
||||
};
|
||||
@ -593,18 +634,21 @@ namespace etl
|
||||
//***************************************************************************
|
||||
// For 2 types.
|
||||
//***************************************************************************
|
||||
template <typename T0,
|
||||
template <typename T0,
|
||||
typename T1>
|
||||
struct type_select<T0, T1>
|
||||
{
|
||||
public:
|
||||
|
||||
template <size_t Id>
|
||||
struct select
|
||||
{
|
||||
// clang-format off
|
||||
typedef typename etl::conditional<Id == 0, T0,
|
||||
typename etl::conditional<Id == 1, T1,
|
||||
etl::null_type<0> >
|
||||
::type>::type type;
|
||||
// clang-format on
|
||||
|
||||
ETL_STATIC_ASSERT(Id < 2, "Invalid Id");
|
||||
};
|
||||
@ -617,17 +661,20 @@ namespace etl
|
||||
struct type_select<T0>
|
||||
{
|
||||
public:
|
||||
|
||||
template <size_t Id>
|
||||
struct select
|
||||
{
|
||||
// clang-format off
|
||||
typedef typename etl::conditional<Id == 0, T0,
|
||||
etl::null_type<0> >
|
||||
::type type;
|
||||
// clang-format on
|
||||
|
||||
ETL_STATIC_ASSERT(Id < 1, "Invalid Id");
|
||||
};
|
||||
};
|
||||
#endif
|
||||
}
|
||||
} // namespace etl
|
||||
|
||||
#endif
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -27,7 +27,7 @@ SOFTWARE.
|
||||
******************************************************************************/
|
||||
|
||||
#if 0
|
||||
#error THIS HEADER IS A GENERATOR. DO NOT INCLUDE.
|
||||
#error THIS HEADER IS A GENERATOR. DO NOT INCLUDE.
|
||||
#endif
|
||||
|
||||
//***************************************************************************
|
||||
@ -49,21 +49,21 @@ SOFTWARE.
|
||||
//***************************************************************************
|
||||
|
||||
#ifndef ETL_VARIANT_POOL_INCLUDED
|
||||
#define ETL_VARIANT_POOL_INCLUDED
|
||||
#define ETL_VARIANT_POOL_INCLUDED
|
||||
|
||||
#include "platform.h"
|
||||
#include "pool.h"
|
||||
#include "type_traits.h"
|
||||
#include "static_assert.h"
|
||||
#include "largest.h"
|
||||
#include "platform.h"
|
||||
#include "largest.h"
|
||||
#include "pool.h"
|
||||
#include "static_assert.h"
|
||||
#include "type_traits.h"
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdint.h>
|
||||
|
||||
namespace etl
|
||||
{
|
||||
#if ETL_USING_CPP11 && !defined(ETL_VARIANT_POOL_FORCE_CPP03_IMPLEMENTATION)
|
||||
#if ETL_USING_CPP11 && !defined(ETL_VARIANT_POOL_FORCE_CPP03_IMPLEMENTATION)
|
||||
//***************************************************************************
|
||||
template <size_t MAX_SIZE_, typename ... Ts>
|
||||
template <size_t MAX_SIZE_, typename... Ts>
|
||||
class variant_pool
|
||||
: public etl::generic_pool<etl::largest<Ts...>::size,
|
||||
etl::largest<Ts...>::alignment,
|
||||
@ -73,7 +73,8 @@ namespace etl
|
||||
|
||||
typedef etl::generic_pool<etl::largest<Ts...>::size,
|
||||
etl::largest<Ts...>::alignment,
|
||||
MAX_SIZE_> base_t;
|
||||
MAX_SIZE_>
|
||||
base_t;
|
||||
|
||||
static const size_t MAX_SIZE = MAX_SIZE_;
|
||||
|
||||
@ -117,11 +118,11 @@ namespace etl
|
||||
private:
|
||||
|
||||
variant_pool(const variant_pool&) ETL_DELETE;
|
||||
variant_pool& operator =(const variant_pool&) ETL_DELETE;
|
||||
variant_pool& operator=(const variant_pool&) ETL_DELETE;
|
||||
};
|
||||
|
||||
//***************************************************************************
|
||||
template <typename ... Ts>
|
||||
template <typename... Ts>
|
||||
class variant_pool_ext
|
||||
: public etl::generic_pool_ext<etl::largest<Ts...>::size,
|
||||
etl::largest<Ts...>::alignment>
|
||||
@ -129,7 +130,8 @@ namespace etl
|
||||
public:
|
||||
|
||||
typedef etl::generic_pool_ext<etl::largest<Ts...>::size,
|
||||
etl::largest<Ts...>::alignment> base_t;
|
||||
etl::largest<Ts...>::alignment>
|
||||
base_t;
|
||||
|
||||
//*************************************************************************
|
||||
/// Default constructor.
|
||||
@ -172,20 +174,20 @@ namespace etl
|
||||
private:
|
||||
|
||||
variant_pool_ext(const variant_pool_ext&) ETL_DELETE;
|
||||
variant_pool_ext& operator =(const variant_pool_ext&) ETL_DELETE;
|
||||
variant_pool_ext& operator=(const variant_pool_ext&) ETL_DELETE;
|
||||
};
|
||||
#else
|
||||
#else
|
||||
//***************************************************************************
|
||||
template <size_t MAX_SIZE_,
|
||||
typename T1,
|
||||
typename T2 = void,
|
||||
typename T3 = void,
|
||||
typename T4 = void,
|
||||
typename T5 = void,
|
||||
typename T6 = void,
|
||||
typename T7 = void,
|
||||
typename T8 = void,
|
||||
typename T9 = void,
|
||||
typename T2 = void,
|
||||
typename T3 = void,
|
||||
typename T4 = void,
|
||||
typename T5 = void,
|
||||
typename T6 = void,
|
||||
typename T7 = void,
|
||||
typename T8 = void,
|
||||
typename T9 = void,
|
||||
typename T10 = void,
|
||||
typename T11 = void,
|
||||
typename T12 = void,
|
||||
@ -202,7 +204,8 @@ namespace etl
|
||||
|
||||
typedef etl::generic_pool<etl::largest<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>::size,
|
||||
etl::largest<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>::alignment,
|
||||
MAX_SIZE_> base_t;
|
||||
MAX_SIZE_>
|
||||
base_t;
|
||||
|
||||
static const size_t MAX_SIZE = MAX_SIZE_;
|
||||
|
||||
@ -213,7 +216,7 @@ namespace etl
|
||||
{
|
||||
}
|
||||
|
||||
#if ETL_CPP11_NOT_SUPPORTED || ETL_USING_STLPORT
|
||||
#if ETL_CPP11_NOT_SUPPORTED || ETL_USING_STLPORT
|
||||
//*************************************************************************
|
||||
/// Creates the object. Default constructor.
|
||||
//*************************************************************************
|
||||
@ -268,7 +271,7 @@ namespace etl
|
||||
|
||||
return base_t::template create<T>(p1, p2, p3, p4);
|
||||
}
|
||||
#else
|
||||
#else
|
||||
//*************************************************************************
|
||||
/// Creates the object from a type. Variadic parameter constructor.
|
||||
//*************************************************************************
|
||||
@ -279,7 +282,7 @@ namespace etl
|
||||
|
||||
return base_t::template create<T>(etl::forward<Args>(args)...);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
/// Destroys the object.
|
||||
@ -287,23 +290,12 @@ namespace etl
|
||||
template <typename T>
|
||||
void destroy(const T* const p)
|
||||
{
|
||||
ETL_STATIC_ASSERT((etl::is_one_of<T, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>::value ||
|
||||
etl::is_base_of<T, T1>::value ||
|
||||
etl::is_base_of<T, T2>::value ||
|
||||
etl::is_base_of<T, T3>::value ||
|
||||
etl::is_base_of<T, T4>::value ||
|
||||
etl::is_base_of<T, T5>::value ||
|
||||
etl::is_base_of<T, T6>::value ||
|
||||
etl::is_base_of<T, T7>::value ||
|
||||
etl::is_base_of<T, T8>::value ||
|
||||
etl::is_base_of<T, T9>::value ||
|
||||
etl::is_base_of<T, T10>::value ||
|
||||
etl::is_base_of<T, T11>::value ||
|
||||
etl::is_base_of<T, T12>::value ||
|
||||
etl::is_base_of<T, T13>::value ||
|
||||
etl::is_base_of<T, T14>::value ||
|
||||
etl::is_base_of<T, T15>::value ||
|
||||
etl::is_base_of<T, T16>::value), "Invalid type");
|
||||
ETL_STATIC_ASSERT((etl::is_one_of<T, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>::value
|
||||
|| etl::is_base_of<T, T1>::value || etl::is_base_of<T, T2>::value || etl::is_base_of<T, T3>::value || etl::is_base_of<T, T4>::value
|
||||
|| etl::is_base_of<T, T5>::value || etl::is_base_of<T, T6>::value || etl::is_base_of<T, T7>::value || etl::is_base_of<T, T8>::value
|
||||
|| etl::is_base_of<T, T9>::value || etl::is_base_of<T, T10>::value || etl::is_base_of<T, T11>::value || etl::is_base_of<T, T12>::value
|
||||
|| etl::is_base_of<T, T13>::value || etl::is_base_of<T, T14>::value || etl::is_base_of<T, T15>::value || etl::is_base_of<T, T16>::value),
|
||||
"Invalid type");
|
||||
|
||||
base_t::destroy(p);
|
||||
}
|
||||
@ -319,19 +311,19 @@ namespace etl
|
||||
private:
|
||||
|
||||
variant_pool(const variant_pool&) ETL_DELETE;
|
||||
variant_pool& operator =(const variant_pool&) ETL_DELETE;
|
||||
variant_pool& operator=(const variant_pool&) ETL_DELETE;
|
||||
};
|
||||
|
||||
//***************************************************************************
|
||||
template <typename T1,
|
||||
typename T2 = void,
|
||||
typename T3 = void,
|
||||
typename T4 = void,
|
||||
typename T5 = void,
|
||||
typename T6 = void,
|
||||
typename T7 = void,
|
||||
typename T8 = void,
|
||||
typename T9 = void,
|
||||
typename T2 = void,
|
||||
typename T3 = void,
|
||||
typename T4 = void,
|
||||
typename T5 = void,
|
||||
typename T6 = void,
|
||||
typename T7 = void,
|
||||
typename T8 = void,
|
||||
typename T9 = void,
|
||||
typename T10 = void,
|
||||
typename T11 = void,
|
||||
typename T12 = void,
|
||||
@ -346,17 +338,18 @@ namespace etl
|
||||
public:
|
||||
|
||||
typedef etl::generic_pool_ext<etl::largest<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>::size,
|
||||
etl::largest<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>::alignment> base_t;
|
||||
etl::largest<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>::alignment>
|
||||
base_t;
|
||||
|
||||
//*************************************************************************
|
||||
/// Default constructor.
|
||||
//*************************************************************************
|
||||
variant_pool_ext(typename base_t::element* buffer, size_t size)
|
||||
: base_t(buffer, size)
|
||||
: base_t(buffer, size)
|
||||
{
|
||||
}
|
||||
|
||||
#if ETL_CPP11_NOT_SUPPORTED || ETL_USING_STLPORT
|
||||
#if ETL_CPP11_NOT_SUPPORTED || ETL_USING_STLPORT
|
||||
//*************************************************************************
|
||||
/// Creates the object. Default constructor.
|
||||
//*************************************************************************
|
||||
@ -411,7 +404,7 @@ namespace etl
|
||||
|
||||
return base_t::template create<T>(p1, p2, p3, p4);
|
||||
}
|
||||
#else
|
||||
#else
|
||||
//*************************************************************************
|
||||
/// Creates the object from a type. Variadic parameter constructor.
|
||||
//*************************************************************************
|
||||
@ -422,7 +415,7 @@ namespace etl
|
||||
|
||||
return base_t::template create<T>(etl::forward<Args>(args)...);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
/// Destroys the object.
|
||||
@ -430,23 +423,12 @@ namespace etl
|
||||
template <typename T>
|
||||
void destroy(const T* const p)
|
||||
{
|
||||
ETL_STATIC_ASSERT((etl::is_one_of<T, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>::value ||
|
||||
etl::is_base_of<T, T1>::value ||
|
||||
etl::is_base_of<T, T2>::value ||
|
||||
etl::is_base_of<T, T3>::value ||
|
||||
etl::is_base_of<T, T4>::value ||
|
||||
etl::is_base_of<T, T5>::value ||
|
||||
etl::is_base_of<T, T6>::value ||
|
||||
etl::is_base_of<T, T7>::value ||
|
||||
etl::is_base_of<T, T8>::value ||
|
||||
etl::is_base_of<T, T9>::value ||
|
||||
etl::is_base_of<T, T10>::value ||
|
||||
etl::is_base_of<T, T11>::value ||
|
||||
etl::is_base_of<T, T12>::value ||
|
||||
etl::is_base_of<T, T13>::value ||
|
||||
etl::is_base_of<T, T14>::value ||
|
||||
etl::is_base_of<T, T15>::value ||
|
||||
etl::is_base_of<T, T16>::value), "Invalid type");
|
||||
ETL_STATIC_ASSERT((etl::is_one_of<T, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>::value
|
||||
|| etl::is_base_of<T, T1>::value || etl::is_base_of<T, T2>::value || etl::is_base_of<T, T3>::value || etl::is_base_of<T, T4>::value
|
||||
|| etl::is_base_of<T, T5>::value || etl::is_base_of<T, T6>::value || etl::is_base_of<T, T7>::value || etl::is_base_of<T, T8>::value
|
||||
|| etl::is_base_of<T, T9>::value || etl::is_base_of<T, T10>::value || etl::is_base_of<T, T11>::value || etl::is_base_of<T, T12>::value
|
||||
|| etl::is_base_of<T, T13>::value || etl::is_base_of<T, T14>::value || etl::is_base_of<T, T15>::value || etl::is_base_of<T, T16>::value),
|
||||
"Invalid type");
|
||||
|
||||
base_t::destroy(p);
|
||||
}
|
||||
@ -454,17 +436,17 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Returns the maximum number of items in the variant_pool.
|
||||
//*************************************************************************
|
||||
size_t max_size() const
|
||||
{
|
||||
return base_t::max_size();
|
||||
size_t max_size() const
|
||||
{
|
||||
return base_t::max_size();
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
variant_pool_ext(const variant_pool_ext&) ETL_DELETE;
|
||||
variant_pool_ext& operator =(const variant_pool_ext&) ETL_DELETE;
|
||||
variant_pool_ext& operator=(const variant_pool_ext&) ETL_DELETE;
|
||||
};
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
} // namespace etl
|
||||
|
||||
#endif
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user