OLD | NEW |
---|---|
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. | |
haraken
2014/11/12 08:34:34
Add a FIXME?
Jens Widell
2014/11/12 08:40:13
Done.
| |
19 'core/dom/GlobalEventHandlers.h', | |
20 ]) | |
21 | |
22 | |
14 cpp_includes = set() | 23 cpp_includes = set() |
15 header_forward_decls = set() | 24 header_forward_decls = set() |
16 | 25 |
17 | 26 |
18 def union_context(union_types, interfaces_info): | 27 def union_context(union_types, interfaces_info): |
19 # For container classes we strip nullable wrappers. For example, | 28 # 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 | 29 # 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 | 30 # because container classes can handle null and it seems that |
22 # distinguishing (A or B)? and (A? or B) doesn't make sense. | 31 # distinguishing (A or B)? and (A? or B) doesn't make sense. |
23 container_cpp_types = set() | 32 container_cpp_types = set() |
24 union_types_for_containers = set() | 33 union_types_for_containers = set() |
25 nullable_cpp_types = set() | 34 nullable_cpp_types = set() |
26 for union_type in union_types: | 35 for union_type in union_types: |
27 cpp_type = union_type.cpp_type | 36 cpp_type = union_type.cpp_type |
28 if cpp_type not in container_cpp_types: | 37 if cpp_type not in container_cpp_types: |
29 union_types_for_containers.add(union_type) | 38 union_types_for_containers.add(union_type) |
30 container_cpp_types.add(cpp_type) | 39 container_cpp_types.add(cpp_type) |
31 if union_type.includes_nullable_type: | 40 if union_type.includes_nullable_type: |
32 nullable_cpp_types.add(cpp_type) | 41 nullable_cpp_types.add(cpp_type) |
33 | 42 |
34 union_types_for_containers = sorted(union_types_for_containers, | 43 union_types_for_containers = sorted(union_types_for_containers, |
35 key=lambda union_type: union_type.cpp_ty pe) | 44 key=lambda union_type: union_type.cpp_ty pe) |
36 nullable_cpp_types = sorted(nullable_cpp_types) | 45 nullable_cpp_types = sorted(nullable_cpp_types) |
37 | 46 |
38 return { | 47 return { |
39 'containers': [container_context(union_type, interfaces_info) | 48 'containers': [container_context(union_type, interfaces_info) |
40 for union_type in union_types_for_containers], | 49 for union_type in union_types_for_containers], |
41 'cpp_includes': sorted(cpp_includes), | 50 'cpp_includes': sorted(cpp_includes - UNION_CPP_INCLUDES_BLACKLIST), |
42 'header_forward_decls': sorted(header_forward_decls), | 51 'header_forward_decls': sorted(header_forward_decls), |
43 'header_includes': sorted(UNION_H_INCLUDES), | 52 'header_includes': sorted(UNION_H_INCLUDES), |
44 'nullable_cpp_types': nullable_cpp_types, | 53 'nullable_cpp_types': nullable_cpp_types, |
45 } | 54 } |
46 | 55 |
47 | 56 |
48 def container_context(union_type, interfaces_info): | 57 def container_context(union_type, interfaces_info): |
49 members = [] | 58 members = [] |
50 | 59 |
51 # These variables refer to member contexts if the given union type has | 60 # These variables refer to member contexts if the given union type has |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
120 'cpp_value_to_v8_value': member.cpp_value_to_v8_value( | 129 'cpp_value_to_v8_value': member.cpp_value_to_v8_value( |
121 cpp_value='impl.getAs%s()' % member.name, isolate='isolate', | 130 cpp_value='impl.getAs%s()' % member.name, isolate='isolate', |
122 creation_context='creationContext'), | 131 creation_context='creationContext'), |
123 'is_traceable': member.is_traceable, | 132 'is_traceable': member.is_traceable, |
124 'rvalue_cpp_type': member.cpp_type_args(used_as_rvalue_type=True), | 133 'rvalue_cpp_type': member.cpp_type_args(used_as_rvalue_type=True), |
125 'specific_type_enum': 'SpecificType' + member.name, | 134 'specific_type_enum': 'SpecificType' + member.name, |
126 'type_name': member.name, | 135 'type_name': member.name, |
127 'v8_value_to_local_cpp_value': member.v8_value_to_local_cpp_value( | 136 'v8_value_to_local_cpp_value': member.v8_value_to_local_cpp_value( |
128 {}, 'v8Value', 'cppValue', needs_exception_state_for_string=True), | 137 {}, 'v8Value', 'cppValue', needs_exception_state_for_string=True), |
129 } | 138 } |
OLD | NEW |