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

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

Issue 11118025: Extract common logic from Backend.BaseClassName(). (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
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 def ImplementationTemplate(self): 94 def ImplementationTemplate(self):
95 template = None 95 template = None
96 interface_name = self._interface_type_info.interface_name() 96 interface_name = self._interface_type_info.interface_name()
97 if interface_name == self._interface.id or not self._database.HasInterface(i nterface_name): 97 if interface_name == self._interface.id or not self._database.HasInterface(i nterface_name):
98 template_file = 'impl_%s.darttemplate' % interface_name 98 template_file = 'impl_%s.darttemplate' % interface_name
99 template = self._template_loader.TryLoad(template_file) 99 template = self._template_loader.TryLoad(template_file)
100 if not template: 100 if not template:
101 template = self._template_loader.Load('dart_implementation.darttemplate') 101 template = self._template_loader.Load('dart_implementation.darttemplate')
102 return template 102 return template
103 103
104 def RootClassName(self):
105 return 'NativeFieldWrapperClass1'
106
104 def AdditionalImplementedInterfaces(self): 107 def AdditionalImplementedInterfaces(self):
105 return [] 108 return []
106 109
107 def NativeSpec(self): 110 def NativeSpec(self):
108 return '' 111 return ''
109 112
110 def StartInterface(self, memebers_emitter): 113 def StartInterface(self, memebers_emitter):
111 # Create emitters for c++ implementation. 114 # Create emitters for c++ implementation.
112 if not IsPureInterface(self._interface.id): 115 if not IsPureInterface(self._interface.id):
113 self._cpp_header_emitter = self._cpp_library_emitter.CreateHeaderEmitter(s elf._interface.id) 116 self._cpp_header_emitter = self._cpp_library_emitter.CreateHeaderEmitter(s elf._interface.id)
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 function_expression = '%s::%s' % (self._interface_type_info.native_type(), c reate_function) 168 function_expression = '%s::%s' % (self._interface_type_info.native_type(), c reate_function)
166 self._GenerateNativeCallback( 169 self._GenerateNativeCallback(
167 'constructorCallback', 170 'constructorCallback',
168 False, 171 False,
169 function_expression, 172 function_expression,
170 self._interface, 173 self._interface,
171 constructor_info.idl_args, 174 constructor_info.idl_args,
172 self._interface.id, 175 self._interface.id,
173 'ConstructorRaisesException' in ext_attrs) 176 'ConstructorRaisesException' in ext_attrs)
174 177
175 def BaseClassName(self):
176 root_class = 'NativeFieldWrapperClass1'
177
178 if not self._interface.parents:
179 return root_class
180
181 supertype = self._interface.parents[0].type.id
182
183 if IsPureInterface(supertype): # The class is a root.
184 return root_class
185
186 # FIXME: We're currently injecting List<..> and EventTarget as
187 # supertypes in dart.idl. We should annotate/preserve as
188 # attributes instead. For now, this hack lets the self._interfaces
189 # inherit, but not the classes.
190 # List methods are injected in AddIndexer.
191 if IsDartListType(supertype) or IsDartCollectionType(supertype):
192 return root_class
193
194 return self._type_registry.TypeInfo(supertype).implementation_name()
195
196 ATTRIBUTES_OF_CONSTRUCTABLE = set([ 178 ATTRIBUTES_OF_CONSTRUCTABLE = set([
197 'CustomConstructor', 179 'CustomConstructor',
198 'V8CustomConstructor', 180 'V8CustomConstructor',
199 'Constructor', 181 'Constructor',
200 'NamedConstructor']) 182 'NamedConstructor'])
201 183
202 def _IsConstructable(self): 184 def _IsConstructable(self):
203 ext_attrs = self._interface.ext_attrs 185 ext_attrs = self._interface.ext_attrs
204 186
205 if self.ATTRIBUTES_OF_CONSTRUCTABLE & set(ext_attrs): 187 if self.ATTRIBUTES_OF_CONSTRUCTABLE & set(ext_attrs):
(...skipping 673 matching lines...) Expand 10 before | Expand all | Expand 10 after
879 def EmitResolver(self, template, output_dir): 861 def EmitResolver(self, template, output_dir):
880 file_path = os.path.join(output_dir, 'DartResolver.cpp') 862 file_path = os.path.join(output_dir, 'DartResolver.cpp')
881 includes_emitter, body_emitter = self._emitters.FileEmitter(file_path).Emit( template) 863 includes_emitter, body_emitter = self._emitters.FileEmitter(file_path).Emit( template)
882 for header_file in self._headers_list: 864 for header_file in self._headers_list:
883 path = os.path.relpath(header_file, output_dir) 865 path = os.path.relpath(header_file, output_dir)
884 includes_emitter.Emit('#include "$PATH"\n', PATH=path) 866 includes_emitter.Emit('#include "$PATH"\n', PATH=path)
885 body_emitter.Emit( 867 body_emitter.Emit(
886 ' if (Dart_NativeFunction func = $CLASS_NAME::resolver(name, argume ntCount))\n' 868 ' if (Dart_NativeFunction func = $CLASS_NAME::resolver(name, argume ntCount))\n'
887 ' return func;\n', 869 ' return func;\n',
888 CLASS_NAME=os.path.splitext(os.path.basename(path))[0]) 870 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