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

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

Issue 21156011: Alter the native code generator to directly use (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 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 881 matching lines...) Expand 10 before | Expand all | Expand 10 after
892 ' $NATIVE_TYPE result = $FUNCTION_CALL;\n' 892 ' $NATIVE_TYPE result = $FUNCTION_CALL;\n'
893 ' if (isNull)\n' 893 ' if (isNull)\n'
894 ' return;\n', 894 ' return;\n',
895 NATIVE_TYPE=return_type_info.native_type(), 895 NATIVE_TYPE=return_type_info.native_type(),
896 FUNCTION_CALL=function_call) 896 FUNCTION_CALL=function_call)
897 value_expression = 'result' 897 value_expression = 'result'
898 else: 898 else:
899 value_expression = function_call 899 value_expression = function_call
900 900
901 # Generate to Dart conversion of C++ value. 901 # Generate to Dart conversion of C++ value.
902 to_dart_conversion = return_type_info.to_dart_conversion(value_expression, self._interface.id, ext_attrs) 902 if return_type_info.native_type() == 'bool':
903 set_return_value = 'Dart_SetBooleanReturnValue(args, %s)' % (value_expre ssion)
904 elif return_type_info.native_type() == 'int':
905 set_return_value = 'Dart_SetIntegerReturnValue(args, %s)' % (value_expre ssion)
906 elif return_type_info.native_type() == 'double':
907 set_return_value = 'Dart_SetDoubleReturnValue(args, %s)' % (value_expres sion)
908 else:
909 to_dart_conversion = return_type_info.to_dart_conversion(value_expressio n, self._interface.id, ext_attrs)
910 set_return_value = 'Dart_SetReturnValue(args, %s)' % (to_dart_conversion )
vsm 2013/07/31 14:59:19 Do we need to still test whether to_dart_conversio
siva 2013/07/31 18:51:59 All the toDart methods are expected to return Dart
903 invocation_emitter.Emit( 911 invocation_emitter.Emit(
904 ' Dart_Handle returnValue = $TO_DART_CONVERSION;\n' 912 ' $RETURN_VALUE;\n',
905 ' if (returnValue)\n' 913 RETURN_VALUE=set_return_value)
906 ' Dart_SetReturnValue(args, returnValue);\n',
907 TO_DART_CONVERSION=to_dart_conversion)
908 914
909 def _GenerateNativeBinding(self, idl_name, argument_count, dart_declaration, 915 def _GenerateNativeBinding(self, idl_name, argument_count, dart_declaration,
910 native_suffix, is_custom, emit_metadata=True): 916 native_suffix, is_custom, emit_metadata=True):
911 metadata = [] 917 metadata = []
912 if emit_metadata: 918 if emit_metadata:
913 metadata = self._metadata.GetFormattedMetadata( 919 metadata = self._metadata.GetFormattedMetadata(
914 self._renamer.GetLibraryName(self._interface), 920 self._renamer.GetLibraryName(self._interface),
915 self._interface, idl_name, ' ') 921 self._interface, idl_name, ' ')
916 922
917 native_binding = '%s_%s_%s' % (self._interface.id, idl_name, native_suffix) 923 native_binding = '%s_%s_%s' % (self._interface.id, idl_name, native_suffix)
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
1039 ' if (Dart_NativeFunction func = $CLASS_NAME::resolver(name, argu mentCount))\n' 1045 ' if (Dart_NativeFunction func = $CLASS_NAME::resolver(name, argu mentCount))\n'
1040 ' return func;\n', 1046 ' return func;\n',
1041 CLASS_NAME=os.path.splitext(os.path.basename(path))[0]) 1047 CLASS_NAME=os.path.splitext(os.path.basename(path))[0])
1042 1048
1043 def _IsOptionalStringArgumentInInitEventMethod(interface, operation, argument): 1049 def _IsOptionalStringArgumentInInitEventMethod(interface, operation, argument):
1044 return ( 1050 return (
1045 interface.id.endswith('Event') and 1051 interface.id.endswith('Event') and
1046 operation.id.startswith('init') and 1052 operation.id.startswith('init') and
1047 argument.ext_attrs.get('Default') == 'Undefined' and 1053 argument.ext_attrs.get('Default') == 'Undefined' and
1048 argument.type.id == 'DOMString') 1054 argument.type.id == 'DOMString')
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