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

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

Issue 11114019: Switch to using IDLTypeInfo.interface_name(). (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 2 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
« no previous file with comments | « lib/html/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 from generator import * 11 from generator import *
12 from systemhtml import SecureOutputType 12 from systemhtml import SecureOutputType
13 13
14 class DartiumBackend(object): 14 class DartiumBackend(object):
15 """Generates Dart implementation for one DOM IDL interface.""" 15 """Generates Dart implementation for one DOM IDL interface."""
16 16
17 def __init__(self, interface, cpp_library_emitter, options): 17 def __init__(self, interface, cpp_library_emitter, options):
18 self._interface = interface 18 self._interface = interface
19 self._cpp_library_emitter = cpp_library_emitter 19 self._cpp_library_emitter = cpp_library_emitter
20 self._database = options.database 20 self._database = options.database
21 self._template_loader = options.templates 21 self._template_loader = options.templates
22 self._type_registry = options.type_registry 22 self._type_registry = options.type_registry
23 self._html_interface_name = options.renamer.RenameInterface(self._interface) 23 self._interface_type_info = self._type_registry.TypeInfo(self._interface.id)
24 24
25 def ImplementationClassName(self): 25 def ImplementationClassName(self):
26 return self._ImplClassName(self._interface.id) 26 return self._ImplClassName(self._interface.id)
27 27
28 def ImplementsMergedMembers(self): 28 def ImplementsMergedMembers(self):
29 # We could not add merged functions to implementation class because 29 # We could not add merged functions to implementation class because
30 # underlying c++ object doesn't implement them. Merged functions are 30 # underlying c++ object doesn't implement them. Merged functions are
31 # generated on merged interface implementation instead. 31 # generated on merged interface implementation instead.
32 return False 32 return False
33 33
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 89
90 cpp_impl_emitter = self._cpp_library_emitter.CreateSourceEmitter(self._inter face.id) 90 cpp_impl_emitter = self._cpp_library_emitter.CreateSourceEmitter(self._inter face.id)
91 cpp_impl_emitter.Emit( 91 cpp_impl_emitter.Emit(
92 self._template_loader.Load('cpp_callback_implementation.template'), 92 self._template_loader.Load('cpp_callback_implementation.template'),
93 INCLUDES=self._GenerateCPPIncludes(cpp_impl_includes), 93 INCLUDES=self._GenerateCPPIncludes(cpp_impl_includes),
94 INTERFACE=self._interface.id, 94 INTERFACE=self._interface.id,
95 HANDLERS=cpp_impl_handlers_emitter.Fragments()) 95 HANDLERS=cpp_impl_handlers_emitter.Fragments())
96 96
97 def ImplementationTemplate(self): 97 def ImplementationTemplate(self):
98 template = None 98 template = None
99 if self._html_interface_name == self._interface.id or not self._database.Has Interface(self._html_interface_name): 99 interface_name = self._interface_type_info.interface_name()
100 template_file = 'impl_%s.darttemplate' % self._html_interface_name 100 if interface_name == self._interface.id or not self._database.HasInterface(i nterface_name):
101 template_file = 'impl_%s.darttemplate' % interface_name
101 template = self._template_loader.TryLoad(template_file) 102 template = self._template_loader.TryLoad(template_file)
102 if not template: 103 if not template:
103 template = self._template_loader.Load('dart_implementation.darttemplate') 104 template = self._template_loader.Load('dart_implementation.darttemplate')
104 return template 105 return template
105 106
106 def AdditionalImplementedInterfaces(self): 107 def AdditionalImplementedInterfaces(self):
107 return [] 108 return []
108 109
109 def NativeSpec(self): 110 def NativeSpec(self):
110 return '' 111 return ''
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 if self.ATTRIBUTES_OF_CONSTRUCTABLE & set(ext_attrs): 211 if self.ATTRIBUTES_OF_CONSTRUCTABLE & set(ext_attrs):
211 return True 212 return True
212 213
213 # FIXME: support other types of ConstructorTemplate. 214 # FIXME: support other types of ConstructorTemplate.
214 if ext_attrs.get('ConstructorTemplate') == 'TypedArray': 215 if ext_attrs.get('ConstructorTemplate') == 'TypedArray':
215 return True 216 return True
216 217
217 return False 218 return False
218 219
219 def EmitFactoryProvider(self, constructor_info, factory_provider, emitter): 220 def EmitFactoryProvider(self, constructor_info, factory_provider, emitter):
220 template_file = 'factoryprovider_%s.darttemplate' % self._html_interface_nam e 221 interface_name = self._interface_type_info.interface_name()
222 template_file = 'factoryprovider_%s.darttemplate' % interface_name
221 template = self._template_loader.TryLoad(template_file) 223 template = self._template_loader.TryLoad(template_file)
222 if not template: 224 if not template:
223 template = self._template_loader.Load('factoryprovider.darttemplate') 225 template = self._template_loader.Load('factoryprovider.darttemplate')
224 226
225 native_binding = '%s_constructor_Callback' % self._interface.id 227 native_binding = '%s_constructor_Callback' % self._interface.id
226 emitter.Emit( 228 emitter.Emit(
227 template, 229 template,
228 FACTORYPROVIDER=factory_provider, 230 FACTORYPROVIDER=factory_provider,
229 INTERFACE=self._html_interface_name, 231 INTERFACE=interface_name,
230 PARAMETERS=constructor_info.ParametersImplementationDeclaration(self._Da rtType), 232 PARAMETERS=constructor_info.ParametersImplementationDeclaration(self._Da rtType),
231 ARGUMENTS=constructor_info.ParametersAsArgumentList(), 233 ARGUMENTS=constructor_info.ParametersAsArgumentList(),
232 NATIVE_NAME=native_binding) 234 NATIVE_NAME=native_binding)
233 235
234 def FinishInterface(self): 236 def FinishInterface(self):
235 self._GenerateCPPHeader() 237 self._GenerateCPPHeader()
236 238
237 self._cpp_impl_emitter.Emit( 239 self._cpp_impl_emitter.Emit(
238 self._template_loader.Load('cpp_implementation.template'), 240 self._template_loader.Load('cpp_implementation.template'),
239 INTERFACE=self._interface.id, 241 INTERFACE=self._interface.id,
(...skipping 643 matching lines...) Expand 10 before | Expand all | Expand 10 after
883 def EmitResolver(self, template, output_dir): 885 def EmitResolver(self, template, output_dir):
884 file_path = os.path.join(output_dir, 'DartResolver.cpp') 886 file_path = os.path.join(output_dir, 'DartResolver.cpp')
885 includes_emitter, body_emitter = self._emitters.FileEmitter(file_path).Emit( template) 887 includes_emitter, body_emitter = self._emitters.FileEmitter(file_path).Emit( template)
886 for header_file in self._headers_list: 888 for header_file in self._headers_list:
887 path = os.path.relpath(header_file, output_dir) 889 path = os.path.relpath(header_file, output_dir)
888 includes_emitter.Emit('#include "$PATH"\n', PATH=path) 890 includes_emitter.Emit('#include "$PATH"\n', PATH=path)
889 body_emitter.Emit( 891 body_emitter.Emit(
890 ' if (Dart_NativeFunction func = $CLASS_NAME::resolver(name, argume ntCount))\n' 892 ' if (Dart_NativeFunction func = $CLASS_NAME::resolver(name, argume ntCount))\n'
891 ' return func;\n', 893 ' return func;\n',
892 CLASS_NAME=os.path.splitext(os.path.basename(path))[0]) 894 CLASS_NAME=os.path.splitext(os.path.basename(path))[0])
OLDNEW
« no previous file with comments | « lib/html/scripts/systemhtml.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698