| 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 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 417 | 417 |
| 418 function_expression = self._GenerateWebCoreFunctionExpression(webcore_functi
on_name, attr) | 418 function_expression = self._GenerateWebCoreFunctionExpression(webcore_functi
on_name, attr) |
| 419 self._GenerateNativeCallback( | 419 self._GenerateNativeCallback( |
| 420 cpp_callback_name, | 420 cpp_callback_name, |
| 421 True, | 421 True, |
| 422 function_expression, | 422 function_expression, |
| 423 attr, | 423 attr, |
| 424 [], | 424 [], |
| 425 attr.type.id, | 425 attr.type.id, |
| 426 attr.type.nullable, | 426 attr.type.nullable, |
| 427 'GetterRaisesException' in attr.ext_attrs) | 427 'GetterRaisesException' in attr.ext_attrs or 'RaisesException' in attr.e
xt_attrs) |
| 428 | 428 |
| 429 def _AddSetter(self, attr, html_name): | 429 def _AddSetter(self, attr, html_name): |
| 430 type_info = self._TypeInfo(attr.type.id) | 430 type_info = self._TypeInfo(attr.type.id) |
| 431 dart_declaration = 'void set %s(%s value)' % (html_name, self._DartType(attr
.type.id)) | 431 dart_declaration = 'void set %s(%s value)' % (html_name, self._DartType(attr
.type.id)) |
| 432 is_custom = set(['Custom', 'CustomSetter', 'V8CustomSetter']) & set(attr.ext
_attrs) | 432 is_custom = set(['Custom', 'CustomSetter', 'V8CustomSetter']) & set(attr.ext
_attrs) |
| 433 cpp_callback_name = self._GenerateNativeBinding(attr.id, 2, | 433 cpp_callback_name = self._GenerateNativeBinding(attr.id, 2, |
| 434 dart_declaration, 'Setter', is_custom) | 434 dart_declaration, 'Setter', is_custom) |
| 435 if is_custom: | 435 if is_custom: |
| 436 return | 436 return |
| 437 | 437 |
| (...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 932 namespace = 'SVGNames' | 932 namespace = 'SVGNames' |
| 933 self._cpp_impl_includes.add('"%s.h"' % namespace) | 933 self._cpp_impl_includes.add('"%s.h"' % namespace) |
| 934 | 934 |
| 935 attribute_name = attr.ext_attrs['Reflect'] or attr.id.lower() | 935 attribute_name = attr.ext_attrs['Reflect'] or attr.id.lower() |
| 936 return 'WebCore::%s::%sAttr' % (namespace, attribute_name) | 936 return 'WebCore::%s::%sAttr' % (namespace, attribute_name) |
| 937 | 937 |
| 938 def _GenerateWebCoreFunctionExpression(self, function_name, idl_node): | 938 def _GenerateWebCoreFunctionExpression(self, function_name, idl_node): |
| 939 if 'ImplementedBy' in idl_node.ext_attrs: | 939 if 'ImplementedBy' in idl_node.ext_attrs: |
| 940 return '%s::%s' % (idl_node.ext_attrs['ImplementedBy'], function_name) | 940 return '%s::%s' % (idl_node.ext_attrs['ImplementedBy'], function_name) |
| 941 if idl_node.is_static: | 941 if idl_node.is_static: |
| 942 return '%s::%s' % (self._interface_type_info.idl_type(), function_name) | 942 return '%s::%s' % (self._interface_type_info.native_type(), function_name) |
| 943 interface_name = self._interface_type_info.idl_type() | 943 interface_name = self._interface_type_info.idl_type() |
| 944 cpp_type_name = _GetCPPTypeName(interface_name, function_name) | 944 cpp_type_name = _GetCPPTypeName(interface_name, function_name) |
| 945 if cpp_type_name == interface_name: | 945 if cpp_type_name == interface_name: |
| 946 return '%s%s' % (self._interface_type_info.receiver(), function_name) | 946 return '%s%s' % (self._interface_type_info.receiver(), function_name) |
| 947 else: | 947 else: |
| 948 return '%s::%s' % (cpp_type_name, function_name) | 948 return '%s::%s' % (cpp_type_name, function_name) |
| 949 | 949 |
| 950 def _IsArgumentOptionalInWebCore(self, operation, argument): | 950 def _IsArgumentOptionalInWebCore(self, operation, argument): |
| 951 if not IsOptional(argument): | 951 if not IsOptional(argument): |
| 952 return False | 952 return False |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1021 ' if (Dart_NativeFunction func = $CLASS_NAME::resolver(name, argu
mentCount))\n' | 1021 ' if (Dart_NativeFunction func = $CLASS_NAME::resolver(name, argu
mentCount))\n' |
| 1022 ' return func;\n', | 1022 ' return func;\n', |
| 1023 CLASS_NAME=os.path.splitext(os.path.basename(path))[0]) | 1023 CLASS_NAME=os.path.splitext(os.path.basename(path))[0]) |
| 1024 | 1024 |
| 1025 def _IsOptionalStringArgumentInInitEventMethod(interface, operation, argument): | 1025 def _IsOptionalStringArgumentInInitEventMethod(interface, operation, argument): |
| 1026 return ( | 1026 return ( |
| 1027 interface.id.endswith('Event') and | 1027 interface.id.endswith('Event') and |
| 1028 operation.id.startswith('init') and | 1028 operation.id.startswith('init') and |
| 1029 argument.ext_attrs.get('Default') == 'Undefined' and | 1029 argument.ext_attrs.get('Default') == 'Undefined' and |
| 1030 argument.type.id == 'DOMString') | 1030 argument.type.id == 'DOMString') |
| OLD | NEW |