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:
@@ -32,7 +32,8 @@ public:
|
||||
SenseApiDesc() = default;
|
||||
SenseApiDesc(const CSenseApiDesc& cDesc)
|
||||
// The caller should sanity check before calling this constructor.
|
||||
: name(cDesc.name)
|
||||
: name(cDesc.name),
|
||||
sal_mgmt_libOps(cDesc.sal_mgmt_libOps)
|
||||
{
|
||||
for (uint32_t i = 0; i < cDesc.numExportedImplexorApis; ++i)
|
||||
{
|
||||
@@ -51,6 +52,7 @@ public:
|
||||
std::string name;
|
||||
// These are the implexors whose APIs this lib exports.
|
||||
std::vector<ExportedImplexorApiDesc> exportedImplexorApis;
|
||||
Csal_mgmt_libOps* sal_mgmt_libOps;
|
||||
|
||||
std::string stringify() const {
|
||||
std::string result = "Name: " + name + "\n";
|
||||
|
||||
@@ -123,7 +123,7 @@ SenseApiManager::getSenseApiLibByApiName(const std::string& apiName)
|
||||
{
|
||||
auto it = std::find_if(senseApiLibs.begin(), senseApiLibs.end(),
|
||||
[&apiName](const std::unique_ptr<SenseApiLib>& lib) {
|
||||
return lib->getSenseApiDesc()->name == apiName;
|
||||
return lib->senseApiDesc.name == apiName;
|
||||
}
|
||||
);
|
||||
|
||||
@@ -173,24 +173,24 @@ std::string SenseApiManager::stringifyLibs() const
|
||||
|
||||
void SenseApiManager::initializeSenseApiLib(SenseApiLib& lib)
|
||||
{
|
||||
if (!lib.getSenseApiDesc()->sal_mgmt_libOps->initializeInd)
|
||||
if (!lib.senseApiDesc.sal_mgmt_libOps->initializeInd)
|
||||
{
|
||||
throw std::runtime_error(
|
||||
std::string(__func__) + ": initializeInd() is NULL for library '"
|
||||
+ lib.libraryPath + "'");
|
||||
}
|
||||
lib.getSenseApiDesc()->sal_mgmt_libOps->initializeInd();
|
||||
lib.senseApiDesc.sal_mgmt_libOps->initializeInd();
|
||||
}
|
||||
|
||||
void SenseApiManager::finalizeSenseApiLib(SenseApiLib& lib)
|
||||
{
|
||||
if (!lib.getSenseApiDesc()->sal_mgmt_libOps->finalizeInd)
|
||||
if (!lib.senseApiDesc.sal_mgmt_libOps->finalizeInd)
|
||||
{
|
||||
throw std::runtime_error(
|
||||
std::string(__func__) + ": finalizeInd() is NULL for library '"
|
||||
+ lib.libraryPath + "'");
|
||||
}
|
||||
lib.getSenseApiDesc()->sal_mgmt_libOps->finalizeInd();
|
||||
lib.senseApiDesc.sal_mgmt_libOps->finalizeInd();
|
||||
}
|
||||
|
||||
void SenseApiManager::initializeAllSenseApiLibs(void)
|
||||
@@ -217,14 +217,14 @@ void SenseApiManager::attachSenseDevice(const SenseDeviceSpec& spec)
|
||||
+ spec.api + "'");
|
||||
}
|
||||
auto& lib = libOpt.value().get();
|
||||
if (!lib.getSenseApiDesc()->sal_mgmt_libOps->attachDeviceReq)
|
||||
if (!lib.senseApiDesc.sal_mgmt_libOps->attachDeviceReq)
|
||||
{
|
||||
throw std::runtime_error(
|
||||
std::string(__func__) + ": attachDeviceReq() is NULL for library '"
|
||||
+ lib.libraryPath + "'");
|
||||
}
|
||||
CSenseDeviceSpec cSpec(spec);
|
||||
lib.getSenseApiDesc()->sal_mgmt_libOps->attachDeviceReq(&cSpec);
|
||||
lib.senseApiDesc.sal_mgmt_libOps->attachDeviceReq(&cSpec);
|
||||
}
|
||||
|
||||
void SenseApiManager::detachSenseDevice(const SenseDeviceSpec& spec)
|
||||
@@ -237,14 +237,14 @@ void SenseApiManager::detachSenseDevice(const SenseDeviceSpec& spec)
|
||||
+ spec.api + "'");
|
||||
}
|
||||
auto& lib = libOpt.value().get();
|
||||
if (!lib.getSenseApiDesc()->sal_mgmt_libOps->detachDeviceReq)
|
||||
if (!lib.senseApiDesc.sal_mgmt_libOps->detachDeviceReq)
|
||||
{
|
||||
throw std::runtime_error(
|
||||
std::string(__func__) + ": detachDeviceReq() is NULL for library '"
|
||||
+ lib.libraryPath + "'");
|
||||
}
|
||||
CSenseDeviceSpec cSpec(spec);
|
||||
lib.getSenseApiDesc()->sal_mgmt_libOps->detachDeviceReq(&cSpec);
|
||||
lib.senseApiDesc.sal_mgmt_libOps->detachDeviceReq(&cSpec);
|
||||
}
|
||||
|
||||
void SenseApiManager::attachAllSenseDevicesFromSpecs(void)
|
||||
|
||||
Reference in New Issue
Block a user