Skip to content

Typed Array discoverability - #909

Merged
dherman merged 31 commits into
mainfrom
typed-array-discoverability
Sep 14, 2022
Merged

Typed Array discoverability#909
dherman merged 31 commits into
mainfrom
typed-array-discoverability

Conversation

@dherman

@dherman dherman commented Jun 17, 2022

Copy link
Copy Markdown
Collaborator

This PR adds API docs for typed arrays, as well as several conveniences in the API:

  • JsTypedArray::new() and JsTypedArray::from_buffer for constructing typed array objects
  • Type aliases for typed array types (e.g. JsUint32Array)

Collectively, these changes should make the Neon typed arrays API more discoverable and easier to get started using.

RFC: neon-bindings/rfcs#47

@dherman
dherman marked this pull request as ready for review July 1, 2022 00:45
@dherman dherman changed the title [draft] Typed Array discoverability Typed Array discoverability Jul 1, 2022
Comment thread crates/neon/src/lib.rs
Comment thread crates/neon/src/types_impl/buffer/types.rs
Comment thread crates/neon/src/types_impl/buffer/types.rs Outdated
Comment thread crates/neon/src/types_impl/buffer/types.rs Outdated
Comment thread crates/neon/src/types_impl/buffer/types.rs Outdated
Comment thread crates/neon/src/types_impl/buffer/types.rs Outdated
Comment thread crates/neon/src/types_impl/buffer/types.rs
@dherman
dherman force-pushed the typed-array-discoverability branch from 0a79f32 to 7ac46cb Compare July 8, 2022 17:57
Comment thread crates/neon/src/types_impl/buffer/types.rs Outdated
Comment thread crates/neon/src/types_impl/buffer/types.rs Outdated
Comment thread crates/neon/src/types_impl/buffer/types.rs Outdated
Comment thread test/napi/src/js/objects.rs Outdated
Comment thread test/napi/src/js/objects.rs Outdated
Comment thread crates/neon/src/types_impl/buffer/types.rs Outdated
@dherman
dherman force-pushed the typed-array-discoverability branch from 1601966 to bdf4a41 Compare July 12, 2022 07:12
dherman added 18 commits July 22, 2022 13:59
…:types API docs

- Delete the PowerPoint-generated digram
- Refactor the module tree slightly, in order to wrap the module docs with `#[aquamarine]` attribute
- Flesh out the remaining blank spots in the typed array API docs
- Change the `Binary` trait to use an associated constant instead of a nullary method
- change from top-to-bottom to left-to-right
- make rectangles rounded
…opy around them

- Turn every node in the diagrams into a link to the relevant type's API docs
… convenient `from_buffer()`

- Add `TypedArray::byte_length()`
- Add `JsTypedArray::{byte_offset, buffer}`
- Revert visibility of Binary back to public to enable typed array abstractions
- Add tests for buffer aliasing and argument validation
- Add tests for `byte_length`, `byte_offset`, and `buffer` methods
…l the metadata, avoiding extra FFI calls to

retrieve that data.
@dherman
dherman force-pushed the typed-array-discoverability branch from 26a4d59 to 3f0fc4c Compare July 22, 2022 21:00
Comment thread crates/neon/src/types_impl/buffer/types.rs
dherman added 2 commits August 1, 2022 11:15
- byte_offset -> offset
- byte_length -> size
- to_region -> region
- to_typed_array and region take &self
- JsArrayBuffer::region static method, for doc discoverability
- add tests about region validation
@dherman
dherman requested a review from kjvalencik August 1, 2022 20:58
Comment thread crates/neon/src/types_impl/buffer/types.rs
Comment thread crates/neon/Cargo.toml Outdated
Comment thread crates/neon/src/types_impl/buffer/mod.rs Outdated
Comment thread crates/neon/src/types_impl/buffer/mod.rs Outdated
Comment thread crates/neon/src/types_impl/buffer/mod.rs Outdated
Comment thread crates/neon/src/types_impl/buffer/mod.rs Outdated
Comment thread crates/neon/src/types_impl/buffer/types.rs Outdated
Comment thread crates/neon/src/types_impl/buffer/types.rs Outdated
Comment thread crates/neon/src/types_impl/buffer/types.rs
Comment thread crates/neon/src/types_impl/buffer/types.rs
Comment thread test/napi/lib/typedarrays.js Outdated
Comment thread crates/neon/src/types_impl/buffer/mod.rs
Comment thread crates/neon/src/types_impl/buffer/mod.rs Outdated
- make doc-related crates (doc-comment, aquamarine) optional
- `Binary` only requires `Clone`, not `Copy` or `Debug`
- `Region` API changes
  * still impls Copy but all its methods take a reference
  * range checks throw `RangeError` instead of panicking
- minor code improvements
  * copy-editing nit in doc comment
  * `buffer/types.rs` imports from `types_impl` not `types` so it's clear why it has private access
  * use `map_err` to clean up some code
  * simplify `detach` test helper function
Comment thread crates/neon/src/types_docs.rs Outdated
Comment thread .cargo/config.toml
@dherman
dherman merged commit 37a9b93 into main Sep 14, 2022
@dherman
dherman deleted the typed-array-discoverability branch September 14, 2022 17:37
@dherman dherman mentioned this pull request Sep 16, 2022
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.

2 participants