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

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

Issue 368313005: IDL: Add support for [TreatNullAs=EmptyString] (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: fix debug compilation Created 6 years, 5 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
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 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 raw_type: 131 raw_type:
132 bool, True if idl_type's raw/primitive C++ type should be returned. 132 bool, True if idl_type's raw/primitive C++ type should be returned.
133 used_as_argument: 133 used_as_argument:
134 bool, True if the C++ type is used as an argument of a method. 134 bool, True if the C++ type is used as an argument of a method.
135 used_as_variadic_argument: 135 used_as_variadic_argument:
136 bool, True if the C++ type is used as a variadic argument of a metho d. 136 bool, True if the C++ type is used as a variadic argument of a metho d.
137 used_in_cpp_sequence: 137 used_in_cpp_sequence:
138 bool, True if the C++ type is used as an element of an array or sequ ence. 138 bool, True if the C++ type is used as an element of an array or sequ ence.
139 """ 139 """
140 def string_mode(): 140 def string_mode():
141 # FIXME: the Web IDL spec requires 'EmptyString', not 'NullString', 141 if extended_attributes.get('TreatNullAs') == 'EmptyString':
142 # but we use NullString for performance. 142 return 'TreatNullAsEmptyString'
143 if idl_type.is_nullable or extended_attributes.get('TreatNullAs') == 'Nu llString': 143 if idl_type.is_nullable or extended_attributes.get('TreatNullAs') == 'Nu llString':
144 if extended_attributes.get('TreatUndefinedAs') == 'NullString': 144 if extended_attributes.get('TreatUndefinedAs') == 'NullString':
145 return 'WithUndefinedOrNullCheck' 145 return 'TreatNullAndUndefinedAsNullString'
146 return 'WithNullCheck' 146 return 'TreatNullAsNullString'
147 return '' 147 return ''
148 148
149 extended_attributes = extended_attributes or {} 149 extended_attributes = extended_attributes or {}
150 idl_type = idl_type.preprocessed_type 150 idl_type = idl_type.preprocessed_type
151 151
152 # Composite types 152 # Composite types
153 if used_as_variadic_argument: 153 if used_as_variadic_argument:
154 array_or_sequence_type = idl_type 154 array_or_sequence_type = idl_type
155 else: 155 else:
156 array_or_sequence_type = idl_type.array_or_sequence_type 156 array_or_sequence_type = idl_type.array_or_sequence_type
(...skipping 557 matching lines...) Expand 10 before | Expand all | Expand 10 after
714 714
715 def literal_cpp_value(idl_type, idl_literal): 715 def literal_cpp_value(idl_type, idl_literal):
716 """Converts an expression that is a valid C++ literal for this type.""" 716 """Converts an expression that is a valid C++ literal for this type."""
717 # FIXME: add validation that idl_type and idl_literal are compatible 717 # FIXME: add validation that idl_type and idl_literal are compatible
718 literal_value = str(idl_literal) 718 literal_value = str(idl_literal)
719 if idl_type.base_type in CPP_UNSIGNED_TYPES: 719 if idl_type.base_type in CPP_UNSIGNED_TYPES:
720 return literal_value + 'u' 720 return literal_value + 'u'
721 return literal_value 721 return literal_value
722 722
723 IdlType.literal_cpp_value = literal_cpp_value 723 IdlType.literal_cpp_value = literal_cpp_value
OLDNEW
« no previous file with comments | « Source/bindings/core/v8/custom/V8XMLHttpRequestCustom.cpp ('k') | Source/bindings/tests/idls/TestObject.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698