8000 Support CharBuffer in Pointer.toBuffer by RicheyWorks · Pull Request #51 · jcuda/jcuda · GitHub
[go: up one dir, main page]

Skip to content

Support CharBuffer in Pointer.toBuffer - #51

Draft
RicheyWorks wants to merge 1 commit into
jcuda:masterfrom
RicheyWorks:fix/char-buffer-pointer-support
Draft

RicheyWorks wants to merge 1 commit into
jcuda:masterfrom
RicheyWorks:fix/char-buffer-pointer-support

Conversation

@RicheyWorks
Copy link
Copy Markdown

Pointer.toBuffer(Buffer) rejects every CharBuffer as an unknown buffer type, even though Pointer.to(char[]) and Pointer.to(Buffer) already accept character data. The missing dispatch also prevents callers from obtaining character pointers that account for the buffer's current position and array slice offset.

Add a CharBuffer path that computes byte offsets using Sizeof.CHAR. Array-backed buffers include the array offset; direct buffers retain the slice's native origin and apply the position as a byte offset. Work on a duplicate to preserve the caller's mark, position and limit, and perform offset arithmetic as long.

The shared JNI code already uses generic GetPrimitiveArrayCritical and GetDirectBufferAddress paths (jcuda-common, commit 9d41fb5), so no native code or signatures change. Read-only heap buffers remain unsupported under the existing input validation.

Validation:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

0