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

Side by Side Diff: third_party/WebKit/Source/bindings/scripts/idl_definitions.py

Issue 2130223002: IDL: traverse enums and implements (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
« no previous file with comments | « no previous file | 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 # Copyright (C) 2013 Google Inc. All rights reserved. 1 # Copyright (C) 2013 Google Inc. All rights reserved.
2 # 2 #
3 # Redistribution and use in source and binary forms, with or without 3 # Redistribution and use in source and binary forms, with or without
4 # modification, are permitted provided that the following conditions are 4 # modification, are permitted provided that the following conditions are
5 # met: 5 # met:
6 # 6 #
7 # * Redistributions of source code must retain the above copyright 7 # * Redistributions of source code must retain the above copyright
8 # notice, this list of conditions and the following disclaimer. 8 # notice, this list of conditions and the following disclaimer.
9 # * Redistributions in binary form must reproduce the above 9 # * Redistributions in binary form must reproduce the above
10 # copyright notice, this list of conditions and the following disclaimer 10 # copyright notice, this list of conditions and the following disclaimer
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 raise ValueError('Unrecognized node class: %s' % child_class) 130 raise ValueError('Unrecognized node class: %s' % child_class)
131 131
132 def accept(self, visitor): 132 def accept(self, visitor):
133 visitor.visit_definitions(self) 133 visitor.visit_definitions(self)
134 for interface in self.interfaces.itervalues(): 134 for interface in self.interfaces.itervalues():
135 interface.accept(visitor) 135 interface.accept(visitor)
136 for callback_function in self.callback_functions.itervalues(): 136 for callback_function in self.callback_functions.itervalues():
137 callback_function.accept(visitor) 137 callback_function.accept(visitor)
138 for dictionary in self.dictionaries.itervalues(): 138 for dictionary in self.dictionaries.itervalues():
139 dictionary.accept(visitor) 139 dictionary.accept(visitor)
140 for enumeration in self.enumerations.itervalues():
141 enumeration.accept(visitor)
142 for implement in self.implements:
143 implement.accept(visitor)
140 for typedef in self.typedefs.itervalues(): 144 for typedef in self.typedefs.itervalues():
141 typedef.accept(visitor) 145 typedef.accept(visitor)
142 146
143 def update(self, other): 147 def update(self, other):
144 """Update with additional IdlDefinitions.""" 148 """Update with additional IdlDefinitions."""
145 for interface_name, new_interface in other.interfaces.iteritems(): 149 for interface_name, new_interface in other.interfaces.iteritems():
146 if not new_interface.is_partial: 150 if not new_interface.is_partial:
147 # Add as new interface 151 # Add as new interface
148 self.interfaces[interface_name] = new_interface 152 self.interfaces[interface_name] = new_interface
149 continue 153 continue
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 251
248 class IdlEnum(object): 252 class IdlEnum(object):
249 # FIXME: remove, just treat enums as a dictionary 253 # FIXME: remove, just treat enums as a dictionary
250 def __init__(self, idl_name, node): 254 def __init__(self, idl_name, node):
251 self.idl_name = idl_name 255 self.idl_name = idl_name
252 self.name = node.GetName() 256 self.name = node.GetName()
253 self.values = [] 257 self.values = []
254 for child in node.GetChildren(): 258 for child in node.GetChildren():
255 self.values.append(child.GetName()) 259 self.values.append(child.GetName())
256 260
261 def accept(self, visitor):
262 visitor.visit_enumeration(self)
263
257 264
258 ################################################################################ 265 ################################################################################
259 # Typedefs 266 # Typedefs
260 ################################################################################ 267 ################################################################################
261 268
262 class IdlTypedef(object): 269 class IdlTypedef(object):
263 idl_type_attributes = ('idl_type',) 270 idl_type_attributes = ('idl_type',)
264 271
265 def __init__(self, node): 272 def __init__(self, node):
266 self.name = node.GetName() 273 self.name = node.GetName()
(...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after
830 837
831 ################################################################################ 838 ################################################################################
832 # Implement statements 839 # Implement statements
833 ################################################################################ 840 ################################################################################
834 841
835 class IdlImplement(object): 842 class IdlImplement(object):
836 def __init__(self, node): 843 def __init__(self, node):
837 self.left_interface = node.GetName() 844 self.left_interface = node.GetName()
838 self.right_interface = node.GetProperty('REFERENCE') 845 self.right_interface = node.GetProperty('REFERENCE')
839 846
847 def accept(self, visitor):
848 visitor.visit_implement(self)
849
840 850
841 ################################################################################ 851 ################################################################################
842 # Extended attributes 852 # Extended attributes
843 ################################################################################ 853 ################################################################################
844 854
845 class Exposure: 855 class Exposure:
846 """An Exposure holds one Exposed or RuntimeEnabled condition. 856 """An Exposure holds one Exposed or RuntimeEnabled condition.
847 Each exposure has two properties: exposed and runtime_enabled. 857 Each exposure has two properties: exposed and runtime_enabled.
848 Exposure(e, r) corresponds to [Exposed(e r)]. Exposure(e) corresponds to 858 Exposure(e, r) corresponds to [Exposed(e r)]. Exposure(e) corresponds to
849 [Exposed=e]. 859 [Exposed=e].
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
1085 1095
1086 def visit_callback_function(self, callback_function): 1096 def visit_callback_function(self, callback_function):
1087 self.visit_typed_object(callback_function) 1097 self.visit_typed_object(callback_function)
1088 1098
1089 def visit_dictionary(self, dictionary): 1099 def visit_dictionary(self, dictionary):
1090 pass 1100 pass
1091 1101
1092 def visit_dictionary_member(self, member): 1102 def visit_dictionary_member(self, member):
1093 self.visit_typed_object(member) 1103 self.visit_typed_object(member)
1094 1104
1105 def visit_enumeration(self, enumeration):
1106 pass
1107
1108 def visit_implement(self, implement):
1109 pass
1110
1095 def visit_interface(self, interface): 1111 def visit_interface(self, interface):
1096 pass 1112 pass
1097 1113
1098 def visit_typedef(self, typedef): 1114 def visit_typedef(self, typedef):
1099 self.visit_typed_object(typedef) 1115 self.visit_typed_object(typedef)
1100 1116
1101 def visit_attribute(self, attribute): 1117 def visit_attribute(self, attribute):
1102 self.visit_typed_object(attribute) 1118 self.visit_typed_object(attribute)
1103 1119
1104 def visit_constant(self, constant): 1120 def visit_constant(self, constant):
1105 self.visit_typed_object(constant) 1121 self.visit_typed_object(constant)
1106 1122
1107 def visit_operation(self, operation): 1123 def visit_operation(self, operation):
1108 self.visit_typed_object(operation) 1124 self.visit_typed_object(operation)
1109 1125
1110 def visit_argument(self, argument): 1126 def visit_argument(self, argument):
1111 self.visit_typed_object(argument) 1127 self.visit_typed_object(argument)
1112 1128
1113 def visit_iterable(self, iterable): 1129 def visit_iterable(self, iterable):
1114 self.visit_typed_object(iterable) 1130 self.visit_typed_object(iterable)
1115 1131
1116 def visit_maplike(self, maplike): 1132 def visit_maplike(self, maplike):
1117 self.visit_typed_object(maplike) 1133 self.visit_typed_object(maplike)
1118 1134
1119 def visit_setlike(self, setlike): 1135 def visit_setlike(self, setlike):
1120 self.visit_typed_object(setlike) 1136 self.visit_typed_object(setlike)
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698