Skip to content

Commit

Permalink
[ffigen] Remove objc_retain from bindings (#1888)
Browse files Browse the repository at this point in the history
  • Loading branch information
liamappelbe authored Jan 14, 2025
1 parent 5e48015 commit 7c7cced
Show file tree
Hide file tree
Showing 7 changed files with 1,527 additions and 1,552 deletions.
1 change: 1 addition & 0 deletions pkgs/ffigen/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
- Handle dart typedefs in import/export of symbol files.
- Add support for blocking ObjC blocks that can be invoked from any thread.
- Add support for blocking ObjC protocol methods.
- Remove explicit `objc_retain` calls from the generated bindings.

## 16.0.0

Expand Down
3 changes: 2 additions & 1 deletion pkgs/ffigen/lib/src/code_generator/objc_interface.dart
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,8 @@ ${generateAsStub ? '' : _generateMethods(w)}
}

@override
String? generateRetain(String value) => 'objc_retain($value)';
String? generateRetain(String value) =>
'(__bridge id)(__bridge_retained void*)($value)';

@override
void visit(Visitation visitation) => visitation.visitObjCInterface(this);
Expand Down
5 changes: 3 additions & 2 deletions pkgs/ffigen/lib/src/code_generator/pointer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ class IncompleteArray extends PointerType {

@override
String getNativeType({String varName = ''}) =>
'${child.getNativeType()} $varName[]';
'${child.getNativeType()}* $varName';

@override
String toString() => '$child[]';
Expand Down Expand Up @@ -153,7 +153,8 @@ class ObjCObjectPointer extends PointerType {
'${getDartType(w)}($value, retain: $objCRetain, release: true)';

@override
String? generateRetain(String value) => 'objc_retain($value)';
String? generateRetain(String value) =>
'(__bridge id)(__bridge_retained void*)($value)';

@override
bool isSupertypeOf(Type other) {
Expand Down
1 change: 0 additions & 1 deletion pkgs/ffigen/lib/src/code_generator/writer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,6 @@ class Writer {
#error "This file must be compiled with ARC enabled"
#endif
id objc_retain(id);
id objc_retainBlock(id);
''');

Expand Down
Loading

0 comments on commit 7c7cced

Please sign in to comment.