OLD | NEW |
---|---|
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 Loading... | |
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 Loading... | |
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 |
OLD | NEW |