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

Coerce BOOL to bool #311

Merged
merged 3 commits into from
Apr 12, 2022
Merged

Coerce BOOL to bool #311

merged 3 commits into from
Apr 12, 2022

Conversation

liamappelbe
Copy link
Contributor

@liamappelbe liamappelbe commented Apr 11, 2022

Objective C's BOOL type can be either bool or signed char, depending on the platform. We want to present a consistent API to the user, and those two types are ABI compatible, so just return bool regardless.
Fixes dart-lang/native#297

Also fix the one other known inconsistency, with va_list, by excluding irrelevant stuff from the native_objc_test.
Fixes dart-lang/native#309

@liamappelbe liamappelbe changed the title Make bool handling configurable Coerce BOOL to bool Apr 11, 2022
@@ -5,7 +5,7 @@ import 'dart:ffi' as ffi;
import 'package:ffi/ffi.dart' as pkg_ffi;

class Foo extends ffi.Struct {
@BOOL()
@ffi.Uint8()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do actually have a Bool type in dart:ffi, is it possible to target that instead?

sel,
aSelector,
) !=
0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do have a Bool type in dart:ffi, can we use that instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm using the existing bool infrastructure for functions and structs. The code being generated here is consistent with existing cases:
https://github.com/dart-lang/ffigen/blob/master/test/code_generator_tests/expected_bindings/_expected_boolean_dartbool_bindings.dart

If you think this should generate Bool instead, that should probably be in a separate bug/PR. It would involve changing func.dart and compound.dart, and isn't really related to this PR.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, that should be a separate PR if we don't target bool already.

@liamappelbe liamappelbe merged commit bc301d5 into master Apr 12, 2022
@liamappelbe liamappelbe deleted the boolfix branch April 12, 2022 17:57
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Objective C's va_list struct is parsed inconsistently ObjC's BOOL isn't handled correctly
2 participants