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

Unified Diff: Source/bindings/scripts/v8_union.py

Issue 953123003: IDL: Put generated union type containers in separate files (Closed) Base URL: svn://svn.chromium.org/blink/trunk
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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/bindings/scripts/code_generator_v8.py ('k') | Source/bindings/templates/templates.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/bindings/scripts/v8_union.py
diff --git a/Source/bindings/scripts/v8_union.py b/Source/bindings/scripts/v8_union.py
index 4ed138fac624837e7d9b30a32819fd6e9c5c1986..f6c96f4ef4b0368d6f24beff4853055381c0c7a2 100644
--- a/Source/bindings/scripts/v8_union.py
+++ b/Source/bindings/scripts/v8_union.py
@@ -2,6 +2,7 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
+import v8_types
import v8_utilities
@@ -12,7 +13,7 @@ UNION_H_INCLUDES = frozenset([
'platform/heap/Handle.h',
])
-UNION_CPP_INCLUDES_BLACKLIST = frozenset([
+UNION_HEADER_INCLUDES_BLACKLIST = frozenset([
# This header defines static functions needed to implement event handler
# attributes in interfaces that implement GlobalEventHandlers. They are not
# needed or used by UnionTypes*.cpp, so including the header causes
@@ -23,44 +24,12 @@ UNION_CPP_INCLUDES_BLACKLIST = frozenset([
])
-cpp_includes = set()
-header_forward_decls = set()
-
-
-def union_context(union_types, interfaces_info):
- cpp_includes.clear()
- header_forward_decls.clear()
-
- # For container classes we strip nullable wrappers. For example,
- # both (A or B)? and (A? or B) will become AOrB. This should be OK
- # because container classes can handle null and it seems that
- # distinguishing (A or B)? and (A? or B) doesn't make sense.
- container_cpp_types = set()
- union_types_for_containers = set()
- nullable_cpp_types = set()
- for union_type in union_types:
- cpp_type = union_type.cpp_type
- if cpp_type not in container_cpp_types:
- union_types_for_containers.add(union_type)
- container_cpp_types.add(cpp_type)
- if union_type.includes_nullable_type:
- nullable_cpp_types.add(cpp_type)
-
- union_types_for_containers = sorted(union_types_for_containers,
- key=lambda union_type: union_type.cpp_type)
- nullable_cpp_types = sorted(nullable_cpp_types)
-
- return {
- 'containers': [container_context(union_type, interfaces_info)
- for union_type in union_types_for_containers],
- 'cpp_includes': sorted(cpp_includes - UNION_CPP_INCLUDES_BLACKLIST),
- 'header_forward_decls': sorted(header_forward_decls),
- 'header_includes': sorted(UNION_H_INCLUDES),
- 'nullable_cpp_types': nullable_cpp_types,
- }
+header_includes = set()
def container_context(union_type, interfaces_info):
+ header_includes.clear()
+ header_includes.update(UNION_H_INCLUDES)
members = []
# These variables refer to member contexts if the given union type has
@@ -111,13 +80,15 @@ def container_context(union_type, interfaces_info):
if dictionary_type and nullable_members == 1:
raise Exception('%s has a dictionary and a nullable member' % union_type.name)
+ cpp_class = union_type.cpp_type
return {
'array_buffer_type': array_buffer_type,
'array_buffer_view_type': array_buffer_view_type,
'array_or_sequence_type': array_or_sequence_type,
'boolean_type': boolean_type,
- 'cpp_class': union_type.cpp_type,
+ 'cpp_class': cpp_class,
'dictionary_type': dictionary_type,
+ 'header_includes': sorted(header_includes - UNION_HEADER_INCLUDES_BLACKLIST),
'includes_nullable_type': union_type.includes_nullable_type,
'interface_types': interface_types,
'members': members,
@@ -125,15 +96,15 @@ def container_context(union_type, interfaces_info):
'numeric_type': numeric_type,
'string_type': string_type,
'type_string': str(union_type),
+ 'v8_class': v8_types.v8_type(cpp_class),
}
def member_context(member, interfaces_info):
- cpp_includes.update(member.includes_for_type)
+ header_includes.update(member.includes_for_type)
interface_info = interfaces_info.get(member.name, None)
if interface_info:
- cpp_includes.update(interface_info.get('dependencies_include_paths', []))
- header_forward_decls.add(member.implemented_as)
+ header_includes.update(interface_info.get('dependencies_include_paths', []))
if member.is_nullable:
member = member.inner_type
return {
« no previous file with comments | « Source/bindings/scripts/code_generator_v8.py ('k') | Source/bindings/templates/templates.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698