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..ae38a6a55c3a07a49a674dde3b241c34e54e33ca 100644 |
--- a/tools/json_schema_compiler/h_generator.py |
+++ b/tools/json_schema_compiler/h_generator.py |
@@ -158,9 +158,12 @@ class HGenerator(object): |
for prop in self._cpp_type_generator.ExpandParams(props): |
if prop.description: |
c.Comment(prop.description) |
+ prop_name = prop.unix_name |
Yoyo Zhou
2012/08/27 23:56:04
Is this needed?
chebert
2012/08/28 21:31:14
Done.
|
+ wrap_optional = not self._cpp_type_generator.IsEnumOrEnumRef(prop) |
Yoyo Zhou
2012/08/27 23:56:04
Can you document the reason for this in a comment?
chebert
2012/08/28 21:31:14
Better yet, I will just get rid of it.
On 2012/08/
|
(c.Append('%s %s;' % ( |
- self._cpp_type_generator.GetCompiledType(prop, wrap_optional=True), |
- prop.unix_name)) |
+ self._cpp_type_generator.GetCompiledType(prop, |
+ wrap_optional=wrap_optional), |
+ prop_name)) |
.Append() |
) |
return c |
@@ -189,6 +192,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) |