servo / rust-mozjs

DEPRECATED - moved to servo/mozjs instead.
Mozilla Public License 2.0
293 stars 122 forks source link

Can't use typedarray macro with generics #330

Open jdm opened 7 years ago

jdm commented 7 years ago

It is not possible to write a function that accepts a generic type that's bounded by TypedArrayElement and extracts a typed array from a JSObject pointer. The macro doesn't like typedarray!(in(cx) let foo: TypedArray<T> = ...) because it accepts an ident, not a ty, and making it accept a ty yields $crate::typedarray::TypedArray<T>::from(...) which is obviously incorrect.

emilio commented 7 years ago

We had some custom code for making the no_jsmanaged_fieds macro work with generics IIRC, probably we can do something similar.