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 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
381 def v8_value_to_cpp_value_array_or_sequence(array_or_sequence_type, v8_value, in
dex): | 381 def v8_value_to_cpp_value_array_or_sequence(array_or_sequence_type, v8_value, in
dex): |
382 # Index is None for setters, index (starting at 0) for method arguments, | 382 # Index is None for setters, index (starting at 0) for method arguments, |
383 # and is used to provide a human-readable exception message | 383 # and is used to provide a human-readable exception message |
384 if index is None: | 384 if index is None: |
385 index = 0 # special case, meaning "setter" | 385 index = 0 # special case, meaning "setter" |
386 else: | 386 else: |
387 index += 1 # human-readable index | 387 index += 1 # human-readable index |
388 if (array_or_sequence_type.is_interface_type and | 388 if (array_or_sequence_type.is_interface_type and |
389 array_or_sequence_type.name != 'Dictionary'): | 389 array_or_sequence_type.name != 'Dictionary'): |
390 this_cpp_type = None | 390 this_cpp_type = None |
391 ref_ptr_type = 'Member' if array_or_sequence_type.is_will_be_garbage_col
lected else 'RefPtr' | 391 ref_ptr_type = 'RefPtrWillBeMember' if array_or_sequence_type.is_will_be
_garbage_collected else 'RefPtr' |
392 expression_format = '(to{ref_ptr_type}NativeArray<{array_or_sequence_typ
e}, V8{array_or_sequence_type}>({v8_value}, {index}, info.GetIsolate()))' | 392 expression_format = '(to{ref_ptr_type}NativeArray<{array_or_sequence_typ
e}, V8{array_or_sequence_type}>({v8_value}, {index}, info.GetIsolate()))' |
393 add_includes_for_type(array_or_sequence_type) | 393 add_includes_for_type(array_or_sequence_type) |
394 else: | 394 else: |
395 ref_ptr_type = None | 395 ref_ptr_type = None |
396 this_cpp_type = array_or_sequence_type.cpp_type | 396 this_cpp_type = array_or_sequence_type.cpp_type |
397 expression_format = 'toNativeArray<{cpp_type}>({v8_value}, {index}, info
.GetIsolate())' | 397 expression_format = 'toNativeArray<{cpp_type}>({v8_value}, {index}, info
.GetIsolate())' |
398 expression = expression_format.format(array_or_sequence_type=array_or_sequen
ce_type.name, cpp_type=this_cpp_type, index=index, ref_ptr_type=ref_ptr_type, v8
_value=v8_value) | 398 expression = expression_format.format(array_or_sequence_type=array_or_sequen
ce_type.name, cpp_type=this_cpp_type, index=index, ref_ptr_type=ref_ptr_type, v8
_value=v8_value) |
399 return expression | 399 return expression |
400 | 400 |
401 | 401 |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
602 def cpp_value_to_v8_value(idl_type, cpp_value, isolate='info.GetIsolate()', crea
tion_context='', extended_attributes=None): | 602 def cpp_value_to_v8_value(idl_type, cpp_value, isolate='info.GetIsolate()', crea
tion_context='', extended_attributes=None): |
603 """Returns an expression that converts a C++ value to a V8 value.""" | 603 """Returns an expression that converts a C++ value to a V8 value.""" |
604 # the isolate parameter is needed for callback interfaces | 604 # the isolate parameter is needed for callback interfaces |
605 idl_type, cpp_value = preprocess_idl_type_and_value(idl_type, cpp_value, ext
ended_attributes) | 605 idl_type, cpp_value = preprocess_idl_type_and_value(idl_type, cpp_value, ext
ended_attributes) |
606 this_v8_conversion_type = idl_type.v8_conversion_type(extended_attributes) | 606 this_v8_conversion_type = idl_type.v8_conversion_type(extended_attributes) |
607 format_string = CPP_VALUE_TO_V8_VALUE[this_v8_conversion_type] | 607 format_string = CPP_VALUE_TO_V8_VALUE[this_v8_conversion_type] |
608 statement = format_string.format(cpp_value=cpp_value, isolate=isolate, creat
ion_context=creation_context) | 608 statement = format_string.format(cpp_value=cpp_value, isolate=isolate, creat
ion_context=creation_context) |
609 return statement | 609 return statement |
610 | 610 |
611 IdlType.cpp_value_to_v8_value = cpp_value_to_v8_value | 611 IdlType.cpp_value_to_v8_value = cpp_value_to_v8_value |
OLD | NEW |