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
WebIDL impl: Replace use of NonNull<JSObject> #30889
Comments
@jdm Does this make sense? Do you know why this wasn't done to begin with? |
Had a quick look everywhere, it seems there are really four cases:
|
It may be that what is required is simply implementing In some ways it would in that case still be nicer to wrap the use of |
This seems reasonable to me! I'm not sure why we didn't integrate the concrete types originally. |
Part of #30862
Where appropriate, we should remove the direct use of unsafe
NonNull<JSObject>
, and replace it with use of the appropriate safe wrapper found in/mozjs/src/typedarray.rs
.Example: AudioBuffer's
getChannelData
WedIDL says to return a
Float32Array
, but implementation returns aNonNull<JSObject>
:servo/components/script/dom/audiobuffer.rs
Line 265 in 8bbcf0a
The return value of the WebIDL method is backed by a
Heap<*mut JSObject>
on the dom struct.Solution:
use js::typedarray::Float32Array
instead ofjs::jsapi::JSObject
.Bonus: wrap the use of
js::typedarray
inside something atdom/bindings/
. (maybe seebindings/iterable.rs
for an example)How to do it?
codegen starts at(probably needs other updates):
servo/components/script/dom/bindings/codegen/CodegenRust.py
Line 1463 in 8bbcf0a
_Methods
are generated.dom/bindings
so that we don't usejs::
directly elsewhere. For example, this kind of code should be hidden from view. In some way this is probably not a bonus, but a prerequisite for 3.More investigation is probably necessary.
The text was updated successfully, but these errors were encountered: