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

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

Issue 2290113002: Add extended attributes to IdlCallbackFunction (Closed)
Patch Set: Created 4 years, 3 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 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 166
167 167
168 ################################################################################ 168 ################################################################################
169 # Callback Functions 169 # Callback Functions
170 ################################################################################ 170 ################################################################################
171 171
172 class IdlCallbackFunction(TypedObject): 172 class IdlCallbackFunction(TypedObject):
173 def __init__(self, idl_name, node): 173 def __init__(self, idl_name, node):
174 children = node.GetChildren() 174 children = node.GetChildren()
175 num_children = len(children) 175 num_children = len(children)
176 if num_children != 2: 176 self.extended_attributes = {}
177 raise ValueError('Expected 2 children, got %s' % num_children) 177 if num_children == 2:
178 type_node, arguments_node = children 178 type_node, arguments_node = children
179 elif num_children == 3:
180 type_node, arguments_node, extended_attributes_node = children
181 self.extended_attributes = (
182 ext_attributes_node_to_extended_attributes(idl_name, extended_at tributes_node))
183 else:
184 raise ValueError('Expected 2 or 3 children, got %s' % num_children)
haraken 2016/08/30 05:27:57 I'd prefer the following pattern: if num_children
Yuki 2016/08/30 05:49:11 Lisa's code looks more Python's way than haraken's
lkawai 2016/08/30 05:57:01 Done.
lkawai 2016/08/30 05:57:01 Acknowledged.
179 arguments_node_class = arguments_node.GetClass() 185 arguments_node_class = arguments_node.GetClass()
180 if arguments_node_class != 'Arguments': 186 if arguments_node_class != 'Arguments':
181 raise ValueError('Expected Arguments node, got %s' % arguments_node_ class) 187 raise ValueError('Expected Arguments node, got %s' % arguments_node_ class)
182 188
183 self.idl_name = idl_name 189 self.idl_name = idl_name
184 self.name = node.GetName() 190 self.name = node.GetName()
185 self.idl_type = type_node_to_type(type_node) 191 self.idl_type = type_node_to_type(type_node)
186 self.arguments = arguments_node_to_arguments(idl_name, arguments_node) 192 self.arguments = arguments_node_to_arguments(idl_name, arguments_node)
187 193
188 def accept(self, visitor): 194 def accept(self, visitor):
(...skipping 930 matching lines...) Expand 10 before | Expand all | Expand 10 after
1119 self.visit_typed_object(argument) 1125 self.visit_typed_object(argument)
1120 1126
1121 def visit_iterable(self, iterable): 1127 def visit_iterable(self, iterable):
1122 self.visit_typed_object(iterable) 1128 self.visit_typed_object(iterable)
1123 1129
1124 def visit_maplike(self, maplike): 1130 def visit_maplike(self, maplike):
1125 self.visit_typed_object(maplike) 1131 self.visit_typed_object(maplike)
1126 1132
1127 def visit_setlike(self, setlike): 1133 def visit_setlike(self, setlike):
1128 self.visit_typed_object(setlike) 1134 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