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

Unified Diff: tools/json_schema_compiler/h_generator.py

Issue 10907151: Extensions Docs Server: Enum values do not show up if enum is a type (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ToString and FromString Created 8 years, 3 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 c1df7ba221f773bef0d80cd19a9138cd85d1f0ce..9690ec6d8f2041f5e40a7be80e75835539f0ab52 100644
--- a/tools/json_schema_compiler/h_generator.py
+++ b/tools/json_schema_compiler/h_generator.py
@@ -135,8 +135,7 @@ class HGenerator(object):
"""
c = Code()
c.Sblock('enum %s {' % enum_name)
- if prop.optional:
- c.Append(self._cpp_type_generator.GetEnumNoneValue(prop) + ',')
+ c.Append(self._cpp_type_generator.GetEnumNoneValue(prop) + ',')
for value in values:
c.Append(self._cpp_type_generator.GetEnumValue(prop, value) + ',')
(c.Eblock('};')
@@ -193,12 +192,16 @@ class HGenerator(object):
if type_.description:
c.Comment(type_.description)
c.Sblock('enum %(classname)s {')
+ c.Append('%s,' % self._cpp_type_generator.GetEnumNoneValue(type_))
for value in type_.enum_values:
- c.Append('%s_%s,' % (classname.upper(), value.upper()))
+ c.Append('%s,' % self._cpp_type_generator.GetEnumValue(type_, value))
(c.Eblock('};')
.Append()
.Append('scoped_ptr<base::Value> CreateEnumValue(%s %s);' %
(classname, classname.lower()))
+ .Append('std::string ToString(%s enum_param);' % classname)
+ .Append('%s From%sString(const std::string& enum_string);' %
+ (classname, classname))
)
else:
if type_.description:
@@ -312,12 +315,19 @@ class HGenerator(object):
prop.enum_values))
create_enum_value = ('scoped_ptr<base::Value> CreateEnumValue(%s %s);' %
(enum_name, prop.unix_name))
+ enum_to_string = 'std::string ToString(%s enum_param);' % enum_name
+ enum_from_string = ('%s From%sString(const std::string& enum_string);' %
+ (enum_name, enum_name))
# If the property is from the UI then we're in a struct so this function
# should be static. If it's from the client, then we're just in a
# namespace so we can't have the static keyword.
if prop.from_json:
create_enum_value = 'static ' + create_enum_value
- c.Append(create_enum_value)
+ enum_to_string = 'static ' + enum_to_string
+ enum_from_string = 'static ' + enum_from_string
not at google - send to devlin 2012/09/18 03:55:20 change to use 'static %s' %...
cduvall 2012/09/21 00:39:28 Done.
+ (c.Append(create_enum_value)
+ .Append(enum_to_string)
+ .Append(enum_from_string))
return c
def _GeneratePrivatePropertyStructures(self, props):

Powered by Google App Engine
This is Rietveld 408576698