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

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

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