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

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

Issue 716773002: Use union types for HTMLSelectElement.add()'s arguments (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: added FIXME Created 6 years, 1 month 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 2014 The Chromium Authors. All rights reserved. 1 # Copyright 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import v8_utilities 5 import v8_utilities
6 6
7 7
8 UNION_H_INCLUDES = frozenset([ 8 UNION_H_INCLUDES = frozenset([
9 'bindings/core/v8/ExceptionState.h', 9 'bindings/core/v8/ExceptionState.h',
10 'bindings/core/v8/V8Binding.h', 10 'bindings/core/v8/V8Binding.h',
11 'platform/heap/Handle.h', 11 'platform/heap/Handle.h',
12 ]) 12 ])
13 13
14 UNION_CPP_INCLUDES_BLACKLIST = frozenset([
15 # This header defines static functions needed to implement event handler
16 # attributes in interfaces that implement GlobalEventHandlers. They are not
17 # needed or used by UnionTypes*.cpp, so including the header causes
18 # compilation errors.
19 # FIXME: We should solve this problem in a way that doesn't involve special-
20 # casing a header like this.
21 'core/dom/GlobalEventHandlers.h',
22 ])
23
24
14 cpp_includes = set() 25 cpp_includes = set()
15 header_forward_decls = set() 26 header_forward_decls = set()
16 27
17 28
18 def union_context(union_types, interfaces_info): 29 def union_context(union_types, interfaces_info):
19 # For container classes we strip nullable wrappers. For example, 30 # For container classes we strip nullable wrappers. For example,
20 # both (A or B)? and (A? or B) will become AOrB. This should be OK 31 # both (A or B)? and (A? or B) will become AOrB. This should be OK
21 # because container classes can handle null and it seems that 32 # because container classes can handle null and it seems that
22 # distinguishing (A or B)? and (A? or B) doesn't make sense. 33 # distinguishing (A or B)? and (A? or B) doesn't make sense.
23 container_cpp_types = set() 34 container_cpp_types = set()
24 union_types_for_containers = set() 35 union_types_for_containers = set()
25 nullable_cpp_types = set() 36 nullable_cpp_types = set()
26 for union_type in union_types: 37 for union_type in union_types:
27 cpp_type = union_type.cpp_type 38 cpp_type = union_type.cpp_type
28 if cpp_type not in container_cpp_types: 39 if cpp_type not in container_cpp_types:
29 union_types_for_containers.add(union_type) 40 union_types_for_containers.add(union_type)
30 container_cpp_types.add(cpp_type) 41 container_cpp_types.add(cpp_type)
31 if union_type.includes_nullable_type: 42 if union_type.includes_nullable_type:
32 nullable_cpp_types.add(cpp_type) 43 nullable_cpp_types.add(cpp_type)
33 44
34 union_types_for_containers = sorted(union_types_for_containers, 45 union_types_for_containers = sorted(union_types_for_containers,
35 key=lambda union_type: union_type.cpp_ty pe) 46 key=lambda union_type: union_type.cpp_ty pe)
36 nullable_cpp_types = sorted(nullable_cpp_types) 47 nullable_cpp_types = sorted(nullable_cpp_types)
37 48
38 return { 49 return {
39 'containers': [container_context(union_type, interfaces_info) 50 'containers': [container_context(union_type, interfaces_info)
40 for union_type in union_types_for_containers], 51 for union_type in union_types_for_containers],
41 'cpp_includes': sorted(cpp_includes), 52 'cpp_includes': sorted(cpp_includes - UNION_CPP_INCLUDES_BLACKLIST),
42 'header_forward_decls': sorted(header_forward_decls), 53 'header_forward_decls': sorted(header_forward_decls),
43 'header_includes': sorted(UNION_H_INCLUDES), 54 'header_includes': sorted(UNION_H_INCLUDES),
44 'nullable_cpp_types': nullable_cpp_types, 55 'nullable_cpp_types': nullable_cpp_types,
45 } 56 }
46 57
47 58
48 def container_context(union_type, interfaces_info): 59 def container_context(union_type, interfaces_info):
49 members = [] 60 members = []
50 61
51 # These variables refer to member contexts if the given union type has 62 # These variables refer to member contexts if the given union type has
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 'cpp_value_to_v8_value': member.cpp_value_to_v8_value( 131 'cpp_value_to_v8_value': member.cpp_value_to_v8_value(
121 cpp_value='impl.getAs%s()' % member.name, isolate='isolate', 132 cpp_value='impl.getAs%s()' % member.name, isolate='isolate',
122 creation_context='creationContext'), 133 creation_context='creationContext'),
123 'is_traceable': member.is_traceable, 134 'is_traceable': member.is_traceable,
124 'rvalue_cpp_type': member.cpp_type_args(used_as_rvalue_type=True), 135 'rvalue_cpp_type': member.cpp_type_args(used_as_rvalue_type=True),
125 'specific_type_enum': 'SpecificType' + member.name, 136 'specific_type_enum': 'SpecificType' + member.name,
126 'type_name': member.name, 137 'type_name': member.name,
127 'v8_value_to_local_cpp_value': member.v8_value_to_local_cpp_value( 138 'v8_value_to_local_cpp_value': member.v8_value_to_local_cpp_value(
128 {}, 'v8Value', 'cppValue', needs_exception_state_for_string=True), 139 {}, 'v8Value', 'cppValue', needs_exception_state_for_string=True),
129 } 140 }
OLDNEW
« no previous file with comments | « Source/bindings/core/v8/custom/V8HTMLOptionsCollectionCustom.cpp ('k') | Source/core/html/HTMLOptionsCollection.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698