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

Unified Diff: tools/json_schema_compiler/h_generator.py

Issue 10790040: JSON Schema Compiler now supports conversion from Choice to base::Value. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 5 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 5f59ffbe04603f83e730b78cf7bbec8c94698bb7..d64e2daf809e3cb8a2b2711ebea8e2ed317f472a 100644
--- a/tools/json_schema_compiler/h_generator.py
+++ b/tools/json_schema_compiler/h_generator.py
@@ -214,6 +214,9 @@ class HGenerator(object):
(c.Eblock()
.Sblock(' private:')
+ .Concat(self._GeneratePrivatePropertyStructures(
+ type_.properties.values()))
+ .Append()
.Append('DISALLOW_COPY_AND_ASSIGN(%(classname)s);')
.Eblock('};')
)
@@ -303,6 +306,23 @@ class HGenerator(object):
c.Append(create_enum_value)
return c
+ def _GeneratePrivatePropertyStructures(self, props):
+ """Generate the private structures required by a property such as OBJECT
+ classes and enums.
+ """
+ c = Code()
+ for prop in props:
+ if prop.type_ == PropertyType.ARRAY:
+ c.Concat(self._GeneratePrivatePropertyStructures([prop.item_type]))
+ c.Append()
+ elif prop.type_ == PropertyType.CHOICES:
+ # We only need GetChoiceValue() if there is a ToValue() method.
+ if prop.from_json and prop.from_client:
not at google - send to devlin 2012/07/19 01:48:22 ditto, why prop.from_json?
chebert 2012/07/19 21:06:17 see cc_generator comment. On 2012/07/19 01:48:22,
+ c.Append('scoped_ptr<base::Value> GetChoiceValue(%s) const;' %
not at google - send to devlin 2012/07/19 01:48:22 static?
chebert 2012/07/19 21:06:17 see cc_generator comment. On 2012/07/19 01:48:22,
+ cpp_util.GetParameterDeclaration(prop,
+ self._cpp_type_generator.GetChoicesEnumType(prop)))
+ return c
+
def _GenerateCreateCallbackArguments(self, function):
"""Generates functions for passing paramaters to a callback.
"""

Powered by Google App Engine
This is Rietveld 408576698