Chromium Code Reviews| Index: Source/bindings/scripts/v8_types.py |
| diff --git a/Source/bindings/scripts/v8_types.py b/Source/bindings/scripts/v8_types.py |
| index cae0e8926a7013adb0674d7e7833f28957ce5f8d..6acb14a7b74a633209c2f80e6487cdaf994b68cb 100644 |
| --- a/Source/bindings/scripts/v8_types.py |
| +++ b/Source/bindings/scripts/v8_types.py |
| @@ -248,8 +248,15 @@ CPP_SPECIAL_CONVERSION_RULES = { |
| } |
| -def cpp_type(idl_type, extended_attributes=None, used_as_argument=False): |
| - """Returns C++ type corresponding to IDL type.""" |
| +def cpp_type(idl_type, extended_attributes=None, used_as_argument=False, used_as_member=False): |
| + """Returns C++ type corresponding to IDL type. |
| + |
| + Args: |
| + used_as_argument: bool, True if idl_type's raw/primitive C++ type |
| + should be returned. |
| + used_as_member: bool, if idl_type is the type of an array or sequence |
| + (which maps to some vector representation in C++.) |
| + """ |
| def string_mode(): |
| # FIXME: the Web IDL spec requires 'EmptyString', not 'NullString', |
| # but we use NullString for performance. |
| @@ -283,7 +290,9 @@ def cpp_type(idl_type, extended_attributes=None, used_as_argument=False): |
| for union_member_type in idl_type.union_member_types) |
| this_array_or_sequence_type = array_or_sequence_type(idl_type) |
| if this_array_or_sequence_type: |
| - return cpp_template_type('Vector', cpp_type(this_array_or_sequence_type)) |
| + will_be_garbage_collected = is_will_be_garbage_collected(this_array_or_sequence_type) |
| + vector_type = 'WillBeHeapVector' if will_be_garbage_collected else 'Vector' |
| + return cpp_template_type(vector_type, cpp_type(this_array_or_sequence_type, used_as_member=will_be_garbage_collected)) |
| if is_typed_array_type(idl_type) and used_as_argument: |
| return idl_type + '*' |
| @@ -292,7 +301,8 @@ def cpp_type(idl_type, extended_attributes=None, used_as_argument=False): |
| if used_as_argument: |
| return implemented_as_class + '*' |
| if is_will_be_garbage_collected(idl_type): |
| - return cpp_template_type('RefPtrWillBeRawPtr', implemented_as_class) |
| + ref_ptr_type = 'RefPtrWillBeMember' if used_as_member else 'RefPtrWillBeRawPtr' |
| + return cpp_template_type(ref_ptr_type, implemented_as_class) |
| return cpp_template_type('RefPtr', implemented_as_class) |
| # Default, assume native type is a pointer with same type name as idl type |
| return idl_type + '*' |
| @@ -468,15 +478,17 @@ def v8_value_to_cpp_value_array_or_sequence(this_array_or_sequence_type, v8_valu |
| index = 0 # special case, meaning "setter" |
| else: |
| index += 1 # human-readable index |
| + ref_ptr_type = None |
|
Nils Barth (inactive)
2014/03/05 07:49:13
Could you move this assignment into the else: bloc
sof
2014/03/05 08:15:17
Done; it's just a style i prefer when used in mode
Nils Barth (inactive)
2014/03/05 09:20:10
Understood; hopefully logic in CG isn't too comple
|
| if (is_interface_type(this_array_or_sequence_type) and |
| this_array_or_sequence_type != 'Dictionary'): |
| this_cpp_type = None |
| - expression_format = '(toRefPtrNativeArray<{array_or_sequence_type}, V8{array_or_sequence_type}>({v8_value}, {index}, info.GetIsolate()))' |
| + ref_ptr_type = 'Member' if is_will_be_garbage_collected(this_array_or_sequence_type) else 'Ref' |
| + expression_format = '(to{ref_ptr_type}PtrNativeArray<{array_or_sequence_type}, V8{array_or_sequence_type}>({v8_value}, {index}, info.GetIsolate()))' |
| add_includes_for_type(this_array_or_sequence_type) |
| else: |
| this_cpp_type = cpp_type(this_array_or_sequence_type) |
| expression_format = 'toNativeArray<{cpp_type}>({v8_value}, {index}, info.GetIsolate())' |
| - expression = expression_format.format(array_or_sequence_type=this_array_or_sequence_type, cpp_type=this_cpp_type, index=index, v8_value=v8_value) |
| + expression = expression_format.format(array_or_sequence_type=this_array_or_sequence_type, cpp_type=this_cpp_type, index=index, ref_ptr_type=ref_ptr_type, v8_value=v8_value) |
| return expression |