Skip to content
This repository has been archived by the owner on Jan 28, 2024. It is now read-only.

Commit

Permalink
fix: objc block trampoline invalid return type (#607)
Browse files Browse the repository at this point in the history
  • Loading branch information
vaind authored Sep 1, 2023
1 parent 952483b commit 3508f98
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion example/objective_c/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ headers:
entry-points:
- '/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/AVFAudio.framework/Headers/AVAudioPlayer.h'
preamble: |
// ignore_for_file: camel_case_types, non_constant_identifier_names, unused_element, unused_field, return_of_invalid_type, void_checks, annotate_overrides, no_leading_underscores_for_local_identifiers, library_private_types_in_public_api
// ignore_for_file: camel_case_types, non_constant_identifier_names, unused_element, unused_field, void_checks, annotate_overrides, no_leading_underscores_for_local_identifiers, library_private_types_in_public_api
10 changes: 8 additions & 2 deletions lib/src/code_generator/objc_block.dart
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,14 @@ $voidPtr $registerClosure(Function fn) {
s.write(', ${params[i].type.getDartType(w)} ${params[i].name}');
}
s.write(') {\n');
s.write(' ${isVoid ? '' : 'return '}$closureRegistry['
'block.ref.target.address]!(');
s.write(' ${isVoid ? '' : 'return '}');
s.write('($closureRegistry[block.ref.target.address]');
s.write(' as ${returnType.getDartType(w)} Function(');
for (int i = 0; i < params.length; ++i) {
s.write('${i == 0 ? '' : ', '}${params[i].type.getDartType(w)}');
}
s.write('))');
s.write('(');
for (int i = 0; i < params.length; ++i) {
s.write('${i == 0 ? '' : ', '}${params[i].name}');
}
Expand Down
2 changes: 2 additions & 0 deletions test/native_objc_test/setup.dart
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ Future<void> clean(List<String> testNames) async {
}

Future<void> main(List<String> arguments) async {
// Allow running this script directly from any path (or an IDE).
Directory.current = Platform.script.resolve('.').toFilePath();
if (!Platform.isMacOS) {
throw OSError('Objective C tests are only supported on MacOS');
}
Expand Down

0 comments on commit 3508f98

Please sign in to comment.