Senselib FFI: Use devDesc object in SenseApiLib, also add per-device metadata to xcbXorg

We also had to write conversion constructors and so on to CSenseDeviceDesc.
The technical debt that's being piled up from this C FFI is excessive.
I think we'll end it here. API Libs will have to be written in C++
from now on. API Lib interfaces will be in C++.

We'll use cross compilers to ensure stability for out-of-tree lib
development.
This commit is contained in:
2025-01-13 11:53:38 -04:00
parent 660f0f0e73
commit a4f96c8dfa
4 changed files with 84 additions and 12 deletions
+43
View File
@@ -71,6 +71,42 @@ struct CSenseDeviceSpec
providerParams[spec.providerParams.size()] = nullptr;
}
CSenseDeviceSpec(const CSenseDeviceSpec& other)
: sensorType(other.sensorType),
implexor(strdup(other.implexor)),
api(strdup(other.api)),
provider(strdup(other.provider)),
deviceSelector(strdup(other.deviceSelector))
{
if (other.apiParams) {
size_t apiParamsSize = 0;
while (other.apiParams[apiParamsSize] != nullptr) {
++apiParamsSize;
}
apiParams = new char*[apiParamsSize + 1];
for (size_t i = 0; i < apiParamsSize; ++i) {
apiParams[i] = strdup(other.apiParams[i]);
}
apiParams[apiParamsSize] = nullptr;
} else {
apiParams = nullptr;
}
if (other.providerParams) {
size_t providerParamsSize = 0;
while (other.providerParams[providerParamsSize] != nullptr) {
++providerParamsSize;
}
providerParams = new char*[providerParamsSize + 1];
for (size_t i = 0; i < providerParamsSize; ++i) {
providerParams[i] = strdup(other.providerParams[i]);
}
providerParams[providerParamsSize] = nullptr;
} else {
providerParams = nullptr;
}
}
~CSenseDeviceSpec(void)
{
free(implexor);
@@ -122,6 +158,13 @@ struct CSenseDeviceSpec
return os.str();
}
bool operator==(const CSenseDeviceSpec& other) const
{
return sensorType == other.sensorType &&
strcmp(provider, other.provider) == 0 &&
strcmp(deviceSelector, other.deviceSelector) == 0;
}
#endif
char sensorType;