servo / rust-mozjs

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

Implement FromJSValConvertible for *mut JSObject #321

Closed KiChjang closed 7 years ago

KiChjang commented 7 years ago

r? @Ms2ger or @nox


This change is Reviewable

Ms2ger commented 7 years ago

Doesn't compile

KiChjang commented 7 years ago

Uhh right, stupid me.

Ms2ger commented 7 years ago

These implementations crash if handed the wrong type of value. Is that intentional?

KiChjang commented 7 years ago

I essentially copied the implementation from JSVal. Shall I instead check that it is an object first, and if not, return an Err(()) or a ConversionResult::Failure?

Ms2ger commented 7 years ago

Let's take a step back. Why did you make this PR?

KiChjang commented 7 years ago

MessagePort contains a WebIDL method that looks like this:

  void postMessage(any message, optional sequence<object> transfer = []);

And so CodegenRust.py is trying to convert a JS HandleValue to a JS object, which currently doesn't exist in rust-mozjs bindings.

jdm commented 7 years ago

Given that this is only needed because of codegen for a feature we don't support yet (transferrable objects), I propose we use optional any transfer and close this PR.