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

Side by Side Diff: client/dom/scripts/systemhtml.py

Issue 9662010: Don't put private members in dart:html interfaces. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Code review changes Created 8 years, 9 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 | client/dom/templates/html/impl/impl_Element.darttemplate » ('j') | 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 system to generate 6 """This module provides shared functionality for the system to generate
7 Dart:html APIs from the IDL database.""" 7 Dart:html APIs from the IDL database."""
8 8
9 from systemfrog import * 9 from systemfrog import *
10 from systeminterface import * 10 from systeminterface import *
(...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after
513 # generate if it should. 513 # generate if it should.
514 def GetEventAttributes(self, interface): 514 def GetEventAttributes(self, interface):
515 events = set([attr for attr in interface.attributes 515 events = set([attr for attr in interface.attributes
516 if self._generator._IsEventAttribute(interface, attr)]) 516 if self._generator._IsEventAttribute(interface, attr)])
517 517
518 if events or interface.id in _html_explicit_event_classes: 518 if events or interface.id in _html_explicit_event_classes:
519 return True, events 519 return True, events
520 else: 520 else:
521 return False, None 521 return False, None
522 522
523 def IsPrivate(self, name):
524 return name.startswith('_')
525
523 class HtmlSystem(System): 526 class HtmlSystem(System):
524 527
525 def __init__(self, templates, database, emitters, output_dir, generator): 528 def __init__(self, templates, database, emitters, output_dir, generator):
526 super(HtmlSystem, self).__init__( 529 super(HtmlSystem, self).__init__(
527 templates, database, emitters, output_dir) 530 templates, database, emitters, output_dir)
528 self._shared = HtmlSystemShared(database, generator) 531 self._shared = HtmlSystemShared(database, generator)
529 532
530 class HtmlInterfacesSystem(HtmlSystem): 533 class HtmlInterfacesSystem(HtmlSystem):
531 534
532 def __init__(self, templates, database, emitters, output_dir, generator): 535 def __init__(self, templates, database, emitters, output_dir, generator):
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
659 self.AddEventAttributes(events) 662 self.AddEventAttributes(events)
660 else: 663 else:
661 self._EmitEventGetter(self._shared.GetParentEventsClass(self._interface)) 664 self._EmitEventGetter(self._shared.GetParentEventsClass(self._interface))
662 665
663 def AddAttribute(self, getter, setter): 666 def AddAttribute(self, getter, setter):
664 html_getter_name = self._shared.RenameInHtmlLibrary( 667 html_getter_name = self._shared.RenameInHtmlLibrary(
665 self._interface, getter.id, 'get:') 668 self._interface, getter.id, 'get:')
666 html_setter_name = self._shared.RenameInHtmlLibrary( 669 html_setter_name = self._shared.RenameInHtmlLibrary(
667 self._interface, getter.id, 'set:') 670 self._interface, getter.id, 'set:')
668 671
669 if not html_getter_name: 672 if not html_getter_name or self._shared.IsPrivate(html_getter_name):
670 getter = None 673 getter = None
671 if not html_setter_name: 674 if not html_setter_name or self._shared.IsPrivate(html_setter_name):
672 setter = None 675 setter = None
673 if not getter and not setter: 676 if not getter and not setter:
674 return 677 return
675 678
676 # We don't yet handle inconsistent renames of the getter and setter yet. 679 # We don't yet handle inconsistent renames of the getter and setter yet.
677 if html_getter_name and html_setter_name: 680 if html_getter_name and html_setter_name:
678 assert html_getter_name == html_setter_name 681 assert html_getter_name == html_setter_name
679 if (getter and setter and 682 if (getter and setter and
680 DartType(getter.type.id) == DartType(setter.type.id)): 683 DartType(getter.type.id) == DartType(setter.type.id)):
681 self._members_emitter.Emit('\n $TYPE $NAME;\n', 684 self._members_emitter.Emit('\n $TYPE $NAME;\n',
682 NAME=html_getter_name, 685 NAME=html_getter_name,
683 TYPE=DartType(getter.type.id)); 686 TYPE=DartType(getter.type.id));
684 return 687 return
685 if getter and not setter: 688 if getter and not setter:
686 self._members_emitter.Emit('\n final $TYPE $NAME;\n', 689 self._members_emitter.Emit('\n final $TYPE $NAME;\n',
687 NAME=html_getter_name, 690 NAME=html_getter_name,
688 TYPE=DartType(getter.type.id)); 691 TYPE=DartType(getter.type.id));
689 return 692 return
690 raise Exception('Unexpected getter/setter combination %s %s' % 693 raise Exception('Unexpected getter/setter combination %s %s' %
691 (getter, setter)) 694 (getter, setter))
692 695
693 def AddOperation(self, info): 696 def AddOperation(self, info):
694 """ 697 """
695 Arguments: 698 Arguments:
696 operations - contains the overloads, one or more operations with the same 699 operations - contains the overloads, one or more operations with the same
697 name. 700 name.
698 """ 701 """
699 html_name = self._shared.RenameInHtmlLibrary(self._interface, info.name) 702 html_name = self._shared.RenameInHtmlLibrary(self._interface, info.name)
700 if html_name: 703 if html_name and not self._shared.IsPrivate(html_name):
701 self._members_emitter.Emit('\n' 704 self._members_emitter.Emit('\n'
702 ' $TYPE $NAME($PARAMS);\n', 705 ' $TYPE $NAME($PARAMS);\n',
703 TYPE=info.type_name, 706 TYPE=info.type_name,
704 NAME=html_name, 707 NAME=html_name,
705 PARAMS=info.ParametersInterfaceDeclaration()) 708 PARAMS=info.ParametersInterfaceDeclaration())
706 709
707 def FinishInterface(self): 710 def FinishInterface(self):
708 pass 711 pass
709 712
710 def AddConstant(self, constant): 713 def AddConstant(self, constant):
(...skipping 1056 matching lines...) Expand 10 before | Expand all | Expand 10 after
1767 # dispatch has removed f(X), leaving only f(Y), but there is no guarantee 1770 # dispatch has removed f(X), leaving only f(Y), but there is no guarantee
1768 # that Y = Z-X, so we need to check for Y. 1771 # that Y = Z-X, so we need to check for Y.
1769 true_code = emitter.Emit( 1772 true_code = emitter.Emit(
1770 '$(INDENT)if ($COND) {\n' 1773 '$(INDENT)if ($COND) {\n'
1771 '$!TRUE' 1774 '$!TRUE'
1772 '$(INDENT)}\n', 1775 '$(INDENT)}\n',
1773 COND=test, INDENT=indent) 1776 COND=test, INDENT=indent)
1774 self.GenerateDispatch( 1777 self.GenerateDispatch(
1775 true_code, info, indent + ' ', position + 1, positive) 1778 true_code, info, indent + ' ', position + 1, positive)
1776 return True 1779 return True
OLDNEW
« no previous file with comments | « no previous file | client/dom/templates/html/impl/impl_Element.darttemplate » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698