style: run clang-format over all files

This commit is contained in:
2026-08-22 15:52:58 +03:00
parent 8828aa3f81
commit f6075307b6
124 changed files with 1607 additions and 1737 deletions
+8 -2
View File
@@ -26,8 +26,14 @@ struct MyType {
PIString m_text;
};
inline PIByteArray & operator <<(PIByteArray & s, const MyType & v) {s << v.m_i << v.m_text; return s;}
inline PIByteArray & operator >>(PIByteArray & s, MyType & v) {s >> v.m_i >> v.m_text; return s;}
inline PIByteArray & operator<<(PIByteArray & s, const MyType & v) {
s << v.m_i << v.m_text;
return s;
}
inline PIByteArray & operator>>(PIByteArray & s, MyType & v) {
s >> v.m_i >> v.m_text;
return s;
}
PIByteArray ba;
PIVector<MyType> my_vec;
+1 -2
View File
@@ -3,5 +3,4 @@
//! [main]
//! [main]
void _() {
};
void _() {};
-2
View File
@@ -2,7 +2,6 @@
void _() {
//! [PIConfig::Entry]
/* "example.conf"
a = 1
@@ -23,5 +22,4 @@ PIConfig conf("example.conf", PIIODevice::ReadOnly);
piCout << conf.getValue("a.b.c").name(); // "c"
piCout << conf.getValue("a.b.c").fullName(); // "a.b.c"
//! [fullName]
};
+6 -5
View File
@@ -1,17 +1,19 @@
#include "pip.h"
void _() {
//! [foreach]
PIVector<int> vec;
vec << 1 << 2 << 3;
piForeach (int & i, vec) piCout << i;
piForeach(int & i, vec)
piCout << i;
// 1
// 2
// 3
piForeach (int & i, vec) i++;
piForeach (int & i, vec) piCout << i;
piForeach(int & i, vec)
i++;
piForeach(int & i, vec)
piCout << i;
// 2
// 3
// 4
@@ -209,5 +211,4 @@ vec << '1' << '2' << '3' << '4' << '5';
piCout << vec;
// {1, 2, 3, 4, 5}
//! [PIVector::PICout<<]
};
+5 -3
View File
@@ -1,6 +1,5 @@
#include "pip.h"
void _() {
//! [swap]
int v1 = 1, v2 = 2;
piCout << v1 << v2; // 1 2
@@ -45,11 +44,14 @@ piCout << piClampf(1, -3, 2); // 1
piCout << piClampf(5, -3, 2); // 2
//! [clamp]
//! [flags]
enum TestEnum {First = 0x1, Second = 0x2, Third = 0x4};
enum TestEnum {
First = 0x1,
Second = 0x2,
Third = 0x4
};
PIFlags<TestEnum> testFlags(First);
testFlags |= Third;
piCout << testFlags[First] << testFlags[Second] << testFlags[Third]; // 1 0 1
piCout << (int)testFlags; // 5
//! [flags]
};
+4 -7
View File
@@ -1,11 +1,12 @@
#include "pip.h"
void _() {
//! [0]
class SomeIO: public PIIODevice {
PIIODEVICE(SomeIO, "myio")
public:
SomeIO(): PIIODevice() {}
protected:
bool openDevice() override {
// open your device here
@@ -27,9 +28,7 @@ REGISTER_DEVICE(SomeIO)
//! [0]
//! [configure]
// file example.conf
dev.reopenEnabled = false
dev.device = /dev/ttyS0
dev.speed = 9600
dev.reopenEnabled = false dev.device = / dev / ttyS0 dev.speed = 9600
// end example.conf
// code
PISerial ser;
@@ -37,8 +36,7 @@ ser.configure("example.conf", "dev");
//! [configure]
//! [configureDevice]
class SomeIO: public PIIODevice {
...
bool configureDevice(const void * e_main, const void * e_parent) override {
... bool configureDevice(const void * e_main, const void * e_parent) override {
PIConfig::Entry * em = (PIConfig::Entry *)e_main;
PIConfig::Entry * ep = (PIConfig::Entry *)e_parent;
setStringParam(readDeviceSetting<PIString>("stringParam", stringParam(), em, ep));
@@ -48,5 +46,4 @@ class SomeIO: public PIIODevice {
...
};
//! [configureDevice]
};
+1 -2
View File
@@ -13,5 +13,4 @@ int main(int argc, char ** argv) {
}
//! [main]
void _() {
};
void _() {};
+2
View File
@@ -3,6 +3,7 @@
//! [main]
class ObjectA: public PIObject {
PIOBJECT(ObjectA)
public:
EVENT_HANDLER1(void, handlerA, const PIString &, str) { piCoutObj << "handler A:" << str; }
EVENT1(eventA1, const PIString &, str);
@@ -11,6 +12,7 @@ public:
class ObjectB: public PIObject {
PIOBJECT(ObjectB)
public:
EVENT_HANDLER2(void, handlerB, int, i, float, f) { piCoutObj << "handler B:" << i << "," << f; }
EVENT1(eventB, PIString, str);
+5 -1
View File
@@ -7,8 +7,11 @@ enum Header {
hVoid
};
class MyObj: public PIObject, public PIParseHelper<uchar> {
class MyObj
: public PIObject
, public PIParseHelper<uchar> {
PIOBJECT(MyObj);
public:
MyObj(): PIParseHelper<uchar>(this) {
// Keys with 1 argument
@@ -58,6 +61,7 @@ enum Header {
class MyObj: public PIObject {
PIOBJECT(MyObj);
public:
EVENT_HANDLER1(void, methodI, int, i) { piCout << "methodI" << i; }
EVENT_HANDLER1(void, methodS, PIString, s) { piCout << "methodS" << s; }
+10 -7
View File
@@ -1,10 +1,17 @@
//! [main]
#include "pip.h"
enum Mode {Start, Manual, Auto, Finish, End};
enum Mode {
Start,
Manual,
Auto,
Finish,
End
};
class Machine: public PIStateMachine<Mode> {
PIOBJECT_SUBCLASS(Machine, PIObject)
public:
Machine() {
addState(Start, "start", HANDLER(startFunc));
@@ -29,12 +36,8 @@ public:
CONNECT2(void, void *, int, &timer, timeout, this, tick);
timer.start(500);
}
virtual void execution(const State & state) {
piCout << "performed conditions:" << currentConditions();
}
virtual void transition(const State & from, const State & to) {
piCout << "switch from" << from.name << "to" << to.name << "state";
}
virtual void execution(const State & state) { piCout << "performed conditions:" << currentConditions(); }
virtual void transition(const State & from, const State & to) { piCout << "switch from" << from.name << "to" << to.name << "state"; }
EVENT_HANDLER(void, startFunc) { piCout << "start function"; }
EVENT_HANDLER(void, manualFunc) { piCout << "manual function"; }
+1 -2
View File
@@ -135,8 +135,7 @@ PIPair<PICloud::TCP::Type, PICloud::TCP::Role> PICloud::TCP::parseHeader(PIByteA
PICloud::TCP::Header hdr;
ba >> hdr;
if (hdr.version != header.version) {
piCout << "[PICloud]"
<< "Invalid PICloud::TCP version!"_tr("PICloud");
piCout << "[PICloud]" << "Invalid PICloud::TCP version!"_tr("PICloud");
return ret;
}
ret.first = (Type)hdr.type;
+3 -6
View File
@@ -40,8 +40,7 @@ PIByteArray piCompress(const PIByteArray & ba, int level) {
ulong sz = zba.size();
ret = compress2(zba.data(), &sz, ba.data(), ba.size(), level);
if (ret != Z_OK) {
piCout << "[PICompress]"
<< "Error: invalid input or not enought memory"_tr("PICompress");
piCout << "[PICompress]" << "Error: invalid input or not enought memory"_tr("PICompress");
return ba;
}
zba.resize(sz);
@@ -59,8 +58,7 @@ PIByteArray piDecompress(const PIByteArray & zba) {
#ifdef PIP_COMPRESS
ullong sz = 0;
if (zba.size() < sizeof(ullong)) {
piCout << "[PICompress]"
<< "Error: invalid input"_tr("PICompress");
piCout << "[PICompress]" << "Error: invalid input"_tr("PICompress");
return zba;
}
PIByteArray ba(zba.data(zba.size() - sizeof(ullong)), sizeof(ullong));
@@ -70,8 +68,7 @@ PIByteArray piDecompress(const PIByteArray & zba) {
ulong s = sz;
ret = uncompress(ba.data(), &s, zba.data(), zba.size() - sizeof(ullong));
if (ret != Z_OK) {
piCout << "[PICompress]"
<< "Error: invalid input or not enought memory"_tr("PICompress");
piCout << "[PICompress]" << "Error: invalid input or not enought memory"_tr("PICompress");
return zba;
}
return ba;
-2
View File
@@ -980,5 +980,3 @@ bool PITerminal::resize(int cols, int rows) {
}
#endif // PIP_HAS_PROCESS
+2 -5
View File
@@ -32,8 +32,7 @@ constexpr int hash_def_key_size = 9;
PICrypt::PICrypt() {
if (!init()) {
piCout << "[PICrypt]"
<< "Error while initialize sodium!"_tr("PICrypt");
piCout << "[PICrypt]" << "Error while initialize sodium!"_tr("PICrypt");
}
nonce_.resize(crypto_secretbox_NONCEBYTES);
key_.resize(crypto_secretbox_KEYBYTES);
@@ -183,9 +182,7 @@ ullong PICrypt::shorthash(const PIString & s, PIByteArray key) {
key.fill(0);
return hash;
}
if (crypto_shorthash_BYTES != sizeof(hash))
piCout << "[PICrypt]"
<< "internal error: bad hash size"_tr("PICrypt");
if (crypto_shorthash_BYTES != sizeof(hash)) piCout << "[PICrypt]" << "internal error: bad hash size"_tr("PICrypt");
if (key.size() != crypto_shorthash_KEYBYTES) {
piCout << "[PICrypt]"
<< "invalid key size %1, should be %2, filled with zeros"_tr("PICrypt").arg(key.size()).arg(crypto_shorthash_KEYBYTES);
+1 -3
View File
@@ -226,9 +226,7 @@ int answer_callback(void * cls,
m = Method::Patch;
if (m == Method::Unknown) {
piCout << "[MicrohttpdServer]"
<< "Warning:"
<< "Unknown method!";
piCout << "[MicrohttpdServer]" << "Warning:" << "Unknown method!";
return MHD_NO;
}
+1 -2
View File
@@ -89,8 +89,7 @@ void PIEthUtilBase::createCryptKey(const PIString & k) {
_key = PICrypt::hash("sodium_bug");
_key = PICrypt::hash(k);
# else
piCout << "[PIEthUtilBase]"
<< "PICrypt wasn`t built!"_tr("PIEthUtilBase");
piCout << "[PIEthUtilBase]" << "PICrypt wasn`t built!"_tr("PIEthUtilBase");
# endif
_crypt = true;
}
+2 -4
View File
@@ -296,10 +296,8 @@ private:
//! \~russian Оператор вывода в \a PICout
inline PICout operator<<(PICout s, const PISystemMonitor::ThreadStats & v) {
s.saveAndSetControls(0);
s << "ThreadInfo(\"" << v.name << "\", created " << v.created << ", work " << v.work_time.toMilliseconds() << " ms"
<< ", kernel " << v.kernel_time.toMilliseconds() << " ms"
<< ", user " << v.user_time.toMilliseconds() << " ms"
<< ")\n";
s << "ThreadInfo(\"" << v.name << "\", created " << v.created << ", work " << v.work_time.toMilliseconds() << " ms" << ", kernel "
<< v.kernel_time.toMilliseconds() << " ms" << ", user " << v.user_time.toMilliseconds() << " ms" << ")\n";
s.restoreControls();
return s;
}
@@ -89,8 +89,10 @@ public:
PIDiagnostics::State diagnostics() const;
//! \~english Returns how many payload bytes of the current packet are already received (all bytes count passed in \a receivePacketStart()).
//! \~russian Возвращает, сколько байтов полезной нагрузки текущего пакета уже получено (общее количество передается в \a receivePacketStart()).
//! \~english Returns how many payload bytes of the current packet are already received (all bytes count passed in \a
//! receivePacketStart()).
//! \~russian Возвращает, сколько байтов полезной нагрузки текущего пакета уже получено (общее количество передается в \a
//! receivePacketStart()).
int receivePacketProgress() const;
//! \~english Returns the current packet framing configuration.
+17 -108
View File
@@ -202,137 +202,46 @@ void PICodeParser::clear() {
defines << Define(PIStringAscii("PICODE"), "") << custom_defines;
macros << Macro(PIStringAscii("PIOBJECT"), "", PIStringList() << "name")
<< Macro(PIStringAscii("PIOBJECT_PARENT"), "", PIStringList() << "parent")
<< Macro(PIStringAscii("PIOBJECT_SUBCLASS"),
"",
PIStringList() << "name"
<< "parent")
<< Macro(PIStringAscii("PIOBJECT_SUBCLASS"), "", PIStringList() << "name" << "parent")
<< Macro(PIStringAscii("PIIODEVICE"), "", PIStringList() << "name")
<< Macro(PIStringAscii("NO_COPY_CLASS"), "", PIStringList() << "name") << Macro(PIStringAscii("PRIVATE_DECLARATION"))
<< Macro(PIStringAscii("EVENT"), "void name();", PIStringList() << "name")
<< Macro(PIStringAscii("EVENT0"), "void name();", PIStringList() << "name")
<< Macro(PIStringAscii("EVENT1"),
"void name(a0 n0);",
PIStringList() << "name"
<< "a0"
<< "n0")
<< Macro(PIStringAscii("EVENT2"),
"void name(a0 n0, a1 n1);",
PIStringList() << "name"
<< "a0"
<< "n0"
<< "a1"
<< "n1")
<< Macro(PIStringAscii("EVENT1"), "void name(a0 n0);", PIStringList() << "name" << "a0" << "n0")
<< Macro(PIStringAscii("EVENT2"), "void name(a0 n0, a1 n1);", PIStringList() << "name" << "a0" << "n0" << "a1" << "n1")
<< Macro(PIStringAscii("EVENT3"),
"void name(a0 n0, a1 n1, a2 n2);",
PIStringList() << "name"
<< "a0"
<< "n0"
<< "a1"
<< "n1"
<< "a2"
<< "n2")
PIStringList() << "name" << "a0" << "n0" << "a1" << "n1" << "a2" << "n2")
<< Macro(PIStringAscii("EVENT4"),
"void name(a0 n0, a1 n1, a2 n2, a3 n3);",
PIStringList() << "name"
<< "a0"
<< "n0"
<< "a1"
<< "n1"
<< "a2"
<< "n2"
<< "a3"
<< "n3")
PIStringList() << "name" << "a0" << "n0" << "a1" << "n1" << "a2" << "n2" << "a3" << "n3")
<< Macro(PIStringAscii("EVENT_HANDLER"),
"ret name()",
PIStringList() << "ret"
<< "name")
<< Macro(PIStringAscii("EVENT_HANDLER0"),
"ret name()",
PIStringList() << "ret"
<< "name")
<< Macro(PIStringAscii("EVENT_HANDLER1"),
"ret name(a0 n0)",
PIStringList() << "ret"
<< "name"
<< "a0"
<< "n0")
<< Macro(PIStringAscii("EVENT_HANDLER"), "ret name()", PIStringList() << "ret" << "name")
<< Macro(PIStringAscii("EVENT_HANDLER0"), "ret name()", PIStringList() << "ret" << "name")
<< Macro(PIStringAscii("EVENT_HANDLER1"), "ret name(a0 n0)", PIStringList() << "ret" << "name" << "a0" << "n0")
<< Macro(PIStringAscii("EVENT_HANDLER2"),
"ret name(a0 n0, a1 n1)",
PIStringList() << "ret"
<< "name"
<< "a0"
<< "n0"
<< "a1"
<< "n1")
PIStringList() << "ret" << "name" << "a0" << "n0" << "a1" << "n1")
<< Macro(PIStringAscii("EVENT_HANDLER3"),
"ret name(a0 n0, a1 n1, a2 n2)",
PIStringList() << "ret"
<< "name"
<< "a0"
<< "n0"
<< "a1"
<< "n1"
<< "a2"
<< "n2")
PIStringList() << "ret" << "name" << "a0" << "n0" << "a1" << "n1" << "a2" << "n2")
<< Macro(PIStringAscii("EVENT_HANDLER4"),
"ret name(a0 n0, a1 n1, a2 n2, a3 n3)",
PIStringList() << "ret"
<< "name"
<< "a0"
<< "n0"
<< "a1"
<< "n1"
<< "a2"
<< "n2"
<< "a3"
<< "n3")
PIStringList() << "ret" << "name" << "a0" << "n0" << "a1" << "n1" << "a2" << "n2" << "a3" << "n3")
<< Macro(PIStringAscii("EVENT_VHANDLER"),
"virtual ret name()",
PIStringList() << "ret"
<< "name")
<< Macro(PIStringAscii("EVENT_VHANDLER0"),
"virtual ret name()",
PIStringList() << "ret"
<< "name")
<< Macro(PIStringAscii("EVENT_VHANDLER1"),
"virtual ret name(a0 n0)",
PIStringList() << "ret"
<< "name"
<< "a0"
<< "n0")
<< Macro(PIStringAscii("EVENT_VHANDLER"), "virtual ret name()", PIStringList() << "ret" << "name")
<< Macro(PIStringAscii("EVENT_VHANDLER0"), "virtual ret name()", PIStringList() << "ret" << "name")
<< Macro(PIStringAscii("EVENT_VHANDLER1"), "virtual ret name(a0 n0)", PIStringList() << "ret" << "name" << "a0" << "n0")
<< Macro(PIStringAscii("EVENT_VHANDLER2"),
"virtual ret name(a0 n0, a1 n1)",
PIStringList() << "ret"
<< "name"
<< "a0"
<< "n0"
<< "a1"
<< "n1")
PIStringList() << "ret" << "name" << "a0" << "n0" << "a1" << "n1")
<< Macro(PIStringAscii("EVENT_VHANDLER3"),
"virtual ret name(a0 n0, a1 n1, a2 n2)",
PIStringList() << "ret"
<< "name"
<< "a0"
<< "n0"
<< "a1"
<< "n1"
<< "a2"
<< "n2")
PIStringList() << "ret" << "name" << "a0" << "n0" << "a1" << "n1" << "a2" << "n2")
<< Macro(PIStringAscii("EVENT_VHANDLER4"),
"virtual ret name(a0 n0, a1 n1, a2 n2, a3 n3)",
PIStringList() << "ret"
<< "name"
<< "a0"
<< "n0"
<< "a1"
<< "n1"
<< "a2"
<< "n2"
<< "a3"
<< "n3");
PIStringList() << "ret" << "name" << "a0" << "n0" << "a1" << "n1" << "a2" << "n2" << "a3" << "n3");
}
+4 -1
View File
@@ -1234,7 +1234,10 @@ public:
//! \~english The function can modify the elements.
//! \~russian Функция может изменять элементы.
//! \~\sa forEach (read-only), PIVector::forEach()
inline PIVector2D<T> & forEach(std::function<void(T &)> func) { mat.forEach(func); return *this; }
inline PIVector2D<T> & forEach(std::function<void(T &)> func) {
mat.forEach(func);
return *this;
}
//! \~english Applies a function to each element and returns a new 2D array of a different type.
//! \~russian Применяет функцию к каждому элементу и возвращает новый двумерный массив другого типа.
+1
View File
@@ -727,6 +727,7 @@ inline bool piDeleteSafety(T *& pointer) {
//! \~russian В данном примере будет выведен "Error!" при каждом \b false возврате из функции.
class PIP_EXPORT PIScopeExitCall {
NO_COPY_CLASS(PIScopeExitCall)
public:
//! \~\brief
//! \~english Constructor that takes a function to execute
-1
View File
@@ -33,7 +33,6 @@
#define PIMEMORYBLOCK_H
//! \~\brief
//! \~english Helper struct to store and restore custom blocks of data to/from PIBinaryStream
//! \~russian Вспомогательная структура для сохранения и извлечения произвольных блоков данных в/из PIBinaryStream
+1 -2
View File
@@ -126,8 +126,7 @@ bool PISPI::openDevice() {
PRIVATE->fd = -1;
return false;
}
piCoutObj << "SPI open" << path() << "speed:" << spi_speed / 1000 << "KHz"
<< "mode" << spi_mode << "bits" << spi_bits;
piCoutObj << "SPI open" << path() << "speed:" << spi_speed / 1000 << "KHz" << "mode" << spi_mode << "bits" << spi_bits;
PRIVATE->spi_ioc_tr.delay_usecs = 0;
PRIVATE->spi_ioc_tr.speed_hz = 0;
PRIVATE->spi_ioc_tr.bits_per_word = spi_bits;
+3 -1
View File
@@ -110,7 +110,9 @@
# define PIP_PLUGIN \
extern "C" { \
PIP_PLUGIN_EXPORT int __PIP_PLUGIN_LOADER_VERSION_FUNC__() { return __PIP_PLUGIN_LOADER_VERSION__; } \
PIP_PLUGIN_EXPORT int __PIP_PLUGIN_LOADER_VERSION_FUNC__() { \
return __PIP_PLUGIN_LOADER_VERSION__; \
} \
}
# define PIP_PLUGIN_STATIC_SECTION_MERGE \
+2 -4
View File
@@ -329,8 +329,7 @@ PISystemTime PITimeMeasurer::elapsedAndReset() {
PISystemTime PISystemTime::Frequency::toSystemTime() const {
if (value_hz <= 0.) {
piCout << "[PISystemTime::Frequency]"
<< "toSystemTime() Warning: invalid hertz: %1"_tr("PISystemTime").arg(value_hz);
piCout << "[PISystemTime::Frequency]" << "toSystemTime() Warning: invalid hertz: %1"_tr("PISystemTime").arg(value_hz);
return PISystemTime();
}
return PISystemTime::fromSeconds(1. / value_hz);
@@ -339,8 +338,7 @@ PISystemTime PISystemTime::Frequency::toSystemTime() const {
PISystemTime::Frequency PISystemTime::Frequency::fromSystemTime(const PISystemTime & st) {
if (st == PISystemTime()) {
piCout << "[PISystemTime::Frequency]"
<< "fromSystemTime() Warning: null frequency"_tr("PISystemTime");
piCout << "[PISystemTime::Frequency]" << "fromSystemTime() Warning: null frequency"_tr("PISystemTime");
return Frequency();
}
return Frequency(1. / st.toSeconds());
+10 -5
View File
@@ -165,11 +165,12 @@ public:
STATIC_INITIALIZER_BEGIN \
__PIVariantInfo__ * vi(__PIVariantInfoStorage__::get().value(__PIVariantFunctions__<classname_from>::typeIDHelper(), nullptr)); \
if (!vi) { \
piCout << "Warning! Using REGISTER_VARIANT_CAST(" #classname_from ", " #classname_to ") before REGISTER_VARIANT(" #classname_from \
"), ignore."; \
piCout << "Warning! Using REGISTER_VARIANT_CAST(" #classname_from ", " #classname_to \
") before REGISTER_VARIANT(" #classname_from "), ignore."; \
return; \
} \
vi->cast[__PIVariantFunctions__<classname_to>::typeIDHelper()] = __PIVariantFunctions__<classname_from>::castHelper<classname_to>; \
vi->cast[__PIVariantFunctions__<classname_to>::typeIDHelper()] = \
__PIVariantFunctions__<classname_from>::castHelper<classname_to>; \
STATIC_INITIALIZER_END \
template<> \
template<> \
@@ -181,10 +182,14 @@ public:
# define REGISTER_VARIANT_CAST_SIMPLE(classname_from, classname_to) \
REGISTER_VARIANT_CAST(classname_from, classname_to) { return classname_to(v); }
REGISTER_VARIANT_CAST(classname_from, classname_to) { \
return classname_to(v); \
}
# define REGISTER_VARIANT_CAST_SIMPLE_H(classname_from, classname_to) REGISTER_VARIANT_CAST_H(classname_from, classname_to)
# define REGISTER_VARIANT_CAST_SIMPLE_CPP(classname_from, classname_to) \
REGISTER_VARIANT_CAST_CPP(classname_from, classname_to) { return classname_to(v); }
REGISTER_VARIANT_CAST_CPP(classname_from, classname_to) { \
return classname_to(v); \
}
#else
+3 -1
View File
@@ -83,7 +83,9 @@
bool supportPrefixesSmaller(int type) const override; \
\
public: \
PIString className() const override { return piTr(#Name, "PIUnits"); } \
PIString className() const override { \
return piTr(#Name, "PIUnits"); \
} \
uint classID() const override { \
static uint ret = PIStringAscii(#Name).hash(); \
return ret; \
+28 -56
View File
@@ -89,8 +89,7 @@ void PIOpenCL::Initializer::init() {
cl_uint plat_num = 0;
ret = clGetPlatformIDs(max_size, cl_platforms, &plat_num);
if (ret != 0) {
piCout << "[PIOpenCL]"
<< "Error: OpenCL platforms not found!"_tr("PIOpenCL");
piCout << "[PIOpenCL]" << "Error: OpenCL platforms not found!"_tr("PIOpenCL");
return;
}
for (uint i = 0; i < plat_num; i++) {
@@ -205,14 +204,12 @@ PIOpenCL::Context * PIOpenCL::Context::create(const PIOpenCL::DeviceList & dl) {
cl_int ret = 0;
cl_context con = clCreateContext(0, cldl.size_s(), cldl.data(), 0, 0, &ret);
if (ret != 0) {
piCout << "[PIOpenCL::Context]"
<< "clCreateContext error" << ret;
piCout << "[PIOpenCL::Context]" << "clCreateContext error" << ret;
return 0;
}
cl_command_queue comq = clCreateCommandQueue(con, cldl[0], 0, &ret);
if (ret != 0) {
piCout << "[PIOpenCL::Context]"
<< "clCreateCommandQueue error" << ret;
piCout << "[PIOpenCL::Context]" << "clCreateCommandQueue error" << ret;
clReleaseContext(con);
return 0;
}
@@ -253,8 +250,7 @@ PIOpenCL::Program * PIOpenCL::Context::createProgram(const PIString & source, co
cl_int ret = 0;
cl_program prog = clCreateProgramWithSource(PRIVATE->context, 1, &csrc, &src_size, &ret);
if (ret != 0) {
piCout << "[PIOpenCL::Context]"
<< "clCreateProgramWithSource error" << ret;
piCout << "[PIOpenCL::Context]" << "clCreateProgramWithSource error" << ret;
if (error) (*error) += "clCreateProgramWithSource error " + PIString::fromNumber(ret);
return 0;
}
@@ -264,8 +260,7 @@ PIOpenCL::Program * PIOpenCL::Context::createProgram(const PIString & source, co
clGetProgramBuildInfo(prog, PRIVATE->devices[0], CL_PROGRAM_BUILD_LOG, sizeof(buffer), buffer, 0);
if (ret != 0) {
clReleaseProgram(prog);
piCout << "[PIOpenCL::Context]"
<< "clBuildProgram error" << ret; // << ":" << buffer;
piCout << "[PIOpenCL::Context]" << "clBuildProgram error" << ret; // << ":" << buffer;
if (error) (*error) = buffer;
return 0;
}
@@ -273,8 +268,7 @@ PIOpenCL::Program * PIOpenCL::Context::createProgram(const PIString & source, co
ret = clGetProgramInfo(prog, CL_PROGRAM_NUM_KERNELS, sizeof(uret), &uret, 0);
if (ret != 0) {
clReleaseProgram(prog);
piCout << "[PIOpenCL::Context]"
<< "clGetProgramInfo error" << ret;
piCout << "[PIOpenCL::Context]" << "clGetProgramInfo error" << ret;
if (error) (*error) = "Can`t retrieve CL_PROGRAM_NUM_KERNELS";
return 0;
}
@@ -283,8 +277,7 @@ PIOpenCL::Program * PIOpenCL::Context::createProgram(const PIString & source, co
ret = clGetProgramInfo(prog, CL_PROGRAM_KERNEL_NAMES, ccnt, knames, 0);
if (ret != 0) {
clReleaseProgram(prog);
piCout << "[PIOpenCL::Context]"
<< "clGetProgramInfo error" << ret;
piCout << "[PIOpenCL::Context]" << "clGetProgramInfo error" << ret;
if (error) (*error) = "Can`t retrieve CL_PROGRAM_KERNEL_NAMES";
return 0;
}
@@ -293,8 +286,7 @@ PIOpenCL::Program * PIOpenCL::Context::createProgram(const PIString & source, co
for (const auto & k: knl) {
cl_kernel kern = clCreateKernel(prog, k.dataAscii(), &ret);
if (ret != 0) {
piCout << "[PIOpenCL::Context]"
<< "clCreateKernel" << k << "error" << ret;
piCout << "[PIOpenCL::Context]" << "clCreateKernel" << k << "error" << ret;
if (error) (*error) += "clCreateKernel(\"" + k + "\") error " + ret;
for (auto * _k: kerns)
clReleaseKernel((cl_kernel)_k);
@@ -370,8 +362,7 @@ bool PIOpenCL::Buffer::init() {
}
PRIVATE->buffer = clCreateBuffer(context_->PRIVATEWB->context, f, elements * def.size(), container ? containerData() : 0, &ret);
if (ret != 0) {
piCout << "[PIOpenCL::Buffer]"
<< "clCreateBuffer error" << ret;
piCout << "[PIOpenCL::Buffer]" << "clCreateBuffer error" << ret;
return false;
}
return true;
@@ -396,8 +387,7 @@ void PIOpenCL::Buffer::clear() {
cl_int ret =
clEnqueueFillBuffer(context_->PRIVATEWB->queue, PRIVATE->buffer, def.data(), def.size_s(), 0, elements * def.size(), 0, 0, 0);
if (ret != 0) {
piCout << "[PIOpenCL::Buffer]"
<< "clEnqueueFillBuffer error" << ret;
piCout << "[PIOpenCL::Buffer]" << "clEnqueueFillBuffer error" << ret;
}
}
@@ -412,8 +402,7 @@ void PIOpenCL::Buffer::copyTo(void * data) {
if (!PRIVATE->buffer) return;
cl_int ret = clEnqueueReadBuffer(context_->PRIVATEWB->queue, PRIVATE->buffer, CL_TRUE, 0, elements * def.size(), data, 0, 0, 0);
if (ret != 0) {
piCout << "[PIOpenCL::Buffer]"
<< "clEnqueueReadBuffer error" << ret;
piCout << "[PIOpenCL::Buffer]" << "clEnqueueReadBuffer error" << ret;
}
}
@@ -430,8 +419,7 @@ void PIOpenCL::Buffer::copyTo(void * data, int elements_count, int elements_offs
0,
0);
if (ret != 0) {
piCout << "[PIOpenCL::Buffer]"
<< "clEnqueueReadBuffer error" << ret;
piCout << "[PIOpenCL::Buffer]" << "clEnqueueReadBuffer error" << ret;
}
}
@@ -451,8 +439,7 @@ void PIOpenCL::Buffer::copyFrom(void * data) {
if (!PRIVATE->buffer) return;
cl_int ret = clEnqueueWriteBuffer(context_->PRIVATEWB->queue, PRIVATE->buffer, CL_TRUE, 0, elements * def.size(), data, 0, 0, 0);
if (ret != 0) {
piCout << "[PIOpenCL::Buffer]"
<< "clEnqueueWriteBuffer error" << ret;
piCout << "[PIOpenCL::Buffer]" << "clEnqueueWriteBuffer error" << ret;
}
}
@@ -469,8 +456,7 @@ void PIOpenCL::Buffer::copyFrom(void * data, int elements_count, int elements_fr
0,
0);
if (ret != 0) {
piCout << "[PIOpenCL::Buffer]"
<< "clEnqueueWriteBuffer error" << ret;
piCout << "[PIOpenCL::Buffer]" << "clEnqueueWriteBuffer error" << ret;
}
}
@@ -498,8 +484,7 @@ void PIOpenCL::Buffer::copy(Buffer * buffer_from,
nullptr,
nullptr);
if (ret != 0) {
piCout << "[PIOpenCL::Buffer]"
<< "clEnqueueCopyBuffer error" << ret;
piCout << "[PIOpenCL::Buffer]" << "clEnqueueCopyBuffer error" << ret;
}
}
@@ -546,14 +531,12 @@ bool PIOpenCL::Program::initKernels(PIVector<void *> kerns) {
bool PIOpenCL::Kernel::execute() {
if (dims.isEmpty()) {
piCout << "[PIOpenCL::Kernel]"
<< "Error: empty range"_tr("PIOpenCL");
piCout << "[PIOpenCL::Kernel]" << "Error: empty range"_tr("PIOpenCL");
return false;
}
cl_int ret = clEnqueueNDRangeKernel(context_->PRIVATEWB->queue, PRIVATE->kernel, dims.size(), 0, dims.data(), 0, 0, 0, 0);
if (ret != 0) {
piCout << "[PIOpenCL::Kernel]"
<< "clEnqueueNDRangeKernel error" << ret;
piCout << "[PIOpenCL::Kernel]" << "clEnqueueNDRangeKernel error" << ret;
return false;
}
return true;
@@ -593,16 +576,14 @@ bool PIOpenCL::Kernel::init() {
cl_int ret = 0;
ret = clGetKernelInfo(PRIVATE->kernel, CL_KERNEL_FUNCTION_NAME, 1024, kname, 0);
if (ret != 0) {
piCout << "[PIOpenCL::Kernel]"
<< "clGetKernelInfo(CL_KERNEL_FUNCTION_NAME) error" << ret;
piCout << "[PIOpenCL::Kernel]" << "clGetKernelInfo(CL_KERNEL_FUNCTION_NAME) error" << ret;
return false;
}
name_ = kname;
cl_uint na = 0;
ret = clGetKernelInfo(PRIVATE->kernel, CL_KERNEL_NUM_ARGS, sizeof(na), &na, 0);
if (ret != 0) {
piCout << "[PIOpenCL::Kernel]"
<< "clGetKernelInfo(CL_KERNEL_NUM_ARGS) error" << ret;
piCout << "[PIOpenCL::Kernel]" << "clGetKernelInfo(CL_KERNEL_NUM_ARGS) error" << ret;
return false;
}
for (cl_uint i = 0; i < na; ++i) {
@@ -623,14 +604,12 @@ void setArgV(cl_kernel k, int index, T v) {
bool PIOpenCL::Kernel::setArgValueS(int index, const PIVariant & value) {
if (index < 0 || index >= args_.size_s()) {
piCout << "[PIOpenCL::Kernel]"
<< "setArgValue invalid index %1"_tr("PIOpenCL").arg(index);
piCout << "[PIOpenCL::Kernel]" << "setArgValue invalid index %1"_tr("PIOpenCL").arg(index);
return false;
}
KernelArg & ka(args_[index]);
if (ka.dims > 0) {
piCout << "[PIOpenCL::Kernel]"
<< "setArgValue set scalar to \"%1 %2\""_tr("PIOpenCL").arg(ka.type_name).arg(ka.arg_name);
piCout << "[PIOpenCL::Kernel]" << "setArgValue set scalar to \"%1 %2\""_tr("PIOpenCL").arg(ka.type_name).arg(ka.arg_name);
return false;
}
switch (ka.arg_type) {
@@ -653,14 +632,12 @@ bool PIOpenCL::Kernel::setArgValueS(int index, const PIVariant & value) {
bool PIOpenCL::Kernel::bindArgValue(int index, Buffer * buffer) {
if (!buffer) return false;
if (index < 0 || index >= args_.size_s()) {
piCout << "[PIOpenCL::Kernel]"
<< "bindArgValue invalid index %1"_tr("PIOpenCL").arg(index);
piCout << "[PIOpenCL::Kernel]" << "bindArgValue invalid index %1"_tr("PIOpenCL").arg(index);
return false;
}
KernelArg & ka(args_[index]);
if (ka.dims <= 0) {
piCout << "[PIOpenCL::Kernel]"
<< "bindArgValue set buffer to \"%1 %2\""_tr("PIOpenCL").arg(ka.type_name).arg(ka.arg_name);
piCout << "[PIOpenCL::Kernel]" << "bindArgValue set buffer to \"%1 %2\""_tr("PIOpenCL").arg(ka.type_name).arg(ka.arg_name);
return false;
}
clSetKernelArg(PRIVATE->kernel, index, sizeof(buffer->PRIVATEWB->buffer), &(buffer->PRIVATEWB->buffer));
@@ -699,22 +676,19 @@ void PIOpenCL::KernelArg::init(void * _k, uint index) {
piZeroMemory(nm, 1024);
ret = clGetKernelArgInfo(k, index, CL_KERNEL_ARG_TYPE_NAME, 1024, nm, 0);
if (ret != 0) {
piCout << "[PIOpenCL::Kernel]"
<< "clGetKernelArgInfo(CL_KERNEL_ARG_TYPE_NAME) error" << ret;
piCout << "[PIOpenCL::Kernel]" << "clGetKernelArgInfo(CL_KERNEL_ARG_TYPE_NAME) error" << ret;
}
type_name = nm;
piZeroMemory(nm, 1024);
ret = clGetKernelArgInfo(k, index, CL_KERNEL_ARG_NAME, 1024, nm, 0);
if (ret != 0) {
piCout << "[PIOpenCL::Kernel]"
<< "clGetKernelArgInfo(CL_KERNEL_ARG_NAME) error" << ret;
piCout << "[PIOpenCL::Kernel]" << "clGetKernelArgInfo(CL_KERNEL_ARG_NAME) error" << ret;
}
arg_name = nm;
cl_kernel_arg_address_qualifier addq = 0;
ret = clGetKernelArgInfo(k, index, CL_KERNEL_ARG_ADDRESS_QUALIFIER, sizeof(addq), &addq, 0);
if (ret != 0) {
piCout << "[PIOpenCL::Kernel]"
<< "clGetKernelArgInfo(CL_KERNEL_ARG_ADDRESS_QUALIFIER) error" << ret;
piCout << "[PIOpenCL::Kernel]" << "clGetKernelArgInfo(CL_KERNEL_ARG_ADDRESS_QUALIFIER) error" << ret;
}
switch (addq) {
case CL_KERNEL_ARG_ADDRESS_GLOBAL: address_qualifier = AddressGlobal; break;
@@ -725,8 +699,7 @@ void PIOpenCL::KernelArg::init(void * _k, uint index) {
cl_kernel_arg_access_qualifier accq = 0;
ret = clGetKernelArgInfo(k, index, CL_KERNEL_ARG_ACCESS_QUALIFIER, sizeof(accq), &accq, 0);
if (ret != 0) {
piCout << "[PIOpenCL::Kernel]"
<< "clGetKernelArgInfo(CL_KERNEL_ARG_ACCESS_QUALIFIER) error" << ret;
piCout << "[PIOpenCL::Kernel]" << "clGetKernelArgInfo(CL_KERNEL_ARG_ACCESS_QUALIFIER) error" << ret;
}
switch (accq) {
case CL_KERNEL_ARG_ACCESS_READ_ONLY: access_qualifier = AccessReadOnly; break;
@@ -737,8 +710,7 @@ void PIOpenCL::KernelArg::init(void * _k, uint index) {
cl_kernel_arg_type_qualifier tq = 0;
ret = clGetKernelArgInfo(k, index, CL_KERNEL_ARG_TYPE_QUALIFIER, sizeof(tq), &tq, 0);
if (ret != 0) {
piCout << "[PIOpenCL::Kernel]"
<< "clGetKernelArgInfo(CL_KERNEL_ARG_TYPE_QUALIFIER) error" << ret;
piCout << "[PIOpenCL::Kernel]" << "clGetKernelArgInfo(CL_KERNEL_ARG_TYPE_QUALIFIER) error" << ret;
}
switch (tq) {
case CL_KERNEL_ARG_TYPE_CONST: type_qualifier = TypeConst; break;
+8 -16
View File
@@ -392,17 +392,12 @@ PICout operator<<(PICout s, const PIUSB::Endpoint & v) {
s.saveAndSetControls(0);
s << PICoutManipulators::NewLine << "{" << PICoutManipulators::NewLine;
if (v.isNull())
s << " "
<< "Null Endpoint";
s << " " << "Null Endpoint";
else {
s << " "
<< "Address: " << v.address << PICoutManipulators::NewLine;
s << " "
<< "Attributes: " << v.attributes << PICoutManipulators::NewLine;
s << " "
<< "Direction: " << (v.direction == PIUSB::Endpoint::Write ? "Write" : "Read") << PICoutManipulators::NewLine;
s << " "
<< "Transfer Type: ";
s << " " << "Address: " << v.address << PICoutManipulators::NewLine;
s << " " << "Attributes: " << v.attributes << PICoutManipulators::NewLine;
s << " " << "Direction: " << (v.direction == PIUSB::Endpoint::Write ? "Write" : "Read") << PICoutManipulators::NewLine;
s << " " << "Transfer Type: ";
switch (v.transfer_type) {
case PIUSB::Endpoint::Control: s << "Control" << PICoutManipulators::NewLine; break;
case PIUSB::Endpoint::Bulk: s << "Bulk" << PICoutManipulators::NewLine; break;
@@ -411,8 +406,7 @@ PICout operator<<(PICout s, const PIUSB::Endpoint & v) {
default: break;
}
if (v.transfer_type == PIUSB::Endpoint::Isochronous) {
s << " "
<< "Synchronisation Type: ";
s << " " << "Synchronisation Type: ";
switch (v.synchronisation_type) {
case PIUSB::Endpoint::NoSynchonisation: s << "No Synchonisation" << PICoutManipulators::NewLine; break;
case PIUSB::Endpoint::Asynchronous: s << "Asynchronous" << PICoutManipulators::NewLine; break;
@@ -420,8 +414,7 @@ PICout operator<<(PICout s, const PIUSB::Endpoint & v) {
case PIUSB::Endpoint::Synchronous: s << "Synchronous" << PICoutManipulators::NewLine; break;
default: break;
}
s << " "
<< "Usage Type: ";
s << " " << "Usage Type: ";
switch (v.usage_type) {
case PIUSB::Endpoint::DataEndpoint: s << "Data Endpoint" << PICoutManipulators::NewLine; break;
case PIUSB::Endpoint::FeedbackEndpoint: s << "Feedback Endpoint" << PICoutManipulators::NewLine; break;
@@ -431,8 +424,7 @@ PICout operator<<(PICout s, const PIUSB::Endpoint & v) {
default: break;
}
}
s << " "
<< "Max Packet Size: " << v.max_packet_size << PICoutManipulators::NewLine;
s << " " << "Max Packet Size: " << v.max_packet_size << PICoutManipulators::NewLine;
}
s << "}" << PICoutManipulators::NewLine;
s.restoreControls();
-1
View File
@@ -11,4 +11,3 @@ TEST(PIFile_Test, openTemporary) {
ASSERT_EQ(ba, f.readAll());
ASSERT_TRUE(f.close());
}
+1 -1
View File
@@ -1,7 +1,7 @@
#include "piliterals_time.h"
#include "piprotectedvariable.h"
#include "pistring.h"
#include "pithread.h"
#include "piliterals_time.h"
#include "gtest/gtest.h"
#include <atomic>
+1 -2
View File
@@ -75,8 +75,7 @@ void CloudServer::stop() {
void CloudServer::printStatus() {
PIMutexLocker locker(mutex_clients);
piCout << " "
<< "Clients for" << server->address() << server_uuid.toHex() << ":";
piCout << " " << "Clients for" << server->address() << server_uuid.toHex() << ":";
for (auto c: clients) {
piCout << " " << c->address() << c->clientId();
}
View File
+1 -2
View File
@@ -106,8 +106,7 @@ void makeClassInfo(Runtime & rt, const PICodeParser::Entity * e) {
}
rt.ts << "\tci_ci[ci->name] = ci;\n";
if (e->parent_scope) {
rt.ts << "\tpci = "
<< "ci_ci.value(\"" << e->parent_scope->name << "\", 0);\n";
rt.ts << "\tpci = " << "ci_ci.value(\"" << e->parent_scope->name << "\", 0);\n";
rt.ts << "\tif (pci) pci->children_info << ci;\n";
}
for (const PICodeParser::Entity * p: e->parents)
+2 -7
View File
@@ -128,15 +128,10 @@ QtDep qt_deps[] = {QtDep("core", PIStringList() << "platforms"),
QtDep("sql", PIStringList() << "sqldrivers"),
QtDep("positioning", PIStringList() << "position"),
QtDep("location", PIStringList() << "geoservices"),
QtDep("multimedia",
PIStringList() << "audio"
<< "mediaservice"
<< "playlistformats"),
QtDep("multimedia", PIStringList() << "audio" << "mediaservice" << "playlistformats"),
QtDep("printsupport", PIStringList() << "printsupport"),
QtDep("virtualkeyboard", PIStringList() << "platforminputcontexts"),
QtDep("sensors",
PIStringList() << "sensors"
<< "sensorgestures"),
QtDep("sensors", PIStringList() << "sensors" << "sensorgestures"),
QtDep("texttospeech", PIStringList() << "texttospeech"),
QtDep("serialbus", PIStringList() << "canbus"),
QtDep()};
Executable → Regular
+5 -7
View File
@@ -184,11 +184,10 @@ public:
addrs_tl->content.clear();
peerinfo_tl->content.clear();
peermap_tl->content.clear();
peers_tl->content << TileList::Row(
"this | 0 | 0 | " + PIString::fromNumber(daemon_.allPeers().size_s())
// + " [em = " + PIString::fromBool(daemon_.lockedEth()) + ",
//" "mm = " + PIString::fromBool(daemon_.lockedMBcasts()) + ", "
//"sm
peers_tl->content << TileList::Row("this | 0 | 0 | " + PIString::fromNumber(daemon_.allPeers().size_s())
// + " [em = " +
//PIString::fromBool(daemon_.lockedEth()) + ", " "mm
//= " + PIString::fromBool(daemon_.lockedMBcasts()) + ", " "sm
//=
//"
//+ PIString::fromBool(daemon_.lockedSends()) + ", " "ms = " +
@@ -396,8 +395,7 @@ int main(int argc, char * argv[]) {
PIINTROSPECTION_START(pisd)
if (cli.hasArgument("daemon")) {
PIStringList args;
args << "-1"
<< "-s";
args << "-1" << "-s";
if (cli.hasArgument("force")) args << "-f";
if (cli.hasArgument("address")) args << "-a" << sip;
if (!name.isEmpty()) args << "-n" << name;
+1 -2
View File
@@ -116,8 +116,7 @@ private:
#endif
<< ft.stateString() << ft.curFile() << ft.diagnostic().receiveSpeed() << ft.diagnostic().sendSpeed() << "("
<< PIString::readableSize(ft.bytesFileCur()) << "/" << PIString::readableSize(ft.bytesFileAll()) << ", "
<< PIString::readableSize(ft.bytesCur()) << "/" << PIString::readableSize(ft.bytesAll()) << ")"
<< "ETA"
<< PIString::readableSize(ft.bytesCur()) << "/" << PIString::readableSize(ft.bytesAll()) << ")" << "ETA"
<< (ft.diagnostic().state().received_bytes_per_sec > 0
? PIString::fromNumber(
PISystemTime::fromSeconds((ft.bytesAll() - ft.bytesCur()) / ft.diagnostic().state().received_bytes_per_sec)