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

Side by Side Diff: tools/json_schema_compiler/cc_generator.py

Issue 2084633002: json_schema_compiler: Don't use deprecated ListValue::Append(Value*) overload. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 6 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 unified diff | Download patch
« no previous file with comments | « no previous file | tools/json_schema_compiler/test/additional_properties_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 from code import Code 5 from code import Code
6 from model import PropertyType 6 from model import PropertyType
7 import cpp_util 7 import cpp_util
8 import schema_util 8 import schema_util
9 import util_cc_helper 9 import util_cc_helper
10 from cpp_namespace_environment import CppNamespaceEnvironment 10 from cpp_namespace_environment import CppNamespaceEnvironment
(...skipping 613 matching lines...) Expand 10 before | Expand all | Expand 10 after
624 underlying_type.property_type == PropertyType.FUNCTION): 624 underlying_type.property_type == PropertyType.FUNCTION):
625 if is_ptr: 625 if is_ptr:
626 vardot = '(%s)->' % var 626 vardot = '(%s)->' % var
627 else: 627 else:
628 vardot = '(%s).' % var 628 vardot = '(%s).' % var
629 return '%sCreateDeepCopy()' % vardot 629 return '%sCreateDeepCopy()' % vardot
630 elif underlying_type.property_type == PropertyType.ENUM: 630 elif underlying_type.property_type == PropertyType.ENUM:
631 maybe_namespace = '' 631 maybe_namespace = ''
632 if type_.property_type == PropertyType.REF: 632 if type_.property_type == PropertyType.REF:
633 maybe_namespace = '%s::' % underlying_type.namespace.unix_name 633 maybe_namespace = '%s::' % underlying_type.namespace.unix_name
634 return 'base::WrapUnique(new base::StringValue(%sToString(%s)))' % ( 634 return 'base::MakeUnique<base::StringValue>(%sToString(%s))' % (
635 maybe_namespace, var) 635 maybe_namespace, var)
636 elif underlying_type.property_type == PropertyType.BINARY: 636 elif underlying_type.property_type == PropertyType.BINARY:
637 if is_ptr: 637 if is_ptr:
638 vardot = var + '->' 638 vardot = var + '->'
639 else: 639 else:
640 vardot = var + '.' 640 vardot = var + '.'
641 return ('base::BinaryValue::CreateWithCopiedBuffer(%sdata(),' 641 return ('base::BinaryValue::CreateWithCopiedBuffer('
642 ' %ssize())' % (vardot, vardot)) 642 '%sdata(), %ssize())' % (vardot, vardot))
643 elif underlying_type.property_type == PropertyType.ARRAY: 643 elif underlying_type.property_type == PropertyType.ARRAY:
644 return '%s' % self._util_cc_helper.CreateValueFromArray( 644 return '%s' % self._util_cc_helper.CreateValueFromArray(
645 var, 645 var,
646 is_ptr) 646 is_ptr)
647 elif underlying_type.property_type.is_fundamental: 647 elif underlying_type.property_type.is_fundamental:
648 if is_ptr: 648 if is_ptr:
649 var = '*%s' % var 649 var = '*%s' % var
650 if underlying_type.property_type == PropertyType.STRING: 650 if underlying_type.property_type == PropertyType.STRING:
651 return 'base::WrapUnique(new base::StringValue(%s))' % var 651 return 'base::MakeUnique<base::StringValue>(%s)' % var
652 else: 652 else:
653 return 'base::WrapUnique(new base::FundamentalValue(%s))' % var 653 return 'base::MakeUnique<base::FundamentalValue>(%s)' % var
654 else: 654 else:
655 raise NotImplementedError('Conversion of %s to base::Value not ' 655 raise NotImplementedError('Conversion of %s to base::Value not '
656 'implemented' % repr(type_.type_)) 656 'implemented' % repr(type_.type_))
657 657
658 def _GenerateParamsCheck(self, function, var): 658 def _GenerateParamsCheck(self, function, var):
659 """Generates a check for the correct number of arguments when creating 659 """Generates a check for the correct number of arguments when creating
660 Params. 660 Params.
661 """ 661 """
662 c = Code() 662 c = Code()
663 num_required = 0 663 num_required = 0
(...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after
1150 if self._generate_error_messages: 1150 if self._generate_error_messages:
1151 params = list(params) + ['base::string16* error'] 1151 params = list(params) + ['base::string16* error']
1152 return ', '.join(str(p) for p in params) 1152 return ', '.join(str(p) for p in params)
1153 1153
1154 def _GenerateArgs(self, args): 1154 def _GenerateArgs(self, args):
1155 """Builds the argument list for a function, given an array of arguments. 1155 """Builds the argument list for a function, given an array of arguments.
1156 """ 1156 """
1157 if self._generate_error_messages: 1157 if self._generate_error_messages:
1158 args = list(args) + ['error'] 1158 args = list(args) + ['error']
1159 return ', '.join(str(a) for a in args) 1159 return ', '.join(str(a) for a in args)
OLDNEW
« no previous file with comments | « no previous file | tools/json_schema_compiler/test/additional_properties_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698