Fold event introspection into getMethods() to keep the provider ABI stable

The previous approach added a getEvents() virtual to LogosProviderObject,
which inserted a new vtable slot and shifted every later slot — an ABI
break that would misdispatch virtual calls whenever an old and new
host/module were mixed across the in-process plugin boundary.

Instead, report events INSIDE the existing getMethods() call: it now
returns the module's whole interface, with each entry tagged
type "method" or "event" (events omit returnType/isInvokable). The
provider vtable is therefore byte-for-byte unchanged, so old/new hosts
and modules stay binary-compatible — a new host reading an old module
sees no event entries (zero events), and an old host reading a new
module just ignores the "type" field (cosmetic). An entry with no
"type" is treated as a method.

- logos_provider_object.h: remove the getEvents() virtual; document that
  getMethods() carries both, and why.
- generator (lidl_gen_provider): emit events as type "event" entries
  inside getMethods(); tag methods type "method"; no getEvents() output.
- module_proxy / qt_provider_object: getPluginMethods()/getPluginEvents()
  are now type-filtered views of getMethods(), plus a new
  getPluginInterface() returning the whole list. (These are name-
  dispatched Q_INVOKABLEs, not vtable surface — adding them is safe.)
- tests: generator asserts events fold into getMethods() tagged "event";
  ModuleProxy asserts the three filtered views; parser tests unchanged.
- docs: spec/project/docs/README updated, incl. an ABI rationale note.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Dario Gabriel Lipicar
2026-06-04 16:10:00 -03:00
co-authored by Claude Opus 4.8
parent 3a123b3191
commit 4989306953
11 changed files with 182 additions and 60 deletions
+30 -5
View File
@@ -1,6 +1,8 @@
#include "module_proxy.h"
#include "logos_provider_object.h"
#include <QDebug>
#include <QJsonObject>
#include <QJsonValue>
ModuleProxy::ModuleProxy(LogosProviderObject* provider, QObject* parent)
: QObject(parent)
@@ -70,6 +72,10 @@ QVariant ModuleProxy::callRemoteMethod(const QString& authToken, const QString&
return QVariant(getPluginEvents());
}
if (methodName == "getPluginInterface" && args.isEmpty()) {
return QVariant(getPluginInterface());
}
qDebug() << "ModuleProxy: callRemoteMethod" << methodName << "args:" << args;
return m_provider->callMethod(methodName, args);
}
@@ -86,7 +92,24 @@ bool ModuleProxy::informModuleToken(const QString& authToken, const QString& mod
return m_provider->informModuleToken(moduleName, token);
}
QJsonArray ModuleProxy::getPluginMethods()
namespace {
// getMethods() returns the module's full interface — both methods and events,
// each tagged with a "type" ("method"/"event"). Split it back out. An entry
// with no "type" counts as a method, so modules built against the pre-events
// SDK (whose getMethods() contains no events) report zero events, not a crash.
QJsonArray filterInterface(const QJsonArray& interface, bool keepEvents)
{
QJsonArray out;
for (const QJsonValue& v : interface) {
const bool isEvent =
v.toObject().value(QStringLiteral("type")).toString() == QStringLiteral("event");
if (isEvent == keepEvents) out.append(v);
}
return out;
}
} // namespace
QJsonArray ModuleProxy::getPluginInterface()
{
if (!m_provider) return QJsonArray();
@@ -94,12 +117,14 @@ QJsonArray ModuleProxy::getPluginMethods()
return m_provider->getMethods();
}
QJsonArray ModuleProxy::getPluginMethods()
{
return filterInterface(getPluginInterface(), /*keepEvents=*/false);
}
QJsonArray ModuleProxy::getPluginEvents()
{
if (!m_provider) return QJsonArray();
qDebug() << "[LogosProviderObject] ModuleProxy: calling LogosProviderObject::getEvents()";
return m_provider->getEvents();
return filterInterface(getPluginInterface(), /*keepEvents=*/true);
}
#include "moc_module_proxy.cpp"