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

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

Issue 386963003: [WIP][NotForLand] IDL dictionary support (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 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
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 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 for argument in self.arguments: 199 for argument in self.arguments:
200 argument.resolve_typedefs(typedefs) 200 argument.resolve_typedefs(typedefs)
201 201
202 202
203 ################################################################################ 203 ################################################################################
204 # Dictionary 204 # Dictionary
205 ################################################################################ 205 ################################################################################
206 206
207 class IdlDictionary(object): 207 class IdlDictionary(object):
208 def __init__(self, node): 208 def __init__(self, node):
209 self.parent = None 209 self.extended_attributes = {}
210 self.is_partial = node.GetProperty('Partial') or False
210 self.name = node.GetName() 211 self.name = node.GetName()
211 self.members = [] 212 self.members = []
213 self.parent = None
212 for child in node.GetChildren(): 214 for child in node.GetChildren():
213 child_class = child.GetClass() 215 child_class = child.GetClass()
214 if child_class == 'Inherit': 216 if child_class == 'Inherit':
215 self.parent = child.GetName() 217 self.parent = child.GetName()
216 elif child_class == 'Key': 218 elif child_class == 'Key':
217 self.members.append(IdlDictionaryMember(child)) 219 self.members.append(IdlDictionaryMember(child))
220 elif child_class == 'ExtAttributes':
221 self.extended_attributes = ext_attributes_node_to_extended_attri butes(child)
218 else: 222 else:
219 raise ValueError('Unrecognized node class: %s' % child_class) 223 raise ValueError('Unrecognized node class: %s' % child_class)
220 224
221 225
222 class IdlDictionaryMember(object): 226 class IdlDictionaryMember(object):
223 def __init__(self, node): 227 def __init__(self, node):
224 self.default_value = None 228 self.default_value = None
225 self.extended_attributes = {} 229 self.extended_attributes = {}
226 self.idl_type = None 230 self.idl_type = None
227 self.name = node.GetName() 231 self.name = node.GetName()
228 for child in node.GetChildren(): 232 for child in node.GetChildren():
229 child_class = child.GetClass() 233 child_class = child.GetClass()
230 if child_class == 'Type': 234 if child_class == 'Type':
231 self.idl_type = type_node_to_type(child) 235 self.idl_type = type_node_to_type(child)
232 elif child_class == 'Default': 236 elif child_class == 'Default':
233 self.default_value = child.GetProperty('VALUE') 237 self.default_value = default_node_to_idl_literal(child)
234 elif child_class == 'ExtAttributes': 238 elif child_class == 'ExtAttributes':
235 self.extended_attributes = ext_attributes_node_to_extended_attri butes(child) 239 self.extended_attributes = ext_attributes_node_to_extended_attri butes(child)
236 else: 240 else:
237 raise ValueError('Unrecognized node class: %s' % child_class) 241 raise ValueError('Unrecognized node class: %s' % child_class)
238 242
239 243
240 ################################################################################ 244 ################################################################################
241 # Enumerations 245 # Enumerations
242 ################################################################################ 246 ################################################################################
243 247
(...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after
798 child_class = child.GetClass() 802 child_class = child.GetClass()
799 if child_class != 'Type': 803 if child_class != 'Type':
800 raise ValueError('Unrecognized node class: %s' % child_class) 804 raise ValueError('Unrecognized node class: %s' % child_class)
801 return type_node_to_type(child) 805 return type_node_to_type(child)
802 806
803 807
804 def union_type_node_to_idl_union_type(node, is_nullable=False): 808 def union_type_node_to_idl_union_type(node, is_nullable=False):
805 member_types = [type_node_to_type(member_type_node) 809 member_types = [type_node_to_type(member_type_node)
806 for member_type_node in node.GetChildren()] 810 for member_type_node in node.GetChildren()]
807 return IdlUnionType(member_types, is_nullable=is_nullable) 811 return IdlUnionType(member_types, is_nullable=is_nullable)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698