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

Unified Diff: tools/json_schema_compiler/cc_generator.py

Issue 850173002: Use std::vector<char> rather than std::string to represent a base::BinaryValue Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 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 | « extensions/browser/api/hid/hid_api.cc ('k') | 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 1d243f03b5ad30fc582e4fb5083a2367eefe1cb7..a17217c24054d1b18b0c995a8ea87b9783dc3a33 100644
--- a/tools/json_schema_compiler/cc_generator.py
+++ b/tools/json_schema_compiler/cc_generator.py
@@ -160,7 +160,7 @@ class _Generator(object):
items.append('%s(false)' % prop.unix_name)
elif (t.property_type == PropertyType.ANY or
t.property_type == PropertyType.ARRAY or
- t.property_type == PropertyType.BINARY or # mapped to std::string
+ t.property_type == PropertyType.BINARY or
t.property_type == PropertyType.CHOICES or
t.property_type == PropertyType.OBJECT or
t.property_type == PropertyType.FUNCTION or
@@ -817,13 +817,14 @@ class _Generator(object):
.Append(' static_cast<const base::BinaryValue*>(%(src_var)s);')
)
if is_ptr:
- (c.Append('%(dst_var)s.reset(')
- .Append(' new std::string(binary_value->GetBuffer(),')
- .Append(' binary_value->GetSize()));')
+ (c.Append('%(dst_var)s.reset(new std::vector<char>(')
+ .Append(' binary_value->GetBuffer(),')
+ .Append(' binary_value->GetBuffer() + binary_value->GetSize()));')
)
else:
- (c.Append('%(dst_var)s.assign(binary_value->GetBuffer(),')
- .Append(' binary_value->GetSize());')
+ (c.Append('%(dst_var)s.assign(')
+ .Append(' binary_value->GetBuffer(),')
+ .Append(' binary_value->GetBuffer() + binary_value->GetSize());')
)
c.Eblock('}')
else:
« no previous file with comments | « extensions/browser/api/hid/hid_api.cc ('k') | tools/json_schema_compiler/cpp_type_generator.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698