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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 is_raises_exception = 'RaisesException' in extended_attributes | 79 is_raises_exception = 'RaisesException' in extended_attributes |
80 | 80 |
81 if idl_type.union_arguments and len(idl_type.union_arguments) > 0: | 81 if idl_type.union_arguments and len(idl_type.union_arguments) > 0: |
82 this_cpp_type = [] | 82 this_cpp_type = [] |
83 for cpp_type in idl_type.member_types: | 83 for cpp_type in idl_type.member_types: |
84 this_cpp_type.append("RefPtr<%s>" % cpp_type) | 84 this_cpp_type.append("RefPtr<%s>" % cpp_type) |
85 else: | 85 else: |
86 this_cpp_type = idl_type.cpp_type | 86 this_cpp_type = idl_type.cpp_type |
87 | 87 |
88 is_auto_scope = not 'DartNoAutoScope' in extended_attributes | 88 is_auto_scope = not 'DartNoAutoScope' in extended_attributes |
| 89 |
| 90 number_of_arguments = len(arguments) |
| 91 |
| 92 number_of_required_arguments = \ |
| 93 len([ |
| 94 argument for argument in arguments |
| 95 if not ((argument.is_optional and not ('Default' in argument.extende
d_attributes or argument.default_value)) or |
| 96 argument.is_variadic)]) |
| 97 |
| 98 arguments_data = [generate_argument(interface, method, argument, index) |
| 99 for index, argument in enumerate(arguments)] |
| 100 |
| 101 is_custom = 'Custom' in extended_attributes or 'DartCustom' in extended_attr
ibutes |
| 102 |
89 method_data = { | 103 method_data = { |
90 'activity_logging_world_list': DartUtilities.activity_logging_world_list
(method), # [ActivityLogging] | 104 'activity_logging_world_list': DartUtilities.activity_logging_world_list
(method), # [ActivityLogging] |
91 'arguments': [generate_argument(interface, method, argument, index) | 105 'arguments': arguments_data, |
92 for index, argument in enumerate(arguments)], | |
93 'conditional_string': DartUtilities.conditional_string(method), | 106 'conditional_string': DartUtilities.conditional_string(method), |
94 'cpp_type': this_cpp_type, | 107 'cpp_type': this_cpp_type, |
95 'cpp_value': this_cpp_value, | 108 'cpp_value': this_cpp_value, |
96 'dart_name': extended_attributes.get('DartName'), | 109 'dart_name': extended_attributes.get('DartName'), |
97 'deprecate_as': DartUtilities.deprecate_as(method), # [DeprecateAs] | 110 'deprecate_as': DartUtilities.deprecate_as(method), # [DeprecateAs] |
98 'do_not_check_signature': not(is_static or | 111 'do_not_check_signature': not(is_static or |
99 DartUtilities.has_extended_attribute(method, | 112 DartUtilities.has_extended_attribute(method, |
100 ['DoNotCheckSecurity', 'DoNotCheckSignature', 'NotEnumerable', | 113 ['DoNotCheckSecurity', 'DoNotCheckSignature', 'NotEnumerable', |
101 'ReadOnly', 'RuntimeEnabled', 'Unforgeable'])), | 114 'ReadOnly', 'RuntimeEnabled', 'Unforgeable'])), |
102 'function_template': function_template(), | 115 'function_template': function_template(), |
103 'idl_type': idl_type.base_type, | 116 'idl_type': idl_type.base_type, |
104 'has_event_listener_argument': has_event_listener_argument, | 117 'has_event_listener_argument': has_event_listener_argument, |
105 'has_exception_state': | 118 'has_exception_state': |
106 has_event_listener_argument or | 119 has_event_listener_argument or |
107 is_raises_exception or | 120 is_raises_exception or |
108 is_check_security_for_frame or | 121 is_check_security_for_frame or |
109 any(argument for argument in arguments | 122 any(argument for argument in arguments |
110 if argument.idl_type.name == 'SerializedScriptValue' or | 123 if argument.idl_type.name == 'SerializedScriptValue' or |
111 argument.idl_type.is_integer_type), | 124 argument.idl_type.is_integer_type), |
112 'is_auto_scope': is_auto_scope, | 125 'is_auto_scope': is_auto_scope, |
113 'auto_scope': DartUtilities.bool_to_cpp(is_auto_scope), | 126 'auto_scope': DartUtilities.bool_to_cpp(is_auto_scope), |
114 'is_call_with_execution_context': DartUtilities.has_extended_attribute_v
alue(method, 'CallWith', 'ExecutionContext'), | 127 'is_call_with_execution_context': DartUtilities.has_extended_attribute_v
alue(method, 'CallWith', 'ExecutionContext'), |
115 'is_call_with_script_arguments': is_call_with_script_arguments, | 128 'is_call_with_script_arguments': is_call_with_script_arguments, |
116 'is_call_with_script_state': is_call_with_script_state, | 129 'is_call_with_script_state': is_call_with_script_state, |
117 'is_check_security_for_frame': is_check_security_for_frame, | 130 'is_check_security_for_frame': is_check_security_for_frame, |
118 'is_check_security_for_node': is_check_security_for_node, | 131 'is_check_security_for_node': is_check_security_for_node, |
119 'is_custom': 'Custom' in extended_attributes or 'DartCustom' in extended
_attributes, | 132 'is_custom': is_custom, |
120 'is_custom_dart': 'DartCustom' in extended_attributes, | 133 'is_custom_dart': 'DartCustom' in extended_attributes, |
121 'is_custom_dart_new': DartUtilities.has_extended_attribute_value(method,
'DartCustom', 'New'), | 134 'is_custom_dart_new': DartUtilities.has_extended_attribute_value(method,
'DartCustom', 'New'), |
122 'is_custom_element_callbacks': is_custom_element_callbacks, | 135 'is_custom_element_callbacks': is_custom_element_callbacks, |
123 'is_do_not_check_security': 'DoNotCheckSecurity' in extended_attributes, | 136 'is_do_not_check_security': 'DoNotCheckSecurity' in extended_attributes, |
124 'is_do_not_check_signature': 'DoNotCheckSignature' in extended_attribute
s, | 137 'is_do_not_check_signature': 'DoNotCheckSignature' in extended_attribute
s, |
125 'is_partial_interface_member': 'PartialInterfaceImplementedAs' in extend
ed_attributes, | 138 'is_partial_interface_member': 'PartialInterfaceImplementedAs' in extend
ed_attributes, |
126 'is_per_world_bindings': 'PerWorldBindings' in extended_attributes, | 139 'is_per_world_bindings': 'PerWorldBindings' in extended_attributes, |
127 'is_raises_exception': is_raises_exception, | 140 'is_raises_exception': is_raises_exception, |
128 'is_read_only': 'ReadOnly' in extended_attributes, | 141 'is_read_only': 'ReadOnly' in extended_attributes, |
129 'is_static': is_static, | 142 'is_static': is_static, |
130 # FIXME(terry): StrictTypeChecking no longer supported; TypeChecking is | 143 # FIXME(terry): StrictTypeChecking no longer supported; TypeChecking is |
131 # new extended attribute. | 144 # new extended attribute. |
132 'is_strict_type_checking': | 145 'is_strict_type_checking': |
133 'StrictTypeChecking' in extended_attributes or | 146 'StrictTypeChecking' in extended_attributes or |
134 'StrictTypeChecking' in interface.extended_attributes, | 147 'StrictTypeChecking' in interface.extended_attributes, |
135 'is_variadic': arguments and arguments[-1].is_variadic, | 148 'is_variadic': arguments and arguments[-1].is_variadic, |
136 'measure_as': DartUtilities.measure_as(method), # [MeasureAs] | 149 'measure_as': DartUtilities.measure_as(method), # [MeasureAs] |
137 'name': name, | 150 'name': name, |
138 'number_of_arguments': len(arguments), | 151 'number_of_arguments': number_of_arguments, |
139 'number_of_required_arguments': len([ | 152 'number_of_required_arguments': number_of_required_arguments, |
140 argument for argument in arguments | |
141 if not ((argument.is_optional and not ('Default' in argument.extende
d_attributes or argument.default_value)) or | |
142 argument.is_variadic)]), | |
143 'number_of_required_or_variadic_arguments': len([ | 153 'number_of_required_or_variadic_arguments': len([ |
144 argument for argument in arguments | 154 argument for argument in arguments |
145 if not argument.is_optional]), | 155 if not argument.is_optional]), |
146 'per_context_enabled_function': DartUtilities.per_context_enabled_functi
on_name(method), # [PerContextEnabled] | 156 'per_context_enabled_function': DartUtilities.per_context_enabled_functi
on_name(method), # [PerContextEnabled] |
147 'property_attributes': property_attributes(method), | 157 'property_attributes': property_attributes(method), |
148 'runtime_enabled_function': DartUtilities.runtime_enabled_function_name(
method), # [RuntimeEnabled] | 158 'runtime_enabled_function': DartUtilities.runtime_enabled_function_name(
method), # [RuntimeEnabled] |
149 'signature': 'v8::Local<v8::Signature>()' if is_static or 'DoNotCheckSig
nature' in extended_attributes else 'defaultSignature', | 159 'signature': 'v8::Local<v8::Signature>()' if is_static or 'DoNotCheckSig
nature' in extended_attributes else 'defaultSignature', |
150 'suppressed': (arguments and arguments[-1].is_variadic), # FIXME: imple
ment variadic | 160 'suppressed': (arguments and arguments[-1].is_variadic), # FIXME: imple
ment variadic |
151 'union_arguments': idl_type.union_arguments, | 161 'union_arguments': idl_type.union_arguments, |
152 'dart_set_return_value': dart_set_return_value(interface.name, method, t
his_cpp_value), | 162 'dart_set_return_value': dart_set_return_value(interface.name, method, t
his_cpp_value), |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
329 | 339 |
330 | 340 |
331 def union_arguments(idl_type): | 341 def union_arguments(idl_type): |
332 """Return list of ['result0Enabled', 'result0', 'result1Enabled', ...] for u
nion types, for use in setting return value""" | 342 """Return list of ['result0Enabled', 'result0', 'result1Enabled', ...] for u
nion types, for use in setting return value""" |
333 return [arg | 343 return [arg |
334 for i in range(len(idl_type.member_types)) | 344 for i in range(len(idl_type.member_types)) |
335 for arg in ['result%sEnabled' % i, 'result%s' % i]] | 345 for arg in ['result%sEnabled' % i, 'result%s' % i]] |
336 | 346 |
337 IdlType.union_arguments = property(lambda self: None) | 347 IdlType.union_arguments = property(lambda self: None) |
338 IdlUnionType.union_arguments = property(union_arguments) | 348 IdlUnionType.union_arguments = property(union_arguments) |
OLD | NEW |