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

Unified Diff: tools/json_schema_compiler/cc_generator.py

Issue 2841623003: Remove base::Value::Get{Buffer,Size} (Closed)
Patch Set: std::vector::assign instead of std::vector::operator= 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..b434df550f6d543ec9f57d778d68b299a8de1794 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,19 +897,12 @@ 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);')
)
if is_ptr:
- (c.Append('%(dst_var)s.reset(new std::vector<char>(')
- .Append(' binary_value->GetBuffer(),')
- .Append(' binary_value->GetBuffer() + binary_value->GetSize()));')
- )
+ c.Append(
+ '%(dst_var)s.reset(new std::vector<char>(%(src_var)s->GetBlob()));')
else:
- (c.Append('%(dst_var)s.assign(')
- .Append(' binary_value->GetBuffer(),')
- .Append(' binary_value->GetBuffer() + binary_value->GetSize());')
- )
+ c.Append('%(dst_var)s = %(src_var)s->GetBlob();')
c.Eblock('}')
else:
raise NotImplementedError(type_)
« no previous file with comments | « ppapi/shared_impl/private/ppb_x509_certificate_private_shared.cc ('k') | tools/json_schema_compiler/util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698