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

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

Issue 1974143002: Revert of Generate separate files for union type containers (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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
Index: third_party/WebKit/Source/bindings/scripts/v8_union.py
diff --git a/third_party/WebKit/Source/bindings/scripts/v8_union.py b/third_party/WebKit/Source/bindings/scripts/v8_union.py
index b7b6ece29470b4012ccfd16b11bf52cc73ed2525..fa22cdbac8cdabb86993dad1181c470e81ae327e 100644
--- a/third_party/WebKit/Source/bindings/scripts/v8_union.py
+++ b/third_party/WebKit/Source/bindings/scripts/v8_union.py
@@ -2,13 +2,8 @@
# 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
-
-UNION_CPP_INCLUDES = frozenset([
- 'bindings/core/v8/ToV8.h',
-])
UNION_H_INCLUDES = frozenset([
'bindings/core/v8/Dictionary.h',
@@ -33,12 +28,37 @@
header_includes = set()
-def container_context(union_type, interfaces_info):
+def union_context(union_types, interfaces_info):
cpp_includes.clear()
header_forward_decls.clear()
header_includes.clear()
- cpp_includes.update(UNION_CPP_INCLUDES)
header_includes.update(UNION_H_INCLUDES)
+
+ # 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()
+ 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)
+
+ union_types_for_containers = sorted(union_types_for_containers,
+ key=lambda union_type: union_type.cpp_type)
+
+ 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(header_includes),
+ }
+
+
+def container_context(union_type, interfaces_info):
members = []
# These variables refer to member contexts if the given union type has
@@ -94,17 +114,13 @@
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': cpp_class,
- 'cpp_includes': sorted(cpp_includes - UNION_CPP_INCLUDES_BLACKLIST),
+ 'cpp_class': union_type.cpp_type,
'dictionary_type': dictionary_type,
- 'header_includes': sorted(header_includes),
- 'header_forward_decls': sorted(header_forward_decls),
'includes_nullable_type': union_type.includes_nullable_type,
'interface_types': interface_types,
'members': members,
@@ -112,7 +128,6 @@
'object_type': object_type,
'string_type': string_type,
'type_string': str(union_type),
- 'v8_class': v8_types.v8_type(cpp_class),
}
@@ -120,7 +135,15 @@
if interface_info:
cpp_includes.update(interface_info.get(
'dependencies_include_paths', []))
- # We need complete types for IDL dictionaries in union containers.
+ # TODO(bashi): Workaround for http://crbug.com/524424
+ # Avoid using forward declaration for IDL dictionaries so that they
+ # aren't imcomplete types in UnionTypes.h. This enables an IDL
+ # dictionary to have a union type which has an IDL dictionary. e.g.
+ # dictionary DictA { (boolean or DictB) member; }
+ # Note that this doesn't cover all cases. We still can't use an IDL
+ # dictionary in a union type when the dictionary contains a union type.
+ # e.g.
+ # void foo((DOMString or DictA) arg); // won't compile
if member.is_dictionary:
header_includes.update(member.includes_for_type())
else:
« no previous file with comments | « third_party/WebKit/Source/bindings/scripts/utilities.py ('k') | third_party/WebKit/Source/bindings/templates/templates.gni » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698