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

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

Issue 340443004: IDL: reuse more code between CG for methods and constructors (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: rename scriptContext -> executionContext Created 6 years, 6 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_interface.py ('k') | Source/bindings/scripts/v8_utilities.py » ('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 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 return '%s.get()' % argument.name 230 return '%s.get()' % argument.name
231 return argument.name 231 return argument.name
232 if (idl_type.is_callback_interface or 232 if (idl_type.is_callback_interface or
233 idl_type.name in ['NodeFilter', 'XPathNSResolver']): 233 idl_type.name in ['NodeFilter', 'XPathNSResolver']):
234 # FIXME: remove this special case 234 # FIXME: remove this special case
235 return '%s.release()' % argument.name 235 return '%s.release()' % argument.name
236 return argument.name 236 return argument.name
237 237
238 # Truncate omitted optional arguments 238 # Truncate omitted optional arguments
239 arguments = method.arguments[:number_of_arguments] 239 arguments = method.arguments[:number_of_arguments]
240 cpp_arguments = v8_utilities.call_with_arguments(method) 240 cpp_arguments = []
241 if method.is_constructor:
242 call_with_values = interface.extended_attributes.get('ConstructorCallWit h')
243 else:
244 call_with_values = method.extended_attributes.get('CallWith')
245 cpp_arguments.extend(v8_utilities.call_with_arguments(call_with_values))
241 # Members of IDL partial interface definitions are implemented in C++ as 246 # Members of IDL partial interface definitions are implemented in C++ as
242 # static member functions, which for instance members (non-static members) 247 # static member functions, which for instance members (non-static members)
243 # take *impl as their first argument 248 # take *impl as their first argument
244 if ('PartialInterfaceImplementedAs' in method.extended_attributes and 249 if ('PartialInterfaceImplementedAs' in method.extended_attributes and
245 not method.is_static): 250 not method.is_static):
246 cpp_arguments.append('*impl') 251 cpp_arguments.append('*impl')
247 cpp_arguments.extend(cpp_argument(argument) for argument in arguments) 252 cpp_arguments.extend(cpp_argument(argument) for argument in arguments)
248 this_union_arguments = method.idl_type and method.idl_type.union_arguments 253 this_union_arguments = method.idl_type and method.idl_type.union_arguments
249 if this_union_arguments: 254 if this_union_arguments:
250 cpp_arguments.extend(this_union_arguments) 255 cpp_arguments.extend(this_union_arguments)
251 256
252 if 'RaisesException' in method.extended_attributes: 257 if ('RaisesException' in method.extended_attributes or
258 (method.is_constructor and
259 has_extended_attribute_value(interface, 'RaisesException', 'Constructor '))):
253 cpp_arguments.append('exceptionState') 260 cpp_arguments.append('exceptionState')
254 261
255 if method.name == 'Constructor': 262 if method.name == 'Constructor':
256 base_name = 'create' 263 base_name = 'create'
257 elif method.name == 'NamedConstructor': 264 elif method.name == 'NamedConstructor':
258 base_name = 'createForJSConstructor' 265 base_name = 'createForJSConstructor'
259 else: 266 else:
260 base_name = v8_utilities.cpp_name(method) 267 base_name = v8_utilities.cpp_name(method)
261 268
262 cpp_method_name = v8_utilities.scoped_name(interface, method, base_name) 269 cpp_method_name = v8_utilities.scoped_name(interface, method, base_name)
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 337
331 338
332 def union_arguments(idl_type): 339 def union_arguments(idl_type):
333 """Return list of ['result0Enabled', 'result0', 'result1Enabled', ...] for u nion types, for use in setting return value""" 340 """Return list of ['result0Enabled', 'result0', 'result1Enabled', ...] for u nion types, for use in setting return value"""
334 return [arg 341 return [arg
335 for i in range(len(idl_type.member_types)) 342 for i in range(len(idl_type.member_types))
336 for arg in ['result%sEnabled' % i, 'result%s' % i]] 343 for arg in ['result%sEnabled' % i, 'result%s' % i]]
337 344
338 IdlType.union_arguments = property(lambda self: None) 345 IdlType.union_arguments = property(lambda self: None)
339 IdlUnionType.union_arguments = property(union_arguments) 346 IdlUnionType.union_arguments = property(union_arguments)
OLDNEW
« no previous file with comments | « Source/bindings/scripts/v8_interface.py ('k') | Source/bindings/scripts/v8_utilities.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698