#15 убрать PIP_CXX11_SUPPORT

This commit is contained in:
2020-07-17 11:51:30 +03:00
parent 33a6382f4d
commit b772928dc1
11 changed files with 8 additions and 92 deletions

View File

@@ -133,11 +133,7 @@ public:
bool direction;
};
#ifdef PIP_CXX11_SUPPORT
typedef std::function<void(KeyEvent, void *)> 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<void(KeyEvent)> slot) {ret_func = [slot](KeyEvent e, void *){slot(e);};}
#endif
//! Returns if exit key if awaiting
bool exitCaptured() const {return exit_enabled;}

View File

@@ -364,7 +364,6 @@ public:
return ret;
}
#ifdef PIP_CXX11_SUPPORT
const PIDeque<T> & forEach(std::function<void(const T &)> 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;}

View File

@@ -358,7 +358,6 @@ public:
return ret;
}
#ifdef PIP_CXX11_SUPPORT
const PIVector<T> & forEach(std::function<void(const T &)> 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;}

View File

@@ -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<void()> * f, const char * loc) {
if (src == 0) {
delete f;
@@ -345,7 +344,6 @@ bool PIObject::piConnectLS(PIObject * src, const PIString & sig, std::function<v
//piCout << "finished";
return true;
}
#endif
void PIObject::piDisconnect(PIObject * src, const PIString & sig, PIObject * dest, void * ev_h) {
@@ -669,8 +667,6 @@ void PIObject::__MetaData::addScope(const PIString & s, uint shash) {
void PIObject::__Connection::destroy() {
#ifdef PIP_CXX11_SUPPORT
if (functor) delete functor;
functor = nullptr;
#endif
}

View File

@@ -459,9 +459,7 @@
#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);
#ifdef PIP_CXX11_SUPPORT
# define CONNECTL(src, event, functor) PIObject::piConnectLS(src, PIStringAscii(#event), PIObject::__newFunctor(&(src)->__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<void()> * f, const char * loc);
template <typename INPUT, typename... TYPES>
static std::function<void()> * __newFunctor(void(*stat_handler)(void*,TYPES...), INPUT functor) {
return (std::function<void()>*)(new std::function<void(TYPES...)>(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<void(T0)>*)i.functor))(v0);
} else {
#endif
if (i.performer) {
PIVector<PIVariant> 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<void(T0, T1)>*)i.functor))(v0, v1);
} else {
#endif
if (i.performer) {
PIVector<PIVariant> 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<void(T0, T1, T2)>*)i.functor))(v0, v1, v2);
} else {
#endif
if (i.performer) {
PIVector<PIVariant> 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<void(T0, T1, T2, T3)>*)i.functor))(v0, v1, v2, v3);
} else {
#endif
if (i.performer) {
PIVector<PIVariant> 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<void()> * functor;
#endif
PIString event;
uint eventID;
PIObject * dest_o;

View File

@@ -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<double>(c.real()), piRound<double>(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

View File

@@ -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

View File

@@ -184,7 +184,6 @@ PIThread::PIThread(void * data, ThreadFunc func, bool startNow, int timer_delay)
}
#ifdef PIP_CXX11_SUPPORT
PIThread::PIThread(std::function<void ()> func, bool startNow, int timer_delay) {
PIINTROSPECTION_THREAD_NEW(this);
tid_ = -1;
@@ -196,7 +195,6 @@ PIThread::PIThread(std::function<void ()> func, bool startNow, int timer_delay)
delay_ = timer_delay;
if (startNow) start(timer_delay);
}
#endif
PIThread::PIThread(bool startNow, int timer_delay): PIObject() {

View File

@@ -60,11 +60,7 @@ public:
static __PIThreadCollection_Initializer__ __PIThreadCollection_initializer__;
#ifdef PIP_CXX11_SUPPORT
typedef std::function<void(void *)> 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<void()> 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<void()> func) {return start(func, -1);}
bool start(std::function<void()> 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<void()> 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<void()> func, const PIString & name = PIString());
#endif
//! \handlers
//! \{

View File

@@ -479,7 +479,6 @@ PITimer::PITimer(TimerEvent slot, void * data, PITimer::TimerImplementation ti):
}
#ifdef PIP_CXX11_SUPPORT
PITimer::PITimer(std::function<void ()> slot, PITimer::TimerImplementation ti) {
imp_mode = ti;
initFirst();
@@ -493,7 +492,7 @@ PITimer::PITimer(std::function<void (void *)> slot, void * data, PITimer::TimerI
data_t = data;
ret_func = [slot](void *d, int){slot(d);};
}
#endif
PITimer::~PITimer() {
destroy();

View File

@@ -26,11 +26,7 @@
#include "pithread.h"
#include "pitime.h"
#ifdef PIP_CXX11_SUPPORT
typedef std::function<void(void *, int)> 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<void ()> slot, TimerImplementation ti = Thread);
//! \brief Constructs timer with "slot" slot void(void *), "data" data and "ti" implementation
explicit PITimer(std::function<void (void *)> 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<void ()> slot) {ret_func = [slot](void *, int){slot();};}
//! \brief Set timer tick function
void setSlot(std::function<void (void *)> 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<void ()> 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<void (void *)> 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--;}}