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

Unified Diff: tools/json_schema_compiler/cc_generator.py

Issue 2841623003: Remove base::Value::Get{Buffer,Size} (Closed)
Patch Set: Created 3 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
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 0cde6cab3193639e7fdc2d5bf7041cfbebf71ac2..4d7884aff40890bb7a383847b3b0e0e472fabbf7 100644
--- a/tools/json_schema_compiler/cc_generator.py
+++ b/tools/json_schema_compiler/cc_generator.py
@@ -888,8 +888,7 @@ class _Generator(object):
dst_var,
failure_value))
elif underlying_type.property_type == PropertyType.BINARY:
- (c.Append('const base::Value* binary_value = NULL;')
- .Sblock('if (!%(src_var)s->IsType(base::Value::Type::BINARY)) {')
+ (c.Sblock('if (!%(src_var)s->IsType(base::Value::Type::BINARY)) {')
.Concat(self._GenerateError(
'"\'%%(key)s\': expected binary, got " + ' +
self._util_cc_helper.GetValueTypeString('%%(src_var)s', True)))
@@ -898,20 +897,10 @@ class _Generator(object):
c.Append('return %(failure_value)s;')
(c.Eblock('}')
.Sblock('else {')
- .Append(' binary_value =')
- .Append(' static_cast<const base::Value*>(%(src_var)s);')
+ .Append(('*' if is_ptr else '') +
+ '%(dst_var)s = %(src_var)s->GetBlob();')
+ .Eblock('}')
)
- if is_ptr:
- (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(')
- .Append(' binary_value->GetBuffer(),')
- .Append(' binary_value->GetBuffer() + binary_value->GetSize());')
- )
- c.Eblock('}')
else:
raise NotImplementedError(type_)
if c.IsEmpty():

Powered by Google App Engine
This is Rietveld 408576698