| 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 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 if method.idl_type.name != 'void': | 278 if method.idl_type.name != 'void': |
| 279 argument_declarations.append('%s* %s' % (method.idl_type.cpp_type, 'resu
lt')) | 279 argument_declarations.append('%s* %s' % (method.idl_type.cpp_type, 'resu
lt')) |
| 280 return argument_declarations | 280 return argument_declarations |
| 281 | 281 |
| 282 | 282 |
| 283 ################################################################################ | 283 ################################################################################ |
| 284 # Value handling | 284 # Value handling |
| 285 ################################################################################ | 285 ################################################################################ |
| 286 | 286 |
| 287 def cpp_value(interface, method, number_of_arguments): | 287 def cpp_value(interface, method, number_of_arguments): |
| 288 def cpp_argument(argument): | |
| 289 idl_type = argument.idl_type | |
| 290 if idl_type.name == 'EventListener': | |
| 291 return argument.name | |
| 292 if (idl_type.name in ['NodeFilter', 'NodeFilterOrNull', | |
| 293 'XPathNSResolver', 'XPathNSResolverOrNull']): | |
| 294 # FIXME: remove this special case | |
| 295 return '%s.release()' % argument.name | |
| 296 return argument.name | |
| 297 | |
| 298 # Truncate omitted optional arguments | 288 # Truncate omitted optional arguments |
| 299 arguments = method.arguments[:number_of_arguments] | 289 arguments = method.arguments[:number_of_arguments] |
| 300 cpp_arguments = [] | 290 cpp_arguments = [] |
| 301 if 'ImplementedInPrivateScript' in method.extended_attributes: | 291 if 'ImplementedInPrivateScript' in method.extended_attributes: |
| 302 cpp_arguments.append('toLocalFrame(toFrameIfNotDetached(info.GetIsolate(
)->GetCurrentContext()))') | 292 cpp_arguments.append('toLocalFrame(toFrameIfNotDetached(info.GetIsolate(
)->GetCurrentContext()))') |
| 303 cpp_arguments.append('impl') | 293 cpp_arguments.append('impl') |
| 304 | 294 |
| 305 if method.is_constructor: | 295 if method.is_constructor: |
| 306 call_with_values = interface.extended_attributes.get('ConstructorCallWit
h') | 296 call_with_values = interface.extended_attributes.get('ConstructorCallWit
h') |
| 307 else: | 297 else: |
| 308 call_with_values = method.extended_attributes.get('CallWith') | 298 call_with_values = method.extended_attributes.get('CallWith') |
| 309 cpp_arguments.extend(v8_utilities.call_with_arguments(call_with_values)) | 299 cpp_arguments.extend(v8_utilities.call_with_arguments(call_with_values)) |
| 310 | 300 |
| 311 # Members of IDL partial interface definitions are implemented in C++ as | 301 # Members of IDL partial interface definitions are implemented in C++ as |
| 312 # static member functions, which for instance members (non-static members) | 302 # static member functions, which for instance members (non-static members) |
| 313 # take *impl as their first argument | 303 # take *impl as their first argument |
| 314 if ('PartialInterfaceImplementedAs' in method.extended_attributes and | 304 if ('PartialInterfaceImplementedAs' in method.extended_attributes and |
| 315 'ImplementedInPrivateScript' not in method.extended_attributes and | 305 'ImplementedInPrivateScript' not in method.extended_attributes and |
| 316 not method.is_static): | 306 not method.is_static): |
| 317 cpp_arguments.append('*impl') | 307 cpp_arguments.append('*impl') |
| 318 cpp_arguments.extend(cpp_argument(argument) for argument in arguments) | 308 cpp_arguments.extend(argument.name for argument in arguments) |
| 319 | 309 |
| 320 if 'ImplementedInPrivateScript' in method.extended_attributes: | 310 if 'ImplementedInPrivateScript' in method.extended_attributes: |
| 321 if method.idl_type.name != 'void': | 311 if method.idl_type.name != 'void': |
| 322 cpp_arguments.append('&result') | 312 cpp_arguments.append('&result') |
| 323 elif ('RaisesException' in method.extended_attributes or | 313 elif ('RaisesException' in method.extended_attributes or |
| 324 (method.is_constructor and | 314 (method.is_constructor and |
| 325 has_extended_attribute_value(interface, 'RaisesException', 'Construct
or'))): | 315 has_extended_attribute_value(interface, 'RaisesException', 'Construct
or'))): |
| 326 cpp_arguments.append('exceptionState') | 316 cpp_arguments.append('exceptionState') |
| 327 | 317 |
| 328 # If a method returns an IDL dictionary or union type, the return value is | 318 # If a method returns an IDL dictionary or union type, the return value is |
| (...skipping 20 matching lines...) Expand all Loading... |
| 349 extended_attributes = method.extended_attributes | 339 extended_attributes = method.extended_attributes |
| 350 if not idl_type or idl_type.name == 'void': | 340 if not idl_type or idl_type.name == 'void': |
| 351 # Constructors and void methods don't have a return type | 341 # Constructors and void methods don't have a return type |
| 352 return None | 342 return None |
| 353 | 343 |
| 354 if ('ImplementedInPrivateScript' in extended_attributes and | 344 if ('ImplementedInPrivateScript' in extended_attributes and |
| 355 not idl_type.is_wrapper_type and | 345 not idl_type.is_wrapper_type and |
| 356 not idl_type.is_basic_type): | 346 not idl_type.is_basic_type): |
| 357 raise Exception('Private scripts supports only primitive types and DOM w
rappers.') | 347 raise Exception('Private scripts supports only primitive types and DOM w
rappers.') |
| 358 | 348 |
| 359 release = False | |
| 360 # [CallWith=ScriptState], [RaisesException] | 349 # [CallWith=ScriptState], [RaisesException] |
| 361 if use_local_result(method): | 350 if use_local_result(method): |
| 362 if idl_type.is_explicit_nullable: | 351 if idl_type.is_explicit_nullable: |
| 363 # result is of type Nullable<T> | 352 # result is of type Nullable<T> |
| 364 cpp_value = 'result.get()' | 353 cpp_value = 'result.get()' |
| 365 else: | 354 else: |
| 366 cpp_value = 'result' | 355 cpp_value = 'result' |
| 367 release = idl_type.release | |
| 368 | 356 |
| 369 script_wrappable = 'impl' if inherits_interface(interface_name, 'Node') else
'' | 357 script_wrappable = 'impl' if inherits_interface(interface_name, 'Node') else
'' |
| 370 return idl_type.v8_set_return_value(cpp_value, extended_attributes, script_w
rappable=script_wrappable, release=release, for_main_world=for_main_world, is_st
atic=method.is_static) | 358 return idl_type.v8_set_return_value(cpp_value, extended_attributes, script_w
rappable=script_wrappable, for_main_world=for_main_world, is_static=method.is_st
atic) |
| 371 | 359 |
| 372 | 360 |
| 373 def v8_value_to_local_cpp_variadic_value(method, argument, index, return_promise
): | 361 def v8_value_to_local_cpp_variadic_value(method, argument, index, return_promise
): |
| 374 assert argument.is_variadic | 362 assert argument.is_variadic |
| 375 idl_type = argument.idl_type | 363 idl_type = argument.idl_type |
| 376 this_cpp_type = idl_type.cpp_type | 364 this_cpp_type = idl_type.cpp_type |
| 377 | 365 |
| 378 if method.returns_promise: | 366 if method.returns_promise: |
| 379 check_expression = 'exceptionState.hadException()' | 367 check_expression = 'exceptionState.hadException()' |
| 380 else: | 368 else: |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 471 return method.idl_type and method.idl_type.name == 'Promise' | 459 return method.idl_type and method.idl_type.name == 'Promise' |
| 472 | 460 |
| 473 IdlOperation.returns_promise = property(method_returns_promise) | 461 IdlOperation.returns_promise = property(method_returns_promise) |
| 474 | 462 |
| 475 | 463 |
| 476 def argument_conversion_needs_exception_state(method, argument): | 464 def argument_conversion_needs_exception_state(method, argument): |
| 477 idl_type = argument.idl_type | 465 idl_type = argument.idl_type |
| 478 return (idl_type.v8_conversion_needs_exception_state or | 466 return (idl_type.v8_conversion_needs_exception_state or |
| 479 argument.is_variadic or | 467 argument.is_variadic or |
| 480 (method.returns_promise and idl_type.is_string_type)) | 468 (method.returns_promise and idl_type.is_string_type)) |
| OLD | NEW |