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

Unified Diff: tools/json_schema_compiler/model.py

Issue 10825029: Added JSON schema compiler support for serialized types (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/model.py
diff --git a/tools/json_schema_compiler/model.py b/tools/json_schema_compiler/model.py
index 5453e11c40a11a6abe9425d5df2a8e997ab726b5..6dd8ccf014812af26018acf20f7b21e4277ebf96 100644
--- a/tools/json_schema_compiler/model.py
+++ b/tools/json_schema_compiler/model.py
@@ -150,6 +150,8 @@ class Property(object):
- |optional| a boolean representing whether the property is optional
- |description| a description of the property (if provided)
- |type_| the model.PropertyType of this property
+ - |serialized_type| the model.PropertyType that this property should be
+ serialized to. Will be None if it's missing from the JSON.
- |ref_type| the type that the REF property is referencing. Can be used to
map to its model.Type
- |item_type| a model.Property representing the type of each element in an
@@ -175,6 +177,7 @@ class Property(object):
self.from_json = from_json
self.from_client = from_client
self.instance_of = json.get('isInstanceOf', None)
+ self.serialized_type = None
_AddProperties(self, json)
if is_additional_properties:
self.type_ = PropertyType.ADDITIONAL_PROPERTIES
@@ -216,6 +219,17 @@ class Property(object):
self.type_ = PropertyType.BINARY
else:
raise ParseException(self, 'type ' + json_type + ' not recognized')
+
+ if 'serialized_type' in json:
+ json_serialized_type = json['serialized_type']
+ if json_serialized_type == 'integer':
+ self.serialized_type = PropertyType.INTEGER
+ elif json_serialized_type == 'int64':
+ self.serialized_type = PropertyType.INT64
+ else:
not at google - send to devlin 2012/07/26 04:51:42 this might as well be the same code that parses 't
mitchellwrosen 2012/07/26 20:00:27 Hmm. Correct me if I'm wrong but it may not make s
not at google - send to devlin 2012/07/27 04:14:28 Yes, that's true. Hmm. For for the types that onl
mitchellwrosen 2012/07/30 20:52:45 Done.
+ # TODO(mwrosen): Support more types as necessary.
+ raise ParseException(self, 'type ' + json_serialized_type +
+ ' not recognized')
elif 'choices' in json:
if not json['choices'] or len(json['choices']) == 0:
raise ParseException(self, 'Choices has no choices')
@@ -285,6 +299,7 @@ class PropertyType(object):
return self.name
INTEGER = _Info(True, "INTEGER")
+ INT64 = _Info(True, "INT64")
not at google - send to devlin 2012/07/26 04:51:42 ooh maybe we can use this to serialize GURLs direc
mitchellwrosen 2012/07/26 20:00:27 What do you mean?
not at google - send to devlin 2012/07/27 04:14:28 I made this comment first. Just meant what I said
DOUBLE = _Info(True, "DOUBLE")
BOOLEAN = _Info(True, "BOOLEAN")
STRING = _Info(True, "STRING")
« tools/json_schema_compiler/cpp_util.py ('K') | « tools/json_schema_compiler/h_generator.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698