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

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

Issue 10831035: Refactor conversion to native. (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 | « lib/dom/scripts/generator.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 812 matching lines...) Expand 10 before | Expand all | Expand 10 after
823 ' if (!scriptArguments)\n' 823 ' if (!scriptArguments)\n'
824 ' goto fail;\n' 824 ' goto fail;\n'
825 ' RefPtr<ScriptCallStack> scriptCallStack(DartUtilities::create ScriptCallStack());\n' 825 ' RefPtr<ScriptCallStack> scriptCallStack(DartUtilities::create ScriptCallStack());\n'
826 ' if (!scriptCallStack->size())\n' 826 ' if (!scriptCallStack->size())\n'
827 ' return;\n', 827 ' return;\n',
828 INDEX=len(arguments) + 1) 828 INDEX=len(arguments) + 1)
829 829
830 # Emit arguments. 830 # Emit arguments.
831 start_index = 1 if needs_receiver else 0 831 start_index = 1 if needs_receiver else 0
832 for i, argument in enumerate(arguments): 832 for i, argument in enumerate(arguments):
833 type_info = self._TypeInfo(argument.type.id)
834 self._cpp_impl_includes |= set(type_info.to_native_includes())
835 argument_name = DartDomNameOfAttribute(argument) 833 argument_name = DartDomNameOfAttribute(argument)
836 type_info.emit_to_native( 834 argument_expression, type, cls, function = self._TypeInfo(argument.type.id ).to_native_info(
837 body_emitter,
838 argument, 835 argument,
839 (IsOptional(argument) and not self._IsArgumentOptionalInWebCore(node, argument)) or (argument.ext_attrs.get('Optional') == 'DefaultIsNullString'), 836 (IsOptional(argument) and not self._IsArgumentOptionalInWebCore(node, argument)) or (argument.ext_attrs.get('Optional') == 'DefaultIsNullString'),
840 argument_name, 837 argument_name,
841 'Dart_GetNativeArgument(args, %i)' % (start_index + i)) 838 self._interface.id)
842 cpp_arguments.append(type_info.argument_expression(argument_name, self._in terface.id)) 839
840 body_emitter.Emit(
841 '\n'
842 ' $TYPE $ARGUMENT_NAME = $CLS::$FUNCTION(Dart_GetNativeArgument (args, $INDEX), exception);\n'
843 ' if (exception)\n'
844 ' goto fail;\n',
845 TYPE=type,
846 ARGUMENT_NAME=argument_name,
847 CLS=cls,
848 FUNCTION=function,
849 INDEX=start_index + i)
850 self._cpp_impl_includes.add('"%s.h"' % cls)
851 cpp_arguments.append(argument_expression)
843 852
844 body_emitter.Emit('\n') 853 body_emitter.Emit('\n')
845 854
846 if 'NeedsUserGestureCheck' in ext_attrs: 855 if 'NeedsUserGestureCheck' in ext_attrs:
847 cpp_arguments.append('DartUtilities::processingUserGesture') 856 cpp_arguments.append('DartUtilities::processingUserGesture')
848 857
849 invocation_emitter = body_emitter 858 invocation_emitter = body_emitter
850 if raises_dom_exception: 859 if raises_dom_exception:
851 cpp_arguments.append('ec') 860 cpp_arguments.append('ec')
852 invocation_emitter = body_emitter.Emit( 861 invocation_emitter = body_emitter.Emit(
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
949 parent_interface = _FindInHierarchy(database, parent_interface, test) 958 parent_interface = _FindInHierarchy(database, parent_interface, test)
950 if parent_interface: 959 if parent_interface:
951 return parent_interface 960 return parent_interface
952 961
953 def _ToWebKitName(name): 962 def _ToWebKitName(name):
954 name = name[0].lower() + name[1:] 963 name = name[0].lower() + name[1:]
955 name = re.sub(r'^(hTML|uRL|jS|xML|xSLT)', lambda s: s.group(1).lower(), 964 name = re.sub(r'^(hTML|uRL|jS|xML|xSLT)', lambda s: s.group(1).lower(),
956 name) 965 name)
957 return re.sub(r'^(create|exclusive)', lambda s: 'is' + s.group(1).capitalize() , 966 return re.sub(r'^(create|exclusive)', lambda s: 'is' + s.group(1).capitalize() ,
958 name) 967 name)
OLDNEW
« no previous file with comments | « lib/dom/scripts/generator.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698