[ffigen] Add the ability to get a pointer to an objective C object (#568)
diff --git a/pkgs/ffigen/lib/src/code_generator/objc_block.dart b/pkgs/ffigen/lib/src/code_generator/objc_block.dart index 310fef1..1599748 100644 --- a/pkgs/ffigen/lib/src/code_generator/objc_block.dart +++ b/pkgs/ffigen/lib/src/code_generator/objc_block.dart
@@ -139,9 +139,6 @@ s.write('''); }'''); - // Get the pointer to the underlying block. - s.write(' ${blockPtr.getCType(w)} get pointer => _id;\n'); - s.write('}\n'); return BindingString( type: BindingStringType.objcBlock, string: s.toString());
diff --git a/pkgs/ffigen/lib/src/code_generator/objc_built_in_functions.dart b/pkgs/ffigen/lib/src/code_generator/objc_built_in_functions.dart index ebb4b20..05cd130 100644 --- a/pkgs/ffigen/lib/src/code_generator/objc_built_in_functions.dart +++ b/pkgs/ffigen/lib/src/code_generator/objc_built_in_functions.dart
@@ -242,6 +242,9 @@ @override int get hashCode => _id.hashCode; + + /// Return a pointer to this object. + $idType get pointer => _id; } '''); }
diff --git a/pkgs/ffigen/test/native_objc_test/cast_test.dart b/pkgs/ffigen/test/native_objc_test/cast_test.dart index 55b787b..c63d940 100644 --- a/pkgs/ffigen/test/native_objc_test/cast_test.dart +++ b/pkgs/ffigen/test/native_objc_test/cast_test.dart
@@ -40,6 +40,11 @@ expect(fromCast, testInstance!); }); + test('pointers are equal', () { + final meAsInt = testInstance!.meAsInt(); + expect(testInstance!.pointer.address, meAsInt); + }); + test('equality equals', () { final meAsInt = testInstance!.meAsInt(); final fromCast = Castaway.castFromPointer(