mirror of
https://github.com/logos-co/logos-cpp-sdk.git
synced 2026-08-31 09:41:06 +00:00
* Add per-event documentation + getPluginEvents introspection Mirror the per-method documentation pipeline for events. Events (declared in a universal module's logos_events: section) now carry a description parsed from their /// doc comments, and are introspectable at runtime via a new getPluginEvents framework call. - lidl_ast: EventDecl gains a description field. - impl_header_parser: capture the event's doc comment (previously discarded) and an optional metadata.json events[].description. - lidl_gen_provider: generated universal provider emits getEvents() override, mirroring getMethods() (name/signature/ parameters/description; no returnType/isInvokable — events are void). - logos_provider_object: default-empty virtual getEvents() so the legacy provider path and QtProviderObject inherit empty. - module_proxy / qt_provider_object: intercept getPluginEvents next to the getPluginMethods special-case. - docs: spec + README event-documentation notes. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * Add unit tests for event documentation + getEvents generation Address review feedback (#71): cover the event-introspection paths that previously only had method-side tests. - impl_header_parser test: assert metadata.json events[].description is parsed; new documented_events fixture asserts `///` doc-comment capture on a logos_events: block (multi-line joined with \n, adjacent-only, plain // ignored). - lidl_gen_provider test: assert the generated dispatch contains getEvents() emitting each event's name/signature/parameters and an escaped description, and that events carry no returnType/isInvokable. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * 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> --------- Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
98 lines
2.7 KiB
C
98 lines
2.7 KiB
C
#ifndef LIDL_AST_H
|
|
#define LIDL_AST_H
|
|
|
|
#include <QString>
|
|
#include <QStringList>
|
|
#include <QVector>
|
|
|
|
struct TypeExpr {
|
|
enum Kind { Primitive, Array, Map, Optional, Named };
|
|
Kind kind = Primitive;
|
|
QString name; // primitive name ("tstr","int",...) or custom type name
|
|
QVector<TypeExpr> elements; // Array: [0]=elem, Map: [0]=key [1]=val, Optional: [0]=inner
|
|
|
|
bool operator==(const TypeExpr& o) const {
|
|
return kind == o.kind && name == o.name && elements == o.elements;
|
|
}
|
|
bool operator!=(const TypeExpr& o) const { return !(*this == o); }
|
|
};
|
|
|
|
struct FieldDecl {
|
|
QString name;
|
|
TypeExpr type;
|
|
bool optional = false;
|
|
|
|
bool operator==(const FieldDecl& o) const {
|
|
return name == o.name && type == o.type && optional == o.optional;
|
|
}
|
|
};
|
|
|
|
struct ParamDecl {
|
|
QString name;
|
|
TypeExpr type;
|
|
|
|
bool operator==(const ParamDecl& o) const {
|
|
return name == o.name && type == o.type;
|
|
}
|
|
};
|
|
|
|
struct MethodDecl {
|
|
QString name;
|
|
QVector<ParamDecl> params;
|
|
TypeExpr returnType;
|
|
// Doc comment adjacent to the method declaration (becomes "description").
|
|
QString description;
|
|
// True when the impl returns LogosMap or LogosList (nlohmann::json).
|
|
// The generator will emit nlohmann→Qt conversion code in the glue layer.
|
|
bool jsonReturn = false;
|
|
// True when the impl returns StdLogosResult.
|
|
// The generator will emit a stdResultToQt() conversion in the glue layer.
|
|
bool resultReturn = false;
|
|
|
|
bool operator==(const MethodDecl& o) const {
|
|
return name == o.name && params == o.params && returnType == o.returnType
|
|
&& description == o.description
|
|
&& jsonReturn == o.jsonReturn && resultReturn == o.resultReturn;
|
|
}
|
|
};
|
|
|
|
struct EventDecl {
|
|
QString name;
|
|
QVector<ParamDecl> params;
|
|
// Doc comment adjacent to the event declaration (becomes "description").
|
|
QString description;
|
|
|
|
bool operator==(const EventDecl& o) const {
|
|
return name == o.name && params == o.params && description == o.description;
|
|
}
|
|
};
|
|
|
|
struct TypeDecl {
|
|
QString name;
|
|
QVector<FieldDecl> fields;
|
|
|
|
bool operator==(const TypeDecl& o) const {
|
|
return name == o.name && fields == o.fields;
|
|
}
|
|
};
|
|
|
|
struct ModuleDecl {
|
|
QString name;
|
|
QString version;
|
|
QString description;
|
|
QString category;
|
|
QStringList depends;
|
|
QVector<TypeDecl> types;
|
|
QVector<MethodDecl> methods;
|
|
QVector<EventDecl> events;
|
|
|
|
bool operator==(const ModuleDecl& o) const {
|
|
return name == o.name && version == o.version
|
|
&& description == o.description && category == o.category
|
|
&& depends == o.depends && types == o.types
|
|
&& methods == o.methods && events == o.events;
|
|
}
|
|
};
|
|
|
|
#endif // LIDL_AST_H
|