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

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

Issue 10824002: JSON Schema Compiler supports functions as PropertyTypes. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 5 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 | « tools/json_schema_compiler/cpp_util.py ('k') | tools/json_schema_compiler/model.py » ('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 9
10 class HGenerator(object): 10 class HGenerator(object):
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 # Generate the enums needed for any fields with "choices" 151 # Generate the enums needed for any fields with "choices"
152 for prop in props: 152 for prop in props:
153 if prop.type_ == PropertyType.CHOICES: 153 if prop.type_ == PropertyType.CHOICES:
154 enum_name = self._cpp_type_generator.GetChoicesEnumType(prop) 154 enum_name = self._cpp_type_generator.GetChoicesEnumType(prop)
155 c.Append('%s %s_type;' % (enum_name, prop.unix_name)) 155 c.Append('%s %s_type;' % (enum_name, prop.unix_name))
156 c.Append() 156 c.Append()
157 157
158 for prop in self._cpp_type_generator.ExpandParams(props): 158 for prop in self._cpp_type_generator.ExpandParams(props):
159 if prop.description: 159 if prop.description:
160 c.Comment(prop.description) 160 c.Comment(prop.description)
161 c.Append('%s %s;' % ( 161 (c.Append('%s %s;' % (
162 self._cpp_type_generator.GetType(prop, wrap_optional=True), 162 self._cpp_type_generator.GetType(prop, wrap_optional=True),
163 prop.unix_name)) 163 prop.unix_name))
164 )
not at google - send to devlin 2012/07/26 00:01:03 need the parens? btw the line below can be moved
164 c.Append() 165 c.Append()
165 return c 166 return c
166 167
167 def _GenerateType(self, type_): 168 def _GenerateType(self, type_):
168 """Generates a struct for a type. 169 """Generates a struct for a type.
169 """ 170 """
170 classname = cpp_util.Classname(schema_util.StripSchemaNamespace(type_.name)) 171 classname = cpp_util.Classname(schema_util.StripSchemaNamespace(type_.name))
171 c = Code() 172 c = Code()
172 173
173 if type_.functions: 174 if type_.functions:
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 345
345 def _GenerateFunctionResults(self, callback): 346 def _GenerateFunctionResults(self, callback):
346 """Generates namespace for passing a function's result back. 347 """Generates namespace for passing a function's result back.
347 """ 348 """
348 c = Code() 349 c = Code()
349 (c.Sblock('namespace Results {') 350 (c.Sblock('namespace Results {')
350 .Concat(self._GenerateCreateCallbackArguments(callback)) 351 .Concat(self._GenerateCreateCallbackArguments(callback))
351 .Eblock('};') 352 .Eblock('};')
352 ) 353 )
353 return c 354 return c
OLDNEW
« no previous file with comments | « tools/json_schema_compiler/cpp_util.py ('k') | tools/json_schema_compiler/model.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698