Commit 0ecce979 authored by Hitoshi Yoshida's avatar Hitoshi Yoshida Committed by Commit Bot

CodeGen: Generate migration adapter API setXxxToNull

Generates setXxxToNull() to set null value on a nullable dictionary
member, whose C++ type uses base::Optional<T>.
This API is a migration adapter, and there are some use cases in
hand-written code.  We also can set a null value for other types using
setXxx() APIs.


Bug: 839389
Change-Id: I6989a58ed3542d4f76f7b9e519f3c49947732904
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2060406
Commit-Queue: Hitoshi Yoshida <peria@chromium.org>
Reviewed-by: default avatarYuki Shiino <yukishiino@chromium.org>
Cr-Commit-Position: refs/heads/master@{#742086}
parent 2988bc84
...@@ -153,6 +153,19 @@ def make_dict_member_set_def(cg_context): ...@@ -153,6 +153,19 @@ def make_dict_member_set_def(cg_context):
_1 = blink_member_name.presence_var _1 = blink_member_name.presence_var
body.append(T(_format("{_1} = true;", _1=_1))) body.append(T(_format("{_1} = true;", _1=_1)))
# Migration Adapter
real_type = member.idl_type.unwrap(typedef=True)
if (real_type.is_nullable and
blink_type_info(real_type).typename.startswith("base::Optional")):
func_to_null_def = CxxFuncDefNode(
name=_format("{}ToNull", blink_member_name.set_api),
arg_decls=[],
return_type="void")
func_to_null_def.set_base_template_vars(cg_context.template_bindings())
func_to_null_def.body.append(
T(_format("{}(base::nullopt);", blink_member_name.set_api)))
return ListNode([func_def, func_to_null_def])
return func_def return func_def
...@@ -772,5 +785,5 @@ def generate_dictionary(dictionary): ...@@ -772,5 +785,5 @@ def generate_dictionary(dictionary):
def generate_dictionaries(web_idl_database): def generate_dictionaries(web_idl_database):
dictionary = web_idl_database.find('GPUCommandBufferDescriptor') dictionary = web_idl_database.find("ComputedEffectTiming")
generate_dictionary(dictionary) generate_dictionary(dictionary)
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