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

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

Issue 10821010: Automatically support fancy Console methods. (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 | 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 661 matching lines...) Expand 10 before | Expand all | Expand 10 after
672 if raises_dom_exception or arguments: 672 if raises_dom_exception or arguments:
673 raises_exceptions = True 673 raises_exceptions = True
674 674
675 if ext_attrs.get('CallWith') == 'ScriptArguments|CallStack': 675 if ext_attrs.get('CallWith') == 'ScriptArguments|CallStack':
676 raises_exceptions = True 676 raises_exceptions = True
677 requires_v8_scope = True 677 requires_v8_scope = True
678 requires_stack_info = True 678 requires_stack_info = True
679 self._cpp_impl_includes.add('"ScriptArguments.h"') 679 self._cpp_impl_includes.add('"ScriptArguments.h"')
680 self._cpp_impl_includes.add('"ScriptCallStack.h"') 680 self._cpp_impl_includes.add('"ScriptCallStack.h"')
681 cpp_arguments = ['scriptArguments', 'scriptCallStack'] 681 cpp_arguments = ['scriptArguments', 'scriptCallStack']
682 # WebKit uses scriptArguments to reconstruct last argument, so
683 # it's not needed and should be just removed.
684 arguments = arguments[:-1]
podivilov 2012/08/21 12:03:27 It does the opposite to DatabaseBuilder.AddMissing
Anton Muhin 2012/08/21 12:04:33 I'd be glad to, but I need proper signatures for a
682 685
683 if ext_attrs.get('CallWith') == 'ScriptExecutionContext': 686 if ext_attrs.get('CallWith') == 'ScriptExecutionContext':
684 raises_exceptions = True 687 raises_exceptions = True
685 requires_script_execution_context = True 688 requires_script_execution_context = True
686 cpp_arguments = ['context'] 689 cpp_arguments = ['context']
687 690
688 if 'ImplementedBy' in ext_attrs: 691 if 'ImplementedBy' in ext_attrs:
689 assert needs_receiver 692 assert needs_receiver
693 self._cpp_impl_includes.add('"%s.h"' % ext_attrs['ImplementedBy'])
690 cpp_arguments.append('receiver') 694 cpp_arguments.append('receiver')
691 self._cpp_impl_includes.add('"%s.h"' % ext_attrs['ImplementedBy'])
692 695
693 if 'NamedConstructor' in ext_attrs: 696 if 'NamedConstructor' in ext_attrs:
694 raises_exceptions = True 697 raises_exceptions = True
695 requires_dom_window = True 698 requires_dom_window = True
696 self._cpp_impl_includes.add('"DOMWindow.h"') 699 self._cpp_impl_includes.add('"DOMWindow.h"')
697 cpp_arguments = ['document'] 700 cpp_arguments = ['document']
698 701
699 if 'Reflect' in ext_attrs: 702 if 'Reflect' in ext_attrs:
700 cpp_arguments = [self._GenerateWebCoreReflectionAttributeName(node)] 703 cpp_arguments = [self._GenerateWebCoreReflectionAttributeName(node)]
701 704
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
785 if requires_stack_info: 788 if requires_stack_info:
786 body_emitter.Emit( 789 body_emitter.Emit(
787 '\n' 790 '\n'
788 ' Dart_Handle customArgument = Dart_GetNativeArgument(args, $IN DEX);\n' 791 ' Dart_Handle customArgument = Dart_GetNativeArgument(args, $IN DEX);\n'
789 ' RefPtr<ScriptArguments> scriptArguments(DartUtilities::create ScriptArguments(customArgument, exception));\n' 792 ' RefPtr<ScriptArguments> scriptArguments(DartUtilities::create ScriptArguments(customArgument, exception));\n'
790 ' if (!scriptArguments)\n' 793 ' if (!scriptArguments)\n'
791 ' goto fail;\n' 794 ' goto fail;\n'
792 ' RefPtr<ScriptCallStack> scriptCallStack(DartUtilities::create ScriptCallStack());\n' 795 ' RefPtr<ScriptCallStack> scriptCallStack(DartUtilities::create ScriptCallStack());\n'
793 ' if (!scriptCallStack->size())\n' 796 ' if (!scriptCallStack->size())\n'
794 ' return;\n', 797 ' return;\n',
795 INDEX=len(arguments)) 798 INDEX=len(arguments) + 1)
796 799
797 # Process Dart cpp_arguments. 800 # Process Dart cpp_arguments.
798 start_index = 0 801 start_index = 1 if needs_receiver else 0
799 if needs_receiver: 802 for i, argument in enumerate(arguments):
800 start_index = 1
801 for (i, argument) in enumerate(arguments):
802 if (i == len(arguments) - 1 and
803 self._interface.id == 'Console' and
804 argument.id == 'arg'):
805 # FIXME: we are skipping last argument here because it was added in
806 # supplemental dart.idl. Cleanup dart.idl and remove this check.
807 break
808 argument_expression = self._GenerateToNative(body_emitter, argument, start _index + i) 803 argument_expression = self._GenerateToNative(body_emitter, argument, start _index + i)
809 cpp_arguments.append(argument_expression) 804 cpp_arguments.append(argument_expression)
810 805
811 body_emitter.Emit('\n') 806 body_emitter.Emit('\n')
812 807
813 # FIXME: rework in IDLs. 808 # FIXME: rework in IDLs.
814 if node.id in ['addEventListener', 'removeEventListener']: 809 if node.id in ['addEventListener', 'removeEventListener']:
815 # addEventListener's and removeEventListener's last argument is marked 810 # addEventListener's and removeEventListener's last argument is marked
816 # as optional in idl, but is not optional in webcore implementation. 811 # as optional in idl, but is not optional in webcore implementation.
817 if len(arguments) == 2: 812 if len(arguments) == 2:
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
932 927
933 def _IsArgumentOptionalInWebCore(argument): 928 def _IsArgumentOptionalInWebCore(argument):
934 return IsOptional(argument) and not 'Callback' in argument.ext_attrs 929 return IsOptional(argument) and not 'Callback' in argument.ext_attrs
935 930
936 def _ToWebKitName(name): 931 def _ToWebKitName(name):
937 name = name[0].lower() + name[1:] 932 name = name[0].lower() + name[1:]
938 name = re.sub(r'^(hTML|uRL|jS|xML|xSLT)', lambda s: s.group(1).lower(), 933 name = re.sub(r'^(hTML|uRL|jS|xML|xSLT)', lambda s: s.group(1).lower(),
939 name) 934 name)
940 return re.sub(r'^(create|exclusive)', lambda s: 'is' + s.group(1).capitalize() , 935 return re.sub(r'^(create|exclusive)', lambda s: 'is' + s.group(1).capitalize() ,
941 name) 936 name)
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698