Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 958 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 969 ' return;\n', | 969 ' return;\n', |
| 970 NATIVE_TYPE=return_type_info.native_type(), | 970 NATIVE_TYPE=return_type_info.native_type(), |
| 971 FUNCTION_CALL=function_call) | 971 FUNCTION_CALL=function_call) |
| 972 value_expression = 'result' | 972 value_expression = 'result' |
| 973 else: | 973 else: |
| 974 value_expression = function_call | 974 value_expression = function_call |
| 975 | 975 |
| 976 # Generate to Dart conversion of C++ value. | 976 # Generate to Dart conversion of C++ value. |
| 977 if return_type_info.dart_type() == 'bool': | 977 if return_type_info.dart_type() == 'bool': |
| 978 set_return_value = 'Dart_SetBooleanReturnValue(args, %s)' % (value_expre ssion) | 978 set_return_value = 'Dart_SetBooleanReturnValue(args, %s)' % (value_expre ssion) |
| 979 elif return_type_info.dart_type() == 'int' and return_type_info.native_typ e() == 'int': | 979 elif return_type_info.dart_type() == 'int': |
| 980 set_return_value = 'Dart_SetIntegerReturnValue(args, %s)' % (value_expre ssion) | 980 if return_type_info.native_type() == 'unsigned': |
| 981 set_return_value = 'DartUtilities::setDartUnsignedReturnValue(args, %s )' % (value_expression) | |
| 982 elif return_type_info.native_type() == 'unsigned long long': | |
| 983 set_return_value = 'DartUtilities::setDartUnsignedLongLongReturnValue( args, %s)' % (value_expression) | |
| 984 else: | |
|
vsm
2013/08/21 22:27:58
Perhaps assert ...native_type() == 'int' here?
siva
2013/08/22 00:46:48
Done.
| |
| 985 set_return_value = 'DartUtilities::setDartIntegerReturnValue(args, %s) ' % (value_expression) | |
| 981 elif return_type_info.dart_type() == 'double': | 986 elif return_type_info.dart_type() == 'double': |
| 982 set_return_value = 'Dart_SetDoubleReturnValue(args, %s)' % (value_expres sion) | 987 set_return_value = 'Dart_SetDoubleReturnValue(args, %s)' % (value_expres sion) |
| 983 elif return_type_info.dart_type() == 'String': | 988 elif return_type_info.dart_type() == 'String': |
| 984 if ext_attrs and 'TreatReturnedNullStringAs' in ext_attrs: | 989 if ext_attrs and 'TreatReturnedNullStringAs' in ext_attrs: |
| 985 set_return_value = 'DartUtilities::setDartStringReturnValueWithNullChe ck(args, %s)' % (value_expression) | 990 set_return_value = 'DartUtilities::setDartStringReturnValueWithNullChe ck(args, %s)' % (value_expression) |
| 986 else: | 991 else: |
| 987 set_return_value = 'DartUtilities::setDartStringReturnValue(args, %s)' % (value_expression) | 992 set_return_value = 'DartUtilities::setDartStringReturnValue(args, %s)' % (value_expression) |
| 988 else: | 993 else: |
| 989 to_dart_conversion = return_type_info.to_dart_conversion(value_expressio n, self._interface.id, ext_attrs) | 994 to_dart_conversion = return_type_info.to_dart_conversion(value_expressio n, self._interface.id, ext_attrs) |
| 990 set_return_value = 'Dart_SetReturnValue(args, %s)' % (to_dart_conversion ) | 995 set_return_value = 'Dart_SetReturnValue(args, %s)' % (to_dart_conversion ) |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1125 ' if (Dart_NativeFunction func = $CLASS_NAME::resolver(name, argu mentCount))\n' | 1130 ' if (Dart_NativeFunction func = $CLASS_NAME::resolver(name, argu mentCount))\n' |
| 1126 ' return func;\n', | 1131 ' return func;\n', |
| 1127 CLASS_NAME=os.path.splitext(os.path.basename(path))[0]) | 1132 CLASS_NAME=os.path.splitext(os.path.basename(path))[0]) |
| 1128 | 1133 |
| 1129 def _IsOptionalStringArgumentInInitEventMethod(interface, operation, argument): | 1134 def _IsOptionalStringArgumentInInitEventMethod(interface, operation, argument): |
| 1130 return ( | 1135 return ( |
| 1131 interface.id.endswith('Event') and | 1136 interface.id.endswith('Event') and |
| 1132 operation.id.startswith('init') and | 1137 operation.id.startswith('init') and |
| 1133 argument.ext_attrs.get('Default') == 'Undefined' and | 1138 argument.ext_attrs.get('Default') == 'Undefined' and |
| 1134 argument.type.id == 'DOMString') | 1139 argument.type.id == 'DOMString') |
| OLD | NEW |