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

Unified Diff: tools/json_schema_compiler/h_generator.py

Issue 10828407: JSON Schema Compiler supports Enums as types. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: added a todo comment Created 8 years, 4 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
« no previous file with comments | « tools/json_schema_compiler/cpp_type_generator.py ('k') | tools/json_schema_compiler/model.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 e1d9f48b0fa3de3ebefb51f377e172fa6c2eb78d..c1df7ba221f773bef0d80cd19a9138cd85d1f0ce 100644
--- a/tools/json_schema_compiler/h_generator.py
+++ b/tools/json_schema_compiler/h_generator.py
@@ -189,6 +189,17 @@ class HGenerator(object):
if type_.description:
c.Comment(type_.description)
c.Append('typedef std::string %(classname)s;')
+ elif type_.type_ == PropertyType.ENUM:
+ if type_.description:
+ c.Comment(type_.description)
+ c.Sblock('enum %(classname)s {')
+ for value in type_.enum_values:
+ c.Append('%s_%s,' % (classname.upper(), value.upper()))
+ (c.Eblock('};')
+ .Append()
+ .Append('scoped_ptr<base::Value> CreateEnumValue(%s %s);' %
+ (classname, classname.lower()))
+ )
else:
if type_.description:
c.Comment(type_.description)
« no previous file with comments | « tools/json_schema_compiler/cpp_type_generator.py ('k') | tools/json_schema_compiler/model.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698