| OLD | NEW |
| (Empty) |
| 1 # Copyright (C) 2013 Google Inc. All rights reserved. | |
| 2 # | |
| 3 # Redistribution and use in source and binary forms, with or without | |
| 4 # modification, are permitted provided that the following conditions are | |
| 5 # met: | |
| 6 # | |
| 7 # * Redistributions of source code must retain the above copyright | |
| 8 # notice, this list of conditions and the following disclaimer. | |
| 9 # * Redistributions in binary form must reproduce the above | |
| 10 # copyright notice, this list of conditions and the following disclaimer | |
| 11 # in the documentation and/or other materials provided with the | |
| 12 # distribution. | |
| 13 # * Neither the name of Google Inc. nor the names of its | |
| 14 # contributors may be used to endorse or promote products derived from | |
| 15 # this software without specific prior written permission. | |
| 16 # | |
| 17 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
| 18 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
| 19 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
| 20 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
| 21 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
| 22 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
| 23 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
| 24 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
| 25 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
| 26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
| 27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
| 28 | |
| 29 """Generate template values for methods. | |
| 30 | |
| 31 Extends IdlArgument with property |default_cpp_value|. | |
| 32 Extends IdlTypeBase and IdlUnionType with property |union_arguments|. | |
| 33 | |
| 34 Design doc: http://www.chromium.org/developers/design-documents/idl-compiler | |
| 35 """ | |
| 36 | |
| 37 from idl_definitions import IdlArgument | |
| 38 from idl_types import IdlTypeBase, IdlUnionType, inherits_interface | |
| 39 from v8_globals import includes | |
| 40 import v8_types | |
| 41 import v8_utilities | |
| 42 from v8_utilities import has_extended_attribute_value | |
| 43 | |
| 44 | |
| 45 # Methods with any of these require custom method registration code in the | |
| 46 # interface's configure*Template() function. | |
| 47 CUSTOM_REGISTRATION_EXTENDED_ATTRIBUTES = frozenset([ | |
| 48 'DoNotCheckSecurity', | |
| 49 'DoNotCheckSignature', | |
| 50 'NotEnumerable', | |
| 51 'Unforgeable', | |
| 52 ]) | |
| 53 | |
| 54 | |
| 55 def argument_needs_try_catch(method, argument): | |
| 56 return_promise = method.idl_type and method.idl_type.name == 'Promise' | |
| 57 idl_type = argument.idl_type | |
| 58 base_type = idl_type.base_type | |
| 59 | |
| 60 return not( | |
| 61 # These cases are handled by separate code paths in the | |
| 62 # generate_argument() macro in engine/bindings/templates/methods.cpp. | |
| 63 idl_type.is_callback_interface or | |
| 64 base_type == 'SerializedScriptValue' or | |
| 65 (argument.is_variadic and idl_type.is_wrapper_type) or | |
| 66 # String and enumeration arguments converted using one of the | |
| 67 # TOSTRING_* macros except for _PROMISE variants in | |
| 68 # engine/bindings/core/v8/V8BindingMacros.h don't use a v8::TryCatch. | |
| 69 ((base_type == 'DOMString' or idl_type.is_enum) and | |
| 70 not argument.is_variadic and | |
| 71 not return_promise)) | |
| 72 | |
| 73 | |
| 74 def use_local_result(method): | |
| 75 extended_attributes = method.extended_attributes | |
| 76 idl_type = method.idl_type | |
| 77 return (has_extended_attribute_value(method, 'CallWith', 'ScriptState') or | |
| 78 'ImplementedInPrivateScript' in extended_attributes or | |
| 79 'RaisesException' in extended_attributes or | |
| 80 idl_type.is_union_type or | |
| 81 idl_type.is_explicit_nullable) | |
| 82 | |
| 83 | |
| 84 def method_context(interface, method): | |
| 85 arguments = method.arguments | |
| 86 extended_attributes = method.extended_attributes | |
| 87 idl_type = method.idl_type | |
| 88 is_static = method.is_static | |
| 89 name = method.name | |
| 90 | |
| 91 idl_type.add_includes_for_type() | |
| 92 this_cpp_value = cpp_value(interface, method, len(arguments)) | |
| 93 | |
| 94 def function_template(): | |
| 95 if is_static: | |
| 96 return 'functionTemplate' | |
| 97 if 'Unforgeable' in extended_attributes: | |
| 98 return 'instanceTemplate' | |
| 99 return 'prototypeTemplate' | |
| 100 | |
| 101 is_implemented_in_private_script = 'ImplementedInPrivateScript' in extended_
attributes | |
| 102 if is_implemented_in_private_script: | |
| 103 includes.add('bindings/core/v8/PrivateScriptRunner.h') | |
| 104 includes.add('core/frame/LocalFrame.h') | |
| 105 includes.add('platform/ScriptForbiddenScope.h') | |
| 106 | |
| 107 # [OnlyExposedToPrivateScript] | |
| 108 is_only_exposed_to_private_script = 'OnlyExposedToPrivateScript' in extended
_attributes | |
| 109 | |
| 110 is_call_with_script_arguments = has_extended_attribute_value(method, 'CallWi
th', 'ScriptArguments') | |
| 111 if is_call_with_script_arguments: | |
| 112 includes.update(['bindings/core/v8/ScriptCallStackFactory.h', | |
| 113 'core/inspector/ScriptArguments.h']) | |
| 114 is_call_with_script_state = has_extended_attribute_value(method, 'CallWith',
'ScriptState') | |
| 115 if is_call_with_script_state: | |
| 116 includes.add('bindings/core/v8/ScriptState.h') | |
| 117 is_check_security_for_node = 'CheckSecurity' in extended_attributes | |
| 118 if is_check_security_for_node: | |
| 119 includes.add('bindings/core/v8/BindingSecurity.h') | |
| 120 is_custom_element_callbacks = 'CustomElementCallbacks' in extended_attribute
s | |
| 121 if is_custom_element_callbacks: | |
| 122 includes.add('core/dom/custom/CustomElementProcessingStack.h') | |
| 123 | |
| 124 is_do_not_check_security = 'DoNotCheckSecurity' in extended_attributes | |
| 125 | |
| 126 is_check_security_for_frame = ( | |
| 127 has_extended_attribute_value(interface, 'CheckSecurity', 'Frame') and | |
| 128 not is_do_not_check_security) | |
| 129 | |
| 130 is_check_security_for_window = ( | |
| 131 has_extended_attribute_value(interface, 'CheckSecurity', 'Window') and | |
| 132 not is_do_not_check_security) | |
| 133 | |
| 134 is_raises_exception = 'RaisesException' in extended_attributes | |
| 135 | |
| 136 arguments_need_try_catch = ( | |
| 137 any(argument_needs_try_catch(method, argument) | |
| 138 for argument in arguments)) | |
| 139 | |
| 140 return { | |
| 141 'activity_logging_world_list': v8_utilities.activity_logging_world_list(
method), # [ActivityLogging] | |
| 142 'arguments': [argument_context(interface, method, argument, index) | |
| 143 for index, argument in enumerate(arguments)], | |
| 144 'argument_declarations_for_private_script': | |
| 145 argument_declarations_for_private_script(interface, method), | |
| 146 'arguments_need_try_catch': arguments_need_try_catch, | |
| 147 'conditional_string': v8_utilities.conditional_string(method), | |
| 148 'cpp_type': (v8_types.cpp_template_type('Nullable', idl_type.cpp_type) | |
| 149 if idl_type.is_explicit_nullable else idl_type.cpp_type), | |
| 150 'cpp_value': this_cpp_value, | |
| 151 'cpp_type_initializer': idl_type.cpp_type_initializer, | |
| 152 'custom_registration_extended_attributes': | |
| 153 CUSTOM_REGISTRATION_EXTENDED_ATTRIBUTES.intersection( | |
| 154 extended_attributes.iterkeys()), | |
| 155 'deprecate_as': v8_utilities.deprecate_as(method), # [DeprecateAs] | |
| 156 'exposed_test': v8_utilities.exposed(method, interface), # [Exposed] | |
| 157 'function_template': function_template(), | |
| 158 'has_custom_registration': is_static or | |
| 159 v8_utilities.has_extended_attribute( | |
| 160 method, CUSTOM_REGISTRATION_EXTENDED_ATTRIBUTES), | |
| 161 'has_exception_state': | |
| 162 is_raises_exception or | |
| 163 is_check_security_for_frame or | |
| 164 is_check_security_for_window or | |
| 165 any(argument for argument in arguments | |
| 166 if argument.idl_type.name == 'SerializedScriptValue' or | |
| 167 argument.idl_type.may_raise_exception_on_conversion), | |
| 168 'idl_type': idl_type.base_type, | |
| 169 'is_call_with_execution_context': has_extended_attribute_value(method, '
CallWith', 'ExecutionContext'), | |
| 170 'is_call_with_script_arguments': is_call_with_script_arguments, | |
| 171 'is_call_with_script_state': is_call_with_script_state, | |
| 172 'is_check_security_for_frame': is_check_security_for_frame, | |
| 173 'is_check_security_for_node': is_check_security_for_node, | |
| 174 'is_check_security_for_window': is_check_security_for_window, | |
| 175 'is_custom': 'Custom' in extended_attributes, | |
| 176 'is_custom_element_callbacks': is_custom_element_callbacks, | |
| 177 'is_do_not_check_security': is_do_not_check_security, | |
| 178 'is_do_not_check_signature': 'DoNotCheckSignature' in extended_attribute
s, | |
| 179 'is_explicit_nullable': idl_type.is_explicit_nullable, | |
| 180 'is_implemented_in_private_script': is_implemented_in_private_script, | |
| 181 'is_partial_interface_member': | |
| 182 'PartialInterfaceImplementedAs' in extended_attributes, | |
| 183 'is_per_world_bindings': 'PerWorldBindings' in extended_attributes, | |
| 184 'is_raises_exception': is_raises_exception, | |
| 185 'is_read_only': 'Unforgeable' in extended_attributes, | |
| 186 'is_static': is_static, | |
| 187 'is_variadic': arguments and arguments[-1].is_variadic, | |
| 188 'measure_as': v8_utilities.measure_as(method), # [MeasureAs] | |
| 189 'name': name, | |
| 190 'number_of_arguments': len(arguments), | |
| 191 'number_of_required_arguments': len([ | |
| 192 argument for argument in arguments | |
| 193 if not (argument.is_optional or argument.is_variadic)]), | |
| 194 'number_of_required_or_variadic_arguments': len([ | |
| 195 argument for argument in arguments | |
| 196 if not argument.is_optional]), | |
| 197 'only_exposed_to_private_script': is_only_exposed_to_private_script, | |
| 198 'private_script_v8_value_to_local_cpp_value': idl_type.v8_value_to_local
_cpp_value( | |
| 199 extended_attributes, 'v8Value', 'cppValue', isolate='scriptState->is
olate()', used_in_private_script=True), | |
| 200 'property_attributes': property_attributes(method), | |
| 201 'runtime_enabled_function': v8_utilities.runtime_enabled_function_name(m
ethod), # [RuntimeEnabled] | |
| 202 'should_be_exposed_to_script': not (is_implemented_in_private_script and
is_only_exposed_to_private_script), | |
| 203 'signature': 'v8::Local<v8::Signature>()' if is_static or 'DoNotCheckSig
nature' in extended_attributes else 'defaultSignature', | |
| 204 'union_arguments': idl_type.union_arguments, | |
| 205 'use_local_result': use_local_result(method), | |
| 206 'v8_set_return_value': v8_set_return_value(interface.name, method, this_
cpp_value), | |
| 207 'v8_set_return_value_for_main_world': v8_set_return_value(interface.name
, method, this_cpp_value, for_main_world=True), | |
| 208 'world_suffixes': ['', 'ForMainWorld'] if 'PerWorldBindings' in extended
_attributes else [''], # [PerWorldBindings], | |
| 209 } | |
| 210 | |
| 211 | |
| 212 def argument_context(interface, method, argument, index): | |
| 213 extended_attributes = argument.extended_attributes | |
| 214 idl_type = argument.idl_type | |
| 215 this_cpp_value = cpp_value(interface, method, index) | |
| 216 is_variadic_wrapper_type = argument.is_variadic and idl_type.is_wrapper_type | |
| 217 return_promise = (method.idl_type.name == 'Promise' if method.idl_type | |
| 218 else False) | |
| 219 | |
| 220 if ('ImplementedInPrivateScript' in extended_attributes and | |
| 221 not idl_type.is_wrapper_type and | |
| 222 not idl_type.is_basic_type): | |
| 223 raise Exception('Private scripts supports only primitive types and DOM w
rappers.') | |
| 224 | |
| 225 default_cpp_value = argument.default_cpp_value | |
| 226 return { | |
| 227 'cpp_type': idl_type.cpp_type_args(extended_attributes=extended_attribut
es, | |
| 228 raw_type=True, | |
| 229 used_as_variadic_argument=argument.is
_variadic), | |
| 230 'cpp_value': this_cpp_value, | |
| 231 # FIXME: check that the default value's type is compatible with the argu
ment's | |
| 232 'default_value': default_cpp_value, | |
| 233 'enum_validation_expression': idl_type.enum_validation_expression, | |
| 234 'handle': '%sHandle' % argument.name, | |
| 235 # FIXME: remove once [Default] removed and just use argument.default_val
ue | |
| 236 'has_default': 'Default' in extended_attributes or default_cpp_value, | |
| 237 'has_type_checking_interface': | |
| 238 (has_extended_attribute_value(interface, 'TypeChecking', 'Interface'
) or | |
| 239 has_extended_attribute_value(method, 'TypeChecking', 'Interface'))
and | |
| 240 idl_type.is_wrapper_type, | |
| 241 'has_type_checking_unrestricted': | |
| 242 (has_extended_attribute_value(interface, 'TypeChecking', 'Unrestrict
ed') or | |
| 243 has_extended_attribute_value(method, 'TypeChecking', 'Unrestricted'
)) and | |
| 244 idl_type.name in ('Float', 'Double'), | |
| 245 # Dictionary is special-cased, but arrays and sequences shouldn't be | |
| 246 'idl_type': idl_type.base_type, | |
| 247 'idl_type_object': idl_type, | |
| 248 'index': index, | |
| 249 'is_clamp': 'Clamp' in extended_attributes, | |
| 250 'is_callback_interface': idl_type.is_callback_interface, | |
| 251 'is_nullable': idl_type.is_nullable, | |
| 252 'is_optional': argument.is_optional, | |
| 253 'is_variadic_wrapper_type': is_variadic_wrapper_type, | |
| 254 'is_wrapper_type': idl_type.is_wrapper_type, | |
| 255 'name': argument.name, | |
| 256 'private_script_cpp_value_to_v8_value': idl_type.cpp_value_to_v8_value( | |
| 257 argument.name, isolate='scriptState->isolate()', | |
| 258 creation_context='scriptState->context()->Global()'), | |
| 259 'v8_set_return_value': v8_set_return_value(interface.name, method, this_
cpp_value), | |
| 260 'v8_set_return_value_for_main_world': v8_set_return_value(interface.name
, method, this_cpp_value, for_main_world=True), | |
| 261 'v8_value_to_local_cpp_value': v8_value_to_local_cpp_value(argument, ind
ex, return_promise=return_promise), | |
| 262 'vector_type': 'Vector', | |
| 263 } | |
| 264 | |
| 265 | |
| 266 def argument_declarations_for_private_script(interface, method): | |
| 267 argument_declarations = ['LocalFrame* frame'] | |
| 268 argument_declarations.append('%s* holderImpl' % interface.name) | |
| 269 argument_declarations.extend(['%s %s' % (argument.idl_type.cpp_type_args( | |
| 270 used_as_rvalue_type=True), argument.name) for argument in method.argumen
ts]) | |
| 271 if method.idl_type.name != 'void': | |
| 272 argument_declarations.append('%s* %s' % (method.idl_type.cpp_type, 'resu
lt')) | |
| 273 return argument_declarations | |
| 274 | |
| 275 | |
| 276 ################################################################################ | |
| 277 # Value handling | |
| 278 ################################################################################ | |
| 279 | |
| 280 def cpp_value(interface, method, number_of_arguments): | |
| 281 def cpp_argument(argument): | |
| 282 idl_type = argument.idl_type | |
| 283 if idl_type.name == 'EventListener': | |
| 284 return argument.name | |
| 285 if (idl_type.is_callback_interface or | |
| 286 idl_type.name in ['NodeFilter', 'NodeFilterOrNull']): | |
| 287 # FIXME: remove this special case | |
| 288 return '%s.release()' % argument.name | |
| 289 return argument.name | |
| 290 | |
| 291 # Truncate omitted optional arguments | |
| 292 arguments = method.arguments[:number_of_arguments] | |
| 293 cpp_arguments = [] | |
| 294 if 'ImplementedInPrivateScript' in method.extended_attributes: | |
| 295 cpp_arguments.append('toFrameIfNotDetached(info.GetIsolate()->GetCurrent
Context())') | |
| 296 cpp_arguments.append('impl') | |
| 297 | |
| 298 if method.is_constructor: | |
| 299 call_with_values = interface.extended_attributes.get('ConstructorCallWit
h') | |
| 300 else: | |
| 301 call_with_values = method.extended_attributes.get('CallWith') | |
| 302 cpp_arguments.extend(v8_utilities.call_with_arguments(call_with_values)) | |
| 303 | |
| 304 # Members of IDL partial interface definitions are implemented in C++ as | |
| 305 # static member functions, which for instance members (non-static members) | |
| 306 # take *impl as their first argument | |
| 307 if ('PartialInterfaceImplementedAs' in method.extended_attributes and | |
| 308 not 'ImplementedInPrivateScript' in method.extended_attributes and | |
| 309 not method.is_static): | |
| 310 cpp_arguments.append('*impl') | |
| 311 cpp_arguments.extend(cpp_argument(argument) for argument in arguments) | |
| 312 | |
| 313 this_union_arguments = method.idl_type and method.idl_type.union_arguments | |
| 314 if this_union_arguments: | |
| 315 cpp_arguments.extend([member_argument['cpp_value'] | |
| 316 for member_argument in this_union_arguments]) | |
| 317 | |
| 318 if 'ImplementedInPrivateScript' in method.extended_attributes: | |
| 319 if method.idl_type.name != 'void': | |
| 320 cpp_arguments.append('&result') | |
| 321 elif ('RaisesException' in method.extended_attributes or | |
| 322 (method.is_constructor and | |
| 323 has_extended_attribute_value(interface, 'RaisesException', 'Constructor
'))): | |
| 324 cpp_arguments.append('exceptionState') | |
| 325 | |
| 326 if method.name == 'Constructor': | |
| 327 base_name = 'create' | |
| 328 elif method.name == 'NamedConstructor': | |
| 329 base_name = 'createForJSConstructor' | |
| 330 elif 'ImplementedInPrivateScript' in method.extended_attributes: | |
| 331 base_name = '%sMethod' % method.name | |
| 332 else: | |
| 333 base_name = v8_utilities.cpp_name(method) | |
| 334 | |
| 335 cpp_method_name = v8_utilities.scoped_name(interface, method, base_name) | |
| 336 return '%s(%s)' % (cpp_method_name, ', '.join(cpp_arguments)) | |
| 337 | |
| 338 | |
| 339 def v8_set_return_value(interface_name, method, cpp_value, for_main_world=False)
: | |
| 340 idl_type = method.idl_type | |
| 341 extended_attributes = method.extended_attributes | |
| 342 if not idl_type or idl_type.name == 'void': | |
| 343 # Constructors and void methods don't have a return type | |
| 344 return None | |
| 345 | |
| 346 if ('ImplementedInPrivateScript' in extended_attributes and | |
| 347 not idl_type.is_wrapper_type and | |
| 348 not idl_type.is_basic_type): | |
| 349 raise Exception('Private scripts supports only primitive types and DOM w
rappers.') | |
| 350 | |
| 351 release = False | |
| 352 # [CallWith=ScriptState], [RaisesException] | |
| 353 if use_local_result(method): | |
| 354 if idl_type.is_explicit_nullable: | |
| 355 # result is of type Nullable<T> | |
| 356 cpp_value = 'result.get()' | |
| 357 else: | |
| 358 cpp_value = 'result' | |
| 359 release = idl_type.release | |
| 360 | |
| 361 script_wrappable = 'impl' if inherits_interface(interface_name, 'Node') else
'' | |
| 362 return idl_type.v8_set_return_value(cpp_value, extended_attributes, script_w
rappable=script_wrappable, release=release, for_main_world=for_main_world) | |
| 363 | |
| 364 | |
| 365 def v8_value_to_local_cpp_variadic_value(argument, index, return_promise): | |
| 366 assert argument.is_variadic | |
| 367 idl_type = argument.idl_type | |
| 368 | |
| 369 suffix = '' | |
| 370 | |
| 371 macro = 'TONATIVE_VOID' | |
| 372 macro_args = [ | |
| 373 argument.name, | |
| 374 'toNativeArguments<%s>(info, %s)' % (idl_type.cpp_type, index), | |
| 375 ] | |
| 376 | |
| 377 if return_promise: | |
| 378 suffix += '_PROMISE' | |
| 379 macro_args.append('info') | |
| 380 | |
| 381 suffix += '_INTERNAL' | |
| 382 | |
| 383 return '%s%s(%s)' % (macro, suffix, ', '.join(macro_args)) | |
| 384 | |
| 385 | |
| 386 def v8_value_to_local_cpp_value(argument, index, return_promise=False): | |
| 387 extended_attributes = argument.extended_attributes | |
| 388 idl_type = argument.idl_type | |
| 389 name = argument.name | |
| 390 if argument.is_variadic: | |
| 391 return v8_value_to_local_cpp_variadic_value(argument, index, return_prom
ise) | |
| 392 return idl_type.v8_value_to_local_cpp_value(extended_attributes, 'info[%s]'
% index, | |
| 393 name, index=index, declare_varia
ble=False, return_promise=return_promise) | |
| 394 | |
| 395 | |
| 396 ################################################################################ | |
| 397 # Auxiliary functions | |
| 398 ################################################################################ | |
| 399 | |
| 400 # [NotEnumerable] | |
| 401 def property_attributes(method): | |
| 402 extended_attributes = method.extended_attributes | |
| 403 property_attributes_list = [] | |
| 404 if 'NotEnumerable' in extended_attributes: | |
| 405 property_attributes_list.append('v8::DontEnum') | |
| 406 if 'Unforgeable' in extended_attributes: | |
| 407 property_attributes_list.append('v8::ReadOnly') | |
| 408 if property_attributes_list: | |
| 409 property_attributes_list.insert(0, 'v8::DontDelete') | |
| 410 return property_attributes_list | |
| 411 | |
| 412 | |
| 413 def union_member_argument_context(idl_type, index): | |
| 414 """Returns a context of union member for argument.""" | |
| 415 this_cpp_value = 'result%d' % index | |
| 416 this_cpp_type = idl_type.cpp_type | |
| 417 this_cpp_type_initializer = idl_type.cpp_type_initializer | |
| 418 cpp_return_value = this_cpp_value | |
| 419 | |
| 420 if not idl_type.cpp_type_has_null_value: | |
| 421 this_cpp_type = v8_types.cpp_template_type('Nullable', this_cpp_type) | |
| 422 this_cpp_type_initializer = '' | |
| 423 cpp_return_value = '%s.get()' % this_cpp_value | |
| 424 | |
| 425 if idl_type.is_string_type: | |
| 426 null_check_value = '!%s.isNull()' % this_cpp_value | |
| 427 else: | |
| 428 null_check_value = this_cpp_value | |
| 429 | |
| 430 return { | |
| 431 'cpp_type': this_cpp_type, | |
| 432 'cpp_type_initializer': this_cpp_type_initializer, | |
| 433 'cpp_value': this_cpp_value, | |
| 434 'null_check_value': null_check_value, | |
| 435 'v8_set_return_value': idl_type.v8_set_return_value( | |
| 436 cpp_value=cpp_return_value, | |
| 437 release=idl_type.release), | |
| 438 } | |
| 439 | |
| 440 | |
| 441 def union_arguments(idl_type): | |
| 442 return [union_member_argument_context(member_idl_type, index) | |
| 443 for index, member_idl_type | |
| 444 in enumerate(idl_type.member_types)] | |
| 445 | |
| 446 | |
| 447 def argument_default_cpp_value(argument): | |
| 448 if argument.idl_type.is_dictionary: | |
| 449 # We always create impl objects for IDL dictionaries. | |
| 450 return '%s::create()' % argument.idl_type.base_type | |
| 451 if not argument.default_value: | |
| 452 return None | |
| 453 return argument.idl_type.literal_cpp_value(argument.default_value) | |
| 454 | |
| 455 IdlTypeBase.union_arguments = None | |
| 456 IdlUnionType.union_arguments = property(union_arguments) | |
| 457 IdlArgument.default_cpp_value = property(argument_default_cpp_value) | |
| OLD | NEW |