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 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 self._cpp_type_generator.GetCompiledType(type_.item_type, | 186 self._cpp_type_generator.GetCompiledType(type_.item_type, |
187 wrap_optional=True)}) | 187 wrap_optional=True)}) |
188 elif type_.type_ == PropertyType.STRING: | 188 elif type_.type_ == PropertyType.STRING: |
189 if type_.description: | 189 if type_.description: |
190 c.Comment(type_.description) | 190 c.Comment(type_.description) |
191 c.Append('typedef std::string %(classname)s;') | 191 c.Append('typedef std::string %(classname)s;') |
192 elif type_.type_ == PropertyType.ENUM: | 192 elif type_.type_ == PropertyType.ENUM: |
193 if type_.description: | 193 if type_.description: |
194 c.Comment(type_.description) | 194 c.Comment(type_.description) |
195 c.Sblock('enum %(classname)s {') | 195 c.Sblock('enum %(classname)s {') |
| 196 c.Append('%s_NONE,' % classname.upper()) |
196 for value in type_.enum_values: | 197 for value in type_.enum_values: |
197 c.Append('%s_%s,' % (classname.upper(), value.upper())) | 198 c.Append('%s_%s,' % (classname.upper(), value.upper())) |
198 (c.Eblock('};') | 199 (c.Eblock('};') |
199 .Append() | 200 .Append() |
200 .Append('scoped_ptr<base::Value> CreateEnumValue(%s %s);' % | 201 .Append('scoped_ptr<base::Value> CreateEnumValue(%s %s);' % |
201 (classname, classname.lower())) | 202 (classname, classname.lower())) |
202 ) | 203 ) |
203 else: | 204 else: |
204 if type_.description: | 205 if type_.description: |
205 c.Comment(type_.description) | 206 c.Comment(type_.description) |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
359 | 360 |
360 def _GenerateFunctionResults(self, callback): | 361 def _GenerateFunctionResults(self, callback): |
361 """Generates namespace for passing a function's result back. | 362 """Generates namespace for passing a function's result back. |
362 """ | 363 """ |
363 c = Code() | 364 c = Code() |
364 (c.Sblock('namespace Results {') | 365 (c.Sblock('namespace Results {') |
365 .Concat(self._GenerateCreateCallbackArguments(callback)) | 366 .Concat(self._GenerateCreateCallbackArguments(callback)) |
366 .Eblock('};') | 367 .Eblock('};') |
367 ) | 368 ) |
368 return c | 369 return c |
OLD | NEW |