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 487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
498 ################################################################################ | 498 ################################################################################ |
499 # Operations | 499 # Operations |
500 ################################################################################ | 500 ################################################################################ |
501 | 501 |
502 class IdlOperation(TypedObject): | 502 class IdlOperation(TypedObject): |
503 def __init__(self, idl_name, node=None): | 503 def __init__(self, idl_name, node=None): |
504 self.arguments = [] | 504 self.arguments = [] |
505 self.extended_attributes = {} | 505 self.extended_attributes = {} |
506 self.specials = [] | 506 self.specials = [] |
507 self.is_constructor = False | 507 self.is_constructor = False |
| 508 self.idl_name = idl_name |
| 509 self.is_static = False |
508 | 510 |
509 if not node: | 511 if not node: |
510 self.is_static = False | |
511 return | 512 return |
512 self.idl_name = idl_name | 513 |
513 self.name = node.GetName() # FIXME: should just be: or '' | 514 self.name = node.GetName() # FIXME: should just be: or '' |
514 # FIXME: AST should use None internally | 515 # FIXME: AST should use None internally |
515 if self.name == '_unnamed_': | 516 if self.name == '_unnamed_': |
516 self.name = '' | 517 self.name = '' |
517 | 518 |
518 self.is_static = bool(node.GetProperty('STATIC')) | 519 self.is_static = bool(node.GetProperty('STATIC')) |
519 property_dictionary = node.GetProperties() | 520 property_dictionary = node.GetProperties() |
520 for special_keyword in SPECIAL_KEYWORD_LIST: | 521 for special_keyword in SPECIAL_KEYWORD_LIST: |
521 if special_keyword in property_dictionary: | 522 if special_keyword in property_dictionary: |
522 self.specials.append(special_keyword.lower()) | 523 self.specials.append(special_keyword.lower()) |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
567 TypedObject.resolve_typedefs(self, typedefs) | 568 TypedObject.resolve_typedefs(self, typedefs) |
568 for argument in self.arguments: | 569 for argument in self.arguments: |
569 argument.resolve_typedefs(typedefs) | 570 argument.resolve_typedefs(typedefs) |
570 | 571 |
571 | 572 |
572 ################################################################################ | 573 ################################################################################ |
573 # Arguments | 574 # Arguments |
574 ################################################################################ | 575 ################################################################################ |
575 | 576 |
576 class IdlArgument(TypedObject): | 577 class IdlArgument(TypedObject): |
577 def __init__(self, idl_name, node): | 578 def __init__(self, idl_name, node=None): |
578 self.extended_attributes = {} | 579 self.extended_attributes = {} |
579 self.idl_type = None | 580 self.idl_type = None |
580 self.is_optional = node.GetProperty('OPTIONAL') # syntax: (optional T) | 581 self.is_optional = False # syntax: (optional T) |
581 self.is_variadic = False # syntax: (T...) | 582 self.is_variadic = False # syntax: (T...) |
582 self.idl_name = idl_name | 583 self.idl_name = idl_name |
| 584 self.default_value = None |
| 585 |
| 586 if not node: |
| 587 return |
| 588 |
| 589 self.is_optional = node.GetProperty('OPTIONAL') |
583 self.name = node.GetName() | 590 self.name = node.GetName() |
584 self.default_value = None | |
585 | 591 |
586 children = node.GetChildren() | 592 children = node.GetChildren() |
587 for child in children: | 593 for child in children: |
588 child_class = child.GetClass() | 594 child_class = child.GetClass() |
589 if child_class == 'Type': | 595 if child_class == 'Type': |
590 self.idl_type = type_node_to_type(child) | 596 self.idl_type = type_node_to_type(child) |
591 elif child_class == 'ExtAttributes': | 597 elif child_class == 'ExtAttributes': |
592 self.extended_attributes = ext_attributes_node_to_extended_attri
butes(idl_name, child) | 598 self.extended_attributes = ext_attributes_node_to_extended_attri
butes(idl_name, child) |
593 elif child_class == 'Argument': | 599 elif child_class == 'Argument': |
594 child_name = child.GetName() | 600 child_name = child.GetName() |
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
936 child_class = child.GetClass() | 942 child_class = child.GetClass() |
937 if child_class != 'Type': | 943 if child_class != 'Type': |
938 raise ValueError('Unrecognized node class: %s' % child_class) | 944 raise ValueError('Unrecognized node class: %s' % child_class) |
939 return type_node_to_type(child) | 945 return type_node_to_type(child) |
940 | 946 |
941 | 947 |
942 def union_type_node_to_idl_union_type(node): | 948 def union_type_node_to_idl_union_type(node): |
943 member_types = [type_node_to_type(member_type_node) | 949 member_types = [type_node_to_type(member_type_node) |
944 for member_type_node in node.GetChildren()] | 950 for member_type_node in node.GetChildren()] |
945 return IdlUnionType(member_types) | 951 return IdlUnionType(member_types) |
OLD | NEW |