refactor: rename PIP_NO_\* to PIP_HAS_\* with inverted logic
All feature flags now use positive naming (enabled by default): - PIP_HAS_FILESYSTEM, PIP_HAS_THREADS, PIP_HAS_SOCKET - PIP_HAS_PROCESS, PIP_HAS_DYNLIB, PIP_HAS_FFT, PIP_HAS_SERIAL Preprocessor guards inverted: - #ifndef PIP_NO_X → #ifdef PIP_HAS_X - #ifdef PIP_NO_X → #ifndef PIP_HAS_X CMake options default ON instead of OFF. Platform blocks set flags OFF to disable features. 85 files transformed via Python script + 2 manual fixes.
This commit is contained in:
@@ -709,7 +709,7 @@ void PICout::applyFormat(PICoutFormat f) {
|
||||
}
|
||||
|
||||
|
||||
#ifndef PIP_NO_THREADS
|
||||
#ifdef PIP_HAS_THREADS
|
||||
PIString PICout::getBuffer() {
|
||||
PIMutexLocker ml(PICout::__mutex__());
|
||||
PIString ret = PICout::__string__();
|
||||
@@ -729,7 +729,7 @@ void PICout::clearBuffer() {
|
||||
PIMutexLocker ml(PICout::__mutex__());
|
||||
PICout::__string__().clear();
|
||||
}
|
||||
#endif // PIP_NO_THREADS
|
||||
#endif // PIP_HAS_THREADS
|
||||
|
||||
|
||||
bool PICout::setOutputDevice(PICout::OutputDevice d, bool on) {
|
||||
|
||||
@@ -32,11 +32,11 @@
|
||||
#include "pibase.h"
|
||||
|
||||
// PIInit stub: enabled for embedded or when core features are missing
|
||||
#if defined(PIP_EMBEDDED) || (defined(PIP_NO_THREADS) && defined(PIP_NO_FILESYSTEM))
|
||||
#if defined(PIP_EMBEDDED) || (!defined(PIP_HAS_THREADS) && !defined(PIP_HAS_FILESYSTEM))
|
||||
# define _PIP_INIT_STUB_
|
||||
#endif
|
||||
|
||||
#ifndef PIP_NO_THREADS
|
||||
#ifdef PIP_HAS_THREADS
|
||||
|
||||
# include "piincludes.h"
|
||||
|
||||
@@ -127,5 +127,5 @@ private:
|
||||
};
|
||||
|
||||
|
||||
#endif // PIP_NO_THREADS
|
||||
#endif // PIP_HAS_THREADS
|
||||
#endif // PIINIT_H
|
||||
|
||||
+14
-14
@@ -22,7 +22,7 @@
|
||||
#include "piconditionvar.h"
|
||||
#include "pithread.h"
|
||||
#include "pitime.h"
|
||||
#ifndef PIP_NO_THREADS
|
||||
#ifdef PIP_HAS_THREADS
|
||||
# include "pifile.h"
|
||||
# include "piiostream.h"
|
||||
# include "pisysteminfo.h"
|
||||
@@ -176,11 +176,11 @@ PIObject::PIObject(const PIString & name): _signature_(__PIOBJECT_SIGNATURE__),
|
||||
in_event_cnt = 0;
|
||||
setName(name);
|
||||
setDebug(true);
|
||||
#ifndef PIP_NO_THREADS
|
||||
#ifdef PIP_HAS_THREADS
|
||||
mutexObjects().lock();
|
||||
#endif
|
||||
objects() << this;
|
||||
#ifndef PIP_NO_THREADS
|
||||
#ifdef PIP_HAS_THREADS
|
||||
mutexObjects().unlock();
|
||||
#endif
|
||||
// piCout << "new" << this;
|
||||
@@ -190,11 +190,11 @@ PIObject::PIObject(const PIString & name): _signature_(__PIOBJECT_SIGNATURE__),
|
||||
PIObject::~PIObject() {
|
||||
in_event_cnt = 0;
|
||||
// piCout << "delete" << this;
|
||||
#ifndef PIP_NO_THREADS
|
||||
#ifdef PIP_HAS_THREADS
|
||||
mutexObjects().lock();
|
||||
#endif
|
||||
objects().removeAll(this);
|
||||
#ifndef PIP_NO_THREADS
|
||||
#ifdef PIP_HAS_THREADS
|
||||
mutexObjects().unlock();
|
||||
#endif
|
||||
deleted(this);
|
||||
@@ -472,7 +472,7 @@ void PIObject::piDisconnect(PIObject * src, const PIString & sig) {
|
||||
src->connections.remove(i);
|
||||
i--;
|
||||
if (dest) {
|
||||
#if !defined(ANDROID) && !defined(MAC_OS) && !defined(PIP_NO_THREADS)
|
||||
#if !defined(ANDROID) && !defined(MAC_OS) && defined(PIP_HAS_THREADS)
|
||||
PIMutexLocker _mld(dest->mutex_connect, src != dest);
|
||||
#endif
|
||||
dest->updateConnectors();
|
||||
@@ -490,7 +490,7 @@ void PIObject::piDisconnectAll() {
|
||||
// piCout << "disconnect"<< src << o;
|
||||
if (!o || (o == this)) continue;
|
||||
if (!o->isPIObject()) continue;
|
||||
#if !defined(ANDROID) && !defined(MAC_OS) && !defined(PIP_NO_THREADS)
|
||||
#if !defined(ANDROID) && !defined(MAC_OS) && defined(PIP_HAS_THREADS)
|
||||
PIMutexLocker _mld(o->mutex_connect, this != o);
|
||||
#endif
|
||||
PIVector<Connection> & oc(o->connections);
|
||||
@@ -555,7 +555,7 @@ PIMap<uint, PIObject::__MetaData> & PIObject::__meta_data() {
|
||||
}
|
||||
|
||||
|
||||
#ifndef PIP_NO_THREADS
|
||||
#ifdef PIP_HAS_THREADS
|
||||
void PIObject::callQueuedEvents() {
|
||||
mutex_queue.lock();
|
||||
PIVector<__QueuedEvent> qe = events_queue;
|
||||
@@ -569,7 +569,7 @@ void PIObject::callQueuedEvents() {
|
||||
if (e.dest_o->thread_safe_) e.dest_o->mutex_.unlock();
|
||||
}
|
||||
}
|
||||
#endif // PIP_NO_THREADS
|
||||
#endif // PIP_HAS_THREADS
|
||||
|
||||
|
||||
//! \details
|
||||
@@ -580,11 +580,11 @@ void PIObject::callQueuedEvents() {
|
||||
//! При первом вызове стартует фоновый поток для удаления объектов.
|
||||
//! Каждый объект из очереди удаляется только когда выйдет из всех
|
||||
//! событий и обработок.
|
||||
#ifndef PIP_NO_THREADS
|
||||
#ifdef PIP_HAS_THREADS
|
||||
void PIObject::deleteLater() {
|
||||
Deleter::instance()->post(this);
|
||||
}
|
||||
#endif // PIP_NO_THREADS
|
||||
#endif // PIP_HAS_THREADS
|
||||
|
||||
|
||||
bool PIObject::findSuitableMethodV(const PIString & method, int args, int & ret_args, PIObject::__MetaFunc & ret) {
|
||||
@@ -744,7 +744,7 @@ void PIObject::dump(const PIString & line_prefix) const {
|
||||
}
|
||||
|
||||
|
||||
#ifndef PIP_NO_THREADS
|
||||
#ifdef PIP_HAS_THREADS
|
||||
void dumpApplication(bool with_objects) {
|
||||
PIMutexLocker _ml(PIObject::mutexObjects());
|
||||
// printf("dump application ...\n");
|
||||
@@ -847,7 +847,7 @@ bool PIObject::Connection::disconnect() const {
|
||||
return ret;
|
||||
}
|
||||
|
||||
#ifndef PIP_NO_THREADS
|
||||
#ifdef PIP_HAS_THREADS
|
||||
PRIVATE_DEFINITION_START(PIObject::Deleter)
|
||||
PIThread thread;
|
||||
PIConditionVariable cond_var;
|
||||
@@ -911,4 +911,4 @@ void PIObject::Deleter::deleteObject(PIObject * o) {
|
||||
}
|
||||
// piCout << "[Deleter] delete" << (uintptr_t)o << "done";
|
||||
}
|
||||
#endif // PIP_NO_THREADS
|
||||
#endif // PIP_HAS_THREADS
|
||||
|
||||
+15
-15
@@ -461,7 +461,7 @@ public:
|
||||
i.performer->postQueuedEvent(__QueuedEvent(i.slot, i.dest, i.dest_o, sender));
|
||||
} else {
|
||||
bool ts = sender->thread_safe_;
|
||||
#ifndef PIP_NO_THREADS
|
||||
#ifdef PIP_HAS_THREADS
|
||||
if (ts) i.dest_o->mutex_.lock();
|
||||
#endif
|
||||
i.dest_o->eventBegin();
|
||||
@@ -471,7 +471,7 @@ public:
|
||||
sender->eventEnd();
|
||||
if (i.dest_o->isPIObject()) {
|
||||
i.dest_o->emitter_ = 0;
|
||||
#ifndef PIP_NO_THREADS
|
||||
#ifdef PIP_HAS_THREADS
|
||||
if (ts) i.dest_o->mutex_.unlock();
|
||||
#endif
|
||||
i.dest_o->eventEnd();
|
||||
@@ -498,7 +498,7 @@ public:
|
||||
i.performer->postQueuedEvent(__QueuedEvent(i.slot, i.dest, i.dest_o, sender, vl));
|
||||
} else {
|
||||
bool ts = sender->thread_safe_;
|
||||
#ifndef PIP_NO_THREADS
|
||||
#ifdef PIP_HAS_THREADS
|
||||
if (ts) i.dest_o->mutex_.lock();
|
||||
#endif
|
||||
i.dest_o->eventBegin();
|
||||
@@ -511,7 +511,7 @@ public:
|
||||
sender->eventEnd();
|
||||
if (i.dest_o->isPIObject()) {
|
||||
i.dest_o->emitter_ = 0;
|
||||
#ifndef PIP_NO_THREADS
|
||||
#ifdef PIP_HAS_THREADS
|
||||
if (ts) i.dest_o->mutex_.unlock();
|
||||
#endif
|
||||
i.dest_o->eventEnd();
|
||||
@@ -538,7 +538,7 @@ public:
|
||||
i.performer->postQueuedEvent(__QueuedEvent(i.slot, i.dest, i.dest_o, sender, vl));
|
||||
} else {
|
||||
bool ts = sender->thread_safe_;
|
||||
#ifndef PIP_NO_THREADS
|
||||
#ifdef PIP_HAS_THREADS
|
||||
if (ts) i.dest_o->mutex_.lock();
|
||||
#endif
|
||||
i.dest_o->eventBegin();
|
||||
@@ -552,7 +552,7 @@ public:
|
||||
sender->eventEnd();
|
||||
if (i.dest_o->isPIObject()) {
|
||||
i.dest_o->emitter_ = 0;
|
||||
#ifndef PIP_NO_THREADS
|
||||
#ifdef PIP_HAS_THREADS
|
||||
if (ts) i.dest_o->mutex_.unlock();
|
||||
#endif
|
||||
i.dest_o->eventEnd();
|
||||
@@ -580,7 +580,7 @@ public:
|
||||
i.performer->postQueuedEvent(__QueuedEvent(i.slot, i.dest, i.dest_o, sender, vl));
|
||||
} else {
|
||||
bool ts = sender->thread_safe_;
|
||||
#ifndef PIP_NO_THREADS
|
||||
#ifdef PIP_HAS_THREADS
|
||||
if (ts) i.dest_o->mutex_.lock();
|
||||
#endif
|
||||
i.dest_o->eventBegin();
|
||||
@@ -595,7 +595,7 @@ public:
|
||||
sender->eventEnd();
|
||||
if (i.dest_o->isPIObject()) {
|
||||
i.dest_o->emitter_ = 0;
|
||||
#ifndef PIP_NO_THREADS
|
||||
#ifdef PIP_HAS_THREADS
|
||||
if (ts) i.dest_o->mutex_.unlock();
|
||||
#endif
|
||||
i.dest_o->eventEnd();
|
||||
@@ -629,7 +629,7 @@ public:
|
||||
i.performer->postQueuedEvent(__QueuedEvent(i.slot, i.dest, i.dest_o, sender, vl));
|
||||
} else {
|
||||
bool ts = sender->thread_safe_;
|
||||
#ifndef PIP_NO_THREADS
|
||||
#ifdef PIP_HAS_THREADS
|
||||
if (ts) i.dest_o->mutex_.lock();
|
||||
#endif
|
||||
i.dest_o->eventBegin();
|
||||
@@ -645,7 +645,7 @@ public:
|
||||
sender->eventEnd();
|
||||
if (i.dest_o->isPIObject()) {
|
||||
i.dest_o->emitter_ = 0;
|
||||
#ifndef PIP_NO_THREADS
|
||||
#ifdef PIP_HAS_THREADS
|
||||
if (ts) i.dest_o->mutex_.unlock();
|
||||
#endif
|
||||
i.dest_o->eventEnd();
|
||||
@@ -658,7 +658,7 @@ public:
|
||||
|
||||
//! \~english Returns the first live object with name "name", or \c nullptr.
|
||||
//! \~russian Возвращает первый живой объект с именем "name", либо \c nullptr.
|
||||
#ifndef PIP_NO_THREADS
|
||||
#ifdef PIP_HAS_THREADS
|
||||
static PIObject * findByName(const PIString & name) {
|
||||
PIMutexLocker _ml(mutexObjects());
|
||||
for (auto * i: PIObject::objects()) {
|
||||
@@ -675,7 +675,7 @@ public:
|
||||
|
||||
//! \~english Returns whether this object belongs to class "T" or one of its registered descendants.
|
||||
//! \~russian Возвращает, принадлежит ли этот объект классу "T" или одному из его зарегистрированных потомков.
|
||||
#ifndef PIP_NO_THREADS
|
||||
#ifdef PIP_HAS_THREADS
|
||||
template<typename T>
|
||||
bool isTypeOf() const {
|
||||
if (!isPIObject()) return false;
|
||||
@@ -820,7 +820,7 @@ private:
|
||||
PIVector<PIVariantSimple> values;
|
||||
};
|
||||
|
||||
#ifndef PIP_NO_THREADS
|
||||
#ifdef PIP_HAS_THREADS
|
||||
class Deleter {
|
||||
public:
|
||||
Deleter();
|
||||
@@ -859,7 +859,7 @@ private:
|
||||
PIObject * emitter_;
|
||||
std::atomic_int in_event_cnt;
|
||||
|
||||
#ifndef PIP_NO_THREADS
|
||||
#ifdef PIP_HAS_THREADS
|
||||
PIMutex mutex_, mutex_connect, mutex_queue;
|
||||
bool thread_safe_, proc_event_queue;
|
||||
#else
|
||||
@@ -868,7 +868,7 @@ private:
|
||||
#endif
|
||||
};
|
||||
|
||||
#ifndef PIP_NO_THREADS
|
||||
#ifdef PIP_HAS_THREADS
|
||||
|
||||
//! \~english Dumps application-level %PIObject diagnostics.
|
||||
//! \~russian Выводит диагностическую информацию уровня приложения для %PIObject.
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
*/
|
||||
|
||||
#include "piwaitevent_p.h"
|
||||
#ifndef PIP_NO_THREADS
|
||||
#ifdef PIP_HAS_THREADS
|
||||
# ifdef WINDOWS
|
||||
// # ifdef _WIN32_WINNT
|
||||
// # undef _WIN32_WINNT
|
||||
@@ -154,4 +154,4 @@ void * PIWaitEvent::getEvent() const {
|
||||
# endif
|
||||
}
|
||||
|
||||
#endif // PIP_NO_THREADS
|
||||
#endif // PIP_HAS_THREADS
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
#ifndef PIWAITEVENT_P_H
|
||||
#define PIWAITEVENT_P_H
|
||||
|
||||
#ifndef PIP_NO_THREADS
|
||||
#ifdef PIP_HAS_THREADS
|
||||
|
||||
# include "pibase.h"
|
||||
// clang-format off
|
||||
@@ -67,5 +67,5 @@ private:
|
||||
};
|
||||
|
||||
|
||||
#endif // PIP_NO_THREADS
|
||||
#endif // PIP_HAS_THREADS
|
||||
#endif // PIWAITEVENT_P_H
|
||||
|
||||
Reference in New Issue
Block a user