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

Expose array data as pointer #411

Open
jpnurmi opened this issue Aug 26, 2020 · 4 comments
Open

Expose array data as pointer #411

jpnurmi opened this issue Aug 26, 2020 · 4 comments
Labels
package:ffigen waiting-on-dart-ffi Issues which are blocked by lacking suppport in dart:ffi

Comments

@jpnurmi
Copy link
Contributor

jpnurmi commented Aug 26, 2020

Consider the aiString structure in Assimp:

struct aiString {
    uint32_t length;
    char data[1024];
};

While the ArrayHelper, that is generated for the data, does offer [] and []= operators for accessing and manipulating the data at each index one by one, it seems like it would be more useful to expose the array data as a pointer:

class aiString extends Struct {
  @Uint32()
  int length;

  Pointer<Int8> get data => Pointer<Int8>.fromAddress(addressOf.address + sizeOf<Uint32>());
}

Int8Pointer would not only offer the same operators, but would also let you have the data as a typed list view too. This struct here is extremely simple, though. Things might get hairy if there are holes/padding involved.

@jpnurmi
Copy link
Contributor Author

jpnurmi commented Aug 27, 2020

Oh, and if dart:ffi had something like @Padding(1024), you could easily fill up the memory gap without having to generate 1024 x Int8.

@dcharkes
Copy link
Collaborator

Blocked by dart-lang/sdk#35763.

@dcharkes dcharkes added the waiting-on-dart-ffi Issues which are blocked by lacking suppport in dart:ffi label Aug 31, 2020
@maks
Copy link

maks commented Feb 19, 2022

@dcharkes is this still blocked given that dart-lang/sdk#35763 has been closed?

@dcharkes
Copy link
Collaborator

Shouldn't that generate the following now?

class aiString extends Struct {
  @Uint32()
  int length;

  Array<Int8> data;
}

Array already provides index access.

https://api.dart.dev/stable/2.14.1/dart-ffi/Array-class.html

Side note: exposing as Pointer would not work. Because the struct might be passed by value and live in Dart memory instead of C memory, in which case it is backed by a TypedData rather than a Pointer. Array wraps either of those.

@liamappelbe liamappelbe transferred this issue from dart-archive/ffigen Nov 15, 2023
HosseinYousefi pushed a commit that referenced this issue Nov 16, 2023
Bumps [subosito/flutter-action](https://github.com/subosito/flutter-action) from 2.10.0 to 2.12.0.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a href="https://github.com/subosito/flutter-action/releases">subosito/flutter-action's releases</a>.</em></p>
<blockquote>
<h2>v2.12.0</h2>
<p>No release notes provided.</p>
<h2>v2.11.0</h2>
<p>Allow git ref as version for master channel:</p>
<pre lang="yaml"><code>steps:
- uses: actions/checkout@v3
- uses: subosito/flutter-action@v2
  with:
    flutter-version: '5b12b74' # tag, commit or branch
    channel: 'master'
- run: flutter --version
</code></pre>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="https://github.com/subosito/flutter-action/commit/2783a3f08e1baf891508463f8c6653c258246225"><code>2783a3f</code></a> ensure setup.sh executable; fixes <a href="https://github.com/subosito/flutter-action/issues/245">#245</a></li>
<li><a href="https://github.com/subosito/flutter-action/commit/c33c37022b3aac486cc5e7aea5c7f6b8b0f421e1"><code>c33c370</code></a> Extract to a temporary location to enable moving of flutter folder. (<a href="https://github.com/subosito/flutter-action/issues/227">#227</a>)</li>
<li><a href="https://github.com/subosito/flutter-action/commit/cc97e1648fff6ca5cc647fa67f47e70f7895510b"><code>cc97e16</code></a> feat: Allow git ref as version in <code>master</code> channel (<a href="https://github.com/subosito/flutter-action/issues/237">#237</a>)</li>
<li><a href="https://github.com/subosito/flutter-action/commit/ed388baf1d5404fd6ef3c54c2f82e6159150b60f"><code>ed388ba</code></a> fixes <a href="https://github.com/subosito/flutter-action/issues/224">#224</a>; update readme</li>
<li>See full diff in <a href="https://github.com/subosito/flutter-action/compare/48cafc24713cca54bbe03cdc3a423187d413aafa...2783a3f08e1baf891508463f8c6653c258246225">compare view</a></li>
</ul>
</details>
<br />

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=subosito/flutter-action&package-manager=github_actions&previous-version=2.10.0&new-version=2.12.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)

</details>
HosseinYousefi pushed a commit that referenced this issue Nov 16, 2023
Bumps [subosito/flutter-action](https://github.com/subosito/flutter-action) from 2.10.0 to 2.12.0.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a href="https://github.com/subosito/flutter-action/releases">subosito/flutter-action's releases</a>.</em></p>
<blockquote>
<h2>v2.12.0</h2>
<p>No release notes provided.</p>
<h2>v2.11.0</h2>
<p>Allow git ref as version for master channel:</p>
<pre lang="yaml"><code>steps:
- uses: actions/checkout@v3
- uses: subosito/flutter-action@v2
  with:
    flutter-version: '5b12b74' # tag, commit or branch
    channel: 'master'
- run: flutter --version
</code></pre>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="https://github.com/subosito/flutter-action/commit/2783a3f08e1baf891508463f8c6653c258246225"><code>2783a3f</code></a> ensure setup.sh executable; fixes <a href="https://github.com/subosito/flutter-action/issues/245">#245</a></li>
<li><a href="https://github.com/subosito/flutter-action/commit/c33c37022b3aac486cc5e7aea5c7f6b8b0f421e1"><code>c33c370</code></a> Extract to a temporary location to enable moving of flutter folder. (<a href="https://github.com/subosito/flutter-action/issues/227">#227</a>)</li>
<li><a href="https://github.com/subosito/flutter-action/commit/cc97e1648fff6ca5cc647fa67f47e70f7895510b"><code>cc97e16</code></a> feat: Allow git ref as version in <code>master</code> channel (<a href="https://github.com/subosito/flutter-action/issues/237">#237</a>)</li>
<li><a href="https://github.com/subosito/flutter-action/commit/ed388baf1d5404fd6ef3c54c2f82e6159150b60f"><code>ed388ba</code></a> fixes <a href="https://github.com/subosito/flutter-action/issues/224">#224</a>; update readme</li>
<li>See full diff in <a href="https://github.com/subosito/flutter-action/compare/48cafc24713cca54bbe03cdc3a423187d413aafa...2783a3f08e1baf891508463f8c6653c258246225">compare view</a></li>
</ul>
</details>
<br />

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=subosito/flutter-action&package-manager=github_actions&previous-version=2.10.0&new-version=2.12.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)

</details>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package:ffigen waiting-on-dart-ffi Issues which are blocked by lacking suppport in dart:ffi
Projects
None yet
Development

No branches or pull requests

4 participants