Add the ability to get a pointer to an objective C object (#568)
diff --git a/lib/src/code_generator/objc_block.dart b/lib/src/code_generator/objc_block.dart
index 310fef1..1599748 100644
--- a/lib/src/code_generator/objc_block.dart
+++ b/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/lib/src/code_generator/objc_built_in_functions.dart b/lib/src/code_generator/objc_built_in_functions.dart
index ebb4b20..05cd130 100644
--- a/lib/src/code_generator/objc_built_in_functions.dart
+++ b/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/test/native_objc_test/cast_test.dart b/test/native_objc_test/cast_test.dart
index 55b787b..c63d940 100644
--- a/test/native_objc_test/cast_test.dart
+++ b/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(