Skip to content

Commit

Permalink
Merge branch 'main' into swiftgen2
Browse files Browse the repository at this point in the history
  • Loading branch information
liamappelbe committed Dec 4, 2024
2 parents 95177db + aa82b97 commit d02eb07
Show file tree
Hide file tree
Showing 45 changed files with 520 additions and 109 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ffi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
sdk: [dev]
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- uses: dart-lang/setup-dart@0a8a0fc875eb934c15d08629302413c671d3f672
- uses: dart-lang/setup-dart@e630b99d28a3b71860378cafdc2a067c71107f94
with:
sdk: ${{ matrix.sdk }}
- id: install
Expand Down Expand Up @@ -62,7 +62,7 @@ jobs:
sdk: [beta, dev]
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- uses: dart-lang/setup-dart@0a8a0fc875eb934c15d08629302413c671d3f672
- uses: dart-lang/setup-dart@e630b99d28a3b71860378cafdc2a067c71107f94
with:
sdk: ${{ matrix.sdk }}
- id: install
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/ffigen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
fail-fast: false
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- uses: subosito/flutter-action@44ac965b96f18d999802d4b807e3256d5a3f9fa1
- uses: subosito/flutter-action@74af56c5ed2697ba4621264652728e8d217e53d3
with:
channel: 'stable'
- id: install
Expand All @@ -54,7 +54,7 @@ jobs:
working-directory: pkgs/ffigen/
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- uses: subosito/flutter-action@44ac965b96f18d999802d4b807e3256d5a3f9fa1
- uses: subosito/flutter-action@74af56c5ed2697ba4621264652728e8d217e53d3
with:
channel: 'stable'
- name: Install dependencies
Expand All @@ -75,7 +75,7 @@ jobs:
working-directory: pkgs/ffigen/
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- uses: subosito/flutter-action@44ac965b96f18d999802d4b807e3256d5a3f9fa1
- uses: subosito/flutter-action@74af56c5ed2697ba4621264652728e8d217e53d3
with:
channel: 'stable'
- name: Install dependencies
Expand Down Expand Up @@ -106,7 +106,7 @@ jobs:
working-directory: pkgs/ffigen/
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- uses: subosito/flutter-action@44ac965b96f18d999802d4b807e3256d5a3f9fa1
- uses: subosito/flutter-action@74af56c5ed2697ba4621264652728e8d217e53d3
with:
channel: 'stable'
- name: Install dependencies
Expand All @@ -124,7 +124,7 @@ jobs:
working-directory: pkgs/ffigen/
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- uses: subosito/flutter-action@44ac965b96f18d999802d4b807e3256d5a3f9fa1
- uses: subosito/flutter-action@74af56c5ed2697ba4621264652728e8d217e53d3
with:
channel: 'stable'
- name: Install dependencies
Expand Down Expand Up @@ -152,7 +152,7 @@ jobs:
working-directory: pkgs/ffigen/
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- uses: subosito/flutter-action@44ac965b96f18d999802d4b807e3256d5a3f9fa1
- uses: subosito/flutter-action@74af56c5ed2697ba4621264652728e8d217e53d3
with:
channel: "master"
- name: Install dependencies
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ffigen_weekly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
working-directory: pkgs/ffigen/
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- uses: subosito/flutter-action@44ac965b96f18d999802d4b807e3256d5a3f9fa1
- uses: subosito/flutter-action@74af56c5ed2697ba4621264652728e8d217e53d3
with:
channel: 'stable'
- name: Install dependencies
Expand Down
24 changes: 12 additions & 12 deletions .github/workflows/jnigen.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
sdk: [stable]
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- uses: subosito/flutter-action@44ac965b96f18d999802d4b807e3256d5a3f9fa1
- uses: subosito/flutter-action@74af56c5ed2697ba4621264652728e8d217e53d3
with:
channel: ${{ matrix.sdk }}
cache: true
Expand Down Expand Up @@ -77,7 +77,7 @@ jobs:
sdk: [stable, beta]
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- uses: subosito/flutter-action@44ac965b96f18d999802d4b807e3256d5a3f9fa1
- uses: subosito/flutter-action@74af56c5ed2697ba4621264652728e8d217e53d3
with:
channel: ${{ matrix.sdk }}
cache: true
Expand Down Expand Up @@ -128,7 +128,7 @@ jobs:
working-directory: ./pkgs/jni
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- uses: subosito/flutter-action@44ac965b96f18d999802d4b807e3256d5a3f9fa1
- uses: subosito/flutter-action@74af56c5ed2697ba4621264652728e8d217e53d3
with:
channel: 'stable'
cache: true
Expand Down Expand Up @@ -167,7 +167,7 @@ jobs:
working-directory: ./pkgs/jni
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- uses: subosito/flutter-action@44ac965b96f18d999802d4b807e3256d5a3f9fa1
- uses: subosito/flutter-action@74af56c5ed2697ba4621264652728e8d217e53d3
with:
channel: 'stable'
cache: true
Expand Down Expand Up @@ -216,7 +216,7 @@ jobs:
working-directory: ./pkgs/jni
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- uses: subosito/flutter-action@44ac965b96f18d999802d4b807e3256d5a3f9fa1
- uses: subosito/flutter-action@74af56c5ed2697ba4621264652728e8d217e53d3
with:
channel: 'stable'
cache: true
Expand All @@ -243,7 +243,7 @@ jobs:
with:
version: latest
platform: x64
- uses: subosito/flutter-action@44ac965b96f18d999802d4b807e3256d5a3f9fa1
- uses: subosito/flutter-action@74af56c5ed2697ba4621264652728e8d217e53d3
with:
channel: 'stable'
cache: true
Expand All @@ -269,7 +269,7 @@ jobs:
working-directory: ./pkgs/jni
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- uses: subosito/flutter-action@44ac965b96f18d999802d4b807e3256d5a3f9fa1
- uses: subosito/flutter-action@74af56c5ed2697ba4621264652728e8d217e53d3
with:
channel: 'stable'
cache: true
Expand All @@ -294,7 +294,7 @@ jobs:
uses: ConorMacBride/install-package@3e7ad059e07782ee54fa35f827df52aae0626f30
with:
brew: clang-format
- uses: subosito/flutter-action@44ac965b96f18d999802d4b807e3256d5a3f9fa1
- uses: subosito/flutter-action@74af56c5ed2697ba4621264652728e8d217e53d3
with:
channel: 'stable'
cache: true
Expand All @@ -317,7 +317,7 @@ jobs:
working-directory: ./pkgs/jni/example
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- uses: subosito/flutter-action@44ac965b96f18d999802d4b807e3256d5a3f9fa1
- uses: subosito/flutter-action@74af56c5ed2697ba4621264652728e8d217e53d3
with:
channel: 'stable'
cache: true
Expand All @@ -341,7 +341,7 @@ jobs:
working-directory: ./pkgs/jni/example
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- uses: subosito/flutter-action@44ac965b96f18d999802d4b807e3256d5a3f9fa1
- uses: subosito/flutter-action@74af56c5ed2697ba4621264652728e8d217e53d3
with:
channel: 'stable'
cache: true
Expand All @@ -365,7 +365,7 @@ jobs:
with:
distribution: 'zulu'
java-version: '17'
- uses: subosito/flutter-action@44ac965b96f18d999802d4b807e3256d5a3f9fa1
- uses: subosito/flutter-action@74af56c5ed2697ba4621264652728e8d217e53d3
with:
channel: 'stable'
cache: true
Expand All @@ -380,7 +380,7 @@ jobs:
working-directory: ./pkgs/jnigen/example/pdfbox_plugin
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- uses: subosito/flutter-action@44ac965b96f18d999802d4b807e3256d5a3f9fa1
- uses: subosito/flutter-action@74af56c5ed2697ba4621264652728e8d217e53d3
with:
channel: 'stable'
cache: true
Expand Down
11 changes: 10 additions & 1 deletion .github/workflows/native.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683

- uses: dart-lang/setup-dart@0a8a0fc875eb934c15d08629302413c671d3f672
- uses: dart-lang/setup-dart@e630b99d28a3b71860378cafdc2a067c71107f94
with:
sdk: ${{ matrix.sdk }}

Expand Down Expand Up @@ -120,6 +120,15 @@ jobs:
- run: dart pub get -C example/link/app_with_asset_treeshaking/
if: ${{ matrix.package == 'native_assets_cli' }}

- run: dart pub get -C test_data/fail_build/
if: ${{ matrix.package == 'native_assets_builder' }}

- run: dart pub get -C test_data/depend_on_fail_build/
if: ${{ matrix.package == 'native_assets_builder' }}

- run: dart pub get -C test_data/depend_on_fail_build_app/
if: ${{ matrix.package == 'native_assets_builder' }}

- run: dart analyze --fatal-infos
# Run on dev to ensure we're not depending on deprecated SDK things.

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/native_toolchain_c.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683

- uses: dart-lang/setup-dart@0a8a0fc875eb934c15d08629302413c671d3f672
- uses: dart-lang/setup-dart@e630b99d28a3b71860378cafdc2a067c71107f94
with:
sdk: ${{ matrix.sdk }}

Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/objective_c.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
fail-fast: false
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- uses: subosito/flutter-action@44ac965b96f18d999802d4b807e3256d5a3f9fa1
- uses: subosito/flutter-action@74af56c5ed2697ba4621264652728e8d217e53d3
with:
channel: 'stable'
- id: install
Expand All @@ -52,7 +52,7 @@ jobs:
working-directory: pkgs/objective_c/
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- uses: subosito/flutter-action@44ac965b96f18d999802d4b807e3256d5a3f9fa1
- uses: subosito/flutter-action@74af56c5ed2697ba4621264652728e8d217e53d3
with:
channel: 'stable'
- name: Install dependencies
Expand Down Expand Up @@ -88,7 +88,7 @@ jobs:
working-directory: pkgs/objective_c/example/
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- uses: subosito/flutter-action@44ac965b96f18d999802d4b807e3256d5a3f9fa1
- uses: subosito/flutter-action@74af56c5ed2697ba4621264652728e8d217e53d3
with:
channel: 'stable'
- name: Install dependencies
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/swift2objc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
fail-fast: false
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- uses: dart-lang/setup-dart@0a8a0fc875eb934c15d08629302413c671d3f672
- uses: dart-lang/setup-dart@e630b99d28a3b71860378cafdc2a067c71107f94
with:
sdk: stable
- id: install
Expand All @@ -50,7 +50,7 @@ jobs:
working-directory: pkgs/swift2objc/
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- uses: dart-lang/setup-dart@0a8a0fc875eb934c15d08629302413c671d3f672
- uses: dart-lang/setup-dart@e630b99d28a3b71860378cafdc2a067c71107f94
with:
sdk: stable
- name: Install dependencies
Expand Down
9 changes: 8 additions & 1 deletion pkgs/ffigen/lib/src/code_generator/pointer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,8 @@ class ObjCObjectPointer extends PointerType {
bool isSupertypeOf(Type other) {
other = other.typealiasType;
// id/Object* is a supertype of all ObjC objects and blocks.
return other is ObjCObjectPointer || other is ObjCInterface ||
return other is ObjCObjectPointer ||
other is ObjCInterface ||
other is ObjCBlock;
}
}
Expand All @@ -176,4 +177,10 @@ class ObjCBlockPointer extends ObjCObjectPointer {

@override
String? generateRetain(String value) => 'objc_retainBlock($value)';

@override
bool isSupertypeOf(Type other) {
other = other.typealiasType;
return other is ObjCBlockPointer || other is ObjCBlock;
}
}
1 change: 0 additions & 1 deletion pkgs/ffigen/lib/src/header_parser/parser.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import 'package:logging/logging.dart';
import '../code_generator.dart';
import '../code_generator/utils.dart';
import '../config_provider.dart';
import '../config_provider/config_types.dart';
import '../strings.dart' as strings;
import '../visitor/apply_config_filters.dart';
import '../visitor/ast.dart';
Expand Down
4 changes: 3 additions & 1 deletion pkgs/ffigen/lib/src/visitor/fix_overridden_methods.dart
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,9 @@ class FixOverriddenMethodsVisitation extends Visitation {
final (root, rootMethod) = _findRootWithMethod(node, method);
// If method and rootMethod are the same kind, then there's nothing to do.
if ((method.kind == ObjCMethodKind.propertyGetter) ==
(rootMethod.kind == ObjCMethodKind.propertyGetter)) continue;
(rootMethod.kind == ObjCMethodKind.propertyGetter)) {
continue;
}
_convertAllSubtreeMethodsToProperties(root, rootMethod);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import 'dart:io';

import 'package:ffigen/ffigen.dart';
import 'package:ffigen/src/code_generator/utils.dart';
import 'package:ffigen/src/config_provider/config.dart';
import 'package:ffigen/src/config_provider/config_types.dart';
import 'package:logging/logging.dart';
import 'package:pub_semver/pub_semver.dart';
Expand Down
36 changes: 28 additions & 8 deletions pkgs/ffigen/test/unit_tests/subtyping_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@ void main() {
final uncle = makeInterface('Uncle', grandparent);
final child = makeInterface('Child', parent);

ObjCBlock makeBlock(Type returnType, List<Type> argTypes) => ObjCBlock(
returnType: returnType,
params: [
for (final t in argTypes) Parameter(type: t, objCConsumed: false),
],
returnsRetained: false,
builtInFunctions: builtInFunctions);

group('ObjCInterface', () {
test('subtype', () {
expect(parent.isSubtypeOf(parent), isTrue);
Expand Down Expand Up @@ -140,14 +148,6 @@ void main() {
});

group('ObjCBlock', () {
ObjCBlock makeBlock(Type returnType, List<Type> argTypes) => ObjCBlock(
returnType: returnType,
params: [
for (final t in argTypes) Parameter(type: t, objCConsumed: false),
],
returnsRetained: false,
builtInFunctions: builtInFunctions);

test('covariant returns', () {
// Return types are covariant. S Function() <: T Function() if S <: T.
final returnsParent = makeBlock(parent, []);
Expand Down Expand Up @@ -237,5 +237,25 @@ void main() {
expect(makeTypealias(parent).isSubtypeOf(child), isFalse);
expect(parent.isSubtypeOf(makeTypealias(child)), isFalse);
});

test('ObjCObjectPointer', () {
expect(ObjCObjectPointer().isSubtypeOf(ObjCObjectPointer()), isTrue);
expect(parent.isSubtypeOf(ObjCObjectPointer()), isTrue);
expect(ObjCObjectPointer().isSubtypeOf(parent), isFalse);

final block = makeBlock(voidType, []);
expect(block.isSubtypeOf(ObjCObjectPointer()), isTrue);
expect(ObjCObjectPointer().isSubtypeOf(block), isFalse);
});

test('ObjCBlockPointer', () {
expect(ObjCBlockPointer().isSubtypeOf(ObjCBlockPointer()), isTrue);
expect(parent.isSubtypeOf(ObjCBlockPointer()), isFalse);
expect(ObjCBlockPointer().isSubtypeOf(parent), isFalse);

final block = makeBlock(voidType, []);
expect(block.isSubtypeOf(ObjCBlockPointer()), isTrue);
expect(ObjCBlockPointer().isSubtypeOf(block), isFalse);
});
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ void main() async {
applicationAssetValidator: validateCodeAssetInApplication,
))!;
final hookUri = packageUri.resolve('hook/build.dart');
print(logMessages.join('\n'));
expect(
logMessages.join('\n'),
isNot(contains('Recompiling ${hookUri.toFilePath()}')),
Expand Down
Loading

0 comments on commit d02eb07

Please sign in to comment.