Skip to content

fix: skip explicit constructors in universal codegen#116

Open
gmelodie wants to merge 1 commit into
masterfrom
fix/codegen-explicit-ctor
Open

fix: skip explicit constructors in universal codegen#116
gmelodie wants to merge 1 commit into
masterfrom
fix/codegen-explicit-ctor

Conversation

@gmelodie

@gmelodie gmelodie commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Summary

logos-cpp-generator's impl-header parser skips constructors via a regex anchored at ^\s*~?<Class>\s*\(, which doesn't match explicit <Class>(. When a module's impl class declares its constructor with explicit (e.g. explicit Libp2pModuleImpl(const Libp2pModuleOptions& opts = {});), the constructor leaks through as a regular method and the generated Qt glue emits:

QVariant Libp2pModuleImpl() { return m_impl.Libp2pModuleImpl(); }
...
Libp2pModuleImpl m_impl;

The method name shadows the type name, so the trailing Libp2pModuleImpl m_impl; field declaration fails with 'Libp2pModuleImpl' does not name a type, and every subsequent reference to m_impl reports was not declared in this scope. This shows up downstream as a nix flake check failure in logos-libp2p-module on the openmetrics scaffold branch.

Workaround: copy the impl header to a temp dir, strip explicit from the ctor line, and feed the sanitized copy to --from-header. --impl-header keeps the original filename so the generated #include still resolves to the real header at compile time. No source files are mutated and the original explicit semantics are preserved everywhere else in the build.

The real fix belongs in logos-cpp-sdk's impl_header_parser.cpp (the ctor regex should permit decl-specifiers); this is a stopgap until that lands.

@gmelodie gmelodie self-assigned this Jun 10, 2026
@gmelodie gmelodie marked this pull request as ready for review June 10, 2026 19:36
@gmelodie gmelodie force-pushed the fix/codegen-explicit-ctor branch from 88c7e8b to f963943 Compare June 10, 2026 19:44
@github-actions

github-actions Bot commented Jun 10, 2026

Copy link
Copy Markdown

📊 External-library doc-test report

The four ways to wrap a C library — each scaffolded into a real module, built against this commit, loaded in logoscore, and called — rendered alongside the commands actually run and their output (updated each run, commit 1ee3efa):

Pages can take a minute to update after the run finishes.

@gmelodie gmelodie force-pushed the fix/codegen-explicit-ctor branch from f963943 to a9903c7 Compare June 10, 2026 19:49
@gmelodie gmelodie force-pushed the fix/codegen-explicit-ctor branch from a9903c7 to 62524be Compare June 10, 2026 19:52
@gmelodie gmelodie marked this pull request as draft June 10, 2026 19:53
@gmelodie gmelodie marked this pull request as ready for review June 10, 2026 19:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant