From d5823428a17e2ab8f17791d717165877a381b64a Mon Sep 17 00:00:00 2001 From: peri4 Date: Fri, 11 Jun 2021 21:11:22 +0300 Subject: [PATCH] FreeRTOS PIByteArray assert --- libs/main/core/pibytearray.h | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/libs/main/core/pibytearray.h b/libs/main/core/pibytearray.h index f9c81938..aadfe784 100644 --- a/libs/main/core/pibytearray.h +++ b/libs/main/core/pibytearray.h @@ -28,6 +28,12 @@ #include "pimap.h" #include "pivector2d.h" +#ifdef FREERTOS +# define _TYPENAME_(T) "?" +#else +# define _TYPENAME_(T) typeid(T).name() +#endif + class PIString; class PIByteArray; @@ -298,7 +304,7 @@ inline PIByteArray & operator >>(PIByteArray & s, uchar & v) {assert(s.size() >= template::value, int>::type = 0> inline PIByteArray::StreamRef operator >>(PIByteArray & s, T & v) { if (s.size() < sizeof(v)) { - printf("error with %s\n", typeid(T).name()); + printf("error with %s\n", _TYPENAME_(T)); assert(s.size() >= sizeof(v)); } memcpy((void*)(&v), s.data(), sizeof(v)); @@ -328,7 +334,7 @@ template() << std::declval()), PIByteArray::StreamRef>::value, int>::type = 0> inline PIByteArray & operator >>(PIByteArray & s, PIVector & v) { if (s.size_s() < 4) { - printf("error with PIVector<%s>\n", typeid(T).name()); + printf("error with PIVector<%s>\n", _TYPENAME_(T)); assert(s.size_s() >= 4); } int sz; s >> sz; @@ -344,7 +350,7 @@ template() << std::declval()), PIByteArray::StreamRef>::value, int>::type = 0> inline PIByteArray & operator >>(PIByteArray & s, PIVector & v) { if (s.size_s() < 4) { - printf("error with PIVector<%s>\n", typeid(T).name()); + printf("error with PIVector<%s>\n", _TYPENAME_(T)); assert(s.size_s() >= 4); } int sz; s >> sz; @@ -359,7 +365,7 @@ template() << std::declval()), PIByteArray::StreamRef>::value, int>::type = 0> inline PIByteArray & operator >>(PIByteArray & s, PIDeque & v) { if (s.size_s() < 4) { - printf("error with PIDeque<%s>\n", typeid(T).name()); + printf("error with PIDeque<%s>\n", _TYPENAME_(T)); assert(s.size_s() >= 4); } int sz; s >> sz; @@ -375,7 +381,7 @@ template() << std::declval()), PIByteArray::StreamRef>::value, int>::type = 0> inline PIByteArray & operator >>(PIByteArray & s, PIDeque & v) { if (s.size_s() < 4) { - printf("error with PIDeque<%s>\n", typeid(T).name()); + printf("error with PIDeque<%s>\n", _TYPENAME_(T)); assert(s.size_s() >= 4); } int sz; s >> sz; @@ -390,7 +396,7 @@ template() << std::declval()), PIByteArray::StreamRef>::value, int>::type = 0> inline PIByteArray & operator >>(PIByteArray & s, PIVector2D & v) { if (s.size_s() < 8) { - printf("error with PIVecto2Dr<%s>\n", typeid(T).name()); + printf("error with PIVecto2Dr<%s>\n", _TYPENAME_(T)); assert(s.size_s() >= 8); } int r, c; s >> r >> c; @@ -407,7 +413,7 @@ template() << std::declval()), PIByteArray::StreamRef>::value, int>::type = 0> inline PIByteArray & operator >>(PIByteArray & s, PIVector2D & v) { if (s.size_s() < 8) { - printf("error with PIVecto2Dr<%s>\n", typeid(T).name()); + printf("error with PIVecto2Dr<%s>\n", _TYPENAME_(T)); assert(s.size_s() >= 8); } int r,c; @@ -463,7 +469,7 @@ inline PIByteArray & operator <<(PIByteArray & s, const PIVector2D & v) { template::value, int>::type = 0> inline PIByteArray & operator >>(PIByteArray & s, PIVector & v) { if (s.size_s() < 4) { - printf("error with PIVector<%s>\n", typeid(T).name()); + printf("error with PIVector<%s>\n", _TYPENAME_(T)); assert(s.size_s() >= 4); } int sz; s >> sz; @@ -476,7 +482,7 @@ inline PIByteArray & operator >>(PIByteArray & s, PIVector & v) { template::value, int>::type = 0> inline PIByteArray & operator >>(PIByteArray & s, PIDeque & v) { if (s.size_s() < 4) { - printf("error with PIDeque<%s>\n", typeid(T).name()); + printf("error with PIDeque<%s>\n", _TYPENAME_(T)); assert(s.size_s() >= 4); } int sz; s >> sz; @@ -489,7 +495,7 @@ inline PIByteArray & operator >>(PIByteArray & s, PIDeque & v) { template::value, int>::type = 0> inline PIByteArray & operator >>(PIByteArray & s, PIVector2D & v) { if (s.size_s() < 8) { - printf("error with PIVecto2Dr<%s>\n", typeid(T).name()); + printf("error with PIVecto2Dr<%s>\n", _TYPENAME_(T)); assert(s.size_s() >= 8); } int r,c; @@ -518,7 +524,7 @@ inline PIByteArray & operator <<(PIByteArray & s, const PIMap & v) { template inline PIByteArray & operator >>(PIByteArray & s, PIMap & v) { if (s.size_s() < 4) { - printf("error with PIMap<%s, %s>\n", typeid(Key).name(), typeid(T).name()); + printf("error with PIMap<%s, %s>\n", _TYPENAME_(Key), _TYPENAME_(T)); assert(s.size_s() >= 4); } int sz; s >> sz; v.pim_index.resize(sz); @@ -553,4 +559,7 @@ template<> inline uint piHash(const PIByteArray & ba) {return ba.hash();} template<> inline void piSwap(PIByteArray & f, PIByteArray & s) {f.swap(s);} +#undef _TYPENAME_ + + #endif // PIBYTEARRAY_H