Closed Bug 1589285 Opened 4 months ago Closed 4 months ago

Provide a safer API for indexing into Web IDL enum string lists

Categories

(Core :: DOM: Bindings (WebIDL), task, P1)

task

Tracking

()

RESOLVED FIXED
mozilla72
Tracking Status
firefox72 --- fixed

People

(Reporter: bzbarsky, Assigned: bzbarsky)

References

Details

Attachments

(3 files)

Right now people cast their enums to ints and index into WhatevetValues::strings, which is not so great. We can provide a type-safe API instead.

Priority: -- → P1

Returning a span ensures that consumers don't try to use this without a length,
but does hide the fact that our string is always null-terminated, at least for
the moment...

Attachment #9101753 - Attachment description: Bug 1589285 part 2. Add Span<const char> overloads of some XPCOM string methods. r=froydnj → Bug 1589285 part 2. Add Span<const char> overloads of some XPCOM string methods. r=kmag

The idea is to stop directly accessing EnumTypeValues::strings in type-unsafe
ways from consumer code.

Blocks: 1582892
Pushed by bzbarsky@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/73ade09e6739
part 1.  Expose a nicer way to get strings given a Web IDL enum value.  r=edgar
https://hg.mozilla.org/integration/autoland/rev/8349fe6d5612
part 2.  Add Span<const char> overloads of some XPCOM string methods.  r=kmag
https://hg.mozilla.org/integration/autoland/rev/fbd7b66b2d88
part 3.  Use the new GetString methods for Web IDL enums in various places.  r=edgar
Status: NEW → RESOLVED
Closed: 4 months ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla72
You need to log in before you can comment on or make changes to this bug.