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

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

Issue 10704008: Make HtmlFrogSystem and NativeImplementationSystem the backends for HtmlInterfacesSystem and remove… (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 5 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 import systembase
12 from generator import * 12 from generator 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(systembase.System): 17 class NativeImplementationSystem(systembase.System):
18 18
19 def __init__(self, templates, database, emitters, output_dir): 19 def __init__(self, templates, database, emitters, output_dir, auxiliary_dir):
20 super(NativeImplementationSystem, self).__init__( 20 super(NativeImplementationSystem, self).__init__(
21 templates, database, emitters, output_dir) 21 templates, database, emitters, output_dir)
22 22 self._auxiliary_dir = auxiliary_dir
23 self._dom_impl_files = [] 23 self._dom_impl_files = []
24 self._cpp_header_files = [] 24 self._cpp_header_files = []
25 self._cpp_impl_files = [] 25 self._cpp_impl_files = []
26 self._html_system = HtmlSystemShared(database) 26 self._html_system = HtmlSystemShared(database)
27 self._factory_provider_emitters = {} 27 self._factory_provider_emitters = {}
28 28
29 def ProcessInterface(self, interface): 29 def ProcessInterface(self, interface):
30 interface_name = interface.id 30 interface_name = interface.id
31 31
32 if IsPureInterface(interface_name): 32 if IsPureInterface(interface_name):
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 113
114 cpp_impl_path = self._FilePathForCppImplementation(self._interface.id) 114 cpp_impl_path = self._FilePathForCppImplementation(self._interface.id)
115 self._cpp_impl_files.append(cpp_impl_path) 115 self._cpp_impl_files.append(cpp_impl_path)
116 cpp_impl_emitter = self._emitters.FileEmitter(cpp_impl_path) 116 cpp_impl_emitter = self._emitters.FileEmitter(cpp_impl_path)
117 cpp_impl_emitter.Emit( 117 cpp_impl_emitter.Emit(
118 self._templates.Load('cpp_callback_implementation.template'), 118 self._templates.Load('cpp_callback_implementation.template'),
119 INCLUDES=_GenerateCPPIncludes(cpp_impl_includes), 119 INCLUDES=_GenerateCPPIncludes(cpp_impl_includes),
120 INTERFACE=self._interface.id, 120 INTERFACE=self._interface.id,
121 HANDLERS=cpp_impl_handlers_emitter.Fragments()) 121 HANDLERS=cpp_impl_handlers_emitter.Fragments())
122 122
123 def GenerateLibraries(self): 123 def GenerateLibraries(self, interface_files):
124 # Generate dart:html library.
125 auxiliary_dir = os.path.relpath(self._auxiliary_dir, self._output_dir)
126 self._GenerateLibFile(
127 'html_dartium.darttemplate',
128 os.path.join(self._output_dir, 'html_dartium.dart'),
129 interface_files + self._dom_impl_files,
130 AUXILIARY_DIR=systembase.MassagePath(auxiliary_dir))
131
124 # Generate DartDerivedSourcesXX.cpp. 132 # Generate DartDerivedSourcesXX.cpp.
125 partitions = 20 # FIXME: this should be configurable. 133 partitions = 20 # FIXME: this should be configurable.
126 sources_count = len(self._cpp_impl_files) 134 sources_count = len(self._cpp_impl_files)
127 for i in range(0, partitions): 135 for i in range(0, partitions):
128 derived_sources_path = os.path.join(self._output_dir, 136 derived_sources_path = os.path.join(self._output_dir,
129 'DartDerivedSources%02i.cpp' % (i + 1)) 137 'DartDerivedSources%02i.cpp' % (i + 1))
130 138
131 includes_emitter = emitter.Emitter() 139 includes_emitter = emitter.Emitter()
132 for impl_file in self._cpp_impl_files[i::partitions]: 140 for impl_file in self._cpp_impl_files[i::partitions]:
133 path = os.path.relpath(impl_file, os.path.dirname(derived_sources_path )) 141 path = os.path.relpath(impl_file, os.path.dirname(derived_sources_path ))
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 184
177 def _EmitterForFactoryProviderBody(self, name): 185 def _EmitterForFactoryProviderBody(self, name):
178 if name not in self._factory_provider_emitters: 186 if name not in self._factory_provider_emitters:
179 file_name = self._FilePathForDartFactoryProviderImplementation(name) 187 file_name = self._FilePathForDartFactoryProviderImplementation(name)
180 self._dom_impl_files.append(file_name) 188 self._dom_impl_files.append(file_name)
181 template = self._templates.Load('factoryprovider_%s.darttemplate' % name) 189 template = self._templates.Load('factoryprovider_%s.darttemplate' % name)
182 file_emitter = self._emitters.FileEmitter(file_name) 190 file_emitter = self._emitters.FileEmitter(file_name)
183 self._factory_provider_emitters[name] = file_emitter.Emit(template) 191 self._factory_provider_emitters[name] = file_emitter.Emit(template)
184 return self._factory_provider_emitters[name] 192 return self._factory_provider_emitters[name]
185 193
186 def DartImplementationFiles(self):
187 return self._dom_impl_files
188
189 194
190 class NativeImplementationGenerator(systembase.BaseGenerator): 195 class NativeImplementationGenerator(systembase.BaseGenerator):
191 """Generates Dart implementation for one DOM IDL interface.""" 196 """Generates Dart implementation for one DOM IDL interface."""
192 197
193 def __init__(self, system, interface, 198 def __init__(self, system, interface,
194 dart_impl_emitter, cpp_header_emitter, cpp_impl_emitter, 199 dart_impl_emitter, cpp_header_emitter, cpp_impl_emitter,
195 base_members, templates): 200 base_members, templates):
196 """Generates Dart and C++ code for the given interface. 201 """Generates Dart and C++ code for the given interface.
197 202
198 Args: 203 Args:
(...skipping 887 matching lines...) Expand 10 before | Expand all | Expand 10 after
1086 1091
1087 def _IsArgumentOptionalInWebCore(argument): 1092 def _IsArgumentOptionalInWebCore(argument):
1088 return IsOptional(argument) and not 'Callback' in argument.ext_attrs 1093 return IsOptional(argument) and not 'Callback' in argument.ext_attrs
1089 1094
1090 def _ToWebKitName(name): 1095 def _ToWebKitName(name):
1091 name = name[0].lower() + name[1:] 1096 name = name[0].lower() + name[1:]
1092 name = re.sub(r'^(hTML|uRL|jS|xML|xSLT)', lambda s: s.group(1).lower(), 1097 name = re.sub(r'^(hTML|uRL|jS|xML|xSLT)', lambda s: s.group(1).lower(),
1093 name) 1098 name)
1094 return re.sub(r'^(create|exclusive)', lambda s: 'is' + s.group(1).capitalize() , 1099 return re.sub(r'^(create|exclusive)', lambda s: 'is' + s.group(1).capitalize() ,
1095 name) 1100 name)
OLDNEW
« lib/dom/scripts/dartdomgenerator.py ('K') | « lib/dom/scripts/systemhtml.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698