| 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 from v8_utilities import (has_extended_attribute_value, is_unforgeable, | 42 from v8_utilities import (has_extended_attribute_value, is_unforgeable, |
| 43 is_legacy_interface_type_checking) | 43 is_legacy_interface_type_checking) |
| 44 | 44 |
| 45 | 45 |
| 46 def method_is_visible(method, interface_is_partial): | 46 def method_is_visible(method, interface_is_partial): |
| 47 if 'overloads' in method: | 47 if 'overloads' in method: |
| 48 return method['overloads']['visible'] and not (method['overloads']['has_
partial_overloads'] and interface_is_partial) | 48 return method['overloads']['visible'] and not (method['overloads']['has_
partial_overloads'] and interface_is_partial) |
| 49 return method['visible'] and 'overload_index' not in method | 49 return method['visible'] and 'overload_index' not in method |
| 50 | 50 |
| 51 | 51 |
| 52 def conditionally_exposed(method): | 52 def is_origin_trial_enabled(method): |
| 53 return bool(method['origin_trial_feature_name']) |
| 54 |
| 55 |
| 56 def is_conditionally_enabled(method): |
| 53 exposed = method['overloads']['exposed_test_all'] if 'overloads' in method e
lse method['exposed_test'] | 57 exposed = method['overloads']['exposed_test_all'] if 'overloads' in method e
lse method['exposed_test'] |
| 54 secure_context = method['overloads']['secure_context_test_all'] if 'overload
s' in method else method['secure_context_test'] | 58 secure_context = method['overloads']['secure_context_test_all'] if 'overload
s' in method else method['secure_context_test'] |
| 55 return exposed or secure_context | 59 return exposed or secure_context |
| 56 | 60 |
| 57 | 61 |
| 58 def filter_conditionally_exposed(methods, interface_is_partial): | 62 def filter_conditionally_enabled(methods, interface_is_partial): |
| 59 return [method for method in methods if ( | 63 return [method for method in methods if ( |
| 60 method_is_visible(method, interface_is_partial) and conditionally_expose
d(method))] | 64 method_is_visible(method, interface_is_partial) and |
| 65 is_conditionally_enabled(method) and |
| 66 not is_origin_trial_enabled(method))] |
| 61 | 67 |
| 62 | 68 |
| 63 def custom_registration(method): | 69 def custom_registration(method): |
| 64 # TODO(dcheng): Currently, bindings must create a function object for each | 70 # TODO(dcheng): Currently, bindings must create a function object for each |
| 65 # realm as a hack to support the incumbent realm. Remove the need for custom | 71 # realm as a hack to support the incumbent realm. Remove the need for custom |
| 66 # registration when Blink properly supports the incumbent realm. | 72 # registration when Blink properly supports the incumbent realm. |
| 67 if method['is_cross_origin']: | 73 if method['is_cross_origin']: |
| 68 return True | 74 return True |
| 69 if 'overloads' in method: | 75 if 'overloads' in method: |
| 70 return (method['overloads']['runtime_determined_lengths'] or | 76 return (method['overloads']['runtime_determined_lengths'] or |
| 71 (method['overloads']['runtime_enabled_all'] and not conditionall
y_exposed(method))) | 77 (method['overloads']['runtime_enabled_all'] and not is_condition
ally_enabled(method))) |
| 72 return method['runtime_enabled_feature_name'] and not conditionally_exposed(
method) | 78 return method['runtime_enabled_feature_name'] and not is_conditionally_enabl
ed(method) |
| 73 | 79 |
| 74 | 80 |
| 75 def filter_custom_registration(methods, interface_is_partial): | 81 def filter_custom_registration(methods, interface_is_partial): |
| 76 return [method for method in methods if ( | 82 return [method for method in methods if ( |
| 77 method_is_visible(method, interface_is_partial) and custom_registration(
method))] | 83 method_is_visible(method, interface_is_partial) and custom_registration(
method))] |
| 78 | 84 |
| 79 | 85 |
| 80 def filter_method_configuration(methods, interface_is_partial): | 86 def filter_method_configuration(methods, interface_is_partial): |
| 81 return [method for method in methods if | 87 return [method for method in methods if |
| 82 method_is_visible(method, interface_is_partial) and | 88 method_is_visible(method, interface_is_partial) and |
| 83 not method['origin_trial_feature_name'] and | 89 not is_origin_trial_enabled(method) and |
| 84 not conditionally_exposed(method) and | 90 not is_conditionally_enabled(method) and |
| 85 not custom_registration(method)] | 91 not custom_registration(method)] |
| 86 | 92 |
| 87 | 93 |
| 88 def method_filters(): | 94 def method_filters(): |
| 89 return {'conditionally_exposed': filter_conditionally_exposed, | 95 return {'custom_registration': filter_custom_registration, |
| 90 'custom_registration': filter_custom_registration, | |
| 91 'has_method_configuration': filter_method_configuration} | 96 'has_method_configuration': filter_method_configuration} |
| 92 | 97 |
| 93 | 98 |
| 94 def use_local_result(method): | 99 def use_local_result(method): |
| 95 extended_attributes = method.extended_attributes | 100 extended_attributes = method.extended_attributes |
| 96 idl_type = method.idl_type | 101 idl_type = method.idl_type |
| 97 return (has_extended_attribute_value(method, 'CallWith', 'ScriptState') or | 102 return (has_extended_attribute_value(method, 'CallWith', 'ScriptState') or |
| 98 'NewObject' in extended_attributes or | 103 'NewObject' in extended_attributes or |
| 99 'RaisesException' in extended_attributes or | 104 'RaisesException' in extended_attributes or |
| 100 idl_type.is_union_type or | 105 idl_type.is_union_type or |
| (...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 483 return method.idl_type and method.idl_type.name == 'Promise' | 488 return method.idl_type and method.idl_type.name == 'Promise' |
| 484 | 489 |
| 485 IdlOperation.returns_promise = property(method_returns_promise) | 490 IdlOperation.returns_promise = property(method_returns_promise) |
| 486 | 491 |
| 487 | 492 |
| 488 def argument_conversion_needs_exception_state(method, argument): | 493 def argument_conversion_needs_exception_state(method, argument): |
| 489 idl_type = argument.idl_type | 494 idl_type = argument.idl_type |
| 490 return (idl_type.v8_conversion_needs_exception_state or | 495 return (idl_type.v8_conversion_needs_exception_state or |
| 491 argument.is_variadic or | 496 argument.is_variadic or |
| 492 (method.returns_promise and idl_type.is_string_type)) | 497 (method.returns_promise and idl_type.is_string_type)) |
| OLD | NEW |