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:
@@ -29,7 +29,7 @@ const uint PIBaseTransfer::signature = 0x54424950;
|
||||
|
||||
PIBaseTransfer::PIBaseTransfer()
|
||||
: crc(standardCRC_16())
|
||||
#ifndef PIP_NO_THREADS
|
||||
#ifdef PIP_HAS_THREADS
|
||||
, diag(false)
|
||||
#endif
|
||||
{
|
||||
@@ -44,7 +44,7 @@ PIBaseTransfer::PIBaseTransfer()
|
||||
send_queue = 0;
|
||||
send_up = 0;
|
||||
timeout_ = 10.;
|
||||
#ifndef PIP_NO_THREADS
|
||||
#ifdef PIP_HAS_THREADS
|
||||
diag.setDisconnectTimeout(PISystemTime::fromSeconds(timeout_ / 10.));
|
||||
diag.setName("PIBaseTransfer");
|
||||
diag.start(20_Hz);
|
||||
@@ -60,7 +60,7 @@ PIBaseTransfer::PIBaseTransfer()
|
||||
|
||||
|
||||
PIBaseTransfer::~PIBaseTransfer() {
|
||||
#ifndef PIP_NO_THREADS
|
||||
#ifdef PIP_HAS_THREADS
|
||||
diag.stopAndWait();
|
||||
#endif
|
||||
break_ = true;
|
||||
@@ -94,7 +94,7 @@ void PIBaseTransfer::setPause(bool pause_) {
|
||||
|
||||
void PIBaseTransfer::setTimeout(double sec) {
|
||||
timeout_ = sec;
|
||||
#ifndef PIP_NO_THREADS
|
||||
#ifdef PIP_HAS_THREADS
|
||||
diag.setDisconnectTimeout(PISystemTime::fromSeconds(sec));
|
||||
#endif
|
||||
}
|
||||
@@ -103,7 +103,7 @@ void PIBaseTransfer::setTimeout(double sec) {
|
||||
void PIBaseTransfer::received(PIByteArray data) {
|
||||
packet_header_size = sizeof(PacketHeader) + customHeader().size();
|
||||
if (data.size() < sizeof(PacketHeader)) {
|
||||
#ifndef PIP_NO_THREADS
|
||||
#ifdef PIP_HAS_THREADS
|
||||
diag.received(data.size(), false);
|
||||
#endif
|
||||
return;
|
||||
@@ -113,12 +113,12 @@ void PIBaseTransfer::received(PIByteArray data) {
|
||||
PacketType pt = (PacketType)h.type;
|
||||
if (!h.check_sig()) {
|
||||
piCoutObj << "invalid packet signature"_tr("PIBaseTransfer");
|
||||
#ifndef PIP_NO_THREADS
|
||||
#ifdef PIP_HAS_THREADS
|
||||
diag.received(data.size(), false);
|
||||
#endif
|
||||
return;
|
||||
} else
|
||||
#ifndef PIP_NO_THREADS
|
||||
#ifdef PIP_HAS_THREADS
|
||||
diag.received(data.size(), true);
|
||||
#endif
|
||||
// piCoutObj << "receive" << h.session_id << h.type << h.id;
|
||||
@@ -195,7 +195,9 @@ void PIBaseTransfer::received(PIByteArray data) {
|
||||
replies.resize(sr.packets + 1);
|
||||
replies.fill(pt_Unknown);
|
||||
pm_string.resize(replies.size(), '-');
|
||||
#ifdef PIP_HAS_THREADS
|
||||
diag.reset();
|
||||
#endif
|
||||
is_receiving = true;
|
||||
break_ = false;
|
||||
mutex_send.lock();
|
||||
@@ -277,7 +279,7 @@ void PIBaseTransfer::received(PIByteArray data) {
|
||||
return;
|
||||
}
|
||||
break;
|
||||
#ifndef PIP_NO_THREADS
|
||||
#ifdef PIP_HAS_THREADS
|
||||
#endif
|
||||
case pt_Pause:
|
||||
mutex_header.lock();
|
||||
@@ -309,7 +311,7 @@ bool PIBaseTransfer::send_process() {
|
||||
mutex_session.lock();
|
||||
packet_header_size = sizeof(PacketHeader) + customHeader().size();
|
||||
break_ = false;
|
||||
#ifndef PIP_NO_THREADS
|
||||
#ifdef PIP_HAS_THREADS
|
||||
diag.reset();
|
||||
#endif
|
||||
sendStarted();
|
||||
@@ -359,7 +361,7 @@ bool PIBaseTransfer::send_process() {
|
||||
}
|
||||
stm.reset();
|
||||
ba = build_packet(i);
|
||||
#ifndef PIP_NO_THREADS
|
||||
#ifdef PIP_HAS_THREADS
|
||||
diag.sended(ba.size_s());
|
||||
#endif
|
||||
sendRequest(ba);
|
||||
@@ -414,7 +416,7 @@ bool PIBaseTransfer::send_process() {
|
||||
continue;
|
||||
}
|
||||
ba = build_packet(chk - 1);
|
||||
#ifndef PIP_NO_THREADS
|
||||
#ifdef PIP_HAS_THREADS
|
||||
diag.sended(ba.size_s());
|
||||
#endif
|
||||
sendRequest(ba);
|
||||
@@ -521,7 +523,7 @@ void PIBaseTransfer::sendReply(PacketType reply) {
|
||||
header.type = reply;
|
||||
PIByteArray ba;
|
||||
ba << header;
|
||||
#ifndef PIP_NO_THREADS
|
||||
#ifdef PIP_HAS_THREADS
|
||||
if (is_sending || is_receiving) diag.sended(ba.size_s());
|
||||
#endif
|
||||
sendRequest(ba);
|
||||
@@ -542,7 +544,7 @@ bool PIBaseTransfer::getStartRequest() {
|
||||
state_string = "send request";
|
||||
PITimeMeasurer tm;
|
||||
while (tm.elapsed_s() < timeout_) {
|
||||
#ifndef PIP_NO_THREADS
|
||||
#ifdef PIP_HAS_THREADS
|
||||
diag.sended(ba.size_s());
|
||||
#endif
|
||||
sendRequest(ba);
|
||||
|
||||
Reference in New Issue
Block a user