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

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

Issue 362993004: Implement Blink-in-JS for DOM attributes (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: 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 | Annotate | Revision Log
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 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 'measure_as': v8_utilities.measure_as(method), # [MeasureAs] 156 'measure_as': v8_utilities.measure_as(method), # [MeasureAs]
157 'name': name, 157 'name': name,
158 'number_of_arguments': len(arguments), 158 'number_of_arguments': len(arguments),
159 'number_of_required_arguments': len([ 159 'number_of_required_arguments': len([
160 argument for argument in arguments 160 argument for argument in arguments
161 if not (argument.is_optional or argument.is_variadic)]), 161 if not (argument.is_optional or argument.is_variadic)]),
162 'number_of_required_or_variadic_arguments': len([ 162 'number_of_required_or_variadic_arguments': len([
163 argument for argument in arguments 163 argument for argument in arguments
164 if not argument.is_optional]), 164 if not argument.is_optional]),
165 'per_context_enabled_function': v8_utilities.per_context_enabled_functio n_name(method), # [PerContextEnabled] 165 'per_context_enabled_function': v8_utilities.per_context_enabled_functio n_name(method), # [PerContextEnabled]
166 'private_script_v8_value_to_local_cpp_value': idl_type.v8_value_to_local _cpp_value(
167 extended_attributes, 'v8Value', 'cppValue', isolate='scriptState->is olate()', used_in_private_script=True),
166 'property_attributes': property_attributes(method), 168 'property_attributes': property_attributes(method),
167 'raw_cpp_type': idl_type.cpp_type_args(raw_type=True),
168 'returned_v8_value_to_local_cpp_value': v8_types.v8_value_to_cpp_value(
169 idl_type, extended_attributes, 'v8Value', 0, isolate='scriptState->i solate()'),
170 'runtime_enabled_function': v8_utilities.runtime_enabled_function_name(m ethod), # [RuntimeEnabled] 169 'runtime_enabled_function': v8_utilities.runtime_enabled_function_name(m ethod), # [RuntimeEnabled]
171 'signature': 'v8::Local<v8::Signature>()' if is_static or 'DoNotCheckSig nature' in extended_attributes else 'defaultSignature', 170 'signature': 'v8::Local<v8::Signature>()' if is_static or 'DoNotCheckSig nature' in extended_attributes else 'defaultSignature',
172 'union_arguments': idl_type.union_arguments, 171 'union_arguments': idl_type.union_arguments,
173 'v8_set_return_value': v8_set_return_value(interface.name, method, this_ cpp_value), 172 'v8_set_return_value': v8_set_return_value(interface.name, method, this_ cpp_value),
174 'v8_set_return_value_for_main_world': v8_set_return_value(interface.name , method, this_cpp_value, for_main_world=True), 173 'v8_set_return_value_for_main_world': v8_set_return_value(interface.name , method, this_cpp_value, for_main_world=True),
175 'world_suffixes': ['', 'ForMainWorld'] if 'PerWorldBindings' in extended _attributes else [''], # [PerWorldBindings], 174 'world_suffixes': ['', 'ForMainWorld'] if 'PerWorldBindings' in extended _attributes else [''], # [PerWorldBindings],
176 } 175 }
177 176
178 177
179 def argument_context(interface, method, argument, index): 178 def argument_context(interface, method, argument, index):
180 extended_attributes = argument.extended_attributes 179 extended_attributes = argument.extended_attributes
181 idl_type = argument.idl_type 180 idl_type = argument.idl_type
182 this_cpp_value = cpp_value(interface, method, index) 181 this_cpp_value = cpp_value(interface, method, index)
183 is_variadic_wrapper_type = argument.is_variadic and idl_type.is_wrapper_type 182 is_variadic_wrapper_type = argument.is_variadic and idl_type.is_wrapper_type
184 183
185 if ('ImplementedInPrivateScript' in extended_attributes and 184 if ('ImplementedInPrivateScript' in extended_attributes and
186 not idl_type.is_wrapper_type and 185 not idl_type.is_wrapper_type and
187 not idl_type.is_basic_type): 186 not idl_type.is_basic_type):
188 raise Exception('Private scripts supports only primitive types and DOM w rappers.') 187 raise Exception('Private scripts supports only primitive types and DOM w rappers.')
189 188
190 return { 189 return {
191 'cpp_type': idl_type.cpp_type_args(extended_attributes=extended_attribut es, 190 'cpp_type': idl_type.cpp_type_args(extended_attributes=extended_attribut es,
192 raw_type=True, 191 raw_type=True,
193 used_as_variadic_argument=argument.is _variadic), 192 used_as_variadic_argument=argument.is _variadic),
194 'cpp_value': this_cpp_value, 193 'cpp_value': this_cpp_value,
195 'cpp_value_to_v8_value': idl_type.cpp_value_to_v8_value(
196 argument.name, isolate='scriptState->isolate()',
197 creation_context='scriptState->context()->Global()'),
198 # FIXME: check that the default value's type is compatible with the argu ment's 194 # FIXME: check that the default value's type is compatible with the argu ment's
199 'default_value': argument.default_cpp_value, 195 'default_value': argument.default_cpp_value,
200 'enum_validation_expression': idl_type.enum_validation_expression, 196 'enum_validation_expression': idl_type.enum_validation_expression,
201 'handle': '%sHandle' % argument.name, 197 'handle': '%sHandle' % argument.name,
202 # FIXME: remove once [Default] removed and just use argument.default_val ue 198 # FIXME: remove once [Default] removed and just use argument.default_val ue
203 'has_default': 'Default' in extended_attributes or argument.default_valu e, 199 'has_default': 'Default' in extended_attributes or argument.default_valu e,
204 'has_type_checking_interface': 200 'has_type_checking_interface':
205 (has_extended_attribute_value(interface, 'TypeChecking', 'Interface' ) or 201 (has_extended_attribute_value(interface, 'TypeChecking', 'Interface' ) or
206 has_extended_attribute_value(method, 'TypeChecking', 'Interface')) and 202 has_extended_attribute_value(method, 'TypeChecking', 'Interface')) and
207 idl_type.is_wrapper_type, 203 idl_type.is_wrapper_type,
208 'has_type_checking_unrestricted': 204 'has_type_checking_unrestricted':
209 (has_extended_attribute_value(interface, 'TypeChecking', 'Unrestrict ed') or 205 (has_extended_attribute_value(interface, 'TypeChecking', 'Unrestrict ed') or
210 has_extended_attribute_value(method, 'TypeChecking', 'Unrestricted' )) and 206 has_extended_attribute_value(method, 'TypeChecking', 'Unrestricted' )) and
211 idl_type.name in ('Float', 'Double'), 207 idl_type.name in ('Float', 'Double'),
212 # Dictionary is special-cased, but arrays and sequences shouldn't be 208 # Dictionary is special-cased, but arrays and sequences shouldn't be
213 'idl_type': not idl_type.array_or_sequence_type and idl_type.base_type, 209 'idl_type': not idl_type.array_or_sequence_type and idl_type.base_type,
214 'idl_type_object': idl_type, 210 'idl_type_object': idl_type,
215 'index': index, 211 'index': index,
216 'is_clamp': 'Clamp' in extended_attributes, 212 'is_clamp': 'Clamp' in extended_attributes,
217 'is_callback_interface': idl_type.is_callback_interface, 213 'is_callback_interface': idl_type.is_callback_interface,
218 'is_nullable': idl_type.is_nullable, 214 'is_nullable': idl_type.is_nullable,
219 'is_optional': argument.is_optional, 215 'is_optional': argument.is_optional,
220 'is_variadic_wrapper_type': is_variadic_wrapper_type, 216 'is_variadic_wrapper_type': is_variadic_wrapper_type,
221 'vector_type': v8_types.cpp_ptr_type('Vector', 'HeapVector', idl_type.gc _type),
222 'is_wrapper_type': idl_type.is_wrapper_type, 217 'is_wrapper_type': idl_type.is_wrapper_type,
223 'name': argument.name, 218 'name': argument.name,
219 'private_script_cpp_value_to_v8_value': idl_type.cpp_value_to_v8_value(
220 argument.name, isolate='scriptState->isolate()',
221 creation_context='scriptState->context()->Global()'),
224 'v8_set_return_value': v8_set_return_value(interface.name, method, this_ cpp_value), 222 'v8_set_return_value': v8_set_return_value(interface.name, method, this_ cpp_value),
225 'v8_set_return_value_for_main_world': v8_set_return_value(interface.name , method, this_cpp_value, for_main_world=True), 223 'v8_set_return_value_for_main_world': v8_set_return_value(interface.name , method, this_cpp_value, for_main_world=True),
226 'v8_value_to_local_cpp_value': v8_value_to_local_cpp_value(argument, ind ex), 224 'v8_value_to_local_cpp_value': v8_value_to_local_cpp_value(argument, ind ex),
225 'vector_type': v8_types.cpp_ptr_type('Vector', 'HeapVector', idl_type.gc _type),
227 } 226 }
228 227
229 228
230 def argument_declarations_for_private_script(interface, method): 229 def argument_declarations_for_private_script(interface, method):
231 argument_declarations = ['LocalFrame* frame'] 230 argument_declarations = ['LocalFrame* frame']
232 argument_declarations.append('%s* holderImpl' % interface.name) 231 argument_declarations.append('%s* holderImpl' % interface.name)
233 argument_declarations.extend(['%s %s' % (argument.idl_type.cpp_type_args( 232 argument_declarations.extend(['%s %s' % (argument.idl_type.cpp_type_args(
234 used_as_argument=True), argument.name) for argument in method.arguments] ) 233 used_as_argument=True), argument.name) for argument in method.arguments] )
235 if method.idl_type.name != 'void': 234 if method.idl_type.name != 'void':
236 argument_declarations.append('%s* %s' % (method.idl_type.cpp_type, 'resu lt')) 235 argument_declarations.append('%s* %s' % (method.idl_type.cpp_type, 'resu lt'))
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 376
378 377
379 def argument_default_cpp_value(argument): 378 def argument_default_cpp_value(argument):
380 if not argument.default_value: 379 if not argument.default_value:
381 return None 380 return None
382 return argument.idl_type.literal_cpp_value(argument.default_value) 381 return argument.idl_type.literal_cpp_value(argument.default_value)
383 382
384 IdlType.union_arguments = property(lambda self: None) 383 IdlType.union_arguments = property(lambda self: None)
385 IdlUnionType.union_arguments = property(union_arguments) 384 IdlUnionType.union_arguments = property(union_arguments)
386 IdlArgument.default_cpp_value = property(argument_default_cpp_value) 385 IdlArgument.default_cpp_value = property(argument_default_cpp_value)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698