diff --git a/library.properties b/library.properties index 0baef0284..91f492212 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=Embedded Template Library -version=9.5.1 +version=9.6.0 author= John Wellbelove maintainer=John Wellbelove sentence=A C++ template library tailored for embedded systems. diff --git a/src/type_lookup.h b/src/type_lookup.h index 068559364..0a7eb03ae 100644 --- a/src/type_lookup.h +++ b/src/type_lookup.h @@ -165,6 +165,20 @@ namespace etl STATIC_ASSERT(((unsigned int)value != (unsigned int)UNKNOWN), "Invalid type"); }; + + //************************************ + template + static unsigned int get_id_from_type(const T&) + { + return get_id_from_type(); + } + + //************************************ + template + static unsigned int get_id_from_type() + { + return id_from_type::value; + } }; //*************************************************************************** @@ -254,6 +268,20 @@ namespace etl STATIC_ASSERT(((unsigned int)value != (unsigned int)UNKNOWN), "Invalid type"); }; + + //************************************ + template + static unsigned int get_id_from_type(const T&) + { + return get_id_from_type(); + } + + //************************************ + template + static unsigned int get_id_from_type() + { + return id_from_type::value; + } }; //*************************************************************************** @@ -340,6 +368,20 @@ namespace etl STATIC_ASSERT(((unsigned int)value != (unsigned int)UNKNOWN), "Invalid type"); }; + + //************************************ + template + static unsigned int get_id_from_type(const T&) + { + return get_id_from_type(); + } + + //************************************ + template + static unsigned int get_id_from_type() + { + return id_from_type::value; + } }; //*************************************************************************** @@ -423,6 +465,20 @@ namespace etl STATIC_ASSERT(((unsigned int)value != (unsigned int)UNKNOWN), "Invalid type"); }; + + //************************************ + template + static unsigned int get_id_from_type(const T&) + { + return get_id_from_type(); + } + + //************************************ + template + static unsigned int get_id_from_type() + { + return id_from_type::value; + } }; //*************************************************************************** @@ -504,6 +560,20 @@ namespace etl STATIC_ASSERT(((unsigned int)value != (unsigned int)UNKNOWN), "Invalid type"); }; + + //************************************ + template + static unsigned int get_id_from_type(const T&) + { + return get_id_from_type(); + } + + //************************************ + template + static unsigned int get_id_from_type() + { + return id_from_type::value; + } }; //*************************************************************************** @@ -581,6 +651,20 @@ namespace etl STATIC_ASSERT(((unsigned int)value != (unsigned int)UNKNOWN), "Invalid type"); }; + + //************************************ + template + static unsigned int get_id_from_type(const T&) + { + return get_id_from_type(); + } + + //************************************ + template + static unsigned int get_id_from_type() + { + return id_from_type::value; + } }; //*************************************************************************** @@ -655,6 +739,20 @@ namespace etl STATIC_ASSERT(((unsigned int)value != (unsigned int)UNKNOWN), "Invalid type"); }; + + //************************************ + template + static unsigned int get_id_from_type(const T&) + { + return get_id_from_type(); + } + + //************************************ + template + static unsigned int get_id_from_type() + { + return id_from_type::value; + } }; //*************************************************************************** @@ -726,6 +824,20 @@ namespace etl STATIC_ASSERT(((unsigned int)value != (unsigned int)UNKNOWN), "Invalid type"); }; + + //************************************ + template + static unsigned int get_id_from_type(const T&) + { + return get_id_from_type(); + } + + //************************************ + template + static unsigned int get_id_from_type() + { + return id_from_type::value; + } }; //*************************************************************************** @@ -795,6 +907,20 @@ namespace etl STATIC_ASSERT(((unsigned int)value != (unsigned int)UNKNOWN), "Invalid type"); }; + + //************************************ + template + static unsigned int get_id_from_type(const T&) + { + return get_id_from_type(); + } + + //************************************ + template + static unsigned int get_id_from_type() + { + return id_from_type::value; + } }; //*************************************************************************** @@ -859,6 +985,20 @@ namespace etl STATIC_ASSERT(((unsigned int)value != (unsigned int)UNKNOWN), "Invalid type"); }; + + //************************************ + template + static unsigned int get_id_from_type(const T&) + { + return get_id_from_type(); + } + + //************************************ + template + static unsigned int get_id_from_type() + { + return id_from_type::value; + } }; //*************************************************************************** @@ -920,6 +1060,20 @@ namespace etl STATIC_ASSERT(((unsigned int)value != (unsigned int)UNKNOWN), "Invalid type"); }; + + //************************************ + template + static unsigned int get_id_from_type(const T&) + { + return get_id_from_type(); + } + + //************************************ + template + static unsigned int get_id_from_type() + { + return id_from_type::value; + } }; //*************************************************************************** @@ -978,6 +1132,20 @@ namespace etl STATIC_ASSERT(((unsigned int)value != (unsigned int)UNKNOWN), "Invalid type"); }; + + //************************************ + template + static unsigned int get_id_from_type(const T&) + { + return get_id_from_type(); + } + + //************************************ + template + static unsigned int get_id_from_type() + { + return id_from_type::value; + } }; //*************************************************************************** @@ -1034,6 +1202,20 @@ namespace etl STATIC_ASSERT(((unsigned int)value != (unsigned int)UNKNOWN), "Invalid type"); }; + + //************************************ + template + static unsigned int get_id_from_type(const T&) + { + return get_id_from_type(); + } + + //************************************ + template + static unsigned int get_id_from_type() + { + return id_from_type::value; + } }; //*************************************************************************** @@ -1086,6 +1268,20 @@ namespace etl STATIC_ASSERT(((unsigned int)value != (unsigned int)UNKNOWN), "Invalid type"); }; + + //************************************ + template + static unsigned int get_id_from_type(const T&) + { + return get_id_from_type(); + } + + //************************************ + template + static unsigned int get_id_from_type() + { + return id_from_type::value; + } }; //*************************************************************************** @@ -1135,6 +1331,20 @@ namespace etl STATIC_ASSERT(((unsigned int)value != (unsigned int)UNKNOWN), "Invalid type"); }; + + //************************************ + template + static unsigned int get_id_from_type(const T&) + { + return get_id_from_type(); + } + + //************************************ + template + static unsigned int get_id_from_type() + { + return id_from_type::value; + } }; //*************************************************************************** @@ -1181,6 +1391,20 @@ namespace etl STATIC_ASSERT(((unsigned int)value != (unsigned int)UNKNOWN), "Invalid type"); }; + + //************************************ + template + static unsigned int get_id_from_type(const T&) + { + return get_id_from_type(); + } + + //************************************ + template + static unsigned int get_id_from_type() + { + return id_from_type::value; + } }; //*************************************************************************** // Default for 16 types. diff --git a/src/type_lookup_generator.h b/src/type_lookup_generator.h index bf9b9baf4..f1316b46e 100644 --- a/src/type_lookup_generator.h +++ b/src/type_lookup_generator.h @@ -145,6 +145,20 @@ namespace etl cog.outl("") cog.outl(" STATIC_ASSERT(((unsigned int)value != (unsigned int)UNKNOWN), \"Invalid type\");") cog.outl(" };") + cog.outl("") + cog.outl(" //************************************") + cog.outl(" template ") + cog.outl(" static unsigned int get_id_from_type(const T&)") + cog.outl(" {") + cog.outl(" return get_id_from_type();") + cog.outl(" }") + cog.outl("") + cog.outl(" //************************************") + cog.outl(" template ") + cog.outl(" static unsigned int get_id_from_type()") + cog.outl(" {") + cog.outl(" return id_from_type::value;") + cog.outl(" }") cog.outl("};") for n in range(int(NTypes) - 1, 0, -1): cog.outl("") @@ -220,6 +234,20 @@ namespace etl cog.outl("") cog.outl(" STATIC_ASSERT(((unsigned int)value != (unsigned int)UNKNOWN), \"Invalid type\");") cog.outl(" };") + cog.outl("") + cog.outl(" //************************************") + cog.outl(" template ") + cog.outl(" static unsigned int get_id_from_type(const T&)") + cog.outl(" {") + cog.outl(" return get_id_from_type();") + cog.outl(" }") + cog.outl("") + cog.outl(" //************************************") + cog.outl(" template ") + cog.outl(" static unsigned int get_id_from_type()") + cog.outl(" {") + cog.outl(" return id_from_type::value;") + cog.outl(" }") cog.outl("};") cog.outl("//***************************************************************************") cog.outl("// Default for %s types." % int(NTypes)) diff --git a/test/codeblocks/.gitignore b/test/codeblocks/.gitignore index f654e5b9d..1c0f0f112 100644 --- a/test/codeblocks/.gitignore +++ b/test/codeblocks/.gitignore @@ -1,3 +1,4 @@ random_*.csv /ETL.depend /ETL.layout +*.depend diff --git a/test/test_type_lookup.cpp b/test/test_type_lookup.cpp index 57fd206d9..c944a9bdb 100644 --- a/test/test_type_lookup.cpp +++ b/test/test_type_lookup.cpp @@ -174,7 +174,38 @@ namespace CHECK_EQUAL((unsigned int) Type15::ID, (unsigned int) Type_Id_Lookup16::id_from_type::value); CHECK_EQUAL((unsigned int) Type16::ID, (unsigned int) Type_Id_Lookup16::id_from_type::value); -// CHECK_EQUAL((unsigned int) Type_Id_Lookup16::UNKNOWN, (unsigned int) Type_Id_Lookup16::id_from_type::value); + CHECK_EQUAL((unsigned int)Type1::ID, (unsigned int)Type_Id_Lookup16::get_id_from_type()); + CHECK_EQUAL((unsigned int)Type1::ID, (unsigned int)Type_Id_Lookup16::get_id_from_type(Type1())); + CHECK_EQUAL((unsigned int)Type2::ID, (unsigned int)Type_Id_Lookup16::get_id_from_type()); + CHECK_EQUAL((unsigned int)Type2::ID, (unsigned int)Type_Id_Lookup16::get_id_from_type(Type2())); + CHECK_EQUAL((unsigned int)Type3::ID, (unsigned int)Type_Id_Lookup16::get_id_from_type()); + CHECK_EQUAL((unsigned int)Type3::ID, (unsigned int)Type_Id_Lookup16::get_id_from_type(Type3())); + CHECK_EQUAL((unsigned int)Type4::ID, (unsigned int)Type_Id_Lookup16::get_id_from_type()); + CHECK_EQUAL((unsigned int)Type4::ID, (unsigned int)Type_Id_Lookup16::get_id_from_type(Type4())); + CHECK_EQUAL((unsigned int)Type5::ID, (unsigned int)Type_Id_Lookup16::get_id_from_type()); + CHECK_EQUAL((unsigned int)Type5::ID, (unsigned int)Type_Id_Lookup16::get_id_from_type(Type5())); + CHECK_EQUAL((unsigned int)Type6::ID, (unsigned int)Type_Id_Lookup16::get_id_from_type()); + CHECK_EQUAL((unsigned int)Type6::ID, (unsigned int)Type_Id_Lookup16::get_id_from_type(Type6())); + CHECK_EQUAL((unsigned int)Type7::ID, (unsigned int)Type_Id_Lookup16::get_id_from_type()); + CHECK_EQUAL((unsigned int)Type7::ID, (unsigned int)Type_Id_Lookup16::get_id_from_type(Type7())); + CHECK_EQUAL((unsigned int)Type8::ID, (unsigned int)Type_Id_Lookup16::get_id_from_type()); + CHECK_EQUAL((unsigned int)Type8::ID, (unsigned int)Type_Id_Lookup16::get_id_from_type(Type8())); + CHECK_EQUAL((unsigned int)Type9::ID, (unsigned int)Type_Id_Lookup16::get_id_from_type()); + CHECK_EQUAL((unsigned int)Type9::ID, (unsigned int)Type_Id_Lookup16::get_id_from_type(Type9())); + CHECK_EQUAL((unsigned int)Type10::ID, (unsigned int)Type_Id_Lookup16::get_id_from_type()); + CHECK_EQUAL((unsigned int)Type10::ID, (unsigned int)Type_Id_Lookup16::get_id_from_type(Type10())); + CHECK_EQUAL((unsigned int)Type11::ID, (unsigned int)Type_Id_Lookup16::get_id_from_type()); + CHECK_EQUAL((unsigned int)Type11::ID, (unsigned int)Type_Id_Lookup16::get_id_from_type(Type11())); + CHECK_EQUAL((unsigned int)Type12::ID, (unsigned int)Type_Id_Lookup16::get_id_from_type()); + CHECK_EQUAL((unsigned int)Type12::ID, (unsigned int)Type_Id_Lookup16::get_id_from_type(Type12())); + CHECK_EQUAL((unsigned int)Type13::ID, (unsigned int)Type_Id_Lookup16::get_id_from_type()); + CHECK_EQUAL((unsigned int)Type13::ID, (unsigned int)Type_Id_Lookup16::get_id_from_type(Type13())); + CHECK_EQUAL((unsigned int)Type14::ID, (unsigned int)Type_Id_Lookup16::get_id_from_type()); + CHECK_EQUAL((unsigned int)Type14::ID, (unsigned int)Type_Id_Lookup16::get_id_from_type(Type14())); + CHECK_EQUAL((unsigned int)Type15::ID, (unsigned int)Type_Id_Lookup16::get_id_from_type()); + CHECK_EQUAL((unsigned int)Type15::ID, (unsigned int)Type_Id_Lookup16::get_id_from_type(Type15())); + CHECK_EQUAL((unsigned int)Type16::ID, (unsigned int)Type_Id_Lookup16::get_id_from_type()); + CHECK_EQUAL((unsigned int)Type16::ID, (unsigned int)Type_Id_Lookup16::get_id_from_type(Type16())); } //************************************************************************* @@ -189,7 +220,23 @@ namespace CHECK_EQUAL((unsigned int) Type15::ID, (unsigned int) Type_Id_Lookup8::id_from_type::value); CHECK_EQUAL((unsigned int) Type16::ID, (unsigned int) Type_Id_Lookup8::id_from_type::value); -// CHECK_EQUAL((unsigned int) Type_Id_Lookup8::UNKNOWN, (unsigned int) Type_Id_Lookup8::id_from_type::value); + CHECK_EQUAL((unsigned int)Type1::ID, (unsigned int)Type_Id_Lookup8::get_id_from_type()); + CHECK_EQUAL((unsigned int)Type1::ID, (unsigned int)Type_Id_Lookup8::get_id_from_type(Type1())); + CHECK_EQUAL((unsigned int)Type2::ID, (unsigned int)Type_Id_Lookup8::get_id_from_type()); + CHECK_EQUAL((unsigned int)Type2::ID, (unsigned int)Type_Id_Lookup8::get_id_from_type(Type2())); + CHECK_EQUAL((unsigned int)Type3::ID, (unsigned int)Type_Id_Lookup8::get_id_from_type()); + CHECK_EQUAL((unsigned int)Type3::ID, (unsigned int)Type_Id_Lookup8::get_id_from_type(Type3())); + CHECK_EQUAL((unsigned int)Type4::ID, (unsigned int)Type_Id_Lookup8::get_id_from_type()); + CHECK_EQUAL((unsigned int)Type4::ID, (unsigned int)Type_Id_Lookup8::get_id_from_type(Type4())); + CHECK_EQUAL((unsigned int)Type13::ID, (unsigned int)Type_Id_Lookup8::get_id_from_type()); + CHECK_EQUAL((unsigned int)Type13::ID, (unsigned int)Type_Id_Lookup8::get_id_from_type(Type13())); + CHECK_EQUAL((unsigned int)Type14::ID, (unsigned int)Type_Id_Lookup8::get_id_from_type()); + CHECK_EQUAL((unsigned int)Type14::ID, (unsigned int)Type_Id_Lookup8::get_id_from_type(Type14())); + CHECK_EQUAL((unsigned int)Type15::ID, (unsigned int)Type_Id_Lookup8::get_id_from_type()); + CHECK_EQUAL((unsigned int)Type15::ID, (unsigned int)Type_Id_Lookup8::get_id_from_type(Type15())); + CHECK_EQUAL((unsigned int)Type16::ID, (unsigned int)Type_Id_Lookup8::get_id_from_type()); + CHECK_EQUAL((unsigned int)Type16::ID, (unsigned int)Type_Id_Lookup8::get_id_from_type(Type16())); + } //************************************************************************* @@ -197,7 +244,8 @@ namespace { CHECK_EQUAL((unsigned int) Type16::ID, (unsigned int) Type_Id_Lookup1::id_from_type::value); -// CHECK_EQUAL((unsigned int) Type_Id_Lookup1::UNKNOWN, (unsigned int) Type_Id_Lookup1::id_from_type::value); + CHECK_EQUAL((unsigned int)Type16::ID, (unsigned int)Type_Id_Lookup1::get_id_from_type()); + CHECK_EQUAL((unsigned int)Type16::ID, (unsigned int)Type_Id_Lookup1::get_id_from_type(Type16())); } //*************************************************************************