Skip to content

Conversation

@liamappelbe
Copy link
Contributor

Implements the same stubbing logic as ffigen uses (a bit simplified since we don't have legacy behavior to worry about). The config include rule specifies which declarations are fully generated. Any type declarations (classes/structs/protocols) that are depended on by the explicitly included declarations are generated as stubs.

Details

  • Moved the existing TransformationMap object into a TransformationState object.
  • The visitors that determine which decls are stubs comes after parsing but before the main transform pass. The result is stored as a Set<Declaration> in TransformationState.stubs.
  • This stub set is used during the main transform pass to omit methods etc from the generated stub classes, and to set ClassDeclaration.isStub.
  • ClassDeclaration.isStub is only used to generate the // This wrapper is a stub comment. There's no StructDeclaration.isStub field because after transformation there are only ClassDeclarations.
  • The main reason for this approach, where the stub decision is stored in TransformationState.stubs rather than ClassDeclaration.isStub, is that users shouldn't be in charge of choosing which classes are stubs (other than by using inclusion rules), since it would be hard to implement this without making it a footgun.
  • Unrelated: Cleaned up pkgs/ffigen/lib/src/header_parser/parser.dart a bit while I was rereading it.

@github-actions
Copy link

github-actions bot commented Aug 15, 2025

PR Health

Breaking changes ✔️
Package Change Current Version New Version Needed Version Looking good?
Changelog Entry ✔️
Package Changed Files

Changes to files need to be accounted for in their respective changelogs.

API leaks ✔️

The following packages contain symbols visible in the public API, but not exported by the library. Export these symbols or remove them from your publicly visible API.

Package Leaked API symbol Leaking sources
License Headers ✔️
// Copyright (c) 2025, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
Files
no missing headers

All source files should start with a license header.

Unrelated files missing license headers
Files
pkgs/jni/lib/src/third_party/generated_bindings.dart
pkgs/objective_c/lib/src/ns_input_stream.dart

@coveralls
Copy link

coveralls commented Aug 15, 2025

Coverage Status

coverage: 87.626% (+0.7%) from 86.905%
when pulling b25d5a7 on swift2objc_stub
into 450a761 on main.

@liamappelbe liamappelbe merged commit bb1a662 into main Aug 19, 2025
22 of 27 checks passed
@liamappelbe liamappelbe deleted the swift2objc_stub branch August 19, 2025 01:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants