Files
logos-cpp-sdk/cpp-generator/experimental/lidl_gen_client.h
Dario LipicarandClaude Opus 4.7 eb71a1aa90 feat: dependency interfaces — SDK code generator (bound wrappers) (#74)
* feat: dependency interfaces — runtime-bound typed wrappers

Turn a declared "interface" (a .lidl file or a pure-C++ header with a
logos_events: block) into a BOUND client wrapper: the target module name
is a constructor argument instead of a baked-in literal, so one interface
can be bound to any satisfying module at runtime.

- generator_lib: new BindMode { Static, Bound }. In Bound mode the ctor
  takes (LogosAPI*, const QString& moduleName) and every invokeRemoteMethod*
  / ensureReplica routes through m_moduleName. Default Static leaves existing
  name-baked output byte-for-byte unchanged.
- legacy/main.cpp: repeatable --interface <name>=<path>[=<impl_class>] flag,
  consumed in --general-only. Parses .lidl via lidlParse and .h via
  parseImplHeader, emits the bound <name>_api.{h,cpp}, and adds
  bind_<name>(moduleName) factories (QString + std::string) to the
  LogosModules umbrella. Also self-resolves local interface_dependencies
  from metadata.json for non-nix builds.
- experimental/lidl_gen_client: same BindMode parity for the --lidl path.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* address review: dedup and validate --interface specs

A repeated --interface <name>=... would emit duplicate #include and
bind_<name>(...) into logos_sdk.h and fail to compile; empty name/path were
silently accepted. Dedup the flag-derived specs by name and drop malformed
ones with an explanatory message on stderr. (Copilot review, PR #74.)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-06-05 20:44:43 -03:00

33 lines
1.3 KiB
C

#ifndef LIDL_GEN_CLIENT_H
#define LIDL_GEN_CLIENT_H
#include "lidl_ast.h"
#include "../legacy/generator_lib.h" // BindMode
#include <QString>
#include <QTextStream>
// Map a LIDL TypeExpr to the Qt type string used in generated client stubs
QString lidlTypeToQt(const TypeExpr& te);
// Convert "my_module" to "MyModule"
QString lidlToPascalCase(const QString& name);
// Generate the client API header (.h) from a ModuleDecl.
// `bindMode == Bound` emits an interface wrapper whose ctor takes the
// target module name at runtime (see BindMode in generator_lib.h); the
// default Static keeps the historical fixed-module wrapper.
QString lidlMakeHeader(const ModuleDecl& module, BindMode bindMode = BindMode::Static);
// Generate the client API source (.cpp) from a ModuleDecl
QString lidlMakeSource(const ModuleDecl& module, BindMode bindMode = BindMode::Static);
// Generate metadata.json content from a ModuleDecl
QString lidlGenerateMetadataJson(const ModuleDecl& module);
// Full pipeline: parse .lidl file, generate client stubs + metadata.json + optional umbrella
// Returns 0 on success, non-zero on error
int lidlGenerateClientStubs(const QString& lidlPath, const QString& outputDir,
bool moduleOnly, QTextStream& out, QTextStream& err);
#endif // LIDL_GEN_CLIENT_H