| 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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 is_check_security_for_frame = ( | 93 is_check_security_for_frame = ( |
| 94 'CheckSecurity' in interface.extended_attributes and | 94 'CheckSecurity' in interface.extended_attributes and |
| 95 'DoNotCheckSecurity' not in extended_attributes) | 95 'DoNotCheckSecurity' not in extended_attributes) |
| 96 is_raises_exception = 'RaisesException' in extended_attributes | 96 is_raises_exception = 'RaisesException' in extended_attributes |
| 97 | 97 |
| 98 arguments_need_try_catch = any(argument_needs_try_catch(argument) | 98 arguments_need_try_catch = any(argument_needs_try_catch(argument) |
| 99 for argument in arguments) | 99 for argument in arguments) |
| 100 | 100 |
| 101 return { | 101 return { |
| 102 'activity_logging_world_list': v8_utilities.activity_logging_world_list(
method), # [ActivityLogging] | 102 'activity_logging_world_list': v8_utilities.activity_logging_world_list(
method), # [ActivityLogging] |
| 103 'arguments': [generate_argument(interface, method, argument, index, argu
ments_need_try_catch) | 103 'arguments': [generate_argument(interface, method, argument, index) |
| 104 for index, argument in enumerate(arguments)], | 104 for index, argument in enumerate(arguments)], |
| 105 'arguments_need_try_catch': arguments_need_try_catch, | 105 'arguments_need_try_catch': arguments_need_try_catch, |
| 106 'conditional_string': v8_utilities.conditional_string(method), | 106 'conditional_string': v8_utilities.conditional_string(method), |
| 107 'cpp_type': idl_type.cpp_type, | 107 'cpp_type': idl_type.cpp_type, |
| 108 'cpp_value': this_cpp_value, | 108 'cpp_value': this_cpp_value, |
| 109 'deprecate_as': v8_utilities.deprecate_as(method), # [DeprecateAs] | 109 'deprecate_as': v8_utilities.deprecate_as(method), # [DeprecateAs] |
| 110 'do_not_check_signature': not(is_static or | 110 'do_not_check_signature': not(is_static or |
| 111 v8_utilities.has_extended_attribute(method, | 111 v8_utilities.has_extended_attribute(method, |
| 112 ['DoNotCheckSecurity', 'DoNotCheckSignature', 'NotEnumerable', | 112 ['DoNotCheckSecurity', 'DoNotCheckSignature', 'NotEnumerable', |
| 113 'ReadOnly', 'RuntimeEnabled', 'Unforgeable'])), | 113 'ReadOnly', 'RuntimeEnabled', 'Unforgeable'])), |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 'property_attributes': property_attributes(method), | 150 'property_attributes': property_attributes(method), |
| 151 'runtime_enabled_function': v8_utilities.runtime_enabled_function_name(m
ethod), # [RuntimeEnabled] | 151 'runtime_enabled_function': v8_utilities.runtime_enabled_function_name(m
ethod), # [RuntimeEnabled] |
| 152 'signature': 'v8::Local<v8::Signature>()' if is_static or 'DoNotCheckSig
nature' in extended_attributes else 'defaultSignature', | 152 'signature': 'v8::Local<v8::Signature>()' if is_static or 'DoNotCheckSig
nature' in extended_attributes else 'defaultSignature', |
| 153 'union_arguments': idl_type.union_arguments, | 153 'union_arguments': idl_type.union_arguments, |
| 154 'v8_set_return_value_for_main_world': v8_set_return_value(interface.name
, method, this_cpp_value, for_main_world=True), | 154 'v8_set_return_value_for_main_world': v8_set_return_value(interface.name
, method, this_cpp_value, for_main_world=True), |
| 155 'v8_set_return_value': v8_set_return_value(interface.name, method, this_
cpp_value), | 155 'v8_set_return_value': v8_set_return_value(interface.name, method, this_
cpp_value), |
| 156 'world_suffixes': ['', 'ForMainWorld'] if 'PerWorldBindings' in extended
_attributes else [''], # [PerWorldBindings] | 156 'world_suffixes': ['', 'ForMainWorld'] if 'PerWorldBindings' in extended
_attributes else [''], # [PerWorldBindings] |
| 157 } | 157 } |
| 158 | 158 |
| 159 | 159 |
| 160 def generate_argument(interface, method, argument, index, method_has_try_catch): | 160 def generate_argument(interface, method, argument, index): |
| 161 extended_attributes = argument.extended_attributes | 161 extended_attributes = argument.extended_attributes |
| 162 idl_type = argument.idl_type | 162 idl_type = argument.idl_type |
| 163 this_cpp_value = cpp_value(interface, method, index) | 163 this_cpp_value = cpp_value(interface, method, index) |
| 164 is_variadic_wrapper_type = argument.is_variadic and idl_type.is_wrapper_type | 164 is_variadic_wrapper_type = argument.is_variadic and idl_type.is_wrapper_type |
| 165 | 165 |
| 166 return { | 166 return { |
| 167 'cpp_type': idl_type.cpp_type_args(extended_attributes=extended_attribut
es, | 167 'cpp_type': idl_type.cpp_type_args(extended_attributes=extended_attribut
es, |
| 168 used_as_argument=True, | 168 used_as_argument=True, |
| 169 used_as_variadic_argument=argument.is
_variadic), | 169 used_as_variadic_argument=argument.is
_variadic), |
| 170 'cpp_value': this_cpp_value, | 170 'cpp_value': this_cpp_value, |
| (...skipping 17 matching lines...) Expand all Loading... |
| 188 'is_clamp': 'Clamp' in extended_attributes, | 188 'is_clamp': 'Clamp' in extended_attributes, |
| 189 'is_callback_interface': idl_type.is_callback_interface, | 189 'is_callback_interface': idl_type.is_callback_interface, |
| 190 'is_nullable': idl_type.is_nullable, | 190 'is_nullable': idl_type.is_nullable, |
| 191 'is_optional': argument.is_optional, | 191 'is_optional': argument.is_optional, |
| 192 'is_variadic_wrapper_type': is_variadic_wrapper_type, | 192 'is_variadic_wrapper_type': is_variadic_wrapper_type, |
| 193 'vector_type': v8_types.cpp_ptr_type('Vector', 'HeapVector', idl_type.gc
_type), | 193 'vector_type': v8_types.cpp_ptr_type('Vector', 'HeapVector', idl_type.gc
_type), |
| 194 'is_wrapper_type': idl_type.is_wrapper_type, | 194 'is_wrapper_type': idl_type.is_wrapper_type, |
| 195 'name': argument.name, | 195 'name': argument.name, |
| 196 'v8_set_return_value_for_main_world': v8_set_return_value(interface.name
, method, this_cpp_value, for_main_world=True), | 196 'v8_set_return_value_for_main_world': v8_set_return_value(interface.name
, method, this_cpp_value, for_main_world=True), |
| 197 'v8_set_return_value': v8_set_return_value(interface.name, method, this_
cpp_value), | 197 'v8_set_return_value': v8_set_return_value(interface.name, method, this_
cpp_value), |
| 198 'v8_value_to_local_cpp_value': v8_value_to_local_cpp_value(argument, ind
ex, method_has_try_catch), | 198 'v8_value_to_local_cpp_value': v8_value_to_local_cpp_value(argument, ind
ex), |
| 199 } | 199 } |
| 200 | 200 |
| 201 | 201 |
| 202 ################################################################################ | 202 ################################################################################ |
| 203 # Value handling | 203 # Value handling |
| 204 ################################################################################ | 204 ################################################################################ |
| 205 | 205 |
| 206 def cpp_value(interface, method, number_of_arguments): | 206 def cpp_value(interface, method, number_of_arguments): |
| 207 def cpp_argument(argument): | 207 def cpp_argument(argument): |
| 208 idl_type = argument.idl_type | 208 idl_type = argument.idl_type |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 | 272 |
| 273 macro = 'TONATIVE_VOID_INTERNAL' | 273 macro = 'TONATIVE_VOID_INTERNAL' |
| 274 macro_args = [ | 274 macro_args = [ |
| 275 argument.name, | 275 argument.name, |
| 276 'toNativeArguments<%s>(info, %s)' % (idl_type.cpp_type, index), | 276 'toNativeArguments<%s>(info, %s)' % (idl_type.cpp_type, index), |
| 277 ] | 277 ] |
| 278 | 278 |
| 279 return '%s(%s)' % (macro, ', '.join(macro_args)) | 279 return '%s(%s)' % (macro, ', '.join(macro_args)) |
| 280 | 280 |
| 281 | 281 |
| 282 def v8_value_to_local_cpp_value(argument, index, method_has_try_catch): | 282 def v8_value_to_local_cpp_value(argument, index): |
| 283 extended_attributes = argument.extended_attributes | 283 extended_attributes = argument.extended_attributes |
| 284 idl_type = argument.idl_type | 284 idl_type = argument.idl_type |
| 285 name = argument.name | 285 name = argument.name |
| 286 if argument.is_variadic: | 286 if argument.is_variadic: |
| 287 return v8_value_to_local_cpp_variadic_value(argument, index) | 287 return v8_value_to_local_cpp_variadic_value(argument, index) |
| 288 # [Default=NullString] | 288 # [Default=NullString] |
| 289 if (argument.is_optional and idl_type.name == 'String' and | 289 if (argument.is_optional and idl_type.name == 'String' and |
| 290 extended_attributes.get('Default') == 'NullString'): | 290 extended_attributes.get('Default') == 'NullString'): |
| 291 v8_value = 'argumentOrNull(info, %s)' % index | 291 v8_value = 'argumentOrNull(info, %s)' % index |
| 292 else: | 292 else: |
| 293 v8_value = 'info[%s]' % index | 293 v8_value = 'info[%s]' % index |
| 294 return idl_type.v8_value_to_local_cpp_value(extended_attributes, v8_value, | 294 return idl_type.v8_value_to_local_cpp_value(extended_attributes, v8_value, |
| 295 name, index=index, declare_varia
ble=False, | 295 name, index=index, declare_varia
ble=False) |
| 296 method_has_try_catch=method_has_
try_catch) | |
| 297 | 296 |
| 298 | 297 |
| 299 ################################################################################ | 298 ################################################################################ |
| 300 # Auxiliary functions | 299 # Auxiliary functions |
| 301 ################################################################################ | 300 ################################################################################ |
| 302 | 301 |
| 303 # [NotEnumerable] | 302 # [NotEnumerable] |
| 304 def property_attributes(method): | 303 def property_attributes(method): |
| 305 extended_attributes = method.extended_attributes | 304 extended_attributes = method.extended_attributes |
| 306 property_attributes_list = [] | 305 property_attributes_list = [] |
| 307 if 'NotEnumerable' in extended_attributes: | 306 if 'NotEnumerable' in extended_attributes: |
| 308 property_attributes_list.append('v8::DontEnum') | 307 property_attributes_list.append('v8::DontEnum') |
| 309 if 'ReadOnly' in extended_attributes: | 308 if 'ReadOnly' in extended_attributes: |
| 310 property_attributes_list.append('v8::ReadOnly') | 309 property_attributes_list.append('v8::ReadOnly') |
| 311 if property_attributes_list: | 310 if property_attributes_list: |
| 312 property_attributes_list.insert(0, 'v8::DontDelete') | 311 property_attributes_list.insert(0, 'v8::DontDelete') |
| 313 return property_attributes_list | 312 return property_attributes_list |
| 314 | 313 |
| 315 | 314 |
| 316 def union_arguments(idl_type): | 315 def union_arguments(idl_type): |
| 317 """Return list of ['result0Enabled', 'result0', 'result1Enabled', ...] for u
nion types, for use in setting return value""" | 316 """Return list of ['result0Enabled', 'result0', 'result1Enabled', ...] for u
nion types, for use in setting return value""" |
| 318 return [arg | 317 return [arg |
| 319 for i in range(len(idl_type.member_types)) | 318 for i in range(len(idl_type.member_types)) |
| 320 for arg in ['result%sEnabled' % i, 'result%s' % i]] | 319 for arg in ['result%sEnabled' % i, 'result%s' % i]] |
| 321 | 320 |
| 322 IdlType.union_arguments = property(lambda self: None) | 321 IdlType.union_arguments = property(lambda self: None) |
| 323 IdlUnionType.union_arguments = property(union_arguments) | 322 IdlUnionType.union_arguments = property(union_arguments) |
| OLD | NEW |