OLD | NEW |
1 # Copyright (C) 2013 Google Inc. All rights reserved. | 1 # Copyright (C) 2013 Google Inc. All rights reserved. |
2 # coding=utf-8 | 2 # coding=utf-8 |
3 # | 3 # |
4 # Redistribution and use in source and binary forms, with or without | 4 # Redistribution and use in source and binary forms, with or without |
5 # modification, are permitted provided that the following conditions are | 5 # modification, are permitted provided that the following conditions are |
6 # met: | 6 # met: |
7 # | 7 # |
8 # * Redistributions of source code must retain the above copyright | 8 # * Redistributions of source code must retain the above copyright |
9 # notice, this list of conditions and the following disclaimer. | 9 # notice, this list of conditions and the following disclaimer. |
10 # * Redistributions in binary form must reproduce the above | 10 # * Redistributions in binary form must reproduce the above |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 | 100 |
101 | 101 |
102 def origin_trial_features(interface, constants, attributes, methods): | 102 def origin_trial_features(interface, constants, attributes, methods): |
103 """ Returns a list of the origin trial features used in this interface. | 103 """ Returns a list of the origin trial features used in this interface. |
104 | 104 |
105 Each element is a dictionary with keys 'name' and 'needs_instance'. | 105 Each element is a dictionary with keys 'name' and 'needs_instance'. |
106 'needs_instance' is true if any member associated with the interface needs | 106 'needs_instance' is true if any member associated with the interface needs |
107 to be installed on every instance of the interface. This list is the union | 107 to be installed on every instance of the interface. This list is the union |
108 of the sets of features used for constants, attributes and methods. | 108 of the sets of features used for constants, attributes and methods. |
109 """ | 109 """ |
| 110 key = 'origin_trial_feature_name' |
110 | 111 |
111 # Collect all members visible on this interface with a defined origin trial | 112 # Collect all members visible on this interface with a defined origin trial |
112 origin_trial_members = ( | 113 origin_trial_constants = [constant for constant in constants if constant[key
]] |
113 [constant for constant in constants if constant['origin_trial_feature_na
me']] + | 114 origin_trial_attributes = [attribute for attribute in attributes if attribut
e[key]] |
114 [attribute for attribute in attributes if attribute['origin_trial_featur
e_name']] + | 115 origin_trial_methods = [method for method in methods if ( |
115 [method for method in methods if ( | 116 v8_methods.method_is_visible(method, interface.is_partial) and method[ke
y])] |
116 v8_methods.method_is_visible(method, interface.is_partial) and | 117 |
117 method['origin_trial_feature_name'])] | 118 feature_names = set([constant[key] for constant in origin_trial_constants] + |
118 ) | 119 [attribute[key] for attribute in origin_trial_attributes
] + |
119 # Group members by origin_trial_feature_name | 120 [method[key] for method in origin_trial_methods]) |
120 members_by_name = itertools.groupby(sorted(origin_trial_members, | 121 |
121 key=itemgetter('origin_trial_feat
ure_name')), | |
122 itemgetter('origin_trial_feature_name')) | |
123 # Construct the list of dictionaries. 'needs_instance' will be true if any | 122 # Construct the list of dictionaries. 'needs_instance' will be true if any |
124 # member for the feature has 'on_instance' defined as true. | 123 # member for the feature has 'on_instance' defined as true. |
125 features = [{'name': name, | 124 features = [{'name': name, |
126 'needs_instance': reduce(or_, (member.get('on_instance', False) | 125 'constants': [constant for constant in origin_trial_constants i
f constant[key] == name], |
127 for member in members))} | 126 'attributes': [attribute for attribute in origin_trial_attribut
es if attribute[key] == name], |
128 for name, members in members_by_name] | 127 'methods': [method for method in origin_trial_methods if method
[key] == name]} |
| 128 for name in feature_names] |
| 129 for feature in features: |
| 130 members = feature['constants'] + feature['attributes'] + feature['method
s'] |
| 131 feature['needs_instance'] = reduce(or_, (member.get('on_instance', False
) for member in members)) |
| 132 |
129 if features: | 133 if features: |
130 includes.add('bindings/core/v8/ScriptState.h') | 134 includes.add('bindings/core/v8/ScriptState.h') |
131 includes.add('core/origin_trials/OriginTrials.h') | 135 includes.add('core/origin_trials/OriginTrials.h') |
132 return sorted(features) | 136 return sorted(features) |
133 | 137 |
134 | 138 |
135 def interface_context(interface, interfaces): | 139 def interface_context(interface, interfaces): |
136 """Creates a Jinja template context for an interface. | 140 """Creates a Jinja template context for an interface. |
137 | 141 |
138 Args: | 142 Args: |
(...skipping 1350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1489 extended_attributes = deleter.extended_attributes | 1493 extended_attributes = deleter.extended_attributes |
1490 is_call_with_script_state = v8_utilities.has_extended_attribute_value(delete
r, 'CallWith', 'ScriptState') | 1494 is_call_with_script_state = v8_utilities.has_extended_attribute_value(delete
r, 'CallWith', 'ScriptState') |
1491 is_ce_reactions = 'CEReactions' in extended_attributes | 1495 is_ce_reactions = 'CEReactions' in extended_attributes |
1492 return { | 1496 return { |
1493 'is_call_with_script_state': is_call_with_script_state, | 1497 'is_call_with_script_state': is_call_with_script_state, |
1494 'is_ce_reactions': is_ce_reactions, | 1498 'is_ce_reactions': is_ce_reactions, |
1495 'is_custom': 'Custom' in extended_attributes, | 1499 'is_custom': 'Custom' in extended_attributes, |
1496 'is_raises_exception': 'RaisesException' in extended_attributes, | 1500 'is_raises_exception': 'RaisesException' in extended_attributes, |
1497 'name': cpp_name(deleter), | 1501 'name': cpp_name(deleter), |
1498 } | 1502 } |
OLD | NEW |