diff --git a/lib/main/console/pikbdlistener.h b/lib/main/console/pikbdlistener.h index 8da6553c..5ea90cd6 100644 --- a/lib/main/console/pikbdlistener.h +++ b/lib/main/console/pikbdlistener.h @@ -133,11 +133,7 @@ public: bool direction; }; -#ifdef PIP_CXX11_SUPPORT typedef std::function KBFunc; -#else - typedef void (*KBFunc)(KeyEvent, void * ); -#endif //! Constructs keyboard listener with external function "slot" and custom data "data" explicit PIKbdListener(KBFunc slot = 0, void * data = 0, bool startNow = true); @@ -154,10 +150,8 @@ public: //! Set external function to "slot" void setSlot(KBFunc slot) {ret_func = slot;} -#ifdef PIP_CXX11_SUPPORT //! Set external function to "slot" void setSlot(std::function slot) {ret_func = [slot](KeyEvent e, void *){slot(e);};} -#endif //! Returns if exit key if awaiting bool exitCaptured() const {return exit_enabled;} diff --git a/lib/main/containers/pideque.h b/lib/main/containers/pideque.h index f9c24a15..d8c8de06 100644 --- a/lib/main/containers/pideque.h +++ b/lib/main/containers/pideque.h @@ -364,7 +364,6 @@ public: return ret; } -#ifdef PIP_CXX11_SUPPORT const PIDeque & forEach(std::function f) const { for (uint i = 0; i < pid_size; ++i) f(pid_data[i + pid_start]); @@ -388,7 +387,6 @@ public: ret << f(pid_data[i + pid_start]); return ret; } -#endif private: inline void _reset() {pid_size = pid_rsize = pid_start = 0; pid_data = 0;} diff --git a/lib/main/containers/pivector.h b/lib/main/containers/pivector.h index 2f4ae66e..d943af3d 100644 --- a/lib/main/containers/pivector.h +++ b/lib/main/containers/pivector.h @@ -358,7 +358,6 @@ public: return ret; } -#ifdef PIP_CXX11_SUPPORT const PIVector & forEach(std::function f) const { for (uint i = 0; i < piv_size; ++i) f(piv_data[i]); @@ -382,7 +381,6 @@ public: ret << f(piv_data[i]); return ret; } -#endif private: inline void _reset() {piv_size = piv_rsize = 0; piv_data = 0;} diff --git a/lib/main/core/piobject.cpp b/lib/main/core/piobject.cpp index 5d190f99..9d420f6f 100644 --- a/lib/main/core/piobject.cpp +++ b/lib/main/core/piobject.cpp @@ -313,7 +313,6 @@ bool PIObject::piConnectU(PIObject * src, const PIString & sig, PIObject * dest_ } -#ifdef PIP_CXX11_SUPPORT bool PIObject::piConnectLS(PIObject * src, const PIString & sig, std::function * f, const char * loc) { if (src == 0) { delete f; @@ -345,7 +344,6 @@ bool PIObject::piConnectLS(PIObject * src, const PIString & sig, std::function__stat_eh_##event##__, functor), LOCATION); -#endif +#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); @@ -499,21 +497,13 @@ class PIP_EXPORT PIObject { typedef void __Parent__; friend class PIIntrospection; public: - + NO_COPY_CLASS(PIObject) + //! Contructs PIObject with name "name" explicit PIObject(const PIString & name = PIString()); virtual ~PIObject(); -#ifdef PIP_CXX11_SUPPORT - explicit PIObject(const PIObject & ) = delete; - void operator =(const PIObject & ) = delete; -#else -private: - explicit PIObject(const PIObject & ); - void operator =(const PIObject & ); -#endif - private: uint _signature_; @@ -607,13 +597,11 @@ public: // / Direct connect static void piConnect(PIObject * src, const PIString & sig, PIObject * dest_o, void * dest, void * ev_h, void * e_h, int args, const char * loc); static bool piConnectU(PIObject * src, const PIString & sig, PIObject * dest_o, void * dest, const PIString & hname, const char * loc, PIObject * performer = 0); -#ifdef PIP_CXX11_SUPPORT static bool piConnectLS(PIObject * src, const PIString & sig, std::function * f, const char * loc); template static std::function * __newFunctor(void(*stat_handler)(void*,TYPES...), INPUT functor) { return (std::function*)(new std::function(functor)); } -#endif // / Through names and mixed static void piConnect(const PIString & src, const PIString & sig, void * dest, void * ev_h); @@ -635,11 +623,9 @@ public: for (int j = 0; j < sender->connections.size_s(); ++j) { __Connection i(sender->connections[j]); if (i.eventID != eventID) continue; -#ifdef PIP_CXX11_SUPPORT if (i.functor) { (*(i.functor))(); } else { -#endif if (i.performer) { i.performer->postQueuedEvent(__QueuedEvent(i.slot, i.dest, i.dest_o, sender)); } else { @@ -652,9 +638,7 @@ public: if (ts) i.dest_o->mutex_.unlock(); } } -#ifdef PIP_CXX11_SUPPORT } -#endif if (!sender->isPIObject()) break; } } @@ -664,11 +648,9 @@ public: for (int j = 0; j < sender->connections.size_s(); ++j) { __Connection i(sender->connections[j]); if (i.eventID != eventID) continue; -#ifdef PIP_CXX11_SUPPORT if (i.functor) { (*((std::function*)i.functor))(v0); } else { -#endif if (i.performer) { PIVector vl; if (i.args_count > 0) vl << PIVariant::fromValue(v0); @@ -684,9 +666,7 @@ public: if (ts) i.dest_o->mutex_.unlock(); } } -#ifdef PIP_CXX11_SUPPORT } -#endif if (!sender->isPIObject()) break; } } @@ -695,11 +675,9 @@ public: for (int j = 0; j < sender->connections.size_s(); ++j) { __Connection i(sender->connections[j]); if (i.eventID != eventID) continue; -#ifdef PIP_CXX11_SUPPORT if (i.functor) { (*((std::function*)i.functor))(v0, v1); } else { -#endif if (i.performer) { PIVector vl; if (i.args_count > 0) vl << PIVariant::fromValue(v0); @@ -719,9 +697,7 @@ public: if (ts) i.dest_o->mutex_.unlock(); } } -#ifdef PIP_CXX11_SUPPORT } -#endif if (!sender->isPIObject()) break; } } @@ -730,11 +706,9 @@ public: for (int j = 0; j < sender->connections.size_s(); ++j) { __Connection i(sender->connections[j]); if (i.eventID != eventID) continue; -#ifdef PIP_CXX11_SUPPORT if (i.functor) { (*((std::function*)i.functor))(v0, v1, v2); } else { -#endif if (i.performer) { PIVector vl; if (i.args_count > 0) vl << PIVariant::fromValue(v0); @@ -756,9 +730,7 @@ public: if (ts) i.dest_o->mutex_.unlock(); } } -#ifdef PIP_CXX11_SUPPORT } -#endif if (!sender->isPIObject()) break; } } @@ -767,11 +739,9 @@ public: for (int j = 0; j < sender->connections.size_s(); ++j) { __Connection i(sender->connections[j]); if (i.eventID != eventID) continue; -#ifdef PIP_CXX11_SUPPORT if (i.functor) { (*((std::function*)i.functor))(v0, v1, v2, v3); } else { -#endif if (i.performer) { PIVector vl; if (i.args_count > 0) vl << PIVariant::fromValue(v0); @@ -795,9 +765,7 @@ public: if (ts) i.dest_o->mutex_.unlock(); } } -#ifdef PIP_CXX11_SUPPORT } -#endif if (!sender->isPIObject()) break; } } @@ -897,16 +865,12 @@ private: dest = d; args_count = ac; performer = p; -#ifdef PIP_CXX11_SUPPORT functor = 0; -#endif } void destroy(); void * slot; void * signal; -#ifdef PIP_CXX11_SUPPORT std::function * functor; -#endif PIString event; uint eventID; PIObject * dest_o; diff --git a/lib/main/math/pimathcomplex.h b/lib/main/math/pimathcomplex.h index 4c1ffe1b..2bcc7fea 100644 --- a/lib/main/math/pimathcomplex.h +++ b/lib/main/math/pimathcomplex.h @@ -68,15 +68,10 @@ inline complexd sign(const complexd & x) {return complexd(sign(x.real()), sign(x inline complexd round(const complexd & c) {return complexd(piRound(c.real()), piRound(c.imag()));} inline complexd floor(const complexd & c) {return complexd(floor(c.real()), floor(c.imag()));} inline complexd ceil (const complexd & c) {return complexd(ceil(c.real()), ceil(c.imag()));} -#ifdef PIP_CXX11_SUPPORT -# define acosc acos -# define asinc asin -# define atanc atan -#else -inline complexd atanc(const complexd & c) {return complexd(0., 0.5) * log((complexd_1 - complexd_i * c) / (complexd_1 + complexd_i * c));} -inline complexd asinc(const complexd & c) {return -complexd_i * log(complexd_i * c + sqrt(complexd_1 - c * c));} -inline complexd acosc(const complexd & c) {return -complexd_i * log(c + complexd_i * sqrt(complexd_1 - c * c));} -#endif + +#define acosc acos +#define asinc asin +#define atanc atan #ifdef CC_GCC # if CC_GCC_VERSION <= 0x025F diff --git a/lib/main/piplatform.h b/lib/main/piplatform.h index 597520b8..73eebc88 100644 --- a/lib/main/piplatform.h +++ b/lib/main/piplatform.h @@ -20,10 +20,6 @@ #ifndef PIPLATFORM_H #define PIPLATFORM_H -#if (__cplusplus >= 201103L) // стандарт C++ 11 или выше - #define PIP_CXX11_SUPPORT -#endif - #if defined(WIN64) || defined(_WIN64) || defined(__WIN64__) # define WINDOWS # define ARCH_BITS_64 diff --git a/lib/main/thread/pithread.cpp b/lib/main/thread/pithread.cpp index 9fdd98eb..5ce598e8 100644 --- a/lib/main/thread/pithread.cpp +++ b/lib/main/thread/pithread.cpp @@ -184,7 +184,6 @@ PIThread::PIThread(void * data, ThreadFunc func, bool startNow, int timer_delay) } -#ifdef PIP_CXX11_SUPPORT PIThread::PIThread(std::function func, bool startNow, int timer_delay) { PIINTROSPECTION_THREAD_NEW(this); tid_ = -1; @@ -196,7 +195,6 @@ PIThread::PIThread(std::function func, bool startNow, int timer_delay) delay_ = timer_delay; if (startNow) start(timer_delay); } -#endif PIThread::PIThread(bool startNow, int timer_delay): PIObject() { diff --git a/lib/main/thread/pithread.h b/lib/main/thread/pithread.h index 2724f674..2e08aa68 100644 --- a/lib/main/thread/pithread.h +++ b/lib/main/thread/pithread.h @@ -60,11 +60,7 @@ public: static __PIThreadCollection_Initializer__ __PIThreadCollection_initializer__; -#ifdef PIP_CXX11_SUPPORT typedef std::function ThreadFunc; -#else -typedef void (*ThreadFunc)(void * ); -#endif class PIP_EXPORT PIThread: public PIObject { @@ -76,10 +72,8 @@ public: //! Contructs thread with custom data "data", external function "func" and main loop delay "loop_delay". PIThread(void * data, ThreadFunc func, bool startNow = false, int loop_delay = -1); -#ifdef PIP_CXX11_SUPPORT //! Contructs thread with external function "func" and main loop delay "loop_delay". PIThread(std::function func, bool startNow = false, int loop_delay = -1); -#endif //! Contructs thread with main loop delay "loop_delay". PIThread(bool startNow = false, int loop_delay = -1); @@ -99,10 +93,8 @@ public: EVENT_HANDLER1(bool, start, int, timer_delay); bool start(ThreadFunc func) {return start(func, -1);} bool start(ThreadFunc func, int timer_delay) {ret_func = func; return start(timer_delay);} -#ifdef PIP_CXX11_SUPPORT bool start(std::function func) {return start(func, -1);} bool start(std::function func, int timer_delay) {ret_func = [func](void*){func();}; return start(timer_delay);} -#endif EVENT_HANDLER0(bool, startOnce); EVENT_HANDLER1(bool, startOnce, ThreadFunc, func) {ret_func = func; return startOnce();} EVENT_HANDLER0(void, stop) {stop(false);} @@ -115,10 +107,8 @@ public: //! \brief Set external function that will be executed after every \a run() void setSlot(ThreadFunc func) {ret_func = func;} -#ifdef PIP_CXX11_SUPPORT //! \brief Set external function that will be executed after every \a run() void setSlot(std::function func) {ret_func = [func](void*){func();};} -#endif //! \brief Set priority of thread void setPriority(PIThread::Priority prior); @@ -161,11 +151,9 @@ public: //! and automatically delete it on function finish static void runOnce(PIObject * object, const char * handler, const PIString & name = PIString()); -#ifdef PIP_CXX11_SUPPORT //! \brief Start function \"func\" in separate thread with name \"name\" //! and automatically delete it on function finish static void runOnce(std::function func, const PIString & name = PIString()); -#endif //! \handlers //! \{ diff --git a/lib/main/thread/pitimer.cpp b/lib/main/thread/pitimer.cpp index f3a68a64..b2878f42 100644 --- a/lib/main/thread/pitimer.cpp +++ b/lib/main/thread/pitimer.cpp @@ -479,7 +479,6 @@ PITimer::PITimer(TimerEvent slot, void * data, PITimer::TimerImplementation ti): } -#ifdef PIP_CXX11_SUPPORT PITimer::PITimer(std::function slot, PITimer::TimerImplementation ti) { imp_mode = ti; initFirst(); @@ -493,7 +492,7 @@ PITimer::PITimer(std::function slot, void * data, PITimer::TimerI data_t = data; ret_func = [slot](void *d, int){slot(d);}; } -#endif + PITimer::~PITimer() { destroy(); diff --git a/lib/main/thread/pitimer.h b/lib/main/thread/pitimer.h index 7ffb9338..842af062 100644 --- a/lib/main/thread/pitimer.h +++ b/lib/main/thread/pitimer.h @@ -26,11 +26,7 @@ #include "pithread.h" #include "pitime.h" -#ifdef PIP_CXX11_SUPPORT typedef std::function TimerEvent; -#else -typedef void (*TimerEvent)(void *, int); -#endif class PITimer; @@ -97,13 +93,11 @@ public: //! \brief Constructs timer with "slot" slot void(void *,int), "data" data and "ti" implementation explicit PITimer(TimerEvent slot, void * data = 0, TimerImplementation ti = Thread); -#ifdef PIP_CXX11_SUPPORT //! \brief Constructs timer with "slot" slot void(), and "ti" implementation explicit PITimer(std::function slot, TimerImplementation ti = Thread); //! \brief Constructs timer with "slot" slot void(void *), "data" data and "ti" implementation explicit PITimer(std::function slot, void * data, TimerImplementation ti = Thread); -#endif virtual ~PITimer(); @@ -160,13 +154,11 @@ public: //! \brief Set timer tick function void setSlot(TimerEvent slot) {ret_func = slot;} -#ifdef PIP_CXX11_SUPPORT //! \brief Set timer tick function void setSlot(std::function slot) {ret_func = [slot](void *, int){slot();};} //! \brief Set timer tick function void setSlot(std::function slot) {ret_func = [slot](void *d, int){slot(d);};} -#endif //! \brief Returns common data passed to tick functions void * data() const {return data_t;} @@ -186,13 +178,11 @@ public: //! \brief Add frequency delimiter \b delim with optional delimiter slot \b slot. void addDelimiter(int delim, TimerEvent slot = 0) {delims << Delimiter(slot, delim);} -#ifdef PIP_CXX11_SUPPORT //! \brief Add frequency delimiter \b delim with optional delimiter slot \b slot. void addDelimiter(int delim, std::function slot) {delims << Delimiter([slot](void *, int){slot();}, delim);} //! \brief Add frequency delimiter \b delim with optional delimiter slot \b slot. void addDelimiter(int delim, std::function slot) {delims << Delimiter([slot](void *d, int){slot(d);}, delim);} -#endif //! \brief Remove all frequency delimiters \b delim. void removeDelimiter(int delim) {for (int i = 0; i < delims.size_s(); ++i) if (delims[i].delim == delim) {delims.remove(i); i--;}}