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/Dictionary.h', | 9 'bindings/core/v8/Dictionary.h', |
10 'bindings/core/v8/ExceptionState.h', | 10 'bindings/core/v8/ExceptionState.h', |
11 'bindings/core/v8/V8Binding.h', | 11 'bindings/core/v8/V8Binding.h', |
12 'platform/heap/Handle.h', | 12 'platform/heap/Handle.h', |
13 ]) | 13 ]) |
14 | 14 |
15 UNION_CPP_INCLUDES_BLACKLIST = frozenset([ | 15 UNION_CPP_INCLUDES_BLACKLIST = frozenset([ |
16 # This header defines static functions needed to implement event handler | 16 # This header defines static functions needed to implement event handler |
17 # attributes in interfaces that implement GlobalEventHandlers. They are not | 17 # attributes in interfaces that implement GlobalEventHandlers. They are not |
18 # needed or used by UnionTypes*.cpp, so including the header causes | 18 # needed or used by UnionTypes*.cpp, so including the header causes |
19 # compilation errors. | 19 # compilation errors. |
20 # FIXME: We should solve this problem in a way that doesn't involve special- | 20 # FIXME: We should solve this problem in a way that doesn't involve special- |
21 # casing a header like this. | 21 # casing a header like this. |
22 'core/dom/GlobalEventHandlers.h', | 22 'core/dom/GlobalEventHandlers.h', |
23 ]) | 23 ]) |
24 | 24 |
25 | 25 |
26 cpp_includes = set() | 26 cpp_includes = set() |
27 header_forward_decls = set() | 27 header_forward_decls = set() |
28 | 28 |
29 | 29 |
30 def union_context(union_types, interfaces_info): | 30 def union_context(union_types, interfaces_info, component): |
bashi
2015/04/01 07:16:51
nit: we generally put component-specific logic in
tasak
2015/04/02 05:31:36
Done.
| |
31 cpp_includes.clear() | 31 cpp_includes.clear() |
32 header_forward_decls.clear() | 32 header_forward_decls.clear() |
33 header_includes = set() | |
34 header_includes.update(UNION_H_INCLUDES) | |
33 | 35 |
34 # For container classes we strip nullable wrappers. For example, | 36 # For container classes we strip nullable wrappers. For example, |
35 # both (A or B)? and (A? or B) will become AOrB. This should be OK | 37 # both (A or B)? and (A? or B) will become AOrB. This should be OK |
36 # because container classes can handle null and it seems that | 38 # because container classes can handle null and it seems that |
37 # distinguishing (A or B)? and (A? or B) doesn't make sense. | 39 # distinguishing (A or B)? and (A? or B) doesn't make sense. |
38 container_cpp_types = set() | 40 container_cpp_types = set() |
39 union_types_for_containers = set() | 41 union_types_for_containers = set() |
40 nullable_cpp_types = set() | 42 nullable_cpp_types = set() |
41 for union_type in union_types: | 43 for union_type in union_types: |
42 cpp_type = union_type.cpp_type | 44 cpp_type = union_type.cpp_type |
43 if cpp_type not in container_cpp_types: | 45 if cpp_type not in container_cpp_types: |
44 union_types_for_containers.add(union_type) | 46 union_types_for_containers.add(union_type) |
45 container_cpp_types.add(cpp_type) | 47 container_cpp_types.add(cpp_type) |
46 if union_type.includes_nullable_type: | 48 if union_type.includes_nullable_type: |
47 nullable_cpp_types.add(cpp_type) | 49 nullable_cpp_types.add(cpp_type) |
48 | 50 |
49 union_types_for_containers = sorted(union_types_for_containers, | 51 union_types_for_containers = sorted(union_types_for_containers, |
50 key=lambda union_type: union_type.cpp_ty pe) | 52 key=lambda union_type: union_type.cpp_ty pe) |
51 nullable_cpp_types = sorted(nullable_cpp_types) | 53 nullable_cpp_types = sorted(nullable_cpp_types) |
54 header_includes.add('%s/%sExport.h' % (component, component.capitalize())) | |
bashi
2015/04/01 07:16:51
nit: how about adding ComonentInfo.include_path_fo
tasak
2015/04/02 05:31:36
Done.
| |
52 | 55 |
53 return { | 56 return { |
54 'containers': [container_context(union_type, interfaces_info) | 57 'containers': [container_context(union_type, interfaces_info) |
55 for union_type in union_types_for_containers], | 58 for union_type in union_types_for_containers], |
56 'cpp_includes': sorted(cpp_includes - UNION_CPP_INCLUDES_BLACKLIST), | 59 'cpp_includes': sorted(cpp_includes - UNION_CPP_INCLUDES_BLACKLIST), |
57 'header_forward_decls': sorted(header_forward_decls), | 60 'header_forward_decls': sorted(header_forward_decls), |
58 'header_includes': sorted(UNION_H_INCLUDES), | 61 'header_includes': sorted(header_includes), |
59 'nullable_cpp_types': nullable_cpp_types, | 62 'nullable_cpp_types': nullable_cpp_types, |
63 'exported': '%s_EXPORT ' % component.upper(), | |
bashi
2015/04/01 07:16:51
nit: I'd prefer dropping the trailing space and ad
bashi
2015/04/01 07:16:51
nit: alphabetical order.
tasak
2015/04/02 05:31:36
Moved 'exported' in the almost same way as Compone
tasak
2015/04/02 05:31:36
Temporarily I would like to use the trailing space
| |
60 } | 64 } |
61 | 65 |
62 | 66 |
63 def container_context(union_type, interfaces_info): | 67 def container_context(union_type, interfaces_info): |
64 members = [] | 68 members = [] |
65 | 69 |
66 # These variables refer to member contexts if the given union type has | 70 # These variables refer to member contexts if the given union type has |
67 # corresponding types. They are used for V8 -> impl conversion. | 71 # corresponding types. They are used for V8 -> impl conversion. |
68 array_buffer_type = None | 72 array_buffer_type = None |
69 array_buffer_view_type = None | 73 array_buffer_view_type = None |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
145 creation_context='creationContext'), | 149 creation_context='creationContext'), |
146 'enum_validation_expression': member.enum_validation_expression, | 150 'enum_validation_expression': member.enum_validation_expression, |
147 'is_traceable': member.is_traceable, | 151 'is_traceable': member.is_traceable, |
148 'rvalue_cpp_type': member.cpp_type_args(used_as_rvalue_type=True), | 152 'rvalue_cpp_type': member.cpp_type_args(used_as_rvalue_type=True), |
149 'specific_type_enum': 'SpecificType' + member.name, | 153 'specific_type_enum': 'SpecificType' + member.name, |
150 'type_name': member.name, | 154 'type_name': member.name, |
151 'v8_value_to_local_cpp_value': member.v8_value_to_local_cpp_value( | 155 'v8_value_to_local_cpp_value': member.v8_value_to_local_cpp_value( |
152 {}, 'v8Value', 'cppValue', isolate='isolate', | 156 {}, 'v8Value', 'cppValue', isolate='isolate', |
153 use_exception_state=True, restricted_float=True), | 157 use_exception_state=True, restricted_float=True), |
154 } | 158 } |
OLD | NEW |