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

Side by Side Diff: lib/dom/scripts/systemnative.py

Issue 10532027: Move interface members traverse logic to BaseGenerator. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 6 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 #!/usr/bin/python 1 #!/usr/bin/python
2 # Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 2 # Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
3 # for details. All rights reserved. Use of this source code is governed by a 3 # for details. All rights reserved. Use of this source code is governed by a
4 # BSD-style license that can be found in the LICENSE file. 4 # BSD-style license that can be found in the LICENSE file.
5 5
6 """This module provides shared functionality for the systems to generate 6 """This module provides shared functionality for the systems to generate
7 native binding from the IDL database.""" 7 native binding from the IDL database."""
8 8
9 import emitter 9 import emitter
10 import os 10 import os
11 import systembase
11 from generator import * 12 from generator import *
12 from systembase import *
13 from systemhtml import DomToHtmlEvent, DomToHtmlEvents, HtmlSystemShared 13 from systemhtml import DomToHtmlEvent, DomToHtmlEvents, HtmlSystemShared
14 from systemhtml import HtmlElementConstructorInfos 14 from systemhtml import HtmlElementConstructorInfos
15 from systemhtml import EmitHtmlElementFactoryConstructors 15 from systemhtml import EmitHtmlElementFactoryConstructors
16 16
17 class NativeImplementationSystem(System): 17 class NativeImplementationSystem(systembase.System):
18 18
19 def __init__(self, templates, database, html_database, html_renames, 19 def __init__(self, templates, database, html_database, html_renames,
20 emitters, output_dir): 20 emitters, output_dir):
21 super(NativeImplementationSystem, self).__init__( 21 super(NativeImplementationSystem, self).__init__(
22 templates, database, emitters, output_dir) 22 templates, database, emitters, output_dir)
23 23
24 self._html_renames = html_renames 24 self._html_renames = html_renames
25 self._dom_impl_files = [] 25 self._dom_impl_files = []
26 self._cpp_header_files = [] 26 self._cpp_header_files = []
27 self._cpp_impl_files = [] 27 self._cpp_impl_files = []
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 self._dom_impl_files.append(file_name) 185 self._dom_impl_files.append(file_name)
186 template = self._templates.Load('factoryprovider_%s.darttemplate' % name) 186 template = self._templates.Load('factoryprovider_%s.darttemplate' % name)
187 file_emitter = self._emitters.FileEmitter(file_name) 187 file_emitter = self._emitters.FileEmitter(file_name)
188 self._factory_provider_emitters[name] = file_emitter.Emit(template) 188 self._factory_provider_emitters[name] = file_emitter.Emit(template)
189 return self._factory_provider_emitters[name] 189 return self._factory_provider_emitters[name]
190 190
191 def DartImplementationFiles(self): 191 def DartImplementationFiles(self):
192 return self._dom_impl_files 192 return self._dom_impl_files
193 193
194 194
195 class NativeImplementationGenerator(object): 195 class NativeImplementationGenerator(systembase.BaseGenerator):
196 """Generates Dart implementation for one DOM IDL interface.""" 196 """Generates Dart implementation for one DOM IDL interface."""
197 197
198 def __init__(self, system, interface, 198 def __init__(self, system, interface,
199 dart_impl_emitter, cpp_header_emitter, cpp_impl_emitter, 199 dart_impl_emitter, cpp_header_emitter, cpp_impl_emitter,
200 base_members, templates): 200 base_members, templates):
201 """Generates Dart and C++ code for the given interface. 201 """Generates Dart and C++ code for the given interface.
202 202
203 Args: 203 Args:
204 system: The NativeImplementationSystem. 204 system: The NativeImplementationSystem.
205 interface: an IDLInterface instance. It is assumed that all types have 205 interface: an IDLInterface instance. It is assumed that all types have
206 been converted to Dart types (e.g. int, String), unless they are in 206 been converted to Dart types (e.g. int, String), unless they are in
207 the same package as the interface. 207 the same package as the interface.
208 dart_impl_emitter: an Emitter for the file containing the Dart 208 dart_impl_emitter: an Emitter for the file containing the Dart
209 implementation class. 209 implementation class.
210 cpp_header_emitter: an Emitter for the file containing the C++ header. 210 cpp_header_emitter: an Emitter for the file containing the C++ header.
211 cpp_impl_emitter: an Emitter for the file containing the C++ 211 cpp_impl_emitter: an Emitter for the file containing the C++
212 implementation. 212 implementation.
213 base_members: a set of names of members defined in a base class. This is 213 base_members: a set of names of members defined in a base class. This is
214 used to avoid static member 'overriding' in the generated Dart code. 214 used to avoid static member 'overriding' in the generated Dart code.
215 """ 215 """
216 super(NativeImplementationGenerator, self).__init__(system._database)
216 self._system = system 217 self._system = system
217 self._interface = interface 218 self._interface = interface
218 self._dart_impl_emitter = dart_impl_emitter 219 self._dart_impl_emitter = dart_impl_emitter
219 self._cpp_header_emitter = cpp_header_emitter 220 self._cpp_header_emitter = cpp_header_emitter
220 self._cpp_impl_emitter = cpp_impl_emitter 221 self._cpp_impl_emitter = cpp_impl_emitter
221 self._base_members = base_members 222 self._base_members = base_members
222 self._templates = templates 223 self._templates = templates
223 self._current_secondary_parent = None 224 self._current_secondary_parent = None
224 self._html_system = self._system._html_system 225 self._html_system = self._system._html_system
225 226
(...skipping 819 matching lines...) Expand 10 before | Expand all | Expand 10 after
1045 for parent in interface.parents: 1046 for parent in interface.parents:
1046 parent_name = parent.type.id 1047 parent_name = parent.type.id
1047 if not database.HasInterface(parent.type.id): 1048 if not database.HasInterface(parent.type.id):
1048 continue 1049 continue
1049 parent_interface = database.GetInterface(parent.type.id) 1050 parent_interface = database.GetInterface(parent.type.id)
1050 if callback(parent_interface): 1051 if callback(parent_interface):
1051 return parent_interface 1052 return parent_interface
1052 parent_interface = _FindParent(parent_interface, database, callback) 1053 parent_interface = _FindParent(parent_interface, database, callback)
1053 if parent_interface: 1054 if parent_interface:
1054 return parent_interface 1055 return parent_interface
OLDNEW
« lib/dom/scripts/systembase.py ('K') | « lib/dom/scripts/systeminterface.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698