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

Use Opaque to represent empty Structs #142

Merged
merged 2 commits into from
Jan 25, 2021

Conversation

mannprerak2
Copy link
Contributor

Closes dart-lang/native#379

  • Use Opaque for representing empty Structs.
  • Updated tests, version, changelog
  • Fixed Globals, updated Global to directly use Pointer<EmptyStruct> instead of emptyStruct.ref for getters of Opaque types.

@dcharkes All the empty structs will now be generated as Opaque, this also includes all those structs which we are unable to generate in dart:ffi, which had all their members removed. Is this the correct behavior? or should we handle those structs in some different way.

@mannprerak2 mannprerak2 requested a review from dcharkes January 21, 2021 05:57
Copy link
Contributor

@dcharkes dcharkes left a comment

Choose a reason for hiding this comment

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

lgtm

@@ -436,7 +440,7 @@ final ffi.DynamicLibrary _dylib;
/// The symbols are looked up in [dynamicLibrary].
Bindings(ffi.DynamicLibrary dynamicLibrary): _dylib = dynamicLibrary;

late final ffi.Pointer<int> _test1 = _dylib.lookup<ffi.Int32>('test1');
Copy link
Contributor

Choose a reason for hiding this comment

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

How did this not fail before?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In the last PR, Tim had updated this manually after generating the result and since the code_generator_tests compare the raw output by ffigen, dartfmt didn't run on this.

Perhaps I should update the code_generator_tests to completely generate bindings (including running dartfmt) and then compare the results? and should I do this in a new PR or this one itself?

Copy link
Contributor

Choose a reason for hiding this comment

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

Separate PR is fine.

Kinda nasty that dartfmt doesn't run on some things, otherwise we could just add tests that check that everything is formatted. Can you take a look at trying to run dartfmt on all Dart files in the repo on the CI and error out if one of them is not formatted as expected or fails to format. Maybe we can have a list of files that we should skip when checking so we can keep the CI green.

@dcharkes dcharkes merged commit 95daa0a into dart-archive:dart-dev Jan 25, 2021
@mannprerak2 mannprerak2 deleted the opaque branch January 25, 2021 09:30
mannprerak2 added a commit to mannprerak2/ffigen that referenced this pull request Mar 1, 2021
* Use Opaque to represent empty structs, updated tests, changelog, version
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.

2 participants