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' | |
Yuki
2016/12/15 06:22:59
Constants should be all capital letters.
s/key/KEY
peria
2016/12/16 02:48:12
Done.
| |
111 | |
112 def member_filter(members): | |
113 return sorted([member for member in members if member.get(key) and not m ember.get('exposed_test')]) | |
114 | |
115 def member_filter_by_name(members, name): | |
116 return [member for member in members if member[key] == name] | |
iclelland
2016/12/16 04:19:22
Very minor nit -- These two methods look very simi
peria
2016/12/16 05:02:10
I got it. I'll put a comment in a follow-up CL.
| |
110 | 117 |
111 # Collect all members visible on this interface with a defined origin trial | 118 # Collect all members visible on this interface with a defined origin trial |
112 origin_trial_members = ( | 119 origin_trial_constants = member_filter(constants) |
113 [constant for constant in constants if constant['origin_trial_feature_na me']] + | 120 origin_trial_attributes = member_filter(attributes) |
114 [attribute for attribute in attributes if attribute['origin_trial_featur e_name']] + | 121 origin_trial_methods = member_filter([method for method in methods |
115 [method for method in methods if ( | 122 if method['should_be_exposed_to_script '] and |
116 v8_methods.method_is_visible(method, interface.is_partial) and | 123 v8_methods.method_is_visible(method, i nterface.is_partial) and |
117 method['origin_trial_feature_name'])] | 124 not v8_methods.conditionally_exposed(m ethod) and |
118 ) | 125 not v8_methods.custom_registration(met hod)]) |
119 # Group members by origin_trial_feature_name | 126 |
120 members_by_name = itertools.groupby(sorted(origin_trial_members, | 127 feature_names = set([member[key] for member in origin_trial_constants + orig in_trial_attributes + origin_trial_methods]) |
121 key=itemgetter('origin_trial_feat ure_name')), | 128 |
122 itemgetter('origin_trial_feature_name')) | |
123 # Construct the list of dictionaries. 'needs_instance' will be true if any | 129 # Construct the list of dictionaries. 'needs_instance' will be true if any |
124 # member for the feature has 'on_instance' defined as true. | 130 # member for the feature has 'on_instance' defined as true. |
125 features = [{'name': name, | 131 features = [{'name': name, |
126 'needs_instance': reduce(or_, (member.get('on_instance', False) | 132 'constants': member_filter_by_name(origin_trial_constants, name ), |
127 for member in members))} | 133 'attributes': member_filter_by_name(origin_trial_attributes, na me), |
128 for name, members in members_by_name] | 134 'methods': member_filter_by_name(origin_trial_methods, name)} |
135 for name in feature_names] | |
136 for feature in features: | |
137 members = feature['constants'] + feature['attributes'] + feature['method s'] | |
138 feature['needs_instance'] = reduce(or_, (member.get('on_instance', False ) for member in members)) | |
139 | |
129 if features: | 140 if features: |
130 includes.add('bindings/core/v8/ScriptState.h') | 141 includes.add('bindings/core/v8/ScriptState.h') |
131 includes.add('core/origin_trials/OriginTrials.h') | 142 includes.add('core/origin_trials/OriginTrials.h') |
132 return sorted(features) | 143 return sorted(features) |
133 | 144 |
134 | 145 |
135 def interface_context(interface, interfaces): | 146 def interface_context(interface, interfaces): |
136 """Creates a Jinja template context for an interface. | 147 """Creates a Jinja template context for an interface. |
137 | 148 |
138 Args: | 149 Args: |
(...skipping 1350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1489 extended_attributes = deleter.extended_attributes | 1500 extended_attributes = deleter.extended_attributes |
1490 is_call_with_script_state = v8_utilities.has_extended_attribute_value(delete r, 'CallWith', 'ScriptState') | 1501 is_call_with_script_state = v8_utilities.has_extended_attribute_value(delete r, 'CallWith', 'ScriptState') |
1491 is_ce_reactions = 'CEReactions' in extended_attributes | 1502 is_ce_reactions = 'CEReactions' in extended_attributes |
1492 return { | 1503 return { |
1493 'is_call_with_script_state': is_call_with_script_state, | 1504 'is_call_with_script_state': is_call_with_script_state, |
1494 'is_ce_reactions': is_ce_reactions, | 1505 'is_ce_reactions': is_ce_reactions, |
1495 'is_custom': 'Custom' in extended_attributes, | 1506 'is_custom': 'Custom' in extended_attributes, |
1496 'is_raises_exception': 'RaisesException' in extended_attributes, | 1507 'is_raises_exception': 'RaisesException' in extended_attributes, |
1497 'name': cpp_name(deleter), | 1508 'name': cpp_name(deleter), |
1498 } | 1509 } |
OLD | NEW |