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

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

Issue 10392127: Move declarative API into events API (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix change schema type reference from 'Event' to 'events.Event' 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 any_helper 7 import any_helper
8 import cpp_util 8 import cpp_util
9 import model 9 import model
10 import schema_util 10 import schema_util
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 # TODO(calamity): Events 93 # TODO(calamity): Events
94 return c 94 return c
95 95
96 def _GenerateType(self, cpp_namespace, type_): 96 def _GenerateType(self, cpp_namespace, type_):
97 """Generates the function definitions for a type. 97 """Generates the function definitions for a type.
98 """ 98 """
99 classname = cpp_util.Classname(schema_util.StripSchemaNamespace(type_.name)) 99 classname = cpp_util.Classname(schema_util.StripSchemaNamespace(type_.name))
100 c = Code() 100 c = Code()
101 101
102 if type_.functions: 102 if type_.functions:
103 # Types with functions are not instantiable in C++ because they are
104 # handled in pure Javascript and hence have no properties or
105 # additionalProperties.
106 if type_.properties:
107 raise NotImplementedError('\n'.join(model.GetModelHierarchy(type_)) +
108 '\nCannot generate both functions and properties on a type')
109 for function in type_.functions.values(): 103 for function in type_.functions.values():
110 (c.Concat( 104 (c.Concat(
111 self._GenerateFunction( 105 self._GenerateFunction(
112 cpp_namespace + '::' + cpp_util.Classname(function.name), 106 cpp_namespace + '::' + cpp_util.Classname(function.name),
113 function)) 107 function))
114 .Append() 108 .Append()
115 ) 109 )
116 elif type_.type_ == PropertyType.OBJECT: 110 elif type_.type_ == PropertyType.OBJECT:
117 (c.Concat(self._GeneratePropertyFunctions( 111 (c.Concat(self._GeneratePropertyFunctions(
118 cpp_namespace, type_.properties.values())) 112 cpp_namespace, type_.properties.values()))
(...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after
661 """ 655 """
662 return (self._cpp_type_generator.GetReferencedProperty(prop).type_ == 656 return (self._cpp_type_generator.GetReferencedProperty(prop).type_ ==
663 PropertyType.ARRAY) 657 PropertyType.ARRAY)
664 658
665 def _IsFundamentalOrFundamentalRef(self, prop): 659 def _IsFundamentalOrFundamentalRef(self, prop):
666 """Determines if this property is a Fundamental type or is a ref to a 660 """Determines if this property is a Fundamental type or is a ref to a
667 Fundamental type. 661 Fundamental type.
668 """ 662 """
669 return (self._cpp_type_generator.GetReferencedProperty(prop).type_. 663 return (self._cpp_type_generator.GetReferencedProperty(prop).type_.
670 is_fundamental) 664 is_fundamental)
OLDNEW
« no previous file with comments | « chrome/test/data/extensions/api_test/webrequest/manifest.json ('k') | tools/json_schema_compiler/h_generator.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698