Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(25)

Side by Side Diff: Source/bindings/scripts/v8_types.py

Issue 700093002: IDL: Support nullable union types (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Source/bindings/scripts/idl_types.py ('k') | Source/bindings/tests/idls/core/TestObject.idl » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 if idl_type.is_interface_type: 186 if idl_type.is_interface_type:
187 implemented_as_class = idl_type.implemented_as 187 implemented_as_class = idl_type.implemented_as
188 if raw_type: 188 if raw_type:
189 return implemented_as_class + '*' 189 return implemented_as_class + '*'
190 new_type = 'Member' if used_in_cpp_sequence else 'RawPtr' 190 new_type = 'Member' if used_in_cpp_sequence else 'RawPtr'
191 ptr_type = cpp_ptr_type(('PassRefPtr' if used_as_rvalue_type else 'RefPt r'), new_type, idl_type.gc_type) 191 ptr_type = cpp_ptr_type(('PassRefPtr' if used_as_rvalue_type else 'RefPt r'), new_type, idl_type.gc_type)
192 return cpp_template_type(ptr_type, implemented_as_class) 192 return cpp_template_type(ptr_type, implemented_as_class)
193 if idl_type.is_dictionary: 193 if idl_type.is_dictionary:
194 return base_idl_type 194 return base_idl_type
195 if idl_type.is_union_type: 195 if idl_type.is_union_type:
196 return idl_type.name 196 return idl_type.as_union_type.name
197 197
198 # Default, assume native type is a pointer with same type name as idl type 198 # Default, assume native type is a pointer with same type name as idl type
199 return base_idl_type + '*' 199 return base_idl_type + '*'
200 200
201 201
202 def cpp_type_initializer(idl_type): 202 def cpp_type_initializer(idl_type):
203 """Returns a string containing a C++ initialization statement for the 203 """Returns a string containing a C++ initialization statement for the
204 corresponding type. 204 corresponding type.
205 205
206 |idl_type| argument is of type IdlType. 206 |idl_type| argument is of type IdlType.
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
510 return '' 510 return ''
511 511
512 # Array or sequence types 512 # Array or sequence types
513 native_array_element_type = idl_type.native_array_element_type 513 native_array_element_type = idl_type.native_array_element_type
514 if native_array_element_type: 514 if native_array_element_type:
515 return v8_value_to_cpp_value_array_or_sequence(native_array_element_type , v8_value, index) 515 return v8_value_to_cpp_value_array_or_sequence(native_array_element_type , v8_value, index)
516 516
517 # Simple types 517 # Simple types
518 idl_type = idl_type.preprocessed_type 518 idl_type = idl_type.preprocessed_type
519 add_includes_for_type(idl_type) 519 add_includes_for_type(idl_type)
520 base_idl_type = idl_type.name if idl_type.is_union_type else idl_type.base_t ype 520 base_idl_type = idl_type.as_union_type.name if idl_type.is_union_type else i dl_type.base_type
521 521
522 if 'EnforceRange' in extended_attributes: 522 if 'EnforceRange' in extended_attributes:
523 arguments = ', '.join([v8_value, 'EnforceRange', 'exceptionState']) 523 arguments = ', '.join([v8_value, 'EnforceRange', 'exceptionState'])
524 elif 'Clamp' in extended_attributes: 524 elif 'Clamp' in extended_attributes:
525 arguments = ', '.join([v8_value, 'Clamp', 'exceptionState']) 525 arguments = ', '.join([v8_value, 'Clamp', 'exceptionState'])
526 elif idl_type.v8_conversion_needs_exception_state: 526 elif idl_type.v8_conversion_needs_exception_state:
527 arguments = ', '.join([v8_value, 'exceptionState']) 527 arguments = ', '.join([v8_value, 'exceptionState'])
528 else: 528 else:
529 arguments = v8_value 529 arguments = v8_value
530 530
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after
855 855
856 856
857 def cpp_type_has_null_value(idl_type): 857 def cpp_type_has_null_value(idl_type):
858 # - String types (String/AtomicString) represent null as a null string, 858 # - String types (String/AtomicString) represent null as a null string,
859 # i.e. one for which String::isNull() returns true. 859 # i.e. one for which String::isNull() returns true.
860 # - Enum types, as they are implemented as Strings. 860 # - Enum types, as they are implemented as Strings.
861 # - Wrapper types (raw pointer or RefPtr/PassRefPtr) represent null as 861 # - Wrapper types (raw pointer or RefPtr/PassRefPtr) represent null as
862 # a null pointer. 862 # a null pointer.
863 # - 'Object' type. We use ScriptValue for object type. 863 # - 'Object' type. We use ScriptValue for object type.
864 return (idl_type.is_string_type or idl_type.is_wrapper_type or 864 return (idl_type.is_string_type or idl_type.is_wrapper_type or
865 idl_type.is_enum or idl_type.base_type == 'object') 865 idl_type.is_enum or idl_type.is_union_type or
866 idl_type.base_type == 'object')
866 867
867 IdlTypeBase.cpp_type_has_null_value = property(cpp_type_has_null_value) 868 IdlTypeBase.cpp_type_has_null_value = property(cpp_type_has_null_value)
868 869
869 870
870 def is_implicit_nullable(idl_type): 871 def is_implicit_nullable(idl_type):
871 # Nullable type where the corresponding C++ type supports a null value. 872 # Nullable type where the corresponding C++ type supports a null value.
872 return idl_type.is_nullable and idl_type.cpp_type_has_null_value 873 return idl_type.is_nullable and idl_type.cpp_type_has_null_value
873 874
874 875
875 def is_explicit_nullable(idl_type): 876 def is_explicit_nullable(idl_type):
876 # Nullable type that isn't implicit nullable (see above.) For such types, 877 # Nullable type that isn't implicit nullable (see above.) For such types,
877 # we use Nullable<T> or similar explicit ways to represent a null value. 878 # we use Nullable<T> or similar explicit ways to represent a null value.
878 return idl_type.is_nullable and not idl_type.is_implicit_nullable 879 return idl_type.is_nullable and not idl_type.is_implicit_nullable
879 880
880 IdlTypeBase.is_implicit_nullable = property(is_implicit_nullable) 881 IdlTypeBase.is_implicit_nullable = property(is_implicit_nullable)
881 IdlUnionType.is_implicit_nullable = False 882 IdlUnionType.is_implicit_nullable = False
882 IdlTypeBase.is_explicit_nullable = property(is_explicit_nullable) 883 IdlTypeBase.is_explicit_nullable = property(is_explicit_nullable)
OLDNEW
« no previous file with comments | « Source/bindings/scripts/idl_types.py ('k') | Source/bindings/tests/idls/core/TestObject.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698