OLD | NEW |
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 Loading... |
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 = ( |
| 222 ext_attributes_node_to_extended_attributes(child)) |
218 else: | 223 else: |
219 raise ValueError('Unrecognized node class: %s' % child_class) | 224 raise ValueError('Unrecognized node class: %s' % child_class) |
220 | 225 |
221 | 226 |
222 class IdlDictionaryMember(object): | 227 class IdlDictionaryMember(object): |
223 def __init__(self, node): | 228 def __init__(self, node): |
224 self.default_value = None | 229 self.default_value = None |
225 self.extended_attributes = {} | 230 self.extended_attributes = {} |
226 self.idl_type = None | 231 self.idl_type = None |
227 self.name = node.GetName() | 232 self.name = node.GetName() |
228 for child in node.GetChildren(): | 233 for child in node.GetChildren(): |
229 child_class = child.GetClass() | 234 child_class = child.GetClass() |
230 if child_class == 'Type': | 235 if child_class == 'Type': |
231 self.idl_type = type_node_to_type(child) | 236 self.idl_type = type_node_to_type(child) |
232 elif child_class == 'Default': | 237 elif child_class == 'Default': |
233 self.default_value = child.GetProperty('VALUE') | 238 self.default_value = default_node_to_idl_literal(child) |
234 elif child_class == 'ExtAttributes': | 239 elif child_class == 'ExtAttributes': |
235 self.extended_attributes = ext_attributes_node_to_extended_attri
butes(child) | 240 self.extended_attributes = ( |
| 241 ext_attributes_node_to_extended_attributes(child)) |
236 else: | 242 else: |
237 raise ValueError('Unrecognized node class: %s' % child_class) | 243 raise ValueError('Unrecognized node class: %s' % child_class) |
238 | 244 |
239 | 245 |
240 ################################################################################ | 246 ################################################################################ |
241 # Enumerations | 247 # Enumerations |
242 ################################################################################ | 248 ################################################################################ |
243 | 249 |
244 class IdlEnum(object): | 250 class IdlEnum(object): |
245 # FIXME: remove, just treat enums as a dictionary | 251 # FIXME: remove, just treat enums as a dictionary |
(...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
798 child_class = child.GetClass() | 804 child_class = child.GetClass() |
799 if child_class != 'Type': | 805 if child_class != 'Type': |
800 raise ValueError('Unrecognized node class: %s' % child_class) | 806 raise ValueError('Unrecognized node class: %s' % child_class) |
801 return type_node_to_type(child) | 807 return type_node_to_type(child) |
802 | 808 |
803 | 809 |
804 def union_type_node_to_idl_union_type(node, is_nullable=False): | 810 def union_type_node_to_idl_union_type(node, is_nullable=False): |
805 member_types = [type_node_to_type(member_type_node) | 811 member_types = [type_node_to_type(member_type_node) |
806 for member_type_node in node.GetChildren()] | 812 for member_type_node in node.GetChildren()] |
807 return IdlUnionType(member_types, is_nullable=is_nullable) | 813 return IdlUnionType(member_types, is_nullable=is_nullable) |
OLD | NEW |