| 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 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 # Only expose as optional if no default value. | 195 # Only expose as optional if no default value. |
| 196 'is_optional': argument.is_optional and not (this_has_default or argumen
t.default_value), | 196 'is_optional': argument.is_optional and not (this_has_default or argumen
t.default_value), |
| 197 'is_strict_type_checking': 'StrictTypeChecking' in extended_attributes, | 197 'is_strict_type_checking': 'StrictTypeChecking' in extended_attributes, |
| 198 'is_variadic_wrapper_type': is_variadic_wrapper_type, | 198 'is_variadic_wrapper_type': is_variadic_wrapper_type, |
| 199 'vector_type': 'WillBeHeapVector' if use_heap_vector_type else 'Vector', | 199 'vector_type': 'WillBeHeapVector' if use_heap_vector_type else 'Vector', |
| 200 'is_wrapper_type': idl_type.is_wrapper_type, | 200 'is_wrapper_type': idl_type.is_wrapper_type, |
| 201 'name': argument.name, | 201 'name': argument.name, |
| 202 'dart_set_return_value_for_main_world': dart_set_return_value(interface.
name, method, this_cpp_value, for_main_world=True), | 202 'dart_set_return_value_for_main_world': dart_set_return_value(interface.
name, method, this_cpp_value, for_main_world=True), |
| 203 'dart_set_return_value': dart_set_return_value(interface.name, method, t
his_cpp_value), | 203 'dart_set_return_value': dart_set_return_value(interface.name, method, t
his_cpp_value), |
| 204 'arg_index': arg_index, | 204 'arg_index': arg_index, |
| 205 'dart_value_to_local_cpp_value': dart_value_to_local_cpp_value(argument,
arg_index, auto_scope), | 205 'dart_value_to_local_cpp_value': dart_value_to_local_cpp_value(interface
, argument, arg_index, auto_scope), |
| 206 } | 206 } |
| 207 return argument_data | 207 return argument_data |
| 208 | 208 |
| 209 | 209 |
| 210 ################################################################################ | 210 ################################################################################ |
| 211 # Value handling | 211 # Value handling |
| 212 ################################################################################ | 212 ################################################################################ |
| 213 | 213 |
| 214 def cpp_value(interface, method, number_of_arguments): | 214 def cpp_value(interface, method, number_of_arguments): |
| 215 def cpp_argument(argument): | 215 def cpp_argument(argument): |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 | 279 |
| 280 auto_scope = not 'DartNoAutoScope' in extended_attributes | 280 auto_scope = not 'DartNoAutoScope' in extended_attributes |
| 281 script_wrappable = 'impl' if inherits_interface(interface_name, 'Node') else
'' | 281 script_wrappable = 'impl' if inherits_interface(interface_name, 'Node') else
'' |
| 282 return idl_type.dart_set_return_value(cpp_value, extended_attributes, | 282 return idl_type.dart_set_return_value(cpp_value, extended_attributes, |
| 283 script_wrappable=script_wrappable, | 283 script_wrappable=script_wrappable, |
| 284 release=release, | 284 release=release, |
| 285 for_main_world=for_main_world, | 285 for_main_world=for_main_world, |
| 286 auto_scope=auto_scope) | 286 auto_scope=auto_scope) |
| 287 | 287 |
| 288 | 288 |
| 289 def dart_value_to_local_cpp_value(argument, index, auto_scope=True): | 289 def dart_value_to_local_cpp_value(interface, argument, index, auto_scope=True): |
| 290 extended_attributes = argument.extended_attributes | 290 extended_attributes = argument.extended_attributes |
| 291 interface_extended_attributes = interface.extended_attributes |
| 291 idl_type = argument.idl_type | 292 idl_type = argument.idl_type |
| 292 name = argument.name | 293 name = argument.name |
| 293 # TODO(terry): Variadic arguments are not handled but treated as one argumen
t. | 294 # TODO(terry): Variadic arguments are not handled but treated as one argumen
t. |
| 294 # if argument.is_variadic: | 295 # if argument.is_variadic: |
| 295 # vector_type = 'WillBeHeapVector' if idl_type.is_will_be_garbage_col
lected else 'Vector' | 296 # vector_type = 'WillBeHeapVector' if idl_type.is_will_be_garbage_col
lected else 'Vector' |
| 296 # return 'V8TRYCATCH_VOID({vector_type}<{cpp_type}>, {name}, toNative
Arguments<{cpp_type}>(info, {index}))'.format( | 297 # return 'V8TRYCATCH_VOID({vector_type}<{cpp_type}>, {name}, toNative
Arguments<{cpp_type}>(info, {index}))'.format( |
| 297 # cpp_type=idl_type.cpp_type, name=name, index=index, vector_
type=vector_type) | 298 # cpp_type=idl_type.cpp_type, name=name, index=index, vector_
type=vector_type) |
| 298 | 299 |
| 299 # FIXME: V8 has some special logic around the addEventListener and | 300 # FIXME: V8 has some special logic around the addEventListener and |
| 300 # removeEventListener methods that should be added in somewhere. | 301 # removeEventListener methods that should be added in somewhere. |
| 301 # There is also some logic in systemnative.py to force a null check | 302 # There is also some logic in systemnative.py to force a null check |
| 302 # for the useCapture argument of those same methods that we may need to | 303 # for the useCapture argument of those same methods that we may need to |
| 303 # pull over. | 304 # pull over. |
| 304 null_check = (argument.is_optional and \ | 305 null_check = (argument.is_optional and \ |
| 305 (idl_type.is_callback_interface or idl_type == 'Dictionary'))
or \ | 306 (idl_type.is_callback_interface or idl_type == 'Dictionary'))
or \ |
| 306 (argument.default_value and argument.default_value.is_null) | 307 (argument.default_value and argument.default_value.is_null) |
| 307 | 308 |
| 308 return idl_type.dart_value_to_local_cpp_value( | 309 return idl_type.dart_value_to_local_cpp_value( |
| 309 argument.extended_attributes, name, null_check, | 310 interface_extended_attributes, extended_attributes, name, null_check, |
| 310 index=index, auto_scope=auto_scope) | 311 index=index, auto_scope=auto_scope) |
| 311 | 312 |
| 312 | 313 |
| 313 ################################################################################ | 314 ################################################################################ |
| 314 # Auxiliary functions | 315 # Auxiliary functions |
| 315 ################################################################################ | 316 ################################################################################ |
| 316 | 317 |
| 317 # [NotEnumerable] | 318 # [NotEnumerable] |
| 318 def property_attributes(method): | 319 def property_attributes(method): |
| 319 extended_attributes = method.extended_attributes | 320 extended_attributes = method.extended_attributes |
| 320 property_attributes_list = [] | 321 property_attributes_list = [] |
| 321 if 'NotEnumerable' in extended_attributes: | 322 if 'NotEnumerable' in extended_attributes: |
| 322 property_attributes_list.append('v8::DontEnum') | 323 property_attributes_list.append('v8::DontEnum') |
| 323 if 'ReadOnly' in extended_attributes: | 324 if 'ReadOnly' in extended_attributes: |
| 324 property_attributes_list.append('v8::ReadOnly') | 325 property_attributes_list.append('v8::ReadOnly') |
| 325 if property_attributes_list: | 326 if property_attributes_list: |
| 326 property_attributes_list.insert(0, 'v8::DontDelete') | 327 property_attributes_list.insert(0, 'v8::DontDelete') |
| 327 return property_attributes_list | 328 return property_attributes_list |
| 328 | 329 |
| 329 | 330 |
| 330 def union_arguments(idl_type): | 331 def union_arguments(idl_type): |
| 331 """Return list of ['result0Enabled', 'result0', 'result1Enabled', ...] for u
nion types, for use in setting return value""" | 332 """Return list of ['result0Enabled', 'result0', 'result1Enabled', ...] for u
nion types, for use in setting return value""" |
| 332 return [arg | 333 return [arg |
| 333 for i in range(len(idl_type.member_types)) | 334 for i in range(len(idl_type.member_types)) |
| 334 for arg in ['result%sEnabled' % i, 'result%s' % i]] | 335 for arg in ['result%sEnabled' % i, 'result%s' % i]] |
| 335 | 336 |
| 336 IdlType.union_arguments = property(lambda self: None) | 337 IdlType.union_arguments = property(lambda self: None) |
| 337 IdlUnionType.union_arguments = property(union_arguments) | 338 IdlUnionType.union_arguments = property(union_arguments) |
| OLD | NEW |