Skip to content

Conversation

@liamappelbe
Copy link
Contributor

@liamappelbe liamappelbe commented Nov 27, 2025

The wrapperName is the name given to the wrapper class that holds all the function pointers, when using the old DynamicLibraryBindings style. Under the @Native style the wrapperName shouldn't be necessary, so we wanted to remove it from NativeExternalBindings.

But we were also using it as a unique ID for the bindings as a whole. In native code, where everything is effectively in the same namespace, this ID was used to give globally unique names to the generated functions, in case a user had multiple sets of ffigen bindings in a single project.

These functions aren't user facing, and don't have to be human readable, so I've switched them to a hash based ID. It now hashes the input and output files to generate the ID. Only the file's basename is included, because the full path varies between machines. So it's still possible to have a collision, but it should be unlikely.

// Before
Protocol* _ObjectiveCBindings_NSCoding(void) { return @protocol(NSCoding); }

// After
Protocol* _1wx624s_NSCoding(void) { return @protocol(NSCoding); }

Fixes #2580

@github-actions
Copy link

github-actions bot commented Nov 27, 2025

PR Health

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/hooks_runner/test_data/download_assets/hook/build.dart
pkgs/objective_c/example/command_line/lib/main.dart
pkgs/objective_c/lib/src/ns_input_stream.dart

This check can be disabled by tagging the PR with skip-license-check.

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
objective_c _FinalizablePointer internal.dart::_ObjCReference::new::_finalizable

This check can be disabled by tagging the PR with skip-leaking-check.

Breaking changes ✔️
Package Change Current Version New Version Needed Version Looking good?
objective_c None 9.2.1 9.2.1 9.2.1 ✔️

This check can be disabled by tagging the PR with skip-breaking-check.

Changelog Entry
Package Changed Files
package:objective_c pkgs/objective_c/lib/src/objective_c_bindings_generated.dart

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

This check can be disabled by tagging the PR with skip-changelog-check.

@coveralls
Copy link

coveralls commented Nov 27, 2025

Coverage Status

coverage: 82.142% (+0.2%) from 81.978%
when pulling 238a565 on ffigen_config_cleanup_3
into 579b84d on main.

@liamappelbe liamappelbe changed the title WIP: [ffigen] Remove NativeExternalBindings.wrapperName [ffigen] Remove NativeExternalBindings.wrapperName Nov 27, 2025
@liamappelbe liamappelbe marked this pull request as ready for review November 27, 2025 23:51
@liamappelbe liamappelbe merged commit 9460b0d into main Dec 1, 2025
32 of 33 checks passed
@liamappelbe liamappelbe deleted the ffigen_config_cleanup_3 branch December 1, 2025 00:12
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.

[ffigen] Dart API: wrapperName is used in @Native bindings in Objective-C mode

3 participants