Added etl::message_packet classes

This commit is contained in:
John Wellbelove 2020-03-23 19:49:24 +00:00
parent 031e86d1e3
commit c90c7967c6
13 changed files with 58 additions and 1512 deletions

3
.gitignore vendored
View File

@ -9,9 +9,12 @@ test/keil/Debug
test/keil/Release
test/keil/Objects
test/keil/Listings
test/cmake-windows/unittest++/src
test/cmake/unittest++/src
examples/ArmTimerCallbacks/Listings
examples/ArmTimerCallbacks/Objects
examples/ArmTimerCallbacks/DebugConfig
build-test-Desktop_x86_windows_msvc2017_pe_32bit-Debug/unittest++/src
#################
## Eclipse

View File

@ -52,3 +52,4 @@
52 bitset
53 indirect_vector
54 queue_spsc_locked
55 message_packet

View File

@ -4,4 +4,5 @@ python -m cogapp -d -e -olargest.h -DNTypes=16 largest_generator.h
python -m cogapp -d -e -osmallest.h -DNTypes=16 smallest_generator.h
python -m cogapp -d -e -otype_traits.h -DIsOneOf=17 type_traits_generator.h
python -m cogapp -d -e -otype_lookup.h -DNTypes=16 type_lookup_generator.h
python -m cogapp -d -e -otype_select.h -DNTypes=16 type_select_generator.h
python -m cogapp -d -e -otype_select.h -DNTypes=16 type_select_generator.h
python -m cogapp -d -e -omessage_packet.h -DHandlers=16 message_packet_generator.h

File diff suppressed because it is too large Load Diff

View File

@ -68,6 +68,7 @@ cog.outl("//********************************************************************
#include "platform.h"
#include "message.h"
#include "message_packet.h"
#include "message_types.h"
#include "alignment.h"
#include "error_handler.h"
@ -272,89 +273,10 @@ namespace etl
cog.outl("{")
cog.outl("public:")
cog.outl("")
cog.outl(" //**********************************************")
cog.outl(" class message_packet")
cog.outl(" {")
cog.outl(" public:")
cog.outl("")
cog.outl(" //********************************************")
cog.outl(" explicit message_packet(const etl::imessage& msg)")
cog.outl(" {")
cog.outl(" const size_t id = msg.message_id;")
cog.outl("")
cog.outl(" void* p = data;")
cog.outl("")
cog.outl(" switch (id)")
cog.outl(" {")
for n in range(1, int(Handlers) + 1):
cog.outl(" case T%s::ID: ::new (p) T%s(static_cast<const T%s&>(msg)); break;" % (n, n, n))
cog.outl(" default: ETL_ASSERT(false, ETL_ERROR(unhandled_message_exception)); break;")
cog.outl(" }")
cog.outl(" }")
cog.outl("")
cog.outl(" //********************************************")
cog.outl(" template <typename T>")
cog.outl(" explicit message_packet(const T& msg)")
cog.outl(" {")
cog.out(" ETL_STATIC_ASSERT((etl::is_one_of<T, ")
cog.out(" typedef etl::message_packet<")
for n in range(1, int(Handlers)):
cog.out("T%s, " % n)
if n % 16 == 0:
cog.outl("")
cog.out(" ")
cog.outl("""T%s>::value), "Unsupported type for this message packet");""" % int(Handlers))
cog.outl("")
cog.outl(" void* p = data;")
cog.outl(" ::new (p) T(static_cast<const T&>(msg));")
cog.outl(" }")
cog.outl("")
cog.outl(" //********************************************")
cog.outl(" ~message_packet()")
cog.outl(" {")
cog.outl(" etl::imessage* pmsg = static_cast<etl::imessage*>(data);")
cog.outl("")
cog.outl("#if defined(ETL_MESSAGES_ARE_VIRTUAL) || defined(ETL_POLYMORPHIC_MESSAGES)")
cog.outl(" pmsg->~imessage();")
cog.outl("#else")
cog.outl(" size_t id = pmsg->message_id;")
cog.outl("")
cog.outl(" switch (id)")
cog.outl(" {")
for n in range(1, int(Handlers) + 1):
cog.outl(" case T%s::ID: static_cast<T%s*>(pmsg)->~T%s(); break;" % (n, n, n))
cog.outl(" default: assert(false); break;")
cog.outl(" }")
cog.outl("#endif")
cog.outl(" }")
cog.outl("")
cog.outl(" //********************************************")
cog.outl(" etl::imessage& get()")
cog.outl(" {")
cog.outl(" return *static_cast<etl::imessage*>(data);")
cog.outl(" }")
cog.outl("")
cog.outl(" //********************************************")
cog.outl(" const etl::imessage& get() const")
cog.outl(" {")
cog.outl(" return *static_cast<const etl::imessage*>(data);")
cog.outl(" }")
cog.outl("")
cog.outl(" enum")
cog.outl(" {")
cog.out(" SIZE = etl::largest<")
for n in range(1, int(Handlers)):
cog.out("T%s, " % n)
cog.outl("T%s>::size," % int(Handlers))
cog.out(" ALIGNMENT = etl::largest<")
for n in range(1, int(Handlers)):
cog.out("T%s, " % n)
cog.outl("T%s>::alignment" % int(Handlers))
cog.outl(" };")
cog.outl("")
cog.outl(" private:")
cog.outl("")
cog.outl(" typename etl::aligned_storage<SIZE, ALIGNMENT>::type data;")
cog.outl(" };")
cog.outl(" T%s> message_packet;" % int(Handlers))
cog.outl("")
cog.outl(" //**********************************************")
cog.outl(" message_router(etl::message_router_id_t id_)")
@ -472,89 +394,10 @@ namespace etl
cog.outl("{")
cog.outl("public:")
cog.outl("")
cog.outl(" //**********************************************")
cog.outl(" class message_packet")
cog.outl(" {")
cog.outl(" public:")
cog.outl("")
cog.outl(" //********************************************")
cog.outl(" explicit message_packet(const etl::imessage& msg)")
cog.outl(" {")
cog.outl(" const size_t id = msg.message_id;")
cog.outl("")
cog.outl(" void* p = data;")
cog.outl("")
cog.outl(" switch (id)")
cog.outl(" {")
for t in range(1, n + 1):
cog.outl(" case T%s::ID: ::new (p) T%s(static_cast<const T%s&>(msg)); break;" % (t, t, t))
cog.outl(" default: ETL_ASSERT(false, ETL_ERROR(unhandled_message_exception)); break;")
cog.outl(" }")
cog.outl(" }")
cog.outl("")
cog.outl(" //********************************************")
cog.outl(" template <typename T>")
cog.outl(" explicit message_packet(const T& msg)")
cog.outl(" {")
cog.out(" ETL_STATIC_ASSERT((etl::is_one_of<T, ")
cog.out(" typedef etl::message_packet<")
for t in range(1, n):
cog.out("T%s, " % t)
if t % 16 == 0:
cog.outl("")
cog.out(" ")
cog.outl("""T%s>::value), "Unsupported type for this message packet");""" % n)
cog.outl("")
cog.outl(" void* p = data;")
cog.outl(" ::new (p) T(static_cast<const T&>(msg));")
cog.outl(" }")
cog.outl("")
cog.outl(" //********************************************")
cog.outl(" ~message_packet()")
cog.outl(" {")
cog.outl(" etl::imessage* pmsg = static_cast<etl::imessage*>(data);")
cog.outl("")
cog.outl("#if defined(ETL_MESSAGES_ARE_VIRTUAL) || defined(ETL_POLYMORPHIC_MESSAGES)")
cog.outl(" pmsg->~imessage();")
cog.outl("#else")
cog.outl(" size_t id = pmsg->message_id;")
cog.outl("")
cog.outl(" switch (id)")
cog.outl(" {")
for t in range(1, n + 1):
cog.outl(" case T%s::ID: static_cast<T%s*>(pmsg)->~T%s(); break;" % (t, t, t))
cog.outl(" default: assert(false); break;")
cog.outl(" }")
cog.outl("#endif")
cog.outl(" }")
cog.outl("")
cog.outl(" //********************************************")
cog.outl(" etl::imessage& get()")
cog.outl(" {")
cog.outl(" return *static_cast<etl::imessage*>(data);")
cog.outl(" }")
cog.outl("")
cog.outl(" //********************************************")
cog.outl(" const etl::imessage& get() const")
cog.outl(" {")
cog.outl(" return *static_cast<const etl::imessage*>(data);")
cog.outl(" }")
cog.outl("")
cog.outl(" enum")
cog.outl(" {")
cog.out(" SIZE = etl::largest<")
for t in range(1, n):
cog.out("T%s, " % t)
cog.outl("T%s>::size," % n)
cog.out(" ALIGNMENT = etl::largest<")
for t in range(1, n):
cog.out("T%s, " % t)
cog.outl("T%s>::alignment" % n)
cog.outl(" };")
cog.outl("")
cog.outl(" private:")
cog.outl("")
cog.outl(" typename etl::aligned_storage<SIZE, ALIGNMENT>::type data;")
cog.outl(" };")
cog.outl(" T%s> message_packet;" % n)
cog.outl("")
cog.outl(" //**********************************************")
cog.outl(" message_router(etl::message_router_id_t id_)")

View File

@ -72,6 +72,7 @@ SOFTWARE.
#define ETL_CONST_OR_CONSTEXPR constexpr
#define ETL_DELETE = delete
#define ETL_EXPLICIT explicit
#define ETL_OVERRIDE override
#if defined(ETL_EXCEPTIONS_DISABLED)
#define ETL_NOEXCEPT
#define ETL_NOEXCEPT_EXPR(expression)
@ -84,6 +85,7 @@ SOFTWARE.
#define ETL_CONST_OR_CONSTEXPR const
#define ETL_DELETE
#define ETL_EXPLICIT
#define ETL_OVERRIDE
#define ETL_NOEXCEPT
#define ETL_NOEXCEPT_EXPR(expression)
#endif

View File

@ -38,8 +38,8 @@ SOFTWARE.
///\ingroup utilities
#define ETL_VERSION_MAJOR 16
#define ETL_VERSION_MINOR 7
#define ETL_VERSION_PATCH 1
#define ETL_VERSION_MINOR 8
#define ETL_VERSION_PATCH 0
#define ETL_VERSION ETL_STRINGIFY(ETL_VERSION_MAJOR) "." ETL_STRINGIFY(ETL_VERSION_MINOR) "." ETL_STRINGIFY(ETL_VERSION_PATCH)
#define ETL_VERSION_W ETL_STRINGIFY(ETL_VERSION_MAJOR) L"." ETL_STRINGIFY(ETL_VERSION_MINOR) L"." ETL_STRINGIFY(ETL_VERSION_PATCH)
#define ETL_VERSION_U16 ETL_STRINGIFY(ETL_VERSION_MAJOR) u"." ETL_STRINGIFY(ETL_VERSION_MINOR) u"." ETL_STRINGIFY(ETL_VERSION_PATCH)

View File

@ -1,6 +1,6 @@
{
"name": "Embedded Template Library",
"version": "16.7.1",
"version": "16.8.0",
"authors": {
"name": "John Wellbelove",
"email": "john.wellbelove@etlcpp.com"

View File

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

View File

@ -1,3 +1,7 @@
===============================================================================
16.8.0
Extracted message_packet from etl::message_router for use as an independant class.
===============================================================================
16.7.1
Fix C++03 compatibility issues in memory.h and utility.h

View File

@ -32,7 +32,6 @@ SOFTWARE.
#include "etl/message_router.h"
#include "etl/queue.h"
#include "etl/largest.h"
#include "etl/packet.h"
//***************************************************************************
// The set of messages.

View File

@ -888,6 +888,9 @@
<ClInclude Include="..\..\include\etl\absolute.h" />
<ClInclude Include="..\..\include\etl\limits.h" />
<ClInclude Include="..\..\include\etl\macros.h" />
<ClInclude Include="..\..\include\etl\message_packet temp.h" />
<ClInclude Include="..\..\include\etl\message_packet.h" />
<ClInclude Include="..\..\include\etl\message_packet_generator.h" />
<ClInclude Include="..\..\include\etl\multi_array.h" />
<ClInclude Include="..\..\include\etl\mutex\mutex_freertos.h" />
<ClInclude Include="..\..\include\etl\negative.h" />
@ -1106,6 +1109,7 @@
<ClCompile Include="..\test_limits.cpp" />
<ClCompile Include="..\test_list_shared_pool.cpp" />
<ClCompile Include="..\test_make_string.cpp" />
<ClCompile Include="..\test_message_packet.cpp" />
<ClCompile Include="..\test_multi_array.cpp" />
<ClCompile Include="..\test_array.cpp">
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">../../../unittest-cpp</AdditionalIncludeDirectories>
@ -1442,6 +1446,7 @@
<ItemGroup>
<None Include="..\..\etl.pspimage" />
<None Include="..\..\etl.xar" />
<None Include="..\..\include\etl\generate_message_packet.bat" />
<None Include="..\..\include\etl\generate_type_select.bat" />
<None Include="..\..\library.json" />
<None Include="..\..\library.properties" />

View File

@ -822,6 +822,15 @@
<ClInclude Include="..\..\include\etl\mutex\mutex_freertos.h">
<Filter>ETL\Utilities\Mutex</Filter>
</ClInclude>
<ClInclude Include="..\..\include\etl\message_packet_generator.h">
<Filter>ETL\Frameworks\Generators</Filter>
</ClInclude>
<ClInclude Include="..\..\include\etl\message_packet temp.h">
<Filter>ETL\Frameworks</Filter>
</ClInclude>
<ClInclude Include="..\..\include\etl\message_packet.h">
<Filter>ETL\Frameworks</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\main.cpp">
@ -1277,6 +1286,9 @@
<ClCompile Include="..\test_parity_checksum.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\test_message_packet.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="..\..\library.properties">
@ -1324,6 +1336,9 @@
<None Include="cpp.hint">
<Filter>Resource Files</Filter>
</None>
<None Include="..\..\include\etl\generate_message_packet.bat">
<Filter>Resource Files\Generators</Filter>
</None>
</ItemGroup>
<ItemGroup>
<Text Include="..\..\include\etl\file_error_numbers.txt">