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

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

Issue 10381089: Revert 136296 - Make all extension api types fully qualified. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 7 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 | Annotate | Revision Log
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 model 8 import model
9 import os 9 import os
10 import schema_util
11 10
12 class HGenerator(object): 11 class HGenerator(object):
13 """A .h generator for a namespace. 12 """A .h generator for a namespace.
14 """ 13 """
15 def __init__(self, namespace, cpp_type_generator): 14 def __init__(self, namespace, cpp_type_generator):
16 self._cpp_type_generator = cpp_type_generator 15 self._cpp_type_generator = cpp_type_generator
17 self._namespace = namespace 16 self._namespace = namespace
18 self._target_namespace = ( 17 self._target_namespace = (
19 self._cpp_type_generator.GetCppNamespaceName(self._namespace)) 18 self._cpp_type_generator.GetCppNamespaceName(self._namespace))
20 19
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 c.Comment(prop.description) 149 c.Comment(prop.description)
151 c.Append('%s %s;' % ( 150 c.Append('%s %s;' % (
152 self._cpp_type_generator.GetType(prop, wrap_optional=True), 151 self._cpp_type_generator.GetType(prop, wrap_optional=True),
153 prop.unix_name)) 152 prop.unix_name))
154 c.Append() 153 c.Append()
155 return c 154 return c
156 155
157 def _GenerateType(self, type_): 156 def _GenerateType(self, type_):
158 """Generates a struct for a type. 157 """Generates a struct for a type.
159 """ 158 """
160 classname = cpp_util.Classname(schema_util.StripSchemaNamespace(type_.name)) 159 classname = cpp_util.Classname(type_.name)
161 c = Code() 160 c = Code()
162 161
163 if type_.functions: 162 if type_.functions:
164 # Types with functions are not instantiable in C++ because they are 163 # Types with functions are not instantiable in C++ because they are
165 # handled in pure Javascript and hence have no properties or 164 # handled in pure Javascript and hence have no properties or
166 # additionalProperties. 165 # additionalProperties.
167 if type_.properties: 166 if type_.properties:
168 raise NotImplementedError('\n'.join(model.GetModelHierarchy(type_)) + 167 raise NotImplementedError('\n'.join(model.GetModelHierarchy(type_)) +
169 '\nCannot generate both functions and properties on a type') 168 '\nCannot generate both functions and properties on a type')
170 c.Sblock('namespace %(classname)s {') 169 c.Sblock('namespace %(classname)s {')
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 c.Comment(param.description) 301 c.Comment(param.description)
303 if param.type_ == PropertyType.ANY: 302 if param.type_ == PropertyType.ANY:
304 c.Comment("Value* Result::Create(Value*) not generated " 303 c.Comment("Value* Result::Create(Value*) not generated "
305 "because it's redundant.") 304 "because it's redundant.")
306 continue 305 continue
307 c.Append('Value* Create(const %s);' % cpp_util.GetParameterDeclaration( 306 c.Append('Value* Create(const %s);' % cpp_util.GetParameterDeclaration(
308 param, self._cpp_type_generator.GetType(param))) 307 param, self._cpp_type_generator.GetType(param)))
309 c.Eblock('};') 308 c.Eblock('};')
310 309
311 return c 310 return c
OLDNEW
« no previous file with comments | « tools/json_schema_compiler/cpp_type_generator_test.py ('k') | tools/json_schema_compiler/idl_schema.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698