Closed
Bug 1048659
Opened 10 years ago
Closed 10 years ago
Returning unions from JS-implemented WebIDL doesn't work
Categories
(Core :: DOM: Core & HTML, defect)
Core
DOM: Core & HTML
Tracking
()
RESOLVED
FIXED
mozilla34
People
(Reporter: bholley, Assigned: mccr8)
References
(Blocks 1 open bug)
Details
Attachments
(1 file, 1 obsolete file)
15.80 KB,
patch
|
peterv
:
review+
|
Details | Diff | Splinter Review |
WebIDL:
(TestInterfaceJSUnionableDictionary or long) pingPongDictionaryOrLong(optional (TestInterfaceJSUnionableDictionary or long) dictOrLong);
JS Implementation method:
pingPongDictionaryOrLong: function(dictOrLong) { return dictOrLong; }
Generated Code: https://pastebin.mozilla.org/5813809
Note the lack of setting aRetVal in TestInterfaceJSJSImpl::PingPongDictionaryOrLong. It seems pretty clear that we need to fix something in getResultConversion, but I don't want to get sidetracked with that right now.
Test coverage for this can be easily enabled by removing the try/catch in test_bug1036214.
Reporter | ||
Comment 1•10 years ago
|
||
I'm guessing that this is something that Boris can fix in a matter of minutes, so I'm putting it in his NI bucket for when he gets back from vacation. No hurry at all here Boris.
Flags: needinfo?(bzbarsky)
Reporter | ||
Comment 2•10 years ago
|
||
Actually, I had to remove the try/catch, because we end up throwing an uncatchable exception - I just made the return type of the method |long| for now.
Comment 4•10 years ago
|
||
Mmm... the tests for this are commented out in TestJSImplGen, lovely.
This used to just fail codegen until I partially implemented it (by accident) in bug 949264; now it just does the wrong thing.
I think all that's needed here is to change getJSToNativeConversionTemplate for unions to do two things:
1) Replace most (all?) uses of isMember by "isMember or isCallbackReturnValue". That will make the conversion happen directly into declName, which will be of owning union type. Maybe make a new isOwningUnion boolean?
2) Crib what the isMozMap() case in getJSToNativeConversionTemplate does to declType/declArgs when not isMember and isCallbackReturnValue. Just make sure to not clobber earlier sets of declArgs, if any.
2)
Flags: needinfo?(bzbarsky)
Comment 5•10 years ago
|
||
Oh, and the point is that (2) will make the declName be a reference to aRetval, so the data will end up in the right place.
Assignee | ||
Comment 6•10 years ago
|
||
I implemented something following bz's comment 4 and it seems to produce reasonable looking output that compiles in one case.
Comment 7•10 years ago
|
||
Why only in the non-nullable case?
Assignee | ||
Comment 8•10 years ago
|
||
(In reply to On vacation Aug 5-18. Please do not request review. from comment #7)
> Why only in the non-nullable case?
Oops, thanks for pointing that out.
The TestExampleGen.webidl cases that return unions were also commented out. Uncommenting them produces:
void ReceiveUnion(OwningCanvasPatternOrCanvasGradient& aRetVal);
void ReceiveUnion2(JSContext* cx, OwningObjectOrLong& aRetVal);
void ReceiveUnionContainingNull(OwningCanvasPatternOrNullOrCanvasGradient& aRetVal);
void ReceiveNullableUnion(Nullable<OwningCanvasPatternOrCanvasGradient>& aRetVal);
void ReceiveNullableUnion2(JSContext* cx, Nullable<OwningObjectOrLong>& aRetVal);
void GetWritableUnion(OwningCanvasPatternOrCanvasGradient& aRetVal) const;
void SetWritableUnion(const CanvasPatternOrCanvasGradient& arg);
void GetWritableUnionContainingNull(OwningCanvasPatternOrNullOrCanvasGradient& aRetVal) const;
void SetWritableUnionContainingNull(const CanvasPatternOrNullOrCanvasGradient& arg);
void GetWritableNullableUnion(Nullable<OwningCanvasPatternOrCanvasGradient>& aRetVal) const;
void SetWritableNullableUnion(const Nullable<CanvasPatternOrCanvasGradient>& arg);
These look reasonable to me, I guess.
Assignee | ||
Comment 9•10 years ago
|
||
I included a few basic tests, as the broken version still compiled, so that's obviously not sufficient.
Attachment #8468923 -
Attachment is obsolete: true
Assignee | ||
Updated•10 years ago
|
Blocks: ParisBindings
Assignee | ||
Updated•10 years ago
|
Attachment #8469645 -
Flags: review?(peterv)
Assignee | ||
Comment 10•10 years ago
|
||
green L64 debug try run: https://treeherder.mozilla.org/ui/#/jobs?repo=try&revision=6a53376d32a4
Comment 11•10 years ago
|
||
Comment on attachment 8469645 [details] [diff] [review]
Return the union we construct in a JS callback.
Review of attachment 8469645 [details] [diff] [review]:
-----------------------------------------------------------------
::: dom/bindings/test/test_returnUnion.html
@@ +26,5 @@
> + is(t.pingPongUnionContainingNull(t2), t2, "ping pong union containing null right case should be identity");
> +
> + is(t.pingPongNullableUnion(t2), t2, "ping pong nullable union left case should be identity");
> + is(t.pingPongNullableUnion(12), 12, "ping pong nullable union for right case should be identity");
> + is(t.pingPongNullableUnion(null), null, "ping pong nullable union for null case should be identity");
Maybe you should use this form of the phrase with "for" everywhere, it's slightly more readable.
Attachment #8469645 -
Flags: review?(peterv) → review+
Assignee | ||
Comment 12•10 years ago
|
||
(In reply to Peter Van der Beken [:peterv] from comment #11)
> Maybe you should use this form of the phrase with "for" everywhere, it's
> slightly more readable.
Good point. Done.
https://hg.mozilla.org/integration/mozilla-inbound/rev/6673cfac7488
Assignee | ||
Updated•10 years ago
|
Assignee | ||
Updated•10 years ago
|
OS: Mac OS X → All
Hardware: x86 → All
Assignee | ||
Comment 13•10 years ago
|
||
Thanks for explaining how to fix this, Boris, it made it a lot easier.
Comment 14•10 years ago
|
||
Thank you for writing the patch and everything!
Comment 15•10 years ago
|
||
Status: NEW → RESOLVED
Closed: 10 years ago
Flags: in-testsuite+
Resolution: --- → FIXED
Target Milestone: --- → mozilla34
Updated•6 years ago
|
Component: DOM → DOM: Core & HTML
You need to log in
before you can comment on or make changes to this bug.
Description
•