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

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

Issue 470063003: IDL: Use IdlArrayOrSequenceType for array/sequence IDL types (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@idl-extend-IdlTypeBase
Patch Set: Created 6 years, 4 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: Source/bindings/scripts/v8_types.py
diff --git a/Source/bindings/scripts/v8_types.py b/Source/bindings/scripts/v8_types.py
index 0ad036b7350ea27008f57eff9eee2a7c7c94fd21..561144123333caf43534d42b25c09203f49ef776 100644
--- a/Source/bindings/scripts/v8_types.py
+++ b/Source/bindings/scripts/v8_types.py
@@ -39,7 +39,7 @@ Design doc: http://www.chromium.org/developers/design-documents/idl-compiler
import posixpath
-from idl_types import IdlTypeBase, IdlType, IdlUnionType
+from idl_types import IdlTypeBase, IdlType, IdlUnionType, IdlArrayOrSequenceType
import v8_attributes # for IdlType.constructor_type_name
from v8_globals import includes
@@ -152,7 +152,7 @@ def cpp_type(idl_type, extended_attributes=None, raw_type=False, used_as_rvalue_
extended_attributes = extended_attributes or {}
idl_type = idl_type.preprocessed_type
- # Composite types
+ # Array or sequence types
if used_as_variadic_argument:
native_array_element_type = idl_type
else:
@@ -227,6 +227,11 @@ IdlUnionType.cpp_type_initializer = property(cpp_type_initializer_union)
IdlUnionType.cpp_type_args = cpp_type_union
+IdlTypeBase.native_array_element_type = None
+IdlArrayOrSequenceType.native_array_element_type = property(
+ lambda self: self.element_type)
+
+
def cpp_template_type(template, inner_type):
"""Returns C++ template specialized to type, with space added if needed."""
if inner_type.endswith('>'):
@@ -347,11 +352,6 @@ INCLUDES_FOR_TYPE = {
def includes_for_type(idl_type):
idl_type = idl_type.preprocessed_type
- # Composite types
- native_array_element_type = idl_type.native_array_element_type
haraken 2014/08/14 14:48:58 Why can we remove this code?
- if native_array_element_type:
- return includes_for_type(native_array_element_type)
-
# Simple types
base_idl_type = idl_type.base_type
if base_idl_type in INCLUDES_FOR_TYPE:
@@ -379,6 +379,8 @@ IdlType.includes_for_type = property(includes_for_type)
IdlUnionType.includes_for_type = property(
lambda self: set.union(*[includes_for_type(member_type)
for member_type in self.member_types]))
+IdlArrayOrSequenceType.includes_for_type = property(
+ lambda self: self.element_type.includes_for_type)
def add_includes_for_type(idl_type):
@@ -472,7 +474,7 @@ def v8_value_to_cpp_value(idl_type, extended_attributes, v8_value, index, isolat
if idl_type.name == 'void':
return ''
- # Composite types
+ # Array and sequence types
haraken 2014/08/14 14:48:58 Nit: and => or (You use "or" in other places.)
native_array_element_type = idl_type.native_array_element_type
if native_array_element_type:
return v8_value_to_cpp_value_array_or_sequence(native_array_element_type, v8_value, index)
@@ -537,7 +539,7 @@ def v8_value_to_local_cpp_value(idl_type, extended_attributes, v8_value, variabl
idl_type = idl_type.preprocessed_type
cpp_value = v8_value_to_cpp_value(idl_type, extended_attributes, v8_value, index, isolate)
args = [variable_name, cpp_value]
- if idl_type.base_type == 'DOMString' and not idl_type.native_array_element_type:
+ if idl_type.base_type == 'DOMString':
macro = 'TOSTRING_DEFAULT' if used_in_private_script else 'TOSTRING_VOID'
elif idl_type.may_raise_exception_on_conversion:
macro = 'TONATIVE_DEFAULT_EXCEPTIONSTATE' if used_in_private_script else 'TONATIVE_VOID_EXCEPTIONSTATE'
@@ -612,15 +614,20 @@ def v8_conversion_type(idl_type, extended_attributes):
or v8SetReturnValue* function; it can be an idl_type, a cpp_type, or a
separate name for the type of conversion (e.g., 'DOMWrapper').
"""
- extended_attributes = extended_attributes or {}
- # Composite types
+ # FIXME: Support union type.
+ if idl_type.is_union_type:
+ return ''
+
+ # Array or sequence types
native_array_element_type = idl_type.native_array_element_type
if native_array_element_type:
if native_array_element_type.is_interface_type:
add_includes_for_type(native_array_element_type)
return 'array'
+ extended_attributes = extended_attributes or {}
+
# Simple types
base_idl_type = idl_type.base_type
# Basic types, without additional includes
@@ -733,6 +740,7 @@ IdlType.release = property(lambda self: self.is_interface_type)
IdlUnionType.release = property(
lambda self: [member_type.is_interface_type
for member_type in self.member_types])
+IdlArrayOrSequenceType.release = False
haraken 2014/08/14 14:48:58 False => None ?
Nils Barth (inactive) 2014/08/14 14:54:56 release is a bool (see above: is_interface_type),
CPP_VALUE_TO_V8_VALUE = {
« Source/bindings/scripts/v8_dictionary.py ('K') | « Source/bindings/scripts/v8_methods.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698