Add "enum class" support to json_schema_compiler. Then use it. |
|||||||||||
Issue descriptionChrome 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.
,
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.
,
May 20 2016
,
May 20 2016
Enum classes have implicit underlying type in. Explicit underlying into gives you the same without the renaming churn.
,
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)
,
Mar 27 2017
,
Apr 21 2017
,
Apr 21 2017
,
Aug 11 2017
,
Aug 11 2017
@tapted, any updates?
,
Aug 11 2017
,
Aug 16 2017
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.
,
Aug 16
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
,
Aug 16
I think this can be shelved. mojo uses enum class. We should just deprecate json_schema_compiler. |
|||||||||||
►
Sign in to add a comment |
|||||||||||
Comment 1 by thakis@chromium.org
, May 18 2016