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

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

Issue 789473002: Introduce [Exposed(Arguments)] in IDL code generator. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years 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 632 matching lines...) Expand 10 before | Expand all | Expand 10 after
643 class IdlImplement(object): 643 class IdlImplement(object):
644 def __init__(self, node): 644 def __init__(self, node):
645 self.left_interface = node.GetName() 645 self.left_interface = node.GetName()
646 self.right_interface = node.GetProperty('REFERENCE') 646 self.right_interface = node.GetProperty('REFERENCE')
647 647
648 648
649 ################################################################################ 649 ################################################################################
650 # Extended attributes 650 # Extended attributes
651 ################################################################################ 651 ################################################################################
652 652
653 class Exposure:
654 """An Exposure holds one Exposed or RuntimeEnabled condition.
655 Each exposure has two property: exposed and runtime_enabled. Exposure(e, r)
haraken 2014/12/09 16:07:55 property => properties
yhirano 2014/12/11 01:38:25 Done.
656 corresponds to [Exposed(e r)]. Exposure(e) corresponds to [Exposed=e].
haraken 2014/12/09 16:07:56 [Exposed(e r)] => [Exposed(e, r)] ?
Jens Widell 2014/12/09 16:19:23 The extended attribute syntax is [Exposed(e r)], o
yhirano 2014/12/11 01:38:25 It's like Exposed(Window GlobalFetch, ServiceWorke
657 """
658 def __init__(self, exposed, runtime_enabled=None):
659 self.exposed = exposed
660 self.runtime_enabled = runtime_enabled
661
662
653 def ext_attributes_node_to_extended_attributes(idl_name, node): 663 def ext_attributes_node_to_extended_attributes(idl_name, node):
654 """ 664 """
655 Returns: 665 Returns:
656 Dictionary of {ExtAttributeName: ExtAttributeValue}. 666 Dictionary of {ExtAttributeName: ExtAttributeValue}.
657 Value is usually a string, with these exceptions: 667 Value is usually a string, with these exceptions:
658 Constructors: value is a list of Arguments nodes, corresponding to 668 Constructors: value is a list of Arguments nodes, corresponding to
659 possible signatures of the constructor. 669 possible signatures of the constructor.
660 CustomConstructors: value is a list of Arguments nodes, corresponding to 670 CustomConstructors: value is a list of Arguments nodes, corresponding to
661 possible signatures of the custom constructor. 671 possible signatures of the custom constructor.
662 NamedConstructor: value is a Call node, corresponding to the single 672 NamedConstructor: value is a Call node, corresponding to the single
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
699 elif name == 'NamedConstructor': 709 elif name == 'NamedConstructor':
700 if child_class and child_class != 'Call': 710 if child_class and child_class != 'Call':
701 raise ValueError('[NamedConstructor] only supports Call as child , but has child of class: %s' % child_class) 711 raise ValueError('[NamedConstructor] only supports Call as child , but has child of class: %s' % child_class)
702 extended_attributes[name] = child 712 extended_attributes[name] = child
703 elif name == 'SetWrapperReferenceTo': 713 elif name == 'SetWrapperReferenceTo':
704 if not child: 714 if not child:
705 raise ValueError('[SetWrapperReferenceTo] requires a child, but has none.') 715 raise ValueError('[SetWrapperReferenceTo] requires a child, but has none.')
706 if child_class != 'Arguments': 716 if child_class != 'Arguments':
707 raise ValueError('[SetWrapperReferenceTo] only supports Argument s as child, but has child of class: %s' % child_class) 717 raise ValueError('[SetWrapperReferenceTo] only supports Argument s as child, but has child of class: %s' % child_class)
708 extended_attributes[name] = arguments_node_to_arguments(idl_name, ch ild) 718 extended_attributes[name] = arguments_node_to_arguments(idl_name, ch ild)
719 elif name == 'Exposed':
720 if child_class and child_class != 'Arguments':
721 raise ValueError('[Exposed] only supports Arguments as child, bu t has child of class: %s' % child_class)
722 exposures = []
723 if child_class == 'Arguments':
724 exposures = [Exposure(exposed=str(arg.idl_type),
725 runtime_enabled=arg.name)
726 for arg in arguments_node_to_arguments('*', child)]
727 else:
728 value = extended_attribute_node.GetProperty('VALUE')
729 if type(value) is str:
730 exposures = [Exposure(exposed=value)]
731 else:
732 exposures = [Exposure(exposed=v) for v in value]
733 extended_attributes[name] = exposures
709 elif child: 734 elif child:
710 raise ValueError('ExtAttributes node with unexpected children: %s' % name) 735 raise ValueError('ExtAttributes node with unexpected children: %s' % name)
711 else: 736 else:
712 value = extended_attribute_node.GetProperty('VALUE') 737 value = extended_attribute_node.GetProperty('VALUE')
713 extended_attributes[name] = value 738 extended_attributes[name] = value
714 739
715 # Store constructors and custom constructors in special list attributes, 740 # Store constructors and custom constructors in special list attributes,
716 # which are deleted later. Note plural in key. 741 # which are deleted later. Note plural in key.
717 if constructors: 742 if constructors:
718 extended_attributes['Constructors'] = constructors 743 extended_attributes['Constructors'] = constructors
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
834 child_class = child.GetClass() 859 child_class = child.GetClass()
835 if child_class != 'Type': 860 if child_class != 'Type':
836 raise ValueError('Unrecognized node class: %s' % child_class) 861 raise ValueError('Unrecognized node class: %s' % child_class)
837 return type_node_to_type(child) 862 return type_node_to_type(child)
838 863
839 864
840 def union_type_node_to_idl_union_type(node): 865 def union_type_node_to_idl_union_type(node):
841 member_types = [type_node_to_type(member_type_node) 866 member_types = [type_node_to_type(member_type_node)
842 for member_type_node in node.GetChildren()] 867 for member_type_node in node.GetChildren()]
843 return IdlUnionType(member_types) 868 return IdlUnionType(member_types)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698