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

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

Issue 474323002: IDL: initialize union member variables (to null/zero) (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 4 months 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/v8_methods.py ('k') | Source/bindings/templates/methods.cpp » ('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 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 return base_idl_type + '*' 196 return base_idl_type + '*'
197 197
198 198
199 def cpp_type_initializer(idl_type): 199 def cpp_type_initializer(idl_type):
200 """Returns a string containing a C++ initialization statement for the 200 """Returns a string containing a C++ initialization statement for the
201 corresponding type. 201 corresponding type.
202 202
203 |idl_type| argument is of type IdlType. 203 |idl_type| argument is of type IdlType.
204 """ 204 """
205 205
206 if (idl_type.is_numeric_type): 206 base_idl_type = idl_type.base_type
207
208 if idl_type.native_array_element_type:
209 return ''
210 if idl_type.is_numeric_type:
207 return ' = 0' 211 return ' = 0'
208 if idl_type.base_type == 'boolean': 212 if base_idl_type == 'boolean':
209 return ' = false' 213 return ' = false'
210 return '' 214 if (base_idl_type in NON_WRAPPER_TYPES or
215 base_idl_type in CPP_SPECIAL_CONVERSION_RULES or
216 base_idl_type == 'any' or
217 idl_type.is_string_type or
218 idl_type.is_enum):
219 return ''
220 return ' = nullptr'
211 221
212 222
213 def cpp_type_union(idl_type, extended_attributes=None, raw_type=False): 223 def cpp_type_union(idl_type, extended_attributes=None, raw_type=False):
214 # FIXME: Need to revisit the design of union support. 224 # FIXME: Need to revisit the design of union support.
215 # http://crbug.com/240176 225 # http://crbug.com/240176
216 return None 226 return None
217 227
218 228
219 def cpp_type_initializer_union(idl_type): 229 def cpp_type_initializer_union(idl_type):
220 return (member_type.cpp_type_initializer for member_type in idl_type.member_ types) 230 return (member_type.cpp_type_initializer for member_type in idl_type.member_ types)
(...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after
806 816
807 817
808 def is_explicit_nullable(idl_type): 818 def is_explicit_nullable(idl_type):
809 # Nullable type that isn't implicit nullable (see above.) For such types, 819 # Nullable type that isn't implicit nullable (see above.) For such types,
810 # we use Nullable<T> or similar explicit ways to represent a null value. 820 # we use Nullable<T> or similar explicit ways to represent a null value.
811 return idl_type.is_nullable and not idl_type.is_implicit_nullable 821 return idl_type.is_nullable and not idl_type.is_implicit_nullable
812 822
813 IdlTypeBase.is_implicit_nullable = property(is_implicit_nullable) 823 IdlTypeBase.is_implicit_nullable = property(is_implicit_nullable)
814 IdlUnionType.is_implicit_nullable = False 824 IdlUnionType.is_implicit_nullable = False
815 IdlTypeBase.is_explicit_nullable = property(is_explicit_nullable) 825 IdlTypeBase.is_explicit_nullable = property(is_explicit_nullable)
OLDNEW
« no previous file with comments | « Source/bindings/scripts/v8_methods.py ('k') | Source/bindings/templates/methods.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698