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 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
303 | 303 |
304 IdlType.is_will_be_garbage_collected = property( | 304 IdlType.is_will_be_garbage_collected = property( |
305 lambda self: self.base_type in IdlType.will_be_garbage_collected_types) | 305 lambda self: self.base_type in IdlType.will_be_garbage_collected_types) |
306 | 306 |
307 IdlType.set_will_be_garbage_collected_types = classmethod( | 307 IdlType.set_will_be_garbage_collected_types = classmethod( |
308 lambda cls, new_will_be_garbage_collected_types: | 308 lambda cls, new_will_be_garbage_collected_types: |
309 cls.will_be_garbage_collected_types.update(new_will_be_garbage_collected _types)) | 309 cls.will_be_garbage_collected_types.update(new_will_be_garbage_collected _types)) |
310 | 310 |
311 | 311 |
312 def gc_type(idl_type): | 312 def gc_type(idl_type): |
313 if idl_type.is_garbage_collected or idl_type.is_dictionary: | 313 if idl_type.is_garbage_collected or idl_type.is_dictionary or idl_type.is_un ion_type: |
haraken
2015/05/01 14:58:13
bashi-san@: Maybe would it make more sense to set
bashi
2015/05/07 23:59:23
Probably, but we might want to seek a better namin
| |
314 return 'GarbageCollectedObject' | 314 return 'GarbageCollectedObject' |
315 if idl_type.is_will_be_garbage_collected: | 315 if idl_type.is_will_be_garbage_collected: |
316 return 'WillBeGarbageCollectedObject' | 316 return 'WillBeGarbageCollectedObject' |
317 return 'RefCountedObject' | 317 return 'RefCountedObject' |
318 | 318 |
319 IdlTypeBase.gc_type = property(gc_type) | 319 IdlTypeBase.gc_type = property(gc_type) |
320 | 320 |
321 | 321 |
322 def is_traceable(idl_type): | 322 def is_traceable(idl_type): |
323 return (idl_type.is_garbage_collected | 323 return (idl_type.is_garbage_collected |
324 or idl_type.is_will_be_garbage_collected | 324 or idl_type.is_will_be_garbage_collected |
325 or idl_type.is_dictionary) | 325 or idl_type.is_dictionary |
326 or idl_type.is_union_type) | |
326 | 327 |
327 IdlTypeBase.is_traceable = property(is_traceable) | 328 IdlTypeBase.is_traceable = property(is_traceable) |
328 IdlUnionType.is_traceable = property( | 329 IdlUnionType.is_traceable = property( |
329 lambda self: any((member_type.is_traceable for member_type in self.member_ty pes))) | 330 lambda self: any((member_type.is_traceable for member_type in self.member_ty pes))) |
330 IdlArrayOrSequenceType.is_traceable = property( | 331 IdlArrayOrSequenceType.is_traceable = property( |
331 lambda self: self.element_type.is_traceable) | 332 lambda self: self.element_type.is_traceable) |
332 | 333 |
333 | 334 |
334 ################################################################################ | 335 ################################################################################ |
335 # Includes | 336 # Includes |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
583 # and is used to provide a human-readable exception message | 584 # and is used to provide a human-readable exception message |
584 if index is None: | 585 if index is None: |
585 index = 0 # special case, meaning "setter" | 586 index = 0 # special case, meaning "setter" |
586 else: | 587 else: |
587 index += 1 # human-readable index | 588 index += 1 # human-readable index |
588 if (native_array_element_type.is_interface_type and | 589 if (native_array_element_type.is_interface_type and |
589 native_array_element_type.name != 'Dictionary'): | 590 native_array_element_type.name != 'Dictionary'): |
590 this_cpp_type = None | 591 this_cpp_type = None |
591 ref_ptr_type = cpp_ptr_type('RefPtr', 'Member', native_array_element_typ e.gc_type) | 592 ref_ptr_type = cpp_ptr_type('RefPtr', 'Member', native_array_element_typ e.gc_type) |
592 expression_format = '(to{ref_ptr_type}NativeArray<{native_array_element_ type}, V8{native_array_element_type}>({v8_value}, {index}, {isolate}, exceptionS tate))' | 593 expression_format = '(to{ref_ptr_type}NativeArray<{native_array_element_ type}, V8{native_array_element_type}>({v8_value}, {index}, {isolate}, exceptionS tate))' |
593 elif native_array_element_type.is_dictionary: | 594 elif native_array_element_type.is_dictionary or native_array_element_type.is _union_type: |
594 ref_ptr_type = None | 595 ref_ptr_type = None |
595 this_cpp_type = native_array_element_type.cpp_type | 596 this_cpp_type = native_array_element_type.cpp_type |
596 expression_format = 'toImplHeapArray<{cpp_type}>({v8_value}, {index}, {i solate}, exceptionState)' | 597 expression_format = 'toImplHeapArray<{cpp_type}>({v8_value}, {index}, {i solate}, exceptionState)' |
597 else: | 598 else: |
598 ref_ptr_type = None | 599 ref_ptr_type = None |
599 this_cpp_type = native_array_element_type.cpp_type | 600 this_cpp_type = native_array_element_type.cpp_type |
600 expression_format = 'toImplArray<{cpp_type}>({v8_value}, {index}, {isola te}, exceptionState)' | 601 expression_format = 'toImplArray<{cpp_type}>({v8_value}, {index}, {isola te}, exceptionState)' |
601 expression = expression_format.format(native_array_element_type=native_array _element_type.name, cpp_type=this_cpp_type, index=index, ref_ptr_type=ref_ptr_ty pe, v8_value=v8_value, isolate=isolate) | 602 expression = expression_format.format(native_array_element_type=native_array _element_type.name, cpp_type=this_cpp_type, index=index, ref_ptr_type=ref_ptr_ty pe, v8_value=v8_value, isolate=isolate) |
602 return expression | 603 return expression |
603 | 604 |
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
978 number_of_nullable_member_types_union) | 979 number_of_nullable_member_types_union) |
979 | 980 |
980 | 981 |
981 def includes_nullable_type_union(idl_type): | 982 def includes_nullable_type_union(idl_type): |
982 # http://heycam.github.io/webidl/#dfn-includes-a-nullable-type | 983 # http://heycam.github.io/webidl/#dfn-includes-a-nullable-type |
983 return idl_type.number_of_nullable_member_types == 1 | 984 return idl_type.number_of_nullable_member_types == 1 |
984 | 985 |
985 IdlTypeBase.includes_nullable_type = False | 986 IdlTypeBase.includes_nullable_type = False |
986 IdlNullableType.includes_nullable_type = True | 987 IdlNullableType.includes_nullable_type = True |
987 IdlUnionType.includes_nullable_type = property(includes_nullable_type_union) | 988 IdlUnionType.includes_nullable_type = property(includes_nullable_type_union) |
OLD | NEW |