New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 612382 link

Starred by 2 users

Issue metadata

Status: WontFix
Owner: ----
Closed: Aug 16
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: All
Pri: 3
Type: Bug

Blocking:
issue 611898



Sign in to add a comment

Add "enum class" support to json_schema_compiler. Then use it.

Project Member Reported by tapted@chromium.org, May 17 2016

Issue description

Chrome Version       : 52.0.2729.3

`enum class` is the new vogue, and supported in all our toolchains.

But, more importantly, an enum class can be forward-declared. This has the benefit that files like ui/views/view.h can use a forward-declare of ui::AXEvent and not have to #include "ax_enums.h"

#including ax_enums.h is a problem because it is a generated header. So, *any* target that #includes view.h needs a chain of *hard* dependencies, and export_dependent_settings that eventually lead to accessibility.gyp:ax_gen

This will help avoid a big amount of confusion around build dependencies for generated headers, and help avoid compile flakes like  Issue 611898 

I just hacked together something in https://codereview.chromium.org/1982193002 and it seems to work pretty well. I don't really know anything about json_schema_compiler though.

Now is your chance to object!

Otherwise, filing this to track the conversion process.
 

Comment 1 by thakis@chromium.org, May 18 2016

You don't need enum class to forward-delare an enum: Just giving the enum an explicit underlying type is enough. That should be much easier to roll out, right?

Comment 2 by tapted@chromium.org, May 19 2016

Hm. It would indeed be easier, but it feels like there would need to be a lot of arbitrary decisions to "pick a size" for each enum. And is there a risk if a forward-declared size gets "stale"? E.g. it looks like you can do silly stuff like the following without generating an error

enum E : short;
int f(E e);
int main() {
  f(static_cast<E>(0));
}


Since we'd likely have to change all the idl files anyway, I think switching to enum class would be preferred in the long run.

The main downside is the churn in renaming, e.g., AX_EVENT_FOO to AXEvent::FOO. But all http://crrev.com/1988613002 needed was a sed script and the wonders of `git cl format` (and since in this case the strings were the same length, that was really only needed in areas that weren't already correctly formatted, and that was cl-format enforced by a presubmit).

The only thing I had to change were a couple of static_casts -- a DLOG(WARNING), and an iterator.

Comment 3 by tapted@chromium.org, May 20 2016

Blocking: 611898

Comment 4 by thakis@chromium.org, May 20 2016

Enum classes have implicit underlying type in. Explicit underlying into gives you the same without the renaming churn.

Comment 5 by tapted@chromium.org, May 20 2016

Ooh - making them all enum Foo : int - does sound like a cool shortcut. Something like this?: https://codereview.chromium.org/1999633002/ . We wouldn't have to change any idl files if we just enforce 'int' on everything enum.

( currently this generates a clang crash -> filed https://llvm.org/bugs/show_bug.cgi?id=27822 -> but it might just be getting triggered due to a compile error)
Labels: NewComponent-Accessibility-Internals NewComponent-Accessibility
Components: Internals>Accessibility
Components: -UI>Accessibility
Labels: -newcomponent-accessibility-internals -newcomponent-accessibility
Labels: triage-dtseng
Components: -Internals>Accessibility
@tapted, any updates?
Labels: -triage-dtseng
Cc: tapted@chromium.org
Owner: ----
Status: Available (was: Started)
I think we should still do this, but it's low priority.

gn is better at tracking dependencies, but it's still easy to forget to add a public_deps entry when you expose a generated header via a component's public API.
Project Member

Comment 13 by sheriffbot@chromium.org, Aug 16

Labels: Hotlist-Recharge-Cold
Status: Untriaged (was: Available)
This issue has been Available for over a year. If it's no longer important or seems unlikely to be fixed, please consider closing it out. If it is important, please re-triage the issue.

Sorry for the inconvenience if the bug really should have been left as Available.

For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
Status: WontFix (was: Untriaged)
I think this can be shelved. mojo uses enum class. We should just deprecate json_schema_compiler.

Sign in to add a comment