Skip to content

Conversation

@liamappelbe
Copy link
Contributor

@liamappelbe liamappelbe commented Oct 22, 2025

Before

// Interface
class AVAudioPlayer extends objc.NSObject {

// Protocol
interface class AVAudioPlayerDelegate extends objc.ObjCProtocolBase
    implements objc.NSObjectProtocol {

After

// Interface
extension type AVAudioPlayer._(objc.ObjCObject object$)
    implements objc.ObjCObject, objc.NSObject {

// Protocol
extension type AVAudioPlayerDelegate._(objc.ObjCProtocol object$)
    implements objc.ObjCProtocol, objc.NSObjectProtocol {

Other changes

  • package:objective_c's collections can no longer directly implement the corresponding Dart collection. So I had to split out the Darty helpers into separate adapter classes.
  • Renamed some APIs for clarity and consistency with jnigen and JS interop:
    • isInstance -> isA
    • castFrom -> as
    • castFromPointer -> fromPointer
    • ObjCObject -> ObjCObjectImpl
    • ObjCProtocol -> ObjCProtocolImpl
    • ObjCObjectBase -> ObjCObject
    • ObjCProtocolBase -> ObjCProtocol

Fixes #2664

@github-actions
Copy link

github-actions bot commented Oct 22, 2025

PR Health

Breaking changes ✔️
Package Change Current Version New Version Needed Version Looking good?
objective_c Breaking 8.1.0 9.0.0-dev.0 9.0.0 ✔️

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

Changelog Entry ✔️
Package Changed Files

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.

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.

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
pkgs/objective_c/lib/src/ns_input_stream.dart

All source files should start with a license header.

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

@github-actions github-actions bot added the type-infra A repository infrastructure change or enhancement label Oct 23, 2025
@coveralls
Copy link

coveralls commented Nov 4, 2025

Coverage Status

coverage: 81.764% (-0.7%) from 82.451%
when pulling 22527ef on ffigen_type_ext
into d2edd93 on main.

@liamappelbe liamappelbe changed the title WIP: [ffigen] Migrate to extension types [ffigen] Migrate to extension types Nov 4, 2025
@liamappelbe liamappelbe marked this pull request as ready for review November 4, 2025 06:18

expect(objectRetainCount(obj1raw), 1);
expect(objectRetainCount(obj2raw), 1);
expect(objectRetainCount(obj1raw), greaterThan(0));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we changing these to a generic greaterThan(0)? The tests are now weaker as a result?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Every now and then I have to switch one of these tests from a number to greaterThan(0) because of some CI flakiness (sometimes the exact number is different on different machines, or different runs on the same machine). Then with this extension type change we're holding fewer total references from Dart to ObjC, so I was going to have to change a bunch of the numbers to new values, or to greaterThan(0). Ultimately we don't really care about the specific number of references, just whether there's 0 or more than 0 references. So I figured it would be better to just switch them all to greaterThan(0), rather than going through and changing all the numbers, only to later switch some of them to greaterThan(0) when the specific number varies on CI.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

package:ffigen package:objective_c package:swiftgen type-infra A repository infrastructure change or enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[ffigen] Convert objects to extension types

4 participants