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

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

Issue 10696033: Create implementation file emitter in HtmlDartInterfaceGenerator. (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
« lib/dom/scripts/systemhtml.py ('K') | « lib/dom/scripts/systemhtml.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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, auxiliary_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 self._auxiliary_dir = auxiliary_dir 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, dart_implementation_emitter):
30 interface_name = interface.id 30 interface_name = interface.id
31 31
32 if IsPureInterface(interface_name):
33 return None
34
35 dart_impl_path = self._FilePathForDartImplementation(interface_name)
36 self._dom_impl_files.append(dart_impl_path)
37
38 cpp_header_path = self._FilePathForCppHeader(interface_name) 32 cpp_header_path = self._FilePathForCppHeader(interface_name)
39 self._cpp_header_files.append(cpp_header_path) 33 self._cpp_header_files.append(cpp_header_path)
40 34
41 cpp_impl_path = self._FilePathForCppImplementation(interface_name) 35 cpp_impl_path = self._FilePathForCppImplementation(interface_name)
42 self._cpp_impl_files.append(cpp_impl_path) 36 self._cpp_impl_files.append(cpp_impl_path)
43 37
44 generator = NativeImplementationGenerator(self, interface, 38 generator = NativeImplementationGenerator(self, interface,
45 self._emitters.FileEmitter(dart_impl_path), 39 dart_implementation_emitter,
46 self._emitters.FileEmitter(cpp_header_path), 40 self._emitters.FileEmitter(cpp_header_path),
47 self._emitters.FileEmitter(cpp_impl_path), 41 self._emitters.FileEmitter(cpp_impl_path),
48 self._BaseDefines(interface), 42 self._BaseDefines(interface),
49 self._templates) 43 self._templates)
50 generator.Generate() 44 generator.Generate()
51 45
52 def ProcessCallback(self, interface, info): 46 def ProcessCallback(self, interface, info):
53 self._interface = interface 47 self._interface = interface
54 48
55 if IsPureInterface(self._interface.id): 49 if IsPureInterface(self._interface.id):
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 155
162 cpp_resolver_emitter = self._emitters.FileEmitter(cpp_resolver_path) 156 cpp_resolver_emitter = self._emitters.FileEmitter(cpp_resolver_path)
163 cpp_resolver_emitter.Emit( 157 cpp_resolver_emitter.Emit(
164 self._templates.Load('cpp_resolver.template'), 158 self._templates.Load('cpp_resolver.template'),
165 INCLUDES=includes_emitter.Fragments(), 159 INCLUDES=includes_emitter.Fragments(),
166 RESOLVER_BODY=resolver_body_emitter.Fragments()) 160 RESOLVER_BODY=resolver_body_emitter.Fragments())
167 161
168 def Finish(self): 162 def Finish(self):
169 pass 163 pass
170 164
171 def _FilePathForDartImplementation(self, interface_name): 165 def HasImplementation(self, interface):
166 return not IsPureInterface(interface)
167
168 def FilePathForDartImplementation(self, interface_name):
172 return os.path.join(self._output_dir, 'dart', 169 return os.path.join(self._output_dir, 'dart',
173 '%sImplementation.dart' % interface_name) 170 '%sImplementation.dart' % interface_name)
174 171
175 def _FilePathForDartFactoryProviderImplementation(self, interface_name): 172 def _FilePathForDartFactoryProviderImplementation(self, interface_name):
176 return os.path.join(self._output_dir, 'dart', 173 return os.path.join(self._output_dir, 'dart',
177 '%sFactoryProviderImplementation.dart' % interface_name) 174 '%sFactoryProviderImplementation.dart' % interface_name)
178 175
179 def _FilePathForCppHeader(self, interface_name): 176 def _FilePathForCppHeader(self, interface_name):
180 return os.path.join(self._output_dir, 'cpp', 'Dart%s.h' % interface_name) 177 return os.path.join(self._output_dir, 'cpp', 'Dart%s.h' % interface_name)
181 178
(...skipping 909 matching lines...) Expand 10 before | Expand all | Expand 10 after
1091 1088
1092 def _IsArgumentOptionalInWebCore(argument): 1089 def _IsArgumentOptionalInWebCore(argument):
1093 return IsOptional(argument) and not 'Callback' in argument.ext_attrs 1090 return IsOptional(argument) and not 'Callback' in argument.ext_attrs
1094 1091
1095 def _ToWebKitName(name): 1092 def _ToWebKitName(name):
1096 name = name[0].lower() + name[1:] 1093 name = name[0].lower() + name[1:]
1097 name = re.sub(r'^(hTML|uRL|jS|xML|xSLT)', lambda s: s.group(1).lower(), 1094 name = re.sub(r'^(hTML|uRL|jS|xML|xSLT)', lambda s: s.group(1).lower(),
1098 name) 1095 name)
1099 return re.sub(r'^(create|exclusive)', lambda s: 'is' + s.group(1).capitalize() , 1096 return re.sub(r'^(create|exclusive)', lambda s: 'is' + s.group(1).capitalize() ,
1100 name) 1097 name)
OLDNEW
« lib/dom/scripts/systemhtml.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