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

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

Issue 10834271: Support typed arrays constructor templates. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 4 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 | « no previous file | tests/html/html.status » ('j') | 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 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 238
239 ext_attrs = self._interface.ext_attrs 239 ext_attrs = self._interface.ext_attrs
240 240
241 if 'CustomConstructor' in ext_attrs: 241 if 'CustomConstructor' in ext_attrs:
242 # We have a custom implementation for it. 242 # We have a custom implementation for it.
243 self._cpp_declarations_emitter.Emit( 243 self._cpp_declarations_emitter.Emit(
244 '\n' 244 '\n'
245 'void constructorCallback(Dart_NativeArguments);\n') 245 'void constructorCallback(Dart_NativeArguments);\n')
246 return 246 return
247 247
248 if ext_attrs.get('ConstructorTemplate') == 'TypedArray':
249 self._cpp_impl_includes.add('"DartArrayBufferViewCustom.h"');
250 self._cpp_definitions_emitter.Emit(
251 '\n'
252 'static void constructorCallback(Dart_NativeArguments args)\n'
253 '{\n'
254 ' WebCore::DartArrayBufferViewInternal::constructWebGLArray<Dart$(INT ERFACE_NAME)>(args);\n'
255 '}\n',
256 INTERFACE_NAME=self._interface.id);
257 return
258
248 create_function = 'create' 259 create_function = 'create'
249 if 'NamedConstructor' in ext_attrs: 260 if 'NamedConstructor' in ext_attrs:
250 create_function = 'createForJSConstructor' 261 create_function = 'createForJSConstructor'
251 function_expression = '%s::%s' % (self._interface_type_info.native_type(), c reate_function) 262 function_expression = '%s::%s' % (self._interface_type_info.native_type(), c reate_function)
252 self._GenerateNativeCallback( 263 self._GenerateNativeCallback(
253 'constructorCallback', 264 'constructorCallback',
254 False, 265 False,
255 function_expression, 266 function_expression,
256 self._interface, 267 self._interface,
257 constructor_info.idl_args, 268 constructor_info.idl_args,
(...skipping 17 matching lines...) Expand all
275 # FIXME: We're currently injecting List<..> and EventTarget as 286 # FIXME: We're currently injecting List<..> and EventTarget as
276 # supertypes in dart.idl. We should annotate/preserve as 287 # supertypes in dart.idl. We should annotate/preserve as
277 # attributes instead. For now, this hack lets the self._interfaces 288 # attributes instead. For now, this hack lets the self._interfaces
278 # inherit, but not the classes. 289 # inherit, but not the classes.
279 # List methods are injected in AddIndexer. 290 # List methods are injected in AddIndexer.
280 if IsDartListType(supertype) or IsDartCollectionType(supertype): 291 if IsDartListType(supertype) or IsDartCollectionType(supertype):
281 return root_class 292 return root_class
282 293
283 return self._ImplClassName(supertype) 294 return self._ImplClassName(supertype)
284 295
296 ATTRIBUTES_OF_CONSTRUCTABLE = set([
podivilov 2012/08/21 12:36:27 Please move to the top of the file.
Anton Muhin 2012/08/21 18:15:55 I am somewhat concerned with moving it far away fr
297 'CustomConstructor',
298 'V8CustomConstructor',
299 'Constructor',
300 'NamedConstructor'])
301
285 def _IsConstructable(self): 302 def _IsConstructable(self):
286 # FIXME: support ConstructorTemplate. 303 ext_attrs = self._interface.ext_attrs
287 return set(['CustomConstructor', 'V8CustomConstructor', 'Constructor', 'Name dConstructor']) & set(self._interface.ext_attrs) 304
305 if self.ATTRIBUTES_OF_CONSTRUCTABLE & set(ext_attrs):
306 return True
307
308 # FIXME: support other types of ConstructorTemplate.
309 if ext_attrs.get('ConstructorTemplate') == 'TypedArray':
310 return True
311
312 return False
288 313
289 def EmitFactoryProvider(self, constructor_info, factory_provider, emitter): 314 def EmitFactoryProvider(self, constructor_info, factory_provider, emitter):
290 template_file = 'factoryprovider_%s.darttemplate' % self._html_interface_nam e 315 template_file = 'factoryprovider_%s.darttemplate' % self._html_interface_nam e
291 template = self._system._templates.TryLoad(template_file) 316 template = self._system._templates.TryLoad(template_file)
292 if not template: 317 if not template:
293 template = self._system._templates.Load('factoryprovider.darttemplate') 318 template = self._system._templates.Load('factoryprovider.darttemplate')
294 319
295 native_binding = '%s_constructor_Callback' % self._interface.id 320 native_binding = '%s_constructor_Callback' % self._interface.id
296 emitter.Emit( 321 emitter.Emit(
297 template, 322 template,
(...skipping 613 matching lines...) Expand 10 before | Expand all | Expand 10 after
911 parent_interface = _FindInHierarchy(database, parent_interface, test) 936 parent_interface = _FindInHierarchy(database, parent_interface, test)
912 if parent_interface: 937 if parent_interface:
913 return parent_interface 938 return parent_interface
914 939
915 def _ToWebKitName(name): 940 def _ToWebKitName(name):
916 name = name[0].lower() + name[1:] 941 name = name[0].lower() + name[1:]
917 name = re.sub(r'^(hTML|uRL|jS|xML|xSLT)', lambda s: s.group(1).lower(), 942 name = re.sub(r'^(hTML|uRL|jS|xML|xSLT)', lambda s: s.group(1).lower(),
918 name) 943 name)
919 return re.sub(r'^(create|exclusive)', lambda s: 'is' + s.group(1).capitalize() , 944 return re.sub(r'^(create|exclusive)', lambda s: 'is' + s.group(1).capitalize() ,
920 name) 945 name)
OLDNEW
« no previous file with comments | « no previous file | tests/html/html.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698