Closed Bug 1784266 Opened 4 years ago Closed 4 years ago

Generate a initializer method for unions

Categories

(Core :: DOM: Bindings (WebIDL), enhancement)

enhancement

Tracking

()

RESOLVED FIXED
107 Branch
Tracking Status
firefox107 --- fixed

People

(Reporter: saschanaz, Assigned: edgar)

References

Details

Attachments

(3 files, 8 external files, 4 obsolete files)

13.46 KB, patch
Details | Diff | Splinter Review
2.57 MB, patch
Details | Diff | Splinter Review
1.29 MB, patch
Details | Diff | Splinter Review

https://phabricator.services.mozilla.com/D153782 had to handcraft its own function to try reading a JS::Value as BufferSource. This feature ideally should be provided by bindings layer so that any change in the layer won't break this function.

I think it would be nice if the codegen moved the generated code that calls the various TryToSet* methods to a single TryToSet or Init method for all union types so anyone that needs to use the same overload logic outside the binding layer doesn't have to reinvent the wheel. We do something similar for the Init methods of dictionary types, so it might make more sense to call it Init for consistency.

Assignee: nobody → echen

This also benefits bug 1712122 which will converts a js object from resolved promise into OwningStringOrBlob.

Summary: Generate a TryToSet method for unions e.g. BufferSource → Generate a initial method for unions
Attached patch binging_diff_D156176.patch (obsolete) — — Splinter Review
Attachment #9292633 - Attachment description: Bug 1784266 - Part 1: Move union conversion code generator to getUnionConversionTemplate; → Bug 1784266 - Part 1: Move union conversion code generator to getUnionConversionTemplate; r?peterv!
Attachment #9292634 - Attachment description: Bug 1784266 - Part 2: Generate init methods for union; → Bug 1784266 - Part 2: Generate init methods for union; r?peterv!
Attachment #9292659 - Attachment description: Bug 1784266 - Part 3: Use generated union init method in sandbox fetch; → Bug 1784266 - Part 3: Use generated union init method in sandbox fetch; r?peterv!
Attachment #9292674 - Attachment description: Bug 1784266 - Part 4: Use generated union init method in TextDecoderStream; → Bug 1784266 - Part 4: Use generated union init method in TextDecoderStream; r?peterv!
Attachment #9292675 - Attachment description: Bug 1784266 - Part 5: Use generated union init method in FileSystemWritableFileStream; → Bug 1784266 - Part 5: Use generated union init method in FileSystemWritableFileStream; r?peterv!
Attachment #9292676 - Attachment description: Bug 1784266 - Part 6: Hide union TrySetTo* methods; → Bug 1784266 - Part 6: Hide union TrySetTo* methods; r?peterv!

Remove the conditional Rooter member in the union conversion structure and switch
the regular union structure to use Rooted
for Record and Sequence that contains
js object (like what we do for Dictionary type). Codegen introudces a new type on
isMember in getJSToNativeConversionInfo() as we need to generate different conversion
code for Sequence and Record if they are union member which now use Rooted* instead
of *Rooter to root js object.

Depends on D156175

TrySetTo* conversion methods are generated in the regular union structure now.

Depends on D157326

Attachment #9292634 - Attachment description: Bug 1784266 - Part 2: Generate init methods for union; r?peterv! → Bug 1784266 - Part 4: Generate init methods for union; r?peterv!
Attachment #9292659 - Attachment description: Bug 1784266 - Part 3: Use generated union init method in sandbox fetch; r?peterv! → Bug 1784266 - Part 5: Use generated union init method in sandbox fetch; r?peterv!
Attachment #9292674 - Attachment description: Bug 1784266 - Part 4: Use generated union init method in TextDecoderStream; r?peterv! → Bug 1784266 - Part 6: Use generated union init method in TextDecoderStream; r?peterv!
Attachment #9292675 - Attachment description: Bug 1784266 - Part 5: Use generated union init method in FileSystemWritableFileStream; r?peterv! → Bug 1784266 - Part 7: Use generated union init method in FileSystemWritableFileStream; r?peterv!
Attachment #9292676 - Attachment description: Bug 1784266 - Part 6: Hide union TrySetTo* methods; r?peterv! → Bug 1784266 - Part 8: Hide union TrySetTo* methods; r?peterv!
Attached patch binging_diff_D157326.patch (obsolete) — — Splinter Review
Attached patch binging_diff_D157327.patch (obsolete) — — Splinter Review
Attached patch binging_diff_D156176.patch (obsolete) — — Splinter Review
Attachment #9292716 - Attachment is obsolete: true
Summary: Generate a initial method for unions → Generate a initializer method for unions
Attachment #9294643 - Attachment is obsolete: true
Attachment #9294644 - Attachment is obsolete: true
Attachment #9294647 - Attachment is obsolete: true
Pushed by echen@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/2e1bb7717cf1 Part 1: Move union conversion code generator to getUnionConversionTemplate; r=peterv https://hg.mozilla.org/integration/autoland/rev/d49d2ab5f276 Part 2: Stop using the union conversion structure to root Record/Sequence type; r=peterv https://hg.mozilla.org/integration/autoland/rev/48e614c747f4 Part 3: Get rid of union conversion structure; r=peterv https://hg.mozilla.org/integration/autoland/rev/93aa22adf984 Part 4: Generate init methods for union; r=peterv https://hg.mozilla.org/integration/autoland/rev/b9d71890967f Part 5: Use generated union init method in sandbox fetch; r=peterv,kmag https://hg.mozilla.org/integration/autoland/rev/8b3214f5f45c Part 6: Use generated union init method in TextDecoderStream; r=peterv https://hg.mozilla.org/integration/autoland/rev/feede7ecc36f Part 7: Use generated union init method in FileSystemWritableFileStream; r=peterv https://hg.mozilla.org/integration/autoland/rev/1a25e73e25c6 Part 8: Hide union TrySetTo* methods; r=peterv
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: