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

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

Issue 2329463004: ABANDONED CL: Changes needed to make things compile after running rewrite_to_chrome_style tool. (Closed)
Patch Set: More fixes - things build fine at this point. Created 3 years, 8 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 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 207
208 # [PrimaryGlobal] and [Global] 208 # [PrimaryGlobal] and [Global]
209 is_global = ('PrimaryGlobal' in extended_attributes or 209 is_global = ('PrimaryGlobal' in extended_attributes or
210 'Global' in extended_attributes) 210 'Global' in extended_attributes)
211 211
212 # [ImmutablePrototype] 212 # [ImmutablePrototype]
213 # TODO(littledan): Is it possible to deduce this based on inheritance, 213 # TODO(littledan): Is it possible to deduce this based on inheritance,
214 # as in the WebIDL spec? 214 # as in the WebIDL spec?
215 is_immutable_prototype = is_global or 'ImmutablePrototype' in extended_attri butes 215 is_immutable_prototype = is_global or 'ImmutablePrototype' in extended_attri butes
216 216
217 wrapper_class_id = ('NodeClassId' if inherits_interface(interface.name, 'Nod e') else 'ObjectClassId') 217 wrapper_class_id = ('kNodeClassId' if inherits_interface(interface.name, 'No de') else 'kObjectClassId')
218 218
219 # [ActiveScriptWrappable] must be accompanied with [DependentLifetime]. 219 # [ActiveScriptWrappable] must be accompanied with [DependentLifetime].
220 if active_scriptwrappable and not is_dependent_lifetime: 220 if active_scriptwrappable and not is_dependent_lifetime:
221 raise Exception('[ActiveScriptWrappable] interface must also specify ' 221 raise Exception('[ActiveScriptWrappable] interface must also specify '
222 '[DependentLifetime]: %s' % interface.name) 222 '[DependentLifetime]: %s' % interface.name)
223 223
224 v8_class_name = v8_utilities.v8_class_name(interface) 224 v8_class_name = v8_utilities.v8_class_name(interface)
225 cpp_class_name = cpp_name(interface) 225 cpp_class_name = cpp_name(interface)
226 cpp_class_name_or_partial = cpp_name_or_partial(interface) 226 cpp_class_name_or_partial = cpp_name_or_partial(interface)
227 v8_class_name_or_partial = v8_utilities.v8_class_name_or_partial(interface) 227 v8_class_name_or_partial = v8_utilities.v8_class_name_or_partial(interface)
(...skipping 15 matching lines...) Expand all
243 'interface_name': interface.name, 243 'interface_name': interface.name,
244 'is_array_buffer_or_view': is_array_buffer_or_view, 244 'is_array_buffer_or_view': is_array_buffer_or_view,
245 'is_check_security': is_check_security, 245 'is_check_security': is_check_security,
246 'is_event_target': is_event_target, 246 'is_event_target': is_event_target,
247 'is_exception': interface.is_exception, 247 'is_exception': interface.is_exception,
248 'is_global': is_global, 248 'is_global': is_global,
249 'is_immutable_prototype': is_immutable_prototype, 249 'is_immutable_prototype': is_immutable_prototype,
250 'is_node': inherits_interface(interface.name, 'Node'), 250 'is_node': inherits_interface(interface.name, 'Node'),
251 'is_partial': interface.is_partial, 251 'is_partial': interface.is_partial,
252 'is_typed_array_type': is_typed_array_type, 252 'is_typed_array_type': is_typed_array_type,
253 'lifetime': 'Dependent' if is_dependent_lifetime else 'Independent', 253 'lifetime': 'kDependent' if is_dependent_lifetime else 'kIndependent',
254 'measure_as': v8_utilities.measure_as(interface, None), # [MeasureAs] 254 'measure_as': v8_utilities.measure_as(interface, None), # [MeasureAs]
255 'needs_runtime_enabled_installer': needs_runtime_enabled_installer, 255 'needs_runtime_enabled_installer': needs_runtime_enabled_installer,
256 'origin_trial_enabled_function': v8_utilities.origin_trial_enabled_funct ion_name(interface), 256 'origin_trial_enabled_function': v8_utilities.origin_trial_enabled_funct ion_name(interface),
257 'parent_interface': parent_interface, 257 'parent_interface': parent_interface,
258 'pass_cpp_type': cpp_name(interface) + '*', 258 'pass_cpp_type': cpp_name(interface) + '*',
259 'active_scriptwrappable': active_scriptwrappable, 259 'active_scriptwrappable': active_scriptwrappable,
260 'runtime_enabled_feature_name': runtime_enabled_feature_name(interface), # [RuntimeEnabled] 260 'runtime_enabled_feature_name': runtime_enabled_feature_name(interface), # [RuntimeEnabled]
261 'v8_class': v8_class_name, 261 'v8_class': v8_class_name,
262 'v8_class_or_partial': v8_class_name_or_partial, 262 'v8_class_or_partial': v8_class_name_or_partial,
263 'wrapper_class_id': wrapper_class_id, 263 'wrapper_class_id': wrapper_class_id,
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
544 }) 544 })
545 545
546 def generated_iterator_method(name, implemented_as=None): 546 def generated_iterator_method(name, implemented_as=None):
547 return generated_method( 547 return generated_method(
548 return_type=IdlType('Iterator'), 548 return_type=IdlType('Iterator'),
549 name=name, 549 name=name,
550 extended_attributes=used_extended_attributes, 550 extended_attributes=used_extended_attributes,
551 implemented_as=implemented_as) 551 implemented_as=implemented_as)
552 552
553 if not interface.has_indexed_elements: 553 if not interface.has_indexed_elements:
554 iterator_method = generated_iterator_method('iterator', implemented_ as='iterator') 554 iterator_method = generated_iterator_method('iterator', implemented_ as='GetIterator')
555 555
556 if interface.iterable or interface.maplike or interface.setlike: 556 if interface.iterable or interface.maplike or interface.setlike:
557 non_overridable_methods = [] 557 non_overridable_methods = []
558 overridable_methods = [] 558 overridable_methods = []
559 559
560 is_value_iterator = interface.iterable and interface.iterable.key_ty pe is None 560 is_value_iterator = interface.iterable and interface.iterable.key_ty pe is None
561 561
562 # For value iterators, the |entries|, |forEach|, |keys| and |values| are originally set 562 # For value iterators, the |entries|, |forEach|, |keys| and |values| are originally set
563 # to corresponding properties in %ArrayPrototype%. 563 # to corresponding properties in %ArrayPrototype%.
564 if not is_value_iterator: 564 if not is_value_iterator:
565 non_overridable_methods.extend([ 565 non_overridable_methods.extend([
566 generated_iterator_method('keys'), 566 generated_iterator_method('Keys'),
567 generated_iterator_method('values'), 567 generated_iterator_method('Values'),
568 generated_iterator_method('entries'), 568 generated_iterator_method('Entries'),
569 569
570 # void forEach(Function callback, [Default=Undefined] option al any thisArg) 570 # void forEach(Function callback, [Default=Undefined] option al any thisArg)
571 generated_method(IdlType('void'), 'forEach', 571 generated_method(IdlType('void'), 'ForEach',
572 arguments=[generated_argument(IdlType('Func tion'), 'callback'), 572 arguments=[generated_argument(IdlType('Func tion'), 'callback'),
573 generated_argument(IdlType('any' ), 'thisArg', 573 generated_argument(IdlType('any' ), 'thisArg',
574 is_optional=T rue, 574 is_optional=T rue,
575 extended_attr ibutes={'Default': 'Undefined'})], 575 extended_attr ibutes={'Default': 'Undefined'})],
576 extended_attributes=forEach_extended_attrib utes), 576 extended_attributes=forEach_extended_attrib utes),
577 ]) 577 ])
578 578
579 if interface.maplike: 579 if interface.maplike:
580 key_argument = generated_argument(interface.maplike.key_type, 'k ey') 580 key_argument = generated_argument(interface.maplike.key_type, 'k ey')
581 value_argument = generated_argument(interface.maplike.value_type , 'value') 581 value_argument = generated_argument(interface.maplike.value_type , 'value')
582 582
583 non_overridable_methods.extend([ 583 non_overridable_methods.extend([
584 generated_method(IdlType('boolean'), 'has', 584 generated_method(IdlType('boolean'), 'Has',
585 arguments=[key_argument], 585 arguments=[key_argument],
586 extended_attributes=used_extended_attribute s), 586 extended_attributes=used_extended_attribute s),
587 generated_method(IdlType('any'), 'get', 587 generated_method(IdlType('any'), 'Get',
588 arguments=[key_argument], 588 arguments=[key_argument],
589 extended_attributes=used_extended_attribute s), 589 extended_attributes=used_extended_attribute s),
590 ]) 590 ])
591 591
592 if not interface.maplike.is_read_only: 592 if not interface.maplike.is_read_only:
593 overridable_methods.extend([ 593 overridable_methods.extend([
594 generated_method(IdlType('void'), 'clear', 594 generated_method(IdlType('void'), 'Clear',
595 extended_attributes=used_extended_attri butes), 595 extended_attributes=used_extended_attri butes),
596 generated_method(IdlType('boolean'), 'delete', 596 generated_method(IdlType('boolean'), 'Delete',
597 arguments=[key_argument], 597 arguments=[key_argument],
598 extended_attributes=used_extended_attri butes), 598 extended_attributes=used_extended_attri butes),
599 generated_method(IdlType(interface.name), 'set', 599 generated_method(IdlType(interface.name), 'Set',
600 arguments=[key_argument, value_argument ], 600 arguments=[key_argument, value_argument ],
601 extended_attributes=used_extended_attri butes), 601 extended_attributes=used_extended_attri butes),
602 ]) 602 ])
603 603
604 if interface.setlike: 604 if interface.setlike:
605 value_argument = generated_argument(interface.setlike.value_type , 'value') 605 value_argument = generated_argument(interface.setlike.value_type , 'value')
606 606
607 non_overridable_methods.extend([ 607 non_overridable_methods.extend([
608 generated_method(IdlType('boolean'), 'has', 608 generated_method(IdlType('boolean'), 'Has',
609 arguments=[value_argument], 609 arguments=[value_argument],
610 extended_attributes=used_extended_attribute s), 610 extended_attributes=used_extended_attribute s),
611 ]) 611 ])
612 612
613 if not interface.setlike.is_read_only: 613 if not interface.setlike.is_read_only:
614 overridable_methods.extend([ 614 overridable_methods.extend([
615 generated_method(IdlType(interface.name), 'add', 615 generated_method(IdlType(interface.name), 'Add',
616 arguments=[value_argument], 616 arguments=[value_argument],
617 extended_attributes=used_extended_attri butes), 617 extended_attributes=used_extended_attri butes),
618 generated_method(IdlType('void'), 'clear', 618 generated_method(IdlType('void'), 'Clear',
619 extended_attributes=used_extended_attri butes), 619 extended_attributes=used_extended_attri butes),
620 generated_method(IdlType('boolean'), 'delete', 620 generated_method(IdlType('boolean'), 'Delete',
621 arguments=[value_argument], 621 arguments=[value_argument],
622 extended_attributes=used_extended_attri butes), 622 extended_attributes=used_extended_attri butes),
623 ]) 623 ])
624 624
625 methods_by_name = {} 625 methods_by_name = {}
626 for method in methods: 626 for method in methods:
627 methods_by_name.setdefault(method['name'], []).append(method) 627 methods_by_name.setdefault(method['name'], []).append(method)
628 628
629 for non_overridable_method in non_overridable_methods: 629 for non_overridable_method in non_overridable_methods:
630 if non_overridable_method['name'] in methods_by_name: 630 if non_overridable_method['name'] in methods_by_name:
(...skipping 19 matching lines...) Expand all
650 if serializer.operation: 650 if serializer.operation:
651 return_type = serializer.operation.idl_type 651 return_type = serializer.operation.idl_type
652 implemented_as = serializer.operation.name 652 implemented_as = serializer.operation.name
653 else: 653 else:
654 return_type = IdlType('any') 654 return_type = IdlType('any')
655 implemented_as = None 655 implemented_as = None
656 if 'CallWith' not in serializer_ext_attrs: 656 if 'CallWith' not in serializer_ext_attrs:
657 serializer_ext_attrs['CallWith'] = 'ScriptState' 657 serializer_ext_attrs['CallWith'] = 'ScriptState'
658 methods.append(generated_method( 658 methods.append(generated_method(
659 return_type=return_type, 659 return_type=return_type,
660 name='toJSON', 660 name='ToJSON',
661 extended_attributes=serializer_ext_attrs, 661 extended_attributes=serializer_ext_attrs,
662 implemented_as=implemented_as)) 662 implemented_as=implemented_as))
663 663
664 # Stringifier 664 # Stringifier
665 if interface.stringifier: 665 if interface.stringifier:
666 stringifier = interface.stringifier 666 stringifier = interface.stringifier
667 stringifier_ext_attrs = stringifier.extended_attributes.copy() 667 stringifier_ext_attrs = stringifier.extended_attributes.copy()
668 if stringifier.attribute: 668 if stringifier.attribute:
669 implemented_as = stringifier.attribute.name 669 implemented_as = stringifier.attribute.name
670 elif stringifier.operation: 670 elif stringifier.operation:
671 implemented_as = stringifier.operation.name 671 implemented_as = stringifier.operation.name
672 else: 672 else:
673 implemented_as = 'toString' 673 implemented_as = 'ToString'
674 methods.append(generated_method( 674 methods.append(generated_method(
675 return_type=IdlType('DOMString'), 675 return_type=IdlType('DOMString'),
676 name='toString', 676 name='ToString',
677 extended_attributes=stringifier_ext_attrs, 677 extended_attributes=stringifier_ext_attrs,
678 implemented_as=implemented_as)) 678 implemented_as=implemented_as))
679 679
680 for method in methods: 680 for method in methods:
681 # The value of the Function object’s “length” property is a Number 681 # The value of the Function object’s “length” property is a Number
682 # determined as follows: 682 # determined as follows:
683 # 1. Let S be the effective overload set for regular operations (if the 683 # 1. Let S be the effective overload set for regular operations (if the
684 # operation is a regular operation) or for static operations (if the 684 # operation is a regular operation) or for static operations (if the
685 # operation is a static operation) with identifier id on interface I and 685 # operation is a static operation) with identifier id on interface I and
686 # with argument count 0. 686 # with argument count 0.
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after
1030 yield test, method 1030 yield test, method
1031 except StopIteration: 1031 except StopIteration:
1032 pass 1032 pass
1033 1033
1034 # 3. Otherwise: if V is null or undefined, and there is an entry in S that 1034 # 3. Otherwise: if V is null or undefined, and there is an entry in S that
1035 # has one of the following types at position i of its type list, 1035 # has one of the following types at position i of its type list,
1036 # • a nullable type 1036 # • a nullable type
1037 try: 1037 try:
1038 method = next(method for idl_type, method in idl_types_methods 1038 method = next(method for idl_type, method in idl_types_methods
1039 if idl_type.is_nullable) 1039 if idl_type.is_nullable)
1040 test = 'isUndefinedOrNull(%s)' % cpp_value 1040 test = 'IsUndefinedOrNull(%s)' % cpp_value
1041 yield test, method 1041 yield test, method
1042 except StopIteration: 1042 except StopIteration:
1043 pass 1043 pass
1044 1044
1045 # 4. Otherwise: if V is a platform object – but not a platform array 1045 # 4. Otherwise: if V is a platform object – but not a platform array
1046 # object – and there is an entry in S that has one of the following 1046 # object – and there is an entry in S that has one of the following
1047 # types at position i of its type list, 1047 # types at position i of its type list,
1048 # • an interface type that V implements 1048 # • an interface type that V implements
1049 # (Unlike most of these tests, this can return multiple methods, since we 1049 # (Unlike most of these tests, this can return multiple methods, since we
1050 # test if it implements an interface. Thus we need a for loop, not a next.) 1050 # test if it implements an interface. Thus we need a for loop, not a next.)
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
1279 return v8_methods.method_context(interface, caller) 1279 return v8_methods.method_context(interface, caller)
1280 1280
1281 def property_getter(getter, cpp_arguments): 1281 def property_getter(getter, cpp_arguments):
1282 if not getter: 1282 if not getter:
1283 return None 1283 return None
1284 1284
1285 def is_null_expression(idl_type): 1285 def is_null_expression(idl_type):
1286 if idl_type.use_output_parameter_for_result: 1286 if idl_type.use_output_parameter_for_result:
1287 return 'result.isNull()' 1287 return 'result.isNull()'
1288 if idl_type.is_string_type: 1288 if idl_type.is_string_type:
1289 return 'result.isNull()' 1289 return 'result.IsNull()'
1290 if idl_type.is_interface_type: 1290 if idl_type.is_interface_type:
1291 return '!result' 1291 return '!result'
1292 if idl_type.base_type in ('any', 'object'): 1292 if idl_type.base_type in ('any', 'object'):
1293 return 'result.isEmpty()' 1293 return 'result.IsEmpty()'
1294 return '' 1294 return ''
1295 1295
1296 extended_attributes = getter.extended_attributes 1296 extended_attributes = getter.extended_attributes
1297 idl_type = getter.idl_type 1297 idl_type = getter.idl_type
1298 idl_type.add_includes_for_type(extended_attributes) 1298 idl_type.add_includes_for_type(extended_attributes)
1299 is_call_with_script_state = v8_utilities.has_extended_attribute_value(getter , 'CallWith', 'ScriptState') 1299 is_call_with_script_state = v8_utilities.has_extended_attribute_value(getter , 'CallWith', 'ScriptState')
1300 is_raises_exception = 'RaisesException' in extended_attributes 1300 is_raises_exception = 'RaisesException' in extended_attributes
1301 use_output_parameter_for_result = idl_type.use_output_parameter_for_result 1301 use_output_parameter_for_result = idl_type.use_output_parameter_for_result
1302 1302
1303 # FIXME: make more generic, so can use v8_methods.cpp_value 1303 # FIXME: make more generic, so can use v8_methods.cpp_value
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
1373 extended_attributes = deleter.extended_attributes 1373 extended_attributes = deleter.extended_attributes
1374 is_call_with_script_state = v8_utilities.has_extended_attribute_value(delete r, 'CallWith', 'ScriptState') 1374 is_call_with_script_state = v8_utilities.has_extended_attribute_value(delete r, 'CallWith', 'ScriptState')
1375 is_ce_reactions = 'CEReactions' in extended_attributes 1375 is_ce_reactions = 'CEReactions' in extended_attributes
1376 return { 1376 return {
1377 'is_call_with_script_state': is_call_with_script_state, 1377 'is_call_with_script_state': is_call_with_script_state,
1378 'is_ce_reactions': is_ce_reactions, 1378 'is_ce_reactions': is_ce_reactions,
1379 'is_custom': 'Custom' in extended_attributes, 1379 'is_custom': 'Custom' in extended_attributes,
1380 'is_raises_exception': 'RaisesException' in extended_attributes, 1380 'is_raises_exception': 'RaisesException' in extended_attributes,
1381 'name': cpp_name(deleter), 1381 'name': cpp_name(deleter),
1382 } 1382 }
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/bindings/scripts/v8_dictionary.py ('k') | third_party/WebKit/Source/bindings/scripts/v8_methods.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698