diff --git a/libs/main/core/piobject.h b/libs/main/core/piobject.h index e85b30c0..939ebb0e 100644 --- a/libs/main/core/piobject.h +++ b/libs/main/core/piobject.h @@ -1,7 +1,7 @@ /*! \file piobject.h * \brief Base object * - * This file declare PIObject class and associated macros + * This file declare PIObject class */ /* PIP - Platform Independent Primitives diff --git a/libs/main/core/piobject_macros.h b/libs/main/core/piobject_macros.h index 261c4531..1f0d27a5 100644 --- a/libs/main/core/piobject_macros.h +++ b/libs/main/core/piobject_macros.h @@ -1,7 +1,7 @@ -/*! \file piobject.h +/*! \file piobject_macros.h * \brief Base object * - * This file declare PIObject class and associated macros + * This file declare macros for PIObject */ /* PIP - Platform Independent Primitives @@ -25,8 +25,6 @@ #ifndef PIOBJECT_MACROS_H #define PIOBJECT_MACROS_H -//#include "piobject_macros.h" - #ifdef DOXYGEN @@ -385,43 +383,63 @@ #define EVENT_VHANDLER0(ret, name) \ EH_INIT0(ret, name) \ - static ret __stat_eh_##name##__(void * __o__) {return ((__PIObject__*)__o__)->name();} \ + static ret __stat_eh_##name##__(void * __o__) { \ + return ((__PIObject__*)__o__)->name();} \ virtual ret name() #define EVENT_VHANDLER1(ret, name, a0, n0) \ EH_INIT1(ret, name, a0, n0) \ - static ret __stat_eh_##name##__(void * __o__, a0 n0) {return ((__PIObject__*)__o__)->name(n0);} \ - static ret __stat_eh_v_##name##__(void * __o__, const PIVariantSimple & v0) {return ((__PIObject__*)__o__)->name(__VVALUE(a0, v0));} \ + static ret __stat_eh_##name##__(void * __o__, a0 n0) { \ + return ((__PIObject__*)__o__)->name(n0);} \ + static ret __stat_eh_v_##name##__(void * __o__, const PIVariantSimple & v0) { \ + return ((__PIObject__*)__o__)->name(__VVALUE(a0, v0));} \ virtual ret name(a0 n0) #define EVENT_VHANDLER2(ret, name, a0, n0, a1, n1) \ EH_INIT2(ret, name, a0, n0, a1, n1) \ - static ret __stat_eh_##name##__(void * __o__, a0 n0, a1 n1) {return ((__PIObject__*)__o__)->name(n0, n1);} \ - static ret __stat_eh_v_##name##__(void * __o__, const PIVariantSimple & v0, const PIVariantSimple & v1) {return ((__PIObject__*)__o__)->name(__VVALUE(a0, v0), __VVALUE(a1, v1));} \ + static ret __stat_eh_##name##__(void * __o__, a0 n0, a1 n1) { \ + return ((__PIObject__*)__o__)->name(n0, n1);} \ + static ret __stat_eh_v_##name##__(void * __o__, const PIVariantSimple & v0, const PIVariantSimple & v1) { \ + return ((__PIObject__*)__o__)->name(__VVALUE(a0, v0), __VVALUE(a1, v1));} \ virtual ret name(a0 n0, a1 n1) #define EVENT_VHANDLER3(ret, name, a0, n0, a1, n1, a2, n2) \ EH_INIT3(ret, name, a0, n0, a1, n1, a2, n2) \ - static ret __stat_eh_##name##__(void * __o__, a0 n0, a1 n1, a2 n2) {return ((__PIObject__*)__o__)->name(n0, n1, n2);} \ - static ret __stat_eh_v_##name##__(void * __o__, const PIVariantSimple & v0, const PIVariantSimple & v1, const PIVariantSimple & v2) {return ((__PIObject__*)__o__)->name(__VVALUE(a0, v0), __VVALUE(a1, v1), __VVALUE(a2, v2));} \ + static ret __stat_eh_##name##__(void * __o__, a0 n0, a1 n1, a2 n2) { \ + return ((__PIObject__*)__o__)->name(n0, n1, n2);} \ + static ret __stat_eh_v_##name##__(void * __o__, const PIVariantSimple & v0, const PIVariantSimple & v1, const PIVariantSimple & v2) { \ + return ((__PIObject__*)__o__)->name(__VVALUE(a0, v0), __VVALUE(a1, v1), __VVALUE(a2, v2));} \ virtual ret name(a0 n0, a1 n1, a2 n2) #define EVENT_VHANDLER4(ret, name, a0, n0, a1, n1, a2, n2, a3, n3) \ EH_INIT4(ret, name, a0, n0, a1, n1, a2, n2, a3, n3) \ - static ret __stat_eh_##name##__(void * __o__, a0 n0, a1 n1, a2 n2, a3 n3) {return ((__PIObject__*)__o__)->name(n0, n1, n2, n3);} \ - static ret __stat_eh_v_##name##__(void * __o__, const PIVariantSimple & v0, const PIVariantSimple & v1, const PIVariantSimple & v2, const PIVariantSimple & v3) {return ((__PIObject__*)__o__)->name(__VVALUE(a0, v0), __VVALUE(a1, v1), __VVALUE(a2, v2), __VVALUE(a3, v3));} \ + static ret __stat_eh_##name##__(void * __o__, a0 n0, a1 n1, a2 n2, a3 n3) { \ + return ((__PIObject__*)__o__)->name(n0, n1, n2, n3);} \ + static ret __stat_eh_v_##name##__(void * __o__, const PIVariantSimple & v0, const PIVariantSimple & v1, const PIVariantSimple & v2, const PIVariantSimple & v3) { \ + return ((__PIObject__*)__o__)->name(__VVALUE(a0, v0), __VVALUE(a1, v1), __VVALUE(a2, v2), __VVALUE(a3, v3));} \ virtual ret name(a0 n0, a1 n1, a2 n2, a3 n3) #define EVENT_VHANDLER EVENT_VHANDLER0 -#define EVENT0(name) EVENT_HANDLER0(void, name) {static uint eid = PIStringAscii(#name).hash(); PIObject::raiseEvent(this, eid);} -#define EVENT1(name, a0, n0) EVENT_HANDLER1(void, name, a0, n0) {static uint eid = PIStringAscii(#name).hash(); PIObject::raiseEvent(this, eid, n0);} -#define EVENT2(name, a0, n0, a1, n1) EVENT_HANDLER2(void, name, a0, n0, a1, n1) {static uint eid = PIStringAscii(#name).hash(); PIObject::raiseEvent(this, eid, n0, n1);} -#define EVENT3(name, a0, n0, a1, n1, a2, n2) EVENT_HANDLER3(void, name, a0, n0, a1, n1, a2, n2) {static uint eid = PIStringAscii(#name).hash(); PIObject::raiseEvent(this, eid, n0, n1, n2);} -#define EVENT4(name, a0, n0, a1, n1, a2, n2, a3, n3) EVENT_HANDLER4(void, name, a0, n0, a1, n1, a2, n2, a3, n3) {static uint eid = PIStringAscii(#name).hash(); PIObject::raiseEvent(this, eid, n0, n1, n2, n3);} +#define EVENT0(name) EVENT_HANDLER0(void, name) { \ + static uint eid = PIStringAscii(#name).hash(); PIObject::raiseEvent(this, eid);} + +#define EVENT1(name, a0, n0) EVENT_HANDLER1(void, name, a0, n0) { \ + static uint eid = PIStringAscii(#name).hash(); PIObject::raiseEvent(this, eid, n0);} + +#define EVENT2(name, a0, n0, a1, n1) EVENT_HANDLER2(void, name, a0, n0, a1, n1) { \ + static uint eid = PIStringAscii(#name).hash(); PIObject::raiseEvent(this, eid, n0, n1);} + +#define EVENT3(name, a0, n0, a1, n1, a2, n2) EVENT_HANDLER3(void, name, a0, n0, a1, n1, a2, n2) { \ + static uint eid = PIStringAscii(#name).hash(); PIObject::raiseEvent(this, eid, n0, n1, n2);} + +#define EVENT4(name, a0, n0, a1, n1, a2, n2, a3, n3) EVENT_HANDLER4(void, name, a0, n0, a1, n1, a2, n2, a3, n3) { \ + static uint eid = PIStringAscii(#name).hash(); PIObject::raiseEvent(this, eid, n0, n1, n2, n3);} + #define EVENT EVENT0 + #define RAISE_EVENT0(src, event) (src)->event(); #define RAISE_EVENT1(src, event, v0) (src)->event(v0); #define RAISE_EVENT2(src, event, v0, v1) (src)->event(v0, v1); @@ -429,35 +447,81 @@ #define RAISE_EVENT4(src, event, v0, v1, v2, v3) (src)->event(v0, v1, v2, v3); #define RAISE_EVENT RAISE_EVENT0 -#define CONNECTU(src, event, dest, handler) PIObject::piConnectU(src, PIStringAscii(#event), dest, dest, PIStringAscii(#handler), LOCATION); -#define CONNECTU_QUEUED(src, event, dest, handler, performer) PIObject::piConnectU(src, PIStringAscii(#event), dest, dest, PIStringAscii(#handler), LOCATION, performer); -#define CONNECTL(src, event, functor) PIObject::piConnectLS(src, PIStringAscii(#event), PIObject::__newFunctor(&(src)->__stat_eh_##event##__, functor), LOCATION); -#define CONNECT0(ret, src, event, dest, handler) PIObject::piConnect(src, PIStringAscii(#event), dest, dest, (void*)(ret(*)(void*))(&(dest)->__stat_eh_##handler##__), (void*)(void(*)(void*))(&(src)->__stat_eh_##event##__), 0, LOCATION); -#define CONNECT1(ret, a0, src, event, dest, handler) PIObject::piConnect(src, PIStringAscii(#event), dest, dest, (void*)(ret(*)(void*, a0))(&(dest)->__stat_eh_##handler##__), (void*)(void(*)(void*, a0))(&(src)->__stat_eh_##event##__), 1, LOCATION); -#define CONNECT2(ret, a0, a1, src, event, dest, handler) PIObject::piConnect(src, PIStringAscii(#event), dest, dest, (void*)(ret(*)(void*, a0, a1))(&(dest)->__stat_eh_##handler##__), (void*)(void(*)(void*, a0, a1))(&(src)->__stat_eh_##event##__), 2, LOCATION); -#define CONNECT3(ret, a0, a1, a2, src, event, dest, handler) PIObject::piConnect(src, PIStringAscii(#event), dest, dest, (void*)(ret(*)(void*, a0, a1, a2))(&(dest)->__stat_eh_##handler##__), (void*)(void(*)(void*, a0, a1, a2))(&(src)->__stat_eh_##event##__), 3, LOCATION); -#define CONNECT4(ret, a0, a1, a2, a3, src, event, dest, handler) PIObject::piConnect(src, PIStringAscii(#event), dest, dest, (void*)(ret(*)(void*, a0, a1, a2, a3))(&(dest)->__stat_eh_##handler##__), (void*)(void(*)(void*, a0, a1, a2, a3))(&(src)->__stat_eh_##event##__), 4, LOCATION); +#define CONNECTU(src, event, dest, handler) \ + PIObject::piConnectU(src, PIStringAscii(#event), dest, dest, PIStringAscii(#handler), LOCATION); + +#define CONNECTU_QUEUED(src, event, dest, handler, performer) \ + PIObject::piConnectU(src, PIStringAscii(#event), dest, dest, PIStringAscii(#handler), LOCATION, performer); + +#define CONNECTL(src, event, functor) \ + PIObject::piConnectLS(src, PIStringAscii(#event), PIObject::__newFunctor(&(src)->__stat_eh_##event##__, functor), LOCATION); + + +#define CONNECT0(ret, src, event, dest, handler) \ + PIObject::piConnect(src, PIStringAscii(#event), dest, dest, (void*)(ret(*)(void*))(&(dest)->__stat_eh_##handler##__), \ + (void*)(void(*)(void*))(&(src)->__stat_eh_##event##__), 0, LOCATION); + +#define CONNECT1(ret, a0, src, event, dest, handler) \ + PIObject::piConnect(src, PIStringAscii(#event), dest, dest, (void*)(ret(*)(void*, a0))(&(dest)->__stat_eh_##handler##__), \ + (void*)(void(*)(void*, a0))(&(src)->__stat_eh_##event##__), 1, LOCATION); + +#define CONNECT2(ret, a0, a1, src, event, dest, handler) \ + PIObject::piConnect(src, PIStringAscii(#event), dest, dest, (void*)(ret(*)(void*, a0, a1))(&(dest)->__stat_eh_##handler##__), \ + (void*)(void(*)(void*, a0, a1))(&(src)->__stat_eh_##event##__), 2, LOCATION); + +#define CONNECT3(ret, a0, a1, a2, src, event, dest, handler) \ + PIObject::piConnect(src, PIStringAscii(#event), dest, dest, (void*)(ret(*)(void*, a0, a1, a2))(&(dest)->__stat_eh_##handler##__), \ + (void*)(void(*)(void*, a0, a1, a2))(&(src)->__stat_eh_##event##__), 3, LOCATION); + +#define CONNECT4(ret, a0, a1, a2, a3, src, event, dest, handler) \ + PIObject::piConnect(src, PIStringAscii(#event), dest, dest, (void*)(ret(*)(void*, a0, a1, a2, a3))(&(dest)->__stat_eh_##handler##__), \ + (void*)(void(*)(void*, a0, a1, a2, a3))(&(src)->__stat_eh_##event##__), 4, LOCATION); + #define CONNECT CONNECT0 -#define WEAK_CONNECT0(ret, src, event, dest, handler) PIObject::piConnect(src, PIStringAscii(#event), dest, dest, (void*)(ret(*)(void*))(&(dest)->__stat_eh_##handler##__), 0, 0, LOCATION); -#define WEAK_CONNECT1(ret, a0, src, event, dest, handler) PIObject::piConnect(src, PIStringAscii(#event), dest, dest, (void*)(ret(*)(void*, a0))(&(dest)->__stat_eh_##handler##__), 0, 1, LOCATION); -#define WEAK_CONNECT2(ret, a0, a1, src, event, dest, handler) PIObject::piConnect(src, PIStringAscii(#event), dest, dest, (void*)(ret(*)(void*, a0, a1))(&(dest)->__stat_eh_##handler##__), 0, 2, LOCATION); -#define WEAK_CONNECT3(ret, a0, a1, a2, src, event, dest, handler) PIObject::piConnect(src, PIStringAscii(#event), dest, dest, (void*)(ret(*)(void*, a0, a1, a2))(&(dest)->__stat_eh_##handler##__), 0, 3, LOCATION); -#define WEAK_CONNECT4(ret, a0, a1, a2, a3, src, event, dest, handler) PIObject::piConnect(src, PIStringAscii(#event), dest, dest, (void*)(ret(*)(void*, a0, a1, a2, a3))(&(dest)->__stat_eh_##handler##__), 0, 4, LOCATION); + +#define WEAK_CONNECT0(ret, src, event, dest, handler) \ + PIObject::piConnect(src, PIStringAscii(#event), dest, dest, (void*)(ret(*)(void*))(&(dest)->__stat_eh_##handler##__), 0, 0, LOCATION); + +#define WEAK_CONNECT1(ret, a0, src, event, dest, handler) \ + PIObject::piConnect(src, PIStringAscii(#event), dest, dest, (void*)(ret(*)(void*, a0))(&(dest)->__stat_eh_##handler##__), 0, 1, LOCATION); + +#define WEAK_CONNECT2(ret, a0, a1, src, event, dest, handler) \ + PIObject::piConnect(src, PIStringAscii(#event), dest, dest, (void*)(ret(*)(void*, a0, a1))(&(dest)->__stat_eh_##handler##__), 0, 2, LOCATION); + +#define WEAK_CONNECT3(ret, a0, a1, a2, src, event, dest, handler) \ + PIObject::piConnect(src, PIStringAscii(#event), dest, dest, (void*)(ret(*)(void*, a0, a1, a2))(&(dest)->__stat_eh_##handler##__), 0, 3, LOCATION); + +#define WEAK_CONNECT4(ret, a0, a1, a2, a3, src, event, dest, handler) \ + PIObject::piConnect(src, PIStringAscii(#event), dest, dest, (void*)(ret(*)(void*, a0, a1, a2, a3))(&(dest)->__stat_eh_##handler##__), 0, 4, LOCATION); + #define WEAK_CONNECT WEAK_CONNECT0 -#define DISCONNECT0(ret, src, event, dest, handler) PIObject::piDisconnect(src, PIStringAscii(#event), dest, (void*)(ret(*)(void*))(&(dest)->__stat_eh_##handler##__)); -#define DISCONNECT1(ret, a0, src, event, dest, handler) PIObject::piDisconnect(src, PIStringAscii(#event), dest, (void*)(ret(*)(void*, a0))(&(dest)->__stat_eh_##handler##__)); -#define DISCONNECT2(ret, a0, a1, src, event, dest, handler) PIObject::piDisconnect(src, PIStringAscii(#event), dest, (void*)(ret(*)(void*, a0, a1))(&(dest)->__stat_eh_##handler##__)); -#define DISCONNECT3(ret, a0, a1, a2, src, event, dest, handler) PIObject::piDisconnect(src, PIStringAscii(#event), dest, (void*)(ret(*)(void*, a0, a1, a2))(&(dest)->__stat_eh_##handler##__)); -#define DISCONNECT4(ret, a0, a1, a2, a3, src, event, dest, handler) PIObject::piDisconnect(src, PIStringAscii(#event), dest, (void*)(ret(*)(void*, a0, a1, a2, a3))(&(dest)->__stat_eh_##handler##__)); + +#define DISCONNECT0(ret, src, event, dest, handler) \ + PIObject::piDisconnect(src, PIStringAscii(#event), dest, (void*)(ret(*)(void*))(&(dest)->__stat_eh_##handler##__)); + +#define DISCONNECT1(ret, a0, src, event, dest, handler) \ + PIObject::piDisconnect(src, PIStringAscii(#event), dest, (void*)(ret(*)(void*, a0))(&(dest)->__stat_eh_##handler##__)); + +#define DISCONNECT2(ret, a0, a1, src, event, dest, handler) \ + PIObject::piDisconnect(src, PIStringAscii(#event), dest, (void*)(ret(*)(void*, a0, a1))(&(dest)->__stat_eh_##handler##__)); + +#define DISCONNECT3(ret, a0, a1, a2, src, event, dest, handler) \ + PIObject::piDisconnect(src, PIStringAscii(#event), dest, (void*)(ret(*)(void*, a0, a1, a2))(&(dest)->__stat_eh_##handler##__)); + +#define DISCONNECT4(ret, a0, a1, a2, a3, src, event, dest, handler) \ + PIObject::piDisconnect(src, PIStringAscii(#event), dest, (void*)(ret(*)(void*, a0, a1, a2, a3))(&(dest)->__stat_eh_##handler##__)); + #define DISCONNECT DISCONNECT0 + #define HANDLER(handler) __stat_eh_##handler##__ #define __PIOBJECT_SIGNATURE__ 0xabcdbadc + #endif diff --git a/libs/main/core/pistring_std.h b/libs/main/core/pistring_std.h index 8d1d05e1..909c5348 100644 --- a/libs/main/core/pistring_std.h +++ b/libs/main/core/pistring_std.h @@ -1,5 +1,5 @@ -/*! \file pistring.h - * \brief String +/*! \file pistring_std.h + * \brief STD for PIString * * This file declare std operators and string conversions */ @@ -23,11 +23,12 @@ */ #ifndef PISTRING_STD_H #define PISTRING_STD_H + + #include #ifdef QNX typedef std::basic_string wstring; #endif - #include "pistringlist.h" @@ -97,4 +98,5 @@ inline std::ostream & operator <<(std::ostream & s, const PIStringList & v) { return s; } + #endif // PISTRING_STD_H diff --git a/libs/main/math/pimathbase.h b/libs/main/math/pimathbase.h index d270c619..ee845dd8 100644 --- a/libs/main/math/pimathbase.h +++ b/libs/main/math/pimathbase.h @@ -95,8 +95,9 @@ const double deg2rad = M_PI_180; const double rad2deg = M_180_PI; -inline int sign(const float & x) {return (x < 0.) ? -1 : (x > 0. ? 1 : 0);} -inline int sign(const double & x) {return (x < 0.) ? -1 : (x > 0. ? 1 : 0);} +inline int sign(const float & x) {return (x < 0.f) ? -1 : (x > 0.f ? 1 : 0);} +inline int sign(const double & x) {return (x < 0. ) ? -1 : (x > 0. ? 1 : 0);} +inline int sign(const ldouble & x) {return (x < 0.L) ? -1 : (x > 0.L ? 1 : 0);} inline int pow2(const int p) {return 1 << p;} inline double sinc(const double & v) {if (v == 0.) return 1.; double t = M_PI * v; return sin(t) / t;} @@ -107,15 +108,15 @@ PIP_EXPORT double piY0(const double & v); PIP_EXPORT double piY1(const double & v); PIP_EXPORT double piYn(int n, const double & v); -template inline constexpr T toDb(T val) {return T(10.) * std::log10(val);} -template inline constexpr T fromDb(T val) {return std::pow(T(10.), val / T(10.));} -inline constexpr float toRad(float deg) {return deg * M_PI_180;} -inline constexpr double toRad(double deg) {return deg * M_PI_180;} -inline constexpr long double toRad(long double deg) {return deg * M_PI_180;} -inline constexpr float toDeg(float rad) {return rad * M_180_PI;} -inline constexpr double toDeg(double rad) {return rad * M_180_PI;} -inline constexpr long double toDeg(long double rad) {return rad * M_180_PI;} +inline constexpr float toRad(float deg) {return deg * M_PI_180;} +inline constexpr double toRad(double deg) {return deg * M_PI_180;} +inline constexpr ldouble toRad(ldouble deg) {return deg * M_PI_180;} +inline constexpr float toDeg(float rad) {return rad * M_180_PI;} +inline constexpr double toDeg(double rad) {return rad * M_180_PI;} +inline constexpr ldouble toDeg(ldouble rad) {return rad * M_180_PI;} template inline constexpr T sqr(const T & v) {return v * v;} +template inline constexpr T toDb (T val) {return T(10.) * std::log10(val);} +template inline constexpr T fromDb(T val) {return std::pow(T(10.), val / T(10.));} // [-1 ; 1] PIP_EXPORT double randomd(); diff --git a/libs/main/math/pimathmatrix.h b/libs/main/math/pimathmatrix.h index 2d9dffd1..8f4304b0 100644 --- a/libs/main/math/pimathmatrix.h +++ b/libs/main/math/pimathmatrix.h @@ -809,7 +809,7 @@ public: * @return matrix type _CMatrix */ _CMatrix &swapRows(uint c0, uint c1) { - PIMM_FOR_R piSwap(_V2D::element(c0, i), _V2D::element(c1, i)); + PIMM_FOR_R piSwap(_V2D::element(c0, i), _V2D::element(c1, i)); return *this; }