-
Notifications
You must be signed in to change notification settings - Fork 117
Usable DataView typed array bindings #453
base: master
Are you sure you want to change the base?
Conversation
Can you add to the existing tests in https://github.com/servo/rust-mozjs/blob/master/tests/typedarray.rs? You can use the example at https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView as inspiration. |
We can't use the TypedArrayElement and TypedArrayElementCreator traits since the functions of length_and_data and create_new would be different in case of a DataView. |
@jdm Help 🤕 |
Could you explain the problem that you are having? What is the code you are trying to write that is not working? |
$get_data: ident) => ( | ||
data_view_element!($t, $element, $unwrap, $length); | ||
impl TypedArrayElementCreator for $t { | ||
unsafe fn create_new(cx: *mut JSContext,array_buffer: *mut JSObject,byte_offset: u32,byte_length: u32) -> *mut JSObject { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jdm
This code creates a create_new function for data view object by extending the TypedArrayElement , and due to the mismatch in definition and prototype we are having errors like (Link to travis CI errors):
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, you're right. I don't know if we can reuse the typed array support code for data views after all :(
See this comment |
I think we will have to create a new DataView type similar to TypedArray which directly wraps these APIs and then add a macro like typedarray! which creates a rooted instance. |
I'll try doing that 👍 |
☔ The latest upstream changes (presumably #541) made this pull request unmergeable. Please resolve the merge conflicts. |
This PR tries to solve issue #406
The changes use the traits of a typed array but the APIs for Dataview object from mozjs are used.
The changes have not been tested , any suggested tests/changes would be appreciated. :)
This change is