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

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

Issue 9455090: Support optional callbacks. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressing Pavel's comments Created 8 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
« no previous file with comments | « no previous file | client/dom/scripts/systemwrapping.py » ('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 514 matching lines...) Expand 10 before | Expand all | Expand 10 after
525 dispatch_emitter: an dispatch_emitter for the body of a block of code. 525 dispatch_emitter: an dispatch_emitter for the body of a block of code.
526 info: the compound information about the operation and its overloads. 526 info: the compound information about the operation and its overloads.
527 indent: an indentation string for generated code. 527 indent: an indentation string for generated code.
528 operation: the IDLOperation to call. 528 operation: the IDLOperation to call.
529 """ 529 """
530 530
531 # FIXME: support ImplementedBy callbacks. 531 # FIXME: support ImplementedBy callbacks.
532 if 'ImplementedBy' in operation.ext_attrs: 532 if 'ImplementedBy' in operation.ext_attrs:
533 return 533 return
534 534
535 for op in self._interface.operations:
536 if op.id != operation.id or len(op.arguments) <= len(operation.arguments):
537 continue
538 next_argument = op.arguments[len(operation.arguments)]
539 if next_argument.is_optional and 'Callback' in next_argument.ext_attrs:
540 # FIXME: '[Optional, Callback]' arguments could be non-optional in
541 # webcore. We need to fix overloads handling to generate native
542 # callbacks properly.
543 return
544
545 self._native_version += 1 535 self._native_version += 1
546 native_name = info.name 536 native_name = info.name
547 if self._native_version > 1: 537 if self._native_version > 1:
548 native_name = '%s_%s' % (native_name, self._native_version) 538 native_name = '%s_%s' % (native_name, self._native_version)
549 argument_list = ', '.join([info.arg_infos[i][0] 539 argument_list = ', '.join([info.arg_infos[i][0]
550 for (i, arg) in enumerate(operation.arguments)]) 540 for (i, arg) in enumerate(operation.arguments)])
551 541
552 # Generate dispatcher. 542 # Generate dispatcher.
553 if info.type_name != 'void': 543 if info.type_name != 'void':
554 dispatch_emitter.Emit('$(INDENT)return _$NATIVENAME($ARGS);\n', 544 dispatch_emitter.Emit('$(INDENT)return _$NATIVENAME($ARGS);\n',
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
729 callback = emitter.Format(template, **template_parameters) 719 callback = emitter.Format(template, **template_parameters)
730 720
731 self._cpp_definitions_emitter.Emit(callback) 721 self._cpp_definitions_emitter.Emit(callback)
732 722
733 def _GenerateParameterAdapter(self, emitter, idl_argument, index): 723 def _GenerateParameterAdapter(self, emitter, idl_argument, index):
734 type_info = GetIDLTypeInfo(idl_argument.type) 724 type_info = GetIDLTypeInfo(idl_argument.type)
735 (adapter_type, include_name) = type_info.parameter_adapter_info() 725 (adapter_type, include_name) = type_info.parameter_adapter_info()
736 if include_name: 726 if include_name:
737 self._cpp_impl_includes[include_name] = 1 727 self._cpp_impl_includes[include_name] = 1
738 flags = '' 728 flags = ''
739 if idl_argument.ext_attrs.get('Optionial') == 'DefaultIsNullString': 729 if (idl_argument.ext_attrs.get('Optionial') == 'DefaultIsNullString' or
740 flags = ', DartUtilities::ConvertNullToEmptyString' 730 ('Optional' in idl_argument.ext_attrs and 'Callback' in idl_argument.ext _attrs)):
731 flags = ', DartUtilities::ConvertNullToDefaultValue'
741 emitter.Emit( 732 emitter.Emit(
742 '\n' 733 '\n'
743 ' const $ADAPTER_TYPE $NAME(Dart_GetNativeArgument(args, $INDEX)$ FLAGS);\n' 734 ' const $ADAPTER_TYPE $NAME(Dart_GetNativeArgument(args, $INDEX)$ FLAGS);\n'
744 ' if (!$NAME.conversionSuccessful()) {\n' 735 ' if (!$NAME.conversionSuccessful()) {\n'
745 ' exception = $NAME.exception();\n' 736 ' exception = $NAME.exception();\n'
746 ' goto fail;\n' 737 ' goto fail;\n'
747 ' }\n', 738 ' }\n',
748 ADAPTER_TYPE=adapter_type, 739 ADAPTER_TYPE=adapter_type,
749 NAME=idl_argument.id, 740 NAME=idl_argument.id,
750 INDEX=index + 1, 741 INDEX=index + 1,
(...skipping 28 matching lines...) Expand all
779 namespace = 'HTMLNames' 770 namespace = 'HTMLNames'
780 svg_exceptions = ['class', 'id', 'onabort', 'onclick', 'onerror', 'onload', 771 svg_exceptions = ['class', 'id', 'onabort', 'onclick', 'onerror', 'onload',
781 'onmousedown', 'onmousemove', 'onmouseout', 'onmouseover', 772 'onmousedown', 'onmousemove', 'onmouseout', 'onmouseover',
782 'onmouseup', 'onresize', 'onscroll', 'onunload'] 773 'onmouseup', 'onresize', 'onscroll', 'onunload']
783 if self._interface.id.startswith('SVG') and not attr.id in svg_exceptions: 774 if self._interface.id.startswith('SVG') and not attr.id in svg_exceptions:
784 namespace = 'SVGNames' 775 namespace = 'SVGNames'
785 self._cpp_impl_includes[namespace] = 1 776 self._cpp_impl_includes[namespace] = 1
786 777
787 attribute_name = attr.ext_attrs['Reflect'] or attr.id.lower() 778 attribute_name = attr.ext_attrs['Reflect'] or attr.id.lower()
788 return 'WebCore::%s::%sAttr' % (namespace, attribute_name) 779 return 'WebCore::%s::%sAttr' % (namespace, attribute_name)
OLDNEW
« no previous file with comments | « no previous file | client/dom/scripts/systemwrapping.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698