| 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 451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 462 ' goto fail;\n' | 462 ' goto fail;\n' |
| 463 ' RefPtr<ScriptCallStack> scriptCallStack(DartUtilities::create
ScriptCallStack());\n' | 463 ' RefPtr<ScriptCallStack> scriptCallStack(DartUtilities::create
ScriptCallStack());\n' |
| 464 ' if (!scriptCallStack->size())\n' | 464 ' if (!scriptCallStack->size())\n' |
| 465 ' return;\n', | 465 ' return;\n', |
| 466 INDEX=len(node.arguments)) | 466 INDEX=len(node.arguments)) |
| 467 arguments.extend(['scriptArguments', 'scriptCallStack']) | 467 arguments.extend(['scriptArguments', 'scriptCallStack']) |
| 468 return True | 468 return True |
| 469 | 469 |
| 470 return False | 470 return False |
| 471 | 471 |
| 472 def AddAttribute(self, attribute): | 472 def AddAttribute(self, attribute, html_name, read_only): |
| 473 getter = attribute | 473 if 'CheckSecurityForNode' in attribute.ext_attrs: |
| 474 setter = attribute if not systembase.IsReadOnly(attribute) else None | |
| 475 if 'CheckSecurityForNode' in (getter or setter).ext_attrs: | |
| 476 # FIXME: exclude from interface as well. | 474 # FIXME: exclude from interface as well. |
| 477 return | 475 return |
| 478 | 476 |
| 479 dom_name = DartDomNameOfAttribute(getter or setter) | 477 self._AddGetter(attribute, html_name) |
| 480 html_getter_name = self._html_system.RenameInHtmlLibrary( | 478 if not read_only: |
| 481 self._interface.id, dom_name, 'get:', implementation_class=True) | 479 self._AddSetter(attribute, html_name) |
| 482 html_setter_name = self._html_system.RenameInHtmlLibrary( | |
| 483 self._interface.id, dom_name, 'set:', implementation_class=True) | |
| 484 | |
| 485 if getter and html_getter_name: | |
| 486 self._AddGetter(getter, html_getter_name) | |
| 487 if setter and html_setter_name: | |
| 488 self._AddSetter(setter, html_setter_name) | |
| 489 | |
| 490 def AddSecondaryAttribute(self, interface, attribute): | |
| 491 self.AddAttribute(attribute) | |
| 492 | 480 |
| 493 def _AddGetter(self, attr, html_name): | 481 def _AddGetter(self, attr, html_name): |
| 494 type_info = GetIDLTypeInfo(attr.type.id) | 482 type_info = GetIDLTypeInfo(attr.type.id) |
| 495 dart_declaration = '%s get %s()' % (self._DartType(attr.type.id), html_name) | 483 dart_declaration = '%s get %s()' % (self._DartType(attr.type.id), html_name) |
| 496 is_custom = 'Custom' in attr.ext_attrs or 'CustomGetter' in attr.ext_attrs | 484 is_custom = 'Custom' in attr.ext_attrs or 'CustomGetter' in attr.ext_attrs |
| 497 cpp_callback_name = self._GenerateNativeBinding(attr.id, 1, | 485 cpp_callback_name = self._GenerateNativeBinding(attr.id, 1, |
| 498 dart_declaration, 'Getter', is_custom) | 486 dart_declaration, 'Getter', is_custom) |
| 499 if is_custom: | 487 if is_custom: |
| 500 return | 488 return |
| 501 | 489 |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 758 check = '%s === _null' % argument_names[position] | 746 check = '%s === _null' % argument_names[position] |
| 759 GenerateCall(operation, position, [check]) | 747 GenerateCall(operation, position, [check]) |
| 760 GenerateCall(operation, len(operation.arguments), []) | 748 GenerateCall(operation, len(operation.arguments), []) |
| 761 | 749 |
| 762 def AddOperation(self, info): | 750 def AddOperation(self, info): |
| 763 self._AddOperation(info) | 751 self._AddOperation(info) |
| 764 | 752 |
| 765 def AddStaticOperation(self, info): | 753 def AddStaticOperation(self, info): |
| 766 self._AddOperation(info) | 754 self._AddOperation(info) |
| 767 | 755 |
| 768 def AddSecondaryOperation(self, interface, info): | 756 def SecondaryContext(self, interface): |
| 769 self.AddOperation(info) | 757 pass |
| 770 | 758 |
| 771 def _GenerateOperationNativeCallback(self, operation, arguments, cpp_callback_
name): | 759 def _GenerateOperationNativeCallback(self, operation, arguments, cpp_callback_
name): |
| 772 webcore_function_name = operation.ext_attrs.get('ImplementedAs', operation.i
d) | 760 webcore_function_name = operation.ext_attrs.get('ImplementedAs', operation.i
d) |
| 773 | 761 |
| 774 parameter_definitions_emitter = emitter.Emitter() | 762 parameter_definitions_emitter = emitter.Emitter() |
| 775 cpp_arguments = [] | 763 cpp_arguments = [] |
| 776 raises_exceptions = self._GenerateCallWithHandling( | 764 raises_exceptions = self._GenerateCallWithHandling( |
| 777 operation, parameter_definitions_emitter, cpp_arguments) | 765 operation, parameter_definitions_emitter, cpp_arguments) |
| 778 raises_exceptions = raises_exceptions or len(arguments) > 0 or operation.rai
ses | 766 raises_exceptions = raises_exceptions or len(arguments) > 0 or operation.rai
ses |
| 779 | 767 |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 981 | 969 |
| 982 def _IsArgumentOptionalInWebCore(argument): | 970 def _IsArgumentOptionalInWebCore(argument): |
| 983 return IsOptional(argument) and not 'Callback' in argument.ext_attrs | 971 return IsOptional(argument) and not 'Callback' in argument.ext_attrs |
| 984 | 972 |
| 985 def _ToWebKitName(name): | 973 def _ToWebKitName(name): |
| 986 name = name[0].lower() + name[1:] | 974 name = name[0].lower() + name[1:] |
| 987 name = re.sub(r'^(hTML|uRL|jS|xML|xSLT)', lambda s: s.group(1).lower(), | 975 name = re.sub(r'^(hTML|uRL|jS|xML|xSLT)', lambda s: s.group(1).lower(), |
| 988 name) | 976 name) |
| 989 return re.sub(r'^(create|exclusive)', lambda s: 'is' + s.group(1).capitalize()
, | 977 return re.sub(r'^(create|exclusive)', lambda s: 'is' + s.group(1).capitalize()
, |
| 990 name) | 978 name) |
| OLD | NEW |