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

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

Issue 10704102: Cleanup attributes generation in dart:html. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 5 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
« lib/dom/scripts/systemhtml.py ('K') | « lib/dom/scripts/systemhtml.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 462 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 ' goto fail;\n' 473 ' goto fail;\n'
474 ' RefPtr<ScriptCallStack> scriptCallStack(DartUtilities::create ScriptCallStack());\n' 474 ' RefPtr<ScriptCallStack> scriptCallStack(DartUtilities::create ScriptCallStack());\n'
475 ' if (!scriptCallStack->size())\n' 475 ' if (!scriptCallStack->size())\n'
476 ' return;\n', 476 ' return;\n',
477 INDEX=len(node.arguments)) 477 INDEX=len(node.arguments))
478 arguments.extend(['scriptArguments', 'scriptCallStack']) 478 arguments.extend(['scriptArguments', 'scriptCallStack'])
479 return True 479 return True
480 480
481 return False 481 return False
482 482
483 def AddAttribute(self, attribute): 483 def AddAttribute(self, attribute, html_name, read_only):
484 getter = attribute 484 if 'CheckSecurityForNode' in attribute.ext_attrs:
485 setter = attribute if not systembase.IsReadOnly(attribute) else None
486 if 'CheckSecurityForNode' in (getter or setter).ext_attrs:
487 # FIXME: exclude from interface as well. 485 # FIXME: exclude from interface as well.
488 return 486 return
489 487
490 dom_name = DartDomNameOfAttribute(getter or setter) 488 self._AddGetter(attribute, html_name)
491 html_getter_name = self._html_system.RenameInHtmlLibrary( 489 if not read_only:
492 self._interface.id, dom_name, 'get:', implementation_class=True) 490 self._AddSetter(attribute, html_name)
493 html_setter_name = self._html_system.RenameInHtmlLibrary(
494 self._interface.id, dom_name, 'set:', implementation_class=True)
495
496 if getter and html_getter_name:
497 self._AddGetter(getter, html_getter_name)
498 if setter and html_setter_name:
499 self._AddSetter(setter, html_setter_name)
500
501 def AddSecondaryAttribute(self, interface, attribute):
502 self.AddAttribute(attribute)
503 491
504 def _AddGetter(self, attr, html_name): 492 def _AddGetter(self, attr, html_name):
505 type_info = GetIDLTypeInfo(attr.type.id) 493 type_info = GetIDLTypeInfo(attr.type.id)
506 dart_declaration = '%s get %s()' % (self._DartType(attr.type.id), html_name) 494 dart_declaration = '%s get %s()' % (self._DartType(attr.type.id), html_name)
507 is_custom = 'Custom' in attr.ext_attrs or 'CustomGetter' in attr.ext_attrs 495 is_custom = 'Custom' in attr.ext_attrs or 'CustomGetter' in attr.ext_attrs
508 cpp_callback_name = self._GenerateNativeBinding(attr.id, 1, 496 cpp_callback_name = self._GenerateNativeBinding(attr.id, 1,
509 dart_declaration, 'Getter', is_custom) 497 dart_declaration, 'Getter', is_custom)
510 if is_custom: 498 if is_custom:
511 return 499 return
512 500
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
769 check = '%s === _null' % argument_names[position] 757 check = '%s === _null' % argument_names[position]
770 GenerateCall(operation, position, [check]) 758 GenerateCall(operation, position, [check])
771 GenerateCall(operation, len(operation.arguments), []) 759 GenerateCall(operation, len(operation.arguments), [])
772 760
773 def AddOperation(self, info): 761 def AddOperation(self, info):
774 self._AddOperation(info) 762 self._AddOperation(info)
775 763
776 def AddStaticOperation(self, info): 764 def AddStaticOperation(self, info):
777 self._AddOperation(info) 765 self._AddOperation(info)
778 766
779 def AddSecondaryOperation(self, interface, info): 767 def SecondaryContext(self, interface):
780 self.AddOperation(info) 768 pass
781 769
782 def _GenerateOperationNativeCallback(self, operation, arguments, cpp_callback_ name): 770 def _GenerateOperationNativeCallback(self, operation, arguments, cpp_callback_ name):
783 webcore_function_name = operation.ext_attrs.get('ImplementedAs', operation.i d) 771 webcore_function_name = operation.ext_attrs.get('ImplementedAs', operation.i d)
784 772
785 parameter_definitions_emitter = emitter.Emitter() 773 parameter_definitions_emitter = emitter.Emitter()
786 cpp_arguments = [] 774 cpp_arguments = []
787 raises_exceptions = self._GenerateCallWithHandling( 775 raises_exceptions = self._GenerateCallWithHandling(
788 operation, parameter_definitions_emitter, cpp_arguments) 776 operation, parameter_definitions_emitter, cpp_arguments)
789 raises_exceptions = raises_exceptions or len(arguments) > 0 or operation.rai ses 777 raises_exceptions = raises_exceptions or len(arguments) > 0 or operation.rai ses
790 778
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
992 980
993 def _IsArgumentOptionalInWebCore(argument): 981 def _IsArgumentOptionalInWebCore(argument):
994 return IsOptional(argument) and not 'Callback' in argument.ext_attrs 982 return IsOptional(argument) and not 'Callback' in argument.ext_attrs
995 983
996 def _ToWebKitName(name): 984 def _ToWebKitName(name):
997 name = name[0].lower() + name[1:] 985 name = name[0].lower() + name[1:]
998 name = re.sub(r'^(hTML|uRL|jS|xML|xSLT)', lambda s: s.group(1).lower(), 986 name = re.sub(r'^(hTML|uRL|jS|xML|xSLT)', lambda s: s.group(1).lower(),
999 name) 987 name)
1000 return re.sub(r'^(create|exclusive)', lambda s: 'is' + s.group(1).capitalize() , 988 return re.sub(r'^(create|exclusive)', lambda s: 'is' + s.group(1).capitalize() ,
1001 name) 989 name)
OLDNEW
« lib/dom/scripts/systemhtml.py ('K') | « lib/dom/scripts/systemhtml.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698