mirror of
https://github.com/ETLCPP/etl.git
synced 2026-04-30 19:09:10 +08:00
Synced message_packet generator to updated code
This commit is contained in:
parent
ff03b2807d
commit
0ad0cec342
@ -71,6 +71,7 @@ cog.outl("//********************************************************************
|
||||
#include "largest.h"
|
||||
#include "alignment.h"
|
||||
#include "utility.h"
|
||||
#include "type_list.h"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
@ -97,6 +98,8 @@ namespace etl
|
||||
|
||||
public:
|
||||
|
||||
using message_types = etl::type_list<TMessageTypes...>;
|
||||
|
||||
//********************************************
|
||||
#include "private/diagnostic_uninitialized_push.h"
|
||||
message_packet()
|
||||
@ -260,7 +263,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>();
|
||||
@ -392,6 +395,132 @@ namespace etl
|
||||
bool valid;
|
||||
};
|
||||
|
||||
//***************************************************************************
|
||||
// The definition for no message types.
|
||||
//***************************************************************************
|
||||
template <>
|
||||
class message_packet<>
|
||||
{
|
||||
private:
|
||||
|
||||
//template <typename T>
|
||||
//static constexpr bool IsMessagePacket = etl::is_same_v< etl::remove_const_t<etl::remove_reference_t<T>>, etl::message_packet<TMessageTypes...>>;
|
||||
|
||||
template <typename T>
|
||||
static constexpr bool IsInMessageList = false;
|
||||
|
||||
template <typename T>
|
||||
static constexpr bool IsIMessage = etl::is_same_v<remove_const_t<etl::remove_reference_t<T>>, etl::imessage>;
|
||||
|
||||
public:
|
||||
|
||||
using message_types = etl::type_list<>;
|
||||
|
||||
//********************************************
|
||||
#include "private/diagnostic_uninitialized_push.h"
|
||||
message_packet()
|
||||
{
|
||||
}
|
||||
#include "private/diagnostic_pop.h"
|
||||
|
||||
//**********************************************
|
||||
message_packet(const message_packet& /*other*/)
|
||||
{
|
||||
}
|
||||
|
||||
#if ETL_USING_CPP11
|
||||
//**********************************************
|
||||
message_packet(message_packet&& /*other*/)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
//**********************************************
|
||||
void copy(const message_packet& /*other*/)
|
||||
{
|
||||
}
|
||||
|
||||
//**********************************************
|
||||
void copy(message_packet&& /*other*/)
|
||||
{
|
||||
}
|
||||
|
||||
//**********************************************
|
||||
#include "private/diagnostic_uninitialized_push.h"
|
||||
message_packet& operator =(const message_packet& /*rhs*/)
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
#include "private/diagnostic_pop.h"
|
||||
|
||||
//**********************************************
|
||||
#include "private/diagnostic_uninitialized_push.h"
|
||||
message_packet& operator =(message_packet&& /*rhs*/)
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
#include "private/diagnostic_pop.h"
|
||||
|
||||
//********************************************
|
||||
~message_packet()
|
||||
{
|
||||
}
|
||||
|
||||
//********************************************
|
||||
bool is_valid() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
//**********************************************
|
||||
static ETL_CONSTEXPR bool accepts(etl::message_id_t /*id*/)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
//**********************************************
|
||||
static ETL_CONSTEXPR bool accepts(const etl::imessage& /*msg*/)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
//**********************************************
|
||||
template <etl::message_id_t Id>
|
||||
static ETL_CONSTEXPR bool accepts()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
//**********************************************
|
||||
template <typename TMessage>
|
||||
static ETL_CONSTEXPR
|
||||
typename etl::enable_if<etl::is_base_of<etl::imessage, TMessage>::value, bool>::type
|
||||
accepts()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
enum
|
||||
{
|
||||
SIZE = 0,
|
||||
ALIGNMENT = 1
|
||||
};
|
||||
};
|
||||
|
||||
//***************************************************************************
|
||||
/// Helper to turn etl::type_list<TTypes...> into etl::message_packet<TTypes...>
|
||||
template <typename TList>
|
||||
struct message_packet_from_type_list;
|
||||
|
||||
template <typename... TTypes>
|
||||
struct message_packet_from_type_list<etl::type_list<TTypes...>>
|
||||
{
|
||||
using type = etl::message_packet<TTypes...>;
|
||||
};
|
||||
|
||||
template <typename TTypeList>
|
||||
using message_packet_from_type_list_t = typename message_packet_from_type_list<TTypeList>::type;
|
||||
|
||||
#else
|
||||
|
||||
/*[[[cog
|
||||
@ -470,8 +599,7 @@ namespace etl
|
||||
cog.outl("// The definition for all %s message types." % Handlers)
|
||||
cog.outl("//***************************************************************************")
|
||||
cog.out("template <")
|
||||
cog.out("typename T1, ")
|
||||
for n in range(2, int(Handlers)):
|
||||
for n in range(1, int(Handlers)):
|
||||
cog.out("typename T%s = void, " % n)
|
||||
if n % 4 == 0:
|
||||
cog.outl("")
|
||||
@ -481,6 +609,15 @@ namespace etl
|
||||
cog.outl("{")
|
||||
cog.outl("public:")
|
||||
cog.outl("")
|
||||
|
||||
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("")
|
||||
|
||||
cog.outl(" //********************************************")
|
||||
cog.outl("#include \"private/diagnostic_uninitialized_push.h\"")
|
||||
cog.outl(" message_packet()")
|
||||
@ -785,6 +922,16 @@ namespace etl
|
||||
cog.outl("{")
|
||||
cog.outl("public:")
|
||||
cog.outl("")
|
||||
|
||||
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("")
|
||||
|
||||
cog.outl(" //********************************************")
|
||||
cog.outl("#include \"private/diagnostic_uninitialized_push.h\"")
|
||||
cog.outl(" message_packet()")
|
||||
@ -1058,6 +1205,62 @@ namespace etl
|
||||
cog.outl("};")
|
||||
]]]*/
|
||||
/*[[[end]]]*/
|
||||
|
||||
//***************************************************************************
|
||||
// Specialisation for 0 message types.
|
||||
//***************************************************************************
|
||||
template <>
|
||||
class message_packet<void, void, void, void, void, void, void, void,
|
||||
void, void, void, void, void, void, void, void>
|
||||
{
|
||||
public:
|
||||
|
||||
#if ETL_USING_CPP11
|
||||
using message_types = etl::type_list<>;
|
||||
#endif
|
||||
|
||||
message_packet()
|
||||
: valid(false)
|
||||
{
|
||||
}
|
||||
|
||||
static ETL_CONSTEXPR bool accepts(etl::message_id_t)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
static ETL_CONSTEXPR bool accepts(const etl::imessage&)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
template <etl::message_id_t Id>
|
||||
static ETL_CONSTEXPR bool accepts()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
template <typename TMessage>
|
||||
static ETL_CONSTEXPR typename etl::enable_if<etl::is_base_of<etl::imessage, TMessage>::value, bool>::type accepts()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool is_valid() const
|
||||
{
|
||||
return valid;
|
||||
}
|
||||
|
||||
enum
|
||||
{
|
||||
SIZE = 0U,
|
||||
ALIGNMENT = 1U
|
||||
};
|
||||
|
||||
private:
|
||||
|
||||
bool valid;
|
||||
};
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@ -251,7 +251,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>();
|
||||
@ -482,7 +482,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 false;
|
||||
@ -522,9 +522,9 @@ namespace etl
|
||||
{
|
||||
public:
|
||||
|
||||
#if ETL_USING_CPP11
|
||||
#if ETL_USING_CPP11
|
||||
using message_types = etl::type_list<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//********************************************
|
||||
#include "private/diagnostic_uninitialized_push.h"
|
||||
@ -850,9 +850,9 @@ namespace etl
|
||||
{
|
||||
public:
|
||||
|
||||
#if ETL_USING_CPP11
|
||||
#if ETL_USING_CPP11
|
||||
using message_types = etl::type_list<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//********************************************
|
||||
#include "private/diagnostic_uninitialized_push.h"
|
||||
@ -1176,9 +1176,9 @@ namespace etl
|
||||
{
|
||||
public:
|
||||
|
||||
#if ETL_USING_CPP11
|
||||
#if ETL_USING_CPP11
|
||||
using message_types = etl::type_list<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14>;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//********************************************
|
||||
#include "private/diagnostic_uninitialized_push.h"
|
||||
@ -1499,9 +1499,9 @@ namespace etl
|
||||
{
|
||||
public:
|
||||
|
||||
#if ETL_USING_CPP11
|
||||
#if ETL_USING_CPP11
|
||||
using message_types = etl::type_list<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13>;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//********************************************
|
||||
#include "private/diagnostic_uninitialized_push.h"
|
||||
@ -1818,9 +1818,9 @@ namespace etl
|
||||
{
|
||||
public:
|
||||
|
||||
#if ETL_USING_CPP11
|
||||
#if ETL_USING_CPP11
|
||||
using message_types = etl::type_list<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//********************************************
|
||||
#include "private/diagnostic_uninitialized_push.h"
|
||||
@ -2131,9 +2131,9 @@ namespace etl
|
||||
{
|
||||
public:
|
||||
|
||||
#if ETL_USING_CPP11
|
||||
#if ETL_USING_CPP11
|
||||
using message_types = etl::type_list<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//********************************************
|
||||
#include "private/diagnostic_uninitialized_push.h"
|
||||
@ -2441,9 +2441,9 @@ namespace etl
|
||||
{
|
||||
public:
|
||||
|
||||
#if ETL_USING_CPP11
|
||||
#if ETL_USING_CPP11
|
||||
using message_types = etl::type_list<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//********************************************
|
||||
#include "private/diagnostic_uninitialized_push.h"
|
||||
@ -2748,9 +2748,9 @@ namespace etl
|
||||
{
|
||||
public:
|
||||
|
||||
#if ETL_USING_CPP11
|
||||
#if ETL_USING_CPP11
|
||||
using message_types = etl::type_list<T1, T2, T3, T4, T5, T6, T7, T8, T9>;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//********************************************
|
||||
#include "private/diagnostic_uninitialized_push.h"
|
||||
@ -3051,9 +3051,9 @@ namespace etl
|
||||
{
|
||||
public:
|
||||
|
||||
#if ETL_USING_CPP11
|
||||
#if ETL_USING_CPP11
|
||||
using message_types = etl::type_list<T1, T2, T3, T4, T5, T6, T7, T8>;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//********************************************
|
||||
#include "private/diagnostic_uninitialized_push.h"
|
||||
@ -3348,9 +3348,9 @@ namespace etl
|
||||
{
|
||||
public:
|
||||
|
||||
#if ETL_USING_CPP11
|
||||
#if ETL_USING_CPP11
|
||||
using message_types = etl::type_list<T1, T2, T3, T4, T5, T6, T7>;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//********************************************
|
||||
#include "private/diagnostic_uninitialized_push.h"
|
||||
@ -3642,9 +3642,9 @@ namespace etl
|
||||
{
|
||||
public:
|
||||
|
||||
#if ETL_USING_CPP11
|
||||
#if ETL_USING_CPP11
|
||||
using message_types = etl::type_list<T1, T2, T3, T4, T5, T6>;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//********************************************
|
||||
#include "private/diagnostic_uninitialized_push.h"
|
||||
@ -3933,9 +3933,9 @@ namespace etl
|
||||
{
|
||||
public:
|
||||
|
||||
#if ETL_USING_CPP11
|
||||
#if ETL_USING_CPP11
|
||||
using message_types = etl::type_list<T1, T2, T3, T4, T5>;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//********************************************
|
||||
#include "private/diagnostic_uninitialized_push.h"
|
||||
@ -4220,9 +4220,9 @@ namespace etl
|
||||
{
|
||||
public:
|
||||
|
||||
#if ETL_USING_CPP11
|
||||
#if ETL_USING_CPP11
|
||||
using message_types = etl::type_list<T1, T2, T3, T4>;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//********************************************
|
||||
#include "private/diagnostic_uninitialized_push.h"
|
||||
@ -4501,9 +4501,9 @@ namespace etl
|
||||
{
|
||||
public:
|
||||
|
||||
#if ETL_USING_CPP11
|
||||
#if ETL_USING_CPP11
|
||||
using message_types = etl::type_list<T1, T2, T3>;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//********************************************
|
||||
#include "private/diagnostic_uninitialized_push.h"
|
||||
@ -4779,9 +4779,9 @@ namespace etl
|
||||
{
|
||||
public:
|
||||
|
||||
#if ETL_USING_CPP11
|
||||
#if ETL_USING_CPP11
|
||||
using message_types = etl::type_list<T1, T2>;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//********************************************
|
||||
#include "private/diagnostic_uninitialized_push.h"
|
||||
@ -5054,12 +5054,9 @@ namespace etl
|
||||
{
|
||||
public:
|
||||
|
||||
//ETL_STATIC_ASSERT(!etl::is_type_list<T1>::value,
|
||||
// "message_packet does not accept an etl::type_list before C++17, or when ETL_MESSAGE_PACKET_FORCE_CPP03_IMPLEMENTATION is defined");
|
||||
|
||||
#if ETL_USING_CPP11
|
||||
#if ETL_USING_CPP11
|
||||
using message_types = etl::type_list<T1>;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//********************************************
|
||||
#include "private/diagnostic_uninitialized_push.h"
|
||||
@ -5352,7 +5349,6 @@ namespace etl
|
||||
template <etl::message_id_t Id>
|
||||
static ETL_CONSTEXPR bool accepts()
|
||||
{
|
||||
//ETL_UNUSED(Id);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user