Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option to generate pointers to fields on struct pointers #331

Open
dcharkes opened this issue Aug 30, 2021 · 0 comments
Open

Option to generate pointers to fields on struct pointers #331

dcharkes opened this issue Aug 30, 2021 · 0 comments
Labels
package:ffigen type-enhancement A request for a change that isn't a bug waiting-on-dart-ffi Issues which are blocked by lacking suppport in dart:ffi

Comments

@dcharkes
Copy link
Collaborator

After we address dart-lang/sdk#41237.

We can add an option to generate extension methods for Pointers to fields of Pointer<MyStruct>:

If we settle on an API like this for getting the offsets:

class MyStruct extends Struct {
  @Int32()
  external int foo;
  @Int64()
  external int bar;

  @OffsetOf(#foo)
  external const int offsetOfFoo;
  @OffsetOf(#bar)
  external const int offsetOfBar;
}

Then we could generate extension methods such as:

extension MyStructFields on Pointer<MyStruct> {
  Pointer<Int32> foo => Pointer.fromAddress(address + MyStruct.offsetOfFoo);

  Pointer<Int64> bar => Pointer.fromAddress(address + MyStruct.offsetOfBar);
}

Which would be handy for cases like dart-archive/ffi#117.

@dcharkes dcharkes added type-enhancement A request for a change that isn't a bug waiting-on-dart-ffi Issues which are blocked by lacking suppport in dart:ffi labels Aug 30, 2021
@liamappelbe liamappelbe transferred this issue from dart-archive/ffigen Nov 15, 2023
parlough pushed a commit to parlough/native that referenced this issue Apr 8, 2024
* Improve Type deduping in objc_msgSend

* WIP

* Finish cleanup

* Fix analysis
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package:ffigen type-enhancement A request for a change that isn't a bug waiting-on-dart-ffi Issues which are blocked by lacking suppport in dart:ffi
Projects
None yet
Development

No branches or pull requests

2 participants