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

feat: Add new ArrayBuffer APIs (copy(), wrap(), allocate(), toData()) #463

Merged
merged 11 commits into from
Jan 7, 2025

Conversation

mrousavy
Copy link
Owner

@mrousavy mrousavy commented Jan 7, 2025

Caution

BREAKING CHANGE: A Swift ArrayBufferHolder's .data property is now UnsafeMutablePointer<UInt8> instead of UnsafeMutableRawPointer. This is safer and more performant.

Adds a few new features around ArrayBuffers:

  • Kotlin
    • Add copy(ByteBuffer)
    • Rename copyOf to copy
  • Swift
    • Add ArrayBufferHolder.wrap(UnsafeMutableRawPointer, ...)
    • Add ArrayBufferHolder.copy(UnsafeMutablePointer<UInt8>, ...)
    • Add ArrayBufferHolder.copy(UnsafeMutableRawPointer, ...)
    • Add ArrayBufferHolder.copy(Data)
    • Add ArrayBufferHolder.toData()
    • BREAKING: Change type of ArrayBufferHolder.data from void* (UnsafeMutableRawPointer) to uint8_t* (UnsafeMutablePointer<UInt8>) as it was an unnecessary upcast before!
  • C++
    • Add ArrayBuffer::wrap(uint8_t*, size_t, DeleteFn&&)
    • Add ArrayBuffer::copy(uint8_t*, size_t)
    • Add ArrayBuffer::allocate(size_t)
    • Add ArrayBuffer::copy(std::vector<uint8_t>&)
    • Rename makeBuffer to copy

Add docs for all of that :)

Copy link

vercel bot commented Jan 7, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
nitro-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 7, 2025 3:35pm

@mrousavy mrousavy merged commit a06c7d4 into main Jan 7, 2025
12 checks passed
@mrousavy mrousavy changed the title feat: Add ArrayBuffer::copyBuffer(..) API feat: Add new ArrayBuffer APIs (copy(), wrap(), allocate(), toData()) Jan 7, 2025
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