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

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

Issue 1033223007: [Extension API Extern Generation] Support inline object definitions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Dan's Created 5 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 unified diff | Download patch
« no previous file with comments | « no previous file | tools/json_schema_compiler/code.py » ('j') | tools/json_schema_compiler/code.py » ('J')
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 489 matching lines...) Expand 10 before | Expand all | Expand 10 after
500 .Append('for (const auto& it : %s) {' % varname) 500 .Append('for (const auto& it : %s) {' % varname)
501 .Append('%s.push_back(%sToString(it));' % (enum_list_var, 501 .Append('%s.push_back(%sToString(it));' % (enum_list_var,
502 maybe_namespace)) 502 maybe_namespace))
503 .Eblock('}')) 503 .Eblock('}'))
504 504
505 # Because the std::vector above is always created for both required and 505 # Because the std::vector above is always created for both required and
506 # optional enum arrays, |is_ptr| is set to false and uses the 506 # optional enum arrays, |is_ptr| is set to false and uses the
507 # std::vector to create the values. 507 # std::vector to create the values.
508 (c.Append(code % 508 (c.Append(code %
509 self._GenerateCreateValueFromType(type_, enum_list_var, False)) 509 self._GenerateCreateValueFromType(type_, enum_list_var, False))
510 .Eblock('}')) 510 .Append('}'))
Devlin 2015/03/27 20:50:11 This Eblock (and another in .h generator) didn't h
511 return c 511 return c
512 512
513 c.Append(code % self._GenerateCreateValueFromType(type_, var, is_ptr)) 513 c.Append(code % self._GenerateCreateValueFromType(type_, var, is_ptr))
514 return c 514 return c
515 515
516 def _GenerateCreateValueFromType(self, type_, var, is_ptr): 516 def _GenerateCreateValueFromType(self, type_, var, is_ptr):
517 """Generates the statement to create a base::Value given a type. 517 """Generates the statement to create a base::Value given a type.
518 518
519 type_: The type of the values being converted. 519 type_: The type of the values being converted.
520 var: The name of the variable. 520 var: The name of the variable.
(...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after
1052 if self._generate_error_messages: 1052 if self._generate_error_messages:
1053 params = list(params) + ['base::string16* error'] 1053 params = list(params) + ['base::string16* error']
1054 return ', '.join(str(p) for p in params) 1054 return ', '.join(str(p) for p in params)
1055 1055
1056 def _GenerateArgs(self, args): 1056 def _GenerateArgs(self, args):
1057 """Builds the argument list for a function, given an array of arguments. 1057 """Builds the argument list for a function, given an array of arguments.
1058 """ 1058 """
1059 if self._generate_error_messages: 1059 if self._generate_error_messages:
1060 args = list(args) + ['error'] 1060 args = list(args) + ['error']
1061 return ', '.join(str(a) for a in args) 1061 return ', '.join(str(a) for a in args)
OLDNEW
« no previous file with comments | « no previous file | tools/json_schema_compiler/code.py » ('j') | tools/json_schema_compiler/code.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698