Commit a74b91d5 authored by jl@opera.com's avatar jl@opera.com

IDL: Clean-up "should use Nullable<>" logic a little

Some duplication had sneaked in as part of the IDL dictionary work, with
IdlTypeBase.impl_should_use_nullable_container meaning almost the same
thing as IdlTypeBase.is_explicit_nullable, except the latter also implies
that the type is nullable.

Common up the actual logic in the new IdlTypeBase.cpp_type_has_null_value
property, and use it for both impl_should_use_nullable_container and
is_{implicit,explicit}_nullable.

Review URL: https://codereview.chromium.org/472803002

git-svn-id: svn://svn.chromium.org/blink/trunk@180287 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 60ce1110
...@@ -396,7 +396,7 @@ def add_includes_for_interface(interface_name): ...@@ -396,7 +396,7 @@ def add_includes_for_interface(interface_name):
def impl_should_use_nullable_container(idl_type): def impl_should_use_nullable_container(idl_type):
return idl_type.native_array_element_type or idl_type.is_primitive_type return not(idl_type.cpp_type_has_null_value)
IdlTypeBase.impl_should_use_nullable_container = property( IdlTypeBase.impl_should_use_nullable_container = property(
impl_should_use_nullable_container) impl_should_use_nullable_container)
...@@ -790,15 +790,20 @@ IdlType.literal_cpp_value = literal_cpp_value ...@@ -790,15 +790,20 @@ IdlType.literal_cpp_value = literal_cpp_value
################################################################################ ################################################################################
def is_implicit_nullable(idl_type): def cpp_type_has_null_value(idl_type):
# Nullable type where the corresponding C++ type supports a null value.
# - String types (String/AtomicString) represent null as a null string, # - String types (String/AtomicString) represent null as a null string,
# i.e. one for which String::isNull() returns true. # i.e. one for which String::isNull() returns true.
# - Wrapper types (raw pointer or RefPtr/PassRefPtr) represent null as # - Wrapper types (raw pointer or RefPtr/PassRefPtr) represent null as
# a null pointer. # a null pointer.
return idl_type.is_nullable and ( return ((idl_type.is_string_type or idl_type.is_wrapper_type) and
(idl_type.is_string_type or idl_type.is_wrapper_type) and not idl_type.native_array_element_type)
not idl_type.native_array_element_type)
IdlTypeBase.cpp_type_has_null_value = property(cpp_type_has_null_value)
def is_implicit_nullable(idl_type):
# Nullable type where the corresponding C++ type supports a null value.
return idl_type.is_nullable and idl_type.cpp_type_has_null_value
def is_explicit_nullable(idl_type): def is_explicit_nullable(idl_type):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment