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
jnigen should offer efficient methods to create and extract data from ByteBuffers #563
Comments
I'm creating bindings for Cronet and have two use cases: I need to convert a complete onReadCompleted: (urlRequest, responseInfo, byteBuffer) {
byteBuffer.flip();
final remaining = byteBuffer.remaining();
final data = Uint8List(remaining);
// TODO: Use a more efficient approach when
// https://github.com/dart-lang/native/issues/563 is fixed.
for (var i = 0; i < remaining; ++i) {
data[i] = byteBuffer.get1(i);
}
responseStream!.add(data);
byteBuffer.clear();
cronetRequest.read(byteBuffer);
}, I have a if (body.isNotEmpty) {
// TODO: Use a more efficient approach when
// https://github.com/dart-lang/native/issues/563 is fixed.
final bodyBytes = JArray(jbyte.type, body.length);
for (var i = 0; i < body.length; ++i) {
bodyBytes[i] = body[i];
}
builder.setUploadDataProvider(
// This also accepts a `java.nio.ByteBuffer`
jb.UploadDataProviders.create4(bodyBytes), _executor); Eventually I'll want to implement by own |
Fixed by dart-lang/jnigen#390. |
Bumps [actions/checkout](https://github.com/actions/checkout) from 3.5.0 to 3.5.2. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](actions/checkout@8f4b7f8...8e5e7e5) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
For example:
The JNI functions that can help with this are:
The text was updated successfully, but these errors were encountered: