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

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 811 matching lines...) Expand 10 before | Expand all | Expand 10 after
822 ' if (!scriptArguments)\n' 822 ' if (!scriptArguments)\n'
823 ' goto fail;\n' 823 ' goto fail;\n'
824 ' RefPtr<ScriptCallStack> scriptCallStack(DartUtilities::create ScriptCallStack());\n' 824 ' RefPtr<ScriptCallStack> scriptCallStack(DartUtilities::create ScriptCallStack());\n'
825 ' if (!scriptCallStack->size())\n' 825 ' if (!scriptCallStack->size())\n'
826 ' return;\n', 826 ' return;\n',
827 INDEX=len(arguments) + 1) 827 INDEX=len(arguments) + 1)
828 828
829 # Emit arguments. 829 # Emit arguments.
830 start_index = 1 if needs_receiver else 0 830 start_index = 1 if needs_receiver else 0
831 for i, argument in enumerate(arguments): 831 for i, argument in enumerate(arguments):
832 type_info = self._TypeInfo(argument.type.id)
833 self._cpp_impl_includes |= set(type_info.to_native_includes())
834 argument_name = DartDomNameOfAttribute(argument) 832 argument_name = DartDomNameOfAttribute(argument)
835 type_info.emit_to_native( 833 argument_expression, type, cls, function = self._TypeInfo(argument.type.id ).to_native_info(
podivilov 2012/08/22 15:21:05 consider returning 'cls::function' to simplify to_
Anton Muhin 2012/08/22 16:38:51 I'd rather not duplicate this logic over here, let
836 body_emitter,
837 argument, 834 argument,
838 (IsOptional(argument) and not self._IsArgumentOptionalInWebCore(node, argument)) or (argument.ext_attrs.get('Optional') == 'DefaultIsNullString'), 835 (IsOptional(argument) and not self._IsArgumentOptionalInWebCore(node, argument)) or (argument.ext_attrs.get('Optional') == 'DefaultIsNullString'),
839 argument_name, 836 argument_name,
840 'Dart_GetNativeArgument(args, %i)' % (start_index + i)) 837 self._interface.id)
841 cpp_arguments.append(type_info.argument_expression(argument_name, self._in terface.id)) 838
839 body_emitter.Emit(
840 '\n'
841 ' $TYPE $ARGUMENT_NAME = $CLS::$FUNCTION(Dart_GetNativeArgument (args, $NO), exception);\n'
842 ' if (exception)\n'
843 ' goto fail;\n',
844 TYPE=type,
845 ARGUMENT_NAME=argument_name,
846 CLS=cls,
847 FUNCTION=function,
848 NO=start_index + i)
podivilov 2012/08/22 15:21:05 nit: INDEX=...
Anton Muhin 2012/08/22 16:38:51 Done.
849 self._cpp_impl_includes.add('"%s.h"' % cls)
850 cpp_arguments.append(argument_expression)
842 851
843 body_emitter.Emit('\n') 852 body_emitter.Emit('\n')
844 853
845 if 'NeedsUserGestureCheck' in ext_attrs: 854 if 'NeedsUserGestureCheck' in ext_attrs:
846 cpp_arguments.append('DartUtilities::processingUserGesture') 855 cpp_arguments.append('DartUtilities::processingUserGesture')
847 856
848 invocation_emitter = body_emitter 857 invocation_emitter = body_emitter
849 if raises_dom_exception: 858 if raises_dom_exception:
850 cpp_arguments.append('ec') 859 cpp_arguments.append('ec')
851 invocation_emitter = body_emitter.Emit( 860 invocation_emitter = body_emitter.Emit(
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
948 parent_interface = _FindInHierarchy(database, parent_interface, test) 957 parent_interface = _FindInHierarchy(database, parent_interface, test)
949 if parent_interface: 958 if parent_interface:
950 return parent_interface 959 return parent_interface
951 960
952 def _ToWebKitName(name): 961 def _ToWebKitName(name):
953 name = name[0].lower() + name[1:] 962 name = name[0].lower() + name[1:]
954 name = re.sub(r'^(hTML|uRL|jS|xML|xSLT)', lambda s: s.group(1).lower(), 963 name = re.sub(r'^(hTML|uRL|jS|xML|xSLT)', lambda s: s.group(1).lower(),
955 name) 964 name)
956 return re.sub(r'^(create|exclusive)', lambda s: 'is' + s.group(1).capitalize() , 965 return re.sub(r'^(create|exclusive)', lambda s: 'is' + s.group(1).capitalize() ,
957 name) 966 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