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

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

Issue 12463028: "Reverting 19586" (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 9 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 from generator import * 11 from generator import *
12 from htmldartgenerator import * 12 from htmldartgenerator import *
13 from systemhtml import js_support_checks, GetCallbackInfo 13 from systemhtml import js_support_checks
14 14
15 class DartiumBackend(HtmlDartGenerator): 15 class DartiumBackend(HtmlDartGenerator):
16 """Generates Dart implementation for one DOM IDL interface.""" 16 """Generates Dart implementation for one DOM IDL interface."""
17 17
18 def __init__(self, interface, cpp_library_emitter, options): 18 def __init__(self, interface, cpp_library_emitter, options):
19 super(DartiumBackend, self).__init__(interface, options) 19 super(DartiumBackend, self).__init__(interface, options)
20 20
21 self._interface = interface 21 self._interface = interface
22 self._cpp_library_emitter = cpp_library_emitter 22 self._cpp_library_emitter = cpp_library_emitter
23 self._database = options.database 23 self._database = options.database
(...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after
469 self.SecureOutputType(info.type_name), 469 self.SecureOutputType(info.type_name),
470 html_name, 470 html_name,
471 info.ParametersDeclaration(self._DartType)) 471 info.ParametersDeclaration(self._DartType))
472 472
473 operation = info.operations[0] 473 operation = info.operations[0]
474 is_custom = 'Custom' in operation.ext_attrs 474 is_custom = 'Custom' in operation.ext_attrs
475 has_optional_arguments = any(self._IsArgumentOptionalInWebCore(operation, ar gument) for argument in operation.arguments) 475 has_optional_arguments = any(self._IsArgumentOptionalInWebCore(operation, ar gument) for argument in operation.arguments)
476 needs_dispatcher = not is_custom and (len(info.operations) > 1 or has_option al_arguments) 476 needs_dispatcher = not is_custom and (len(info.operations) > 1 or has_option al_arguments)
477 477
478 if not needs_dispatcher: 478 if not needs_dispatcher:
479 if info.callback_args: 479 # Bind directly to native implementation
480 self._AddFutureifiedOperation(info, html_name) 480 argument_count = (0 if info.IsStatic() else 1) + len(info.param_infos)
481 else: 481 cpp_callback_name = self._GenerateNativeBinding(
482 # Bind directly to native implementation 482 info.name, argument_count, dart_declaration, 'Callback', is_custom)
483 argument_count = (0 if info.IsStatic() else 1) + len(info.param_infos) 483 if not is_custom:
484 cpp_callback_name = self._GenerateNativeBinding( 484 self._GenerateOperationNativeCallback(operation, operation.arguments, cp p_callback_name)
485 info.name, argument_count, dart_declaration, 'Callback', is_custom)
486 if not is_custom:
487 self._GenerateOperationNativeCallback(operation, operation.arguments, cpp_callback_name)
488 else: 485 else:
489 self._GenerateDispatcher(info.operations, dart_declaration, [info.name for info in info.param_infos]) 486 self._GenerateDispatcher(info.operations, dart_declaration, [info.name for info in info.param_infos])
490 487
491 def _GenerateDispatcher(self, operations, dart_declaration, parameter_names): 488 def _GenerateDispatcher(self, operations, dart_declaration, parameter_names):
492 489
493 def GenerateCall( 490 def GenerateCall(
494 stmts_emitter, call_emitter, version, operation, argument_count): 491 stmts_emitter, call_emitter, version, operation, argument_count):
495 overload_name = '_%s_%s' % (operation.id, version) 492 overload_name = '_%s_%s' % (operation.id, version)
496 argument_list = ', '.join(parameter_names[:argument_count]) 493 argument_list = ', '.join(parameter_names[:argument_count])
497 call_emitter.Emit('$NAME($ARGS)', NAME=overload_name, ARGS=argument_list) 494 call_emitter.Emit('$NAME($ARGS)', NAME=overload_name, ARGS=argument_list)
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
897 ' if (Dart_NativeFunction func = $CLASS_NAME::resolver(name, argu mentCount))\n' 894 ' if (Dart_NativeFunction func = $CLASS_NAME::resolver(name, argu mentCount))\n'
898 ' return func;\n', 895 ' return func;\n',
899 CLASS_NAME=os.path.splitext(os.path.basename(path))[0]) 896 CLASS_NAME=os.path.splitext(os.path.basename(path))[0])
900 897
901 def _IsOptionalStringArgumentInInitEventMethod(interface, operation, argument): 898 def _IsOptionalStringArgumentInInitEventMethod(interface, operation, argument):
902 return ( 899 return (
903 interface.id.endswith('Event') and 900 interface.id.endswith('Event') and
904 operation.id.startswith('init') and 901 operation.id.startswith('init') and
905 argument.ext_attrs.get('Optional') == 'DefaultIsUndefined' and 902 argument.ext_attrs.get('Optional') == 'DefaultIsUndefined' and
906 argument.type.id == 'DOMString') 903 argument.type.id == 'DOMString')
OLDNEW
« no previous file with comments | « tools/dom/scripts/systemhtml.py ('k') | tools/dom/templates/html/impl/impl_XMLHttpRequest.darttemplate » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698