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

Unified Diff: tools/json_schema_compiler/cc_generator.py

Issue 10198005: Implement handling of binary data in JSON schema compiler (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 8 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 | « no previous file | tools/json_schema_compiler/cpp_type_generator.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/json_schema_compiler/cc_generator.py
diff --git a/tools/json_schema_compiler/cc_generator.py b/tools/json_schema_compiler/cc_generator.py
index 7f7cb560c4eff42b2c7bc2157cd71fa20aac6153..af81b5ab3a2750ca6b8fa186fced692e5a0a69d4 100644
--- a/tools/json_schema_compiler/cc_generator.py
+++ b/tools/json_schema_compiler/cc_generator.py
@@ -44,6 +44,7 @@ class CCGenerator(object):
.Append('using base::Value;')
.Append('using base::DictionaryValue;')
.Append('using base::ListValue;')
+ .Append('using base::BinaryValue;')
.Append('using %s;' % any_helper.ANY_CLASS)
.Append()
.Concat(self._cpp_type_generator.GetRootNamespaceStart())
@@ -144,6 +145,8 @@ class CCGenerator(object):
items.append('%s(0.0)' % prop.unix_name)
elif t == PropertyType.BOOLEAN:
items.append('%s(false)' % prop.unix_name)
+ elif t == PropertyType.BINARY:
+ items.append('%s(NULL)' % prop.unix_name)
elif (t == PropertyType.ADDITIONAL_PROPERTIES or
t == PropertyType.ANY or
t == PropertyType.ARRAY or
@@ -537,6 +540,13 @@ class CCGenerator(object):
(c.Append('else')
.Append(' return %(failure_value)s;')
)
+ elif prop.type_ == PropertyType.BINARY:
+ # This is the same if the property is optional or not. We need a pointer
+ # to the BinaryValue to be able to populate it, so a scoped_ptr is used
+ # whether it is optional or required.
+ (c.Append('%(dst)s->%(name)s.reset(')
+ .Append(' static_cast<BinaryValue*>(%(value_var)s)->DeepCopy());')
+ )
else:
raise NotImplementedError(prop.type_)
c.Eblock('}')
« no previous file with comments | « no previous file | tools/json_schema_compiler/cpp_type_generator.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698