I took the opportunity to move away from the NonNull<nsAString> hack
we had for string arguments, since just passing in a
FakeDependentString works fine and callees are now less likely to
declare their arg as being of that type.
In the process of doing that, I ran into what looks like a substantive
bug in the "owning union with string default value" case: We were
doing mValue.mString.Value() without ever having constructed
mValue.mString!
I took the opportunity to move away from the NonNull<nsAString> hack
we had for string arguments, since just passing in a
FakeDependentString works fine and callees are now less likely to
declare their arg as being of that type.
In the process of doing that, I ran into what looks like a substantive
bug in the "owning union with string default value" case: We were
doing mValue.mString.Value() without ever having constructed
mValue.mString!
It's a little unfortunate that we need both ${jsvalHandle} and
${jsvalRef}, but the only other option is to consistently have a
MutableHandle in this code. If the thing we have to work with is a
Rooted, that means doing JS::MutableHandle<JS::Value>(&myRooted) as
the thing to substitute for ${jsvalHandle}. Just using "&myRooted"
doesn't work, because things like "&myRooted.set()" or
"&myRooted.address()" fail, even if parenthesized as
"(&myRooted).set()", because &myRooted is actually a Rooted*, not a
MutableHandle.
We could go the JS::MutableHandle<JS::Value>(&myRooted) route if
desired; it would primarily uglify dictionary and sequence to-js
conversions. With the setup in this patch, ideally it looks pretty
idiomatic except for the use of .set() instead of operator= on Rooted.
At this point we could really just hoist the JSAPI call, but it's just
cumbersome enough with all the casts that I don't really want to stick
it in the codegen.
There are several changes here:
1) Adds some MutableThis methods to Optional, Nullable, and dictionaries to
effectively allow doing a const_cast without knowing the actual type being
templated over. I needed this because I do not in fact know that type in
the relevant code. I'm open to suggestions for a better name for this
method.
2) Adds some operator& to RootedJSValue to make it look more like a JS::Value,
and in particular so I can JS_WrapValue the thing in it.
3) Adds a Slot() method to NonNullLazyRootedObject, just like NonNull has.
4) Adds an operator& to LazyRootedObject to make it look more like JSObject* so
I can JS_WrapObject the thing in it.
5) Implements the actual rewrapping of the arguments into the content compartment.
6) Fixes a small preexisting bug in which we didn't look at named constructors
in getTypesFromDescriptor (this was causing my tests to not compile).
7) Changes Xrays to not enter the content compartment when calling a WebIDL
constructor.
8) Adds some friend API to report things as not being functions.