New issue
Advanced search Search tips

Issue 805603 link

Starred by 1 user

Issue metadata

Status: WontFix
Owner: ----
Closed: Today
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 3
Type: Feature



Sign in to add a comment

Mojo c++ bindings feature requests for enums: iterators, ParseString

Project Member Reported by dmazz...@chromium.org, Jan 24 2018

Issue description

Some feature requests for the Mojo C++ bindings.

I'm happy to contribute these, but I'd like to get thoughts from the owners first to see if these sound like a good idea or not.

(1)

I'm working on migrating the accessibility enums to mojo now, and there are a few places where we iterate over all possible values of an enum. Now that mojo generates enum classes, this is a bit uglier now (requires typecasting), but could be made even cleaner and more foolproof with autogenerated code.

Example places where we could use this:
https://cs.chromium.org/search/?q=<%3D.ax%5Cw%2Blast

We could either add an iterator (https://stackoverflow.com/questions/8498300/allow-for-range-based-for-with-enum-classes), or a function like ForAllMyEnum(void(*callback)(MyEnumValue));

(2)

Mojo generates a stream insertion operator now. It'd be nice to also provide ToString, and ParseString, which is useful for cases where we're sending an extension message from JavaScript back into C++ and the string value comes from a mojo enum.

 

Comment 1 by oksamyt@chromium.org, Today (16 hours ago)

Status: WontFix (was: Untriaged)
Neither of these cases are likely to be common enough to justify the code size. There is also ambiguity in iterating over enums where a single integral value has multiple names. If more use cases arise for either of these suggestions, we can reconsider them.

Sign in to add a comment