Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(522)

Unified Diff: tools/json_schema_compiler/h_generator.py

Issue 1982193002: Add enum class support to json_schema_compiler (idl files) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: enum -> enum_class, TODOs Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: tools/json_schema_compiler/h_generator.py
diff --git a/tools/json_schema_compiler/h_generator.py b/tools/json_schema_compiler/h_generator.py
index c64241cd62d6d66b46230ee62cf84867f0432e08..7ee0b333a6931295f75f361b97205e56da73237c 100644
--- a/tools/json_schema_compiler/h_generator.py
+++ b/tools/json_schema_compiler/h_generator.py
@@ -141,13 +141,16 @@ class _Generator(object):
"""Generate a code object with the declaration of a C++ enum.
"""
c = Code()
- c.Sblock('enum %s {' % enum_name)
- c.Append(self._type_helper.GetEnumNoneValue(type_) + ',')
+ c.Sblock('enum %s%s {' % (type_.is_class and 'class ' or '', enum_name))
Devlin 2016/05/19 00:33:12 ha nifty, but is this pythonic? Maybe it's my c++
tapted 2016/05/19 12:22:32 Ah, apparently this is me revealing how long it's
+ c.Append(self._type_helper.GetEnumNoneValue(
+ type_, is_in_declaration=True) + ',')
for value in type_.enum_values:
- current_enum_string = self._type_helper.GetEnumValue(type_, value)
+ current_enum_string = self._type_helper.GetEnumValue(
+ type_, value, is_in_declaration=True)
c.Append(current_enum_string + ',')
c.Append('%s = %s,' % (
- self._type_helper.GetEnumLastValue(type_), current_enum_string))
+ self._type_helper.GetEnumLastValue(type_, is_in_declaration=True),
+ current_enum_string))
c.Eblock('};')
return c

Powered by Google App Engine
This is Rietveld 408576698