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

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

Issue 911433003: IDL: Auto-declare remaining methods implied by maplike<>/setlike<> (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@idl-iterable-continued
Patch Set: Created 5 years, 10 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 # coding=utf-8 2 # coding=utf-8
3 # 3 #
4 # Redistribution and use in source and binary forms, with or without 4 # Redistribution and use in source and binary forms, with or without
5 # modification, are permitted provided that the following conditions are 5 # modification, are permitted provided that the following conditions are
6 # met: 6 # met:
7 # 7 #
8 # * Redistributions of source code must retain the above copyright 8 # * Redistributions of source code must retain the above copyright
9 # notice, this list of conditions and the following disclaimer. 9 # notice, this list of conditions and the following disclaimer.
10 # * Redistributions in binary form must reproduce the above 10 # * Redistributions in binary form must reproduce the above
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 391
392 # void forEach(Function callback, [Default=Undefined] optional a ny thisArg) 392 # void forEach(Function callback, [Default=Undefined] optional a ny thisArg)
393 generated_method(IdlType('void'), 'forEach', 393 generated_method(IdlType('void'), 'forEach',
394 arguments=[generated_argument(IdlType('Function '), 'callback'), 394 arguments=[generated_argument(IdlType('Function '), 'callback'),
395 generated_argument(IdlType('any'), ' thisArg', 395 generated_argument(IdlType('any'), ' thisArg',
396 is_optional=True, 396 is_optional=True,
397 extended_attribut es={'Default': 'Undefined'})], 397 extended_attribut es={'Default': 'Undefined'})],
398 extended_attributes=forEach_extended_attributes ), 398 extended_attributes=forEach_extended_attributes ),
399 ] 399 ]
400 400
401 if interface.maplike:
402 key_argument = generated_argument(interface.maplike.key_type, 'k ey')
403 value_argument = generated_argument(interface.maplike.value_type , 'value')
404
405 implicit_methods.extend([
406 generated_method(IdlType('boolean'), 'has',
407 arguments=[key_argument],
408 extended_attributes=used_extended_attribute s),
409 generated_method(IdlType('any'), 'get',
410 arguments=[key_argument],
411 extended_attributes=used_extended_attribute s),
412 ])
413
414 if not interface.maplike.is_read_only:
415 implicit_methods.extend([
416 generated_method(IdlType('void'), 'clear',
417 extended_attributes=used_extended_attri butes),
418 generated_method(IdlType('boolean'), 'delete',
419 arguments=[key_argument],
420 extended_attributes=used_extended_attri butes),
421 generated_method(IdlType(interface.name), 'set',
422 arguments=[key_argument, value_argument ],
423 extended_attributes=used_extended_attri butes),
424 ])
425
426 if interface.setlike:
427 value_argument = generated_argument(interface.setlike.value_type , 'value')
428
429 implicit_methods.extend([
430 generated_method(IdlType('boolean'), 'has',
431 arguments=[value_argument],
432 extended_attributes=used_extended_attribute s),
433 ])
434
435 if not interface.setlike.is_read_only:
436 implicit_methods.extend([
437 generated_method(IdlType(interface.name), 'add',
438 arguments=[value_argument],
439 extended_attributes=used_extended_attri butes),
440 generated_method(IdlType('void'), 'clear',
441 extended_attributes=used_extended_attri butes),
442 generated_method(IdlType('boolean'), 'delete',
443 arguments=[value_argument],
444 extended_attributes=used_extended_attri butes),
445 ])
446
401 methods_by_name = {} 447 methods_by_name = {}
402 for method in methods: 448 for method in methods:
403 methods_by_name.setdefault(method['name'], []).append(method) 449 methods_by_name.setdefault(method['name'], []).append(method)
404 450
405 for implicit_method in implicit_methods: 451 for implicit_method in implicit_methods:
406 if implicit_method['name'] in methods_by_name: 452 if implicit_method['name'] in methods_by_name:
407 # FIXME: Check that the existing method is compatible. 453 # FIXME: Check that the existing method is compatible.
408 continue 454 continue
409 methods.append(implicit_method) 455 methods.append(implicit_method)
410 456
411 # FIXME: maplike<> and setlike<> should also imply the presence of a 457 # FIXME: maplike<> and setlike<> should also imply the presence of a
412 # subset of keys(), values(), entries(), forEach(), has(), get(), add(), 458 # 'size' attribute.
413 # set(), delete() and clear(), and a 'size' attribute.
414 459
415 # Stringifier 460 # Stringifier
416 if interface.stringifier: 461 if interface.stringifier:
417 stringifier = interface.stringifier 462 stringifier = interface.stringifier
418 stringifier_ext_attrs = stringifier.extended_attributes.copy() 463 stringifier_ext_attrs = stringifier.extended_attributes.copy()
419 if stringifier.attribute: 464 if stringifier.attribute:
420 stringifier_ext_attrs['ImplementedAs'] = stringifier.attribute.name 465 stringifier_ext_attrs['ImplementedAs'] = stringifier.attribute.name
421 elif stringifier.operation: 466 elif stringifier.operation:
422 stringifier_ext_attrs['ImplementedAs'] = stringifier.operation.name 467 stringifier_ext_attrs['ImplementedAs'] = stringifier.operation.name
423 methods.append(generated_method( 468 methods.append(generated_method(
(...skipping 821 matching lines...) Expand 10 before | Expand all | Expand 10 after
1245 if str(idl_type) != 'boolean': 1290 if str(idl_type) != 'boolean':
1246 raise Exception( 1291 raise Exception(
1247 'Only deleters with boolean type are allowed, but type is "%s"' % 1292 'Only deleters with boolean type are allowed, but type is "%s"' %
1248 idl_type) 1293 idl_type)
1249 extended_attributes = deleter.extended_attributes 1294 extended_attributes = deleter.extended_attributes
1250 return { 1295 return {
1251 'is_custom': 'Custom' in extended_attributes, 1296 'is_custom': 'Custom' in extended_attributes,
1252 'is_raises_exception': 'RaisesException' in extended_attributes, 1297 'is_raises_exception': 'RaisesException' in extended_attributes,
1253 'name': cpp_name(deleter), 1298 'name': cpp_name(deleter),
1254 } 1299 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698