Chromium Code Reviews| Index: Source/bindings/scripts/v8_types.py |
| diff --git a/Source/bindings/scripts/v8_types.py b/Source/bindings/scripts/v8_types.py |
| index 5f930d324866e2c464a5fc00dbfe2af65cc1d62c..2500b0c554689a12edfbafbce195ad9ce7664ea4 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, IdlArrayOrSequenceType |
| +from idl_types import IdlTypeBase, IdlType, IdlUnionType, IdlArrayOrSequenceType, IdlNullableType |
| import v8_attributes # for IdlType.constructor_type_name |
| from v8_globals import includes |
| @@ -75,12 +75,16 @@ TYPED_ARRAYS = { |
| IdlTypeBase.is_typed_array_element_type = False |
| IdlType.is_typed_array_element_type = property( |
| lambda self: self.base_type in TYPED_ARRAYS) |
| +IdlNullableType.is_typed_array_element_type = property( |
|
Nils Barth (inactive)
2014/08/19 13:53:38
Remove?
|
| + lambda self: self.inner_type.is_typed_array_element_type) |
| IdlTypeBase.is_wrapper_type = False |
| IdlType.is_wrapper_type = property( |
| lambda self: (self.is_interface_type and |
| self.base_type not in NON_WRAPPER_TYPES)) |
| +IdlNullableType.is_wrapper_type = property( |
|
Nils Barth (inactive)
2014/08/19 13:53:38
Remove?
|
| + lambda self: self.inner_type.is_wrapper_type) |
| ################################################################################ |
| @@ -242,6 +246,8 @@ IdlUnionType.cpp_type_args = cpp_type_union |
| IdlTypeBase.native_array_element_type = None |
| IdlArrayOrSequenceType.native_array_element_type = property( |
| lambda self: self.element_type) |
| +IdlNullableType.native_array_element_type = property( |
|
bashi
2014/08/19 13:51:42
If we take this approach, can we remove this?
|
| + lambda self: self.inner_type.native_array_element_type) |
| def cpp_template_type(template, inner_type): |
| @@ -285,7 +291,7 @@ def implemented_as(idl_type): |
| return base_idl_type |
| -IdlType.implemented_as = property(implemented_as) |
| +IdlTypeBase.implemented_as = property(implemented_as) |
| IdlType.set_implemented_as_interfaces = classmethod( |
| lambda cls, new_implemented_as_interfaces: |
| @@ -295,8 +301,7 @@ IdlType.set_implemented_as_interfaces = classmethod( |
| # [GarbageCollected] |
| IdlType.garbage_collected_types = set() |
| -IdlTypeBase.is_garbage_collected = False |
| -IdlType.is_garbage_collected = property( |
| +IdlTypeBase.is_garbage_collected = property( |
| lambda self: self.base_type in IdlType.garbage_collected_types) |
| IdlType.set_garbage_collected_types = classmethod( |
| @@ -307,8 +312,7 @@ IdlType.set_garbage_collected_types = classmethod( |
| # [WillBeGarbageCollected] |
| IdlType.will_be_garbage_collected_types = set() |
| -IdlTypeBase.is_will_be_garbage_collected = False |
| -IdlType.is_will_be_garbage_collected = property( |
| +IdlTypeBase.is_will_be_garbage_collected = property( |
| lambda self: self.base_type in IdlType.will_be_garbage_collected_types) |
| IdlType.set_will_be_garbage_collected_types = classmethod( |
| @@ -393,6 +397,8 @@ IdlUnionType.includes_for_type = property( |
| for member_type in self.member_types])) |
| IdlArrayOrSequenceType.includes_for_type = property( |
| lambda self: self.element_type.includes_for_type) |
| +IdlNullableType.includes_for_type = property( |
|
Nils Barth (inactive)
2014/08/19 13:53:38
Remove?
|
| + lambda self: self.inner_type.includes_for_type) |
| def add_includes_for_type(idl_type): |
| @@ -605,7 +611,10 @@ def preprocess_idl_type_and_value(idl_type, cpp_value, extended_attributes): |
| if idl_type.base_type in ['long long', 'unsigned long long']: |
| # long long and unsigned long long are not representable in ECMAScript; |
| # we represent them as doubles. |
| - idl_type = IdlType('double', is_nullable=idl_type.is_nullable) |
| + is_nullable = idl_type.is_nullable |
| + idl_type = IdlType('double') |
| + if is_nullable: |
| + idl_type = IdlNullableType(idl_type) |
| cpp_value = 'static_cast<double>(%s)' % cpp_value |
| # HTML5 says that unsigned reflected attributes should be in the range |
| # [0, 2^31). When a value isn't in this range, a default value (or 0) |
| @@ -738,7 +747,7 @@ def v8_set_return_value_union(idl_type, cpp_value, extended_attributes=None, scr |
| IdlTypeBase.v8_set_return_value = v8_set_return_value |
| IdlUnionType.v8_set_return_value = v8_set_return_value_union |
| -IdlType.release = property(lambda self: self.is_interface_type) |
| +IdlTypeBase.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]) |
| @@ -792,7 +801,7 @@ def literal_cpp_value(idl_type, idl_literal): |
| return literal_value + 'u' |
| return literal_value |
| -IdlType.literal_cpp_value = literal_cpp_value |
| +IdlTypeBase.literal_cpp_value = literal_cpp_value |
| ################################################################################ |