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

Provide a helper method to wrap an ArrayBufferView #14

Merged
merged 1 commit into from
May 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/main/java/java/nio/ByteBuffer.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ public static ByteBuffer allocateDirect (int capacity) {
public static ByteBuffer wrapArrayBuffer(ArrayBuffer arrayBuffer) {
return new ByteBuffer(arrayBuffer);
}
public static ByteBuffer wrapArrayBuffer(ArrayBuffer arrayBuffer, int capacity, int offset) {
return new ByteBuffer(arrayBuffer, capacity, offset);
}
public ByteBuffer wrap(ArrayBuffer arrayBuffer) {
return new ByteBuffer(arrayBuffer);
}
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/org/gwtproject/nio/TypedArrayHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ public class TypedArrayHelper {
public static ByteBuffer wrap(ArrayBuffer ab) {
return ByteBuffer.wrapArrayBuffer(ab);
}
public static ByteBuffer wrap(ArrayBufferView ab) {
return ByteBuffer.wrapArrayBuffer(ab.buffer, ab.byteLength, ab.byteOffset);
}
public static ArrayBufferView unwrap(ByteBuffer bb) {
return bb.getTypedArray();
}
Expand Down