Files
Dario LipicarandClaude Opus 4.7 2a029fb0b1 feat: dependency interfaces — test-interface-module-cpp verification module (#20)
* feat: test-interface-module-cpp — dependency-interface smoke test

Add a universal core module that declares a LOCAL basic_calc interface
(interfaces/basic_calc.h, a subset of test_basic_module_cpp's API) and binds
it to a module name at runtime via modules().bind_basic_calc(name), exercising
the bound wrapper's typed sync + event accessors plus the no-validation path.
Registered in flake.nix (modules + packages).

Requires logos-cpp-sdk#74, logos-module-builder#108, logos-plugin-qt#8.

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

* address review: make basic_calc.h valid C++ standalone

Include logos_module_context.h in the interface header so the logos_events
token (it expands to public) is defined — the header is now valid C++ on
its own, not only as generator input. (Copilot review, PR #20.)

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

* bump module-builder

---------

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

45 lines
1.6 KiB
C++

#pragma once
// A DEPENDENCY INTERFACE — a method/event contract decoupled from any
// concrete module. It names NO module; any module whose own API is a
// superset of this can satisfy it. The consumer binds it to a concrete
// module name at runtime (modules().bind_basic_calc("some_module")).
//
// This file is the consuming module's own pure-C++ interface declaration
// (the same language the universal module is written in). The Logos
// generator parses it — public methods + the logos_events: block — and
// emits a BOUND wrapper class `BasicCalc` whose target module name is a
// runtime ctor argument rather than baked in.
//
// `test_basic_module_cpp` satisfies this interface: its API includes
// echo / addInts / returnTrue and a `testEvent(data)` event, plus much
// more (the superset rule).
//
// NOTE: types are std (std::string / int64_t) because the consuming
// module is `interface: "universal"`; the bound wrapper inherits that
// api-style.
#include <cstdint>
#include <string>
// Defines the `logos_events` token (it expands to `public`), so this header
// is valid C++ on its own — not just as generator input.
#include <logos_module_context.h>
class IBasicCalc {
public:
// Echo a string back unchanged.
std::string echo(const std::string& input);
// Add two integers.
int64_t addInts(int64_t a, int64_t b);
// Always-true sentinel — proves a zero-arg bool method binds.
bool returnTrue();
logos_events:
// Emitted by the provider; the consumer subscribes via the bound
// wrapper's generated onTestEvent(...) accessor.
void testEvent(const std::string& data);
};