Commit 4d7a7630 authored by Hitoshi Yoshida's avatar Hitoshi Yoshida Committed by Commit Bot

CodeGen: Do not use const T* for some user defined types

In concept, we would like constant dictionaries' getters to return
constant references.  However, it can be harmful for developers to
make some sorts of types, e.g. interfaces, constant.

This CL makes it to return a non const reference for those types.


Bug: 839389
Change-Id: I33d4e378e278baf5620c3d8cac39b65a0e590cb7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2301712
Commit-Queue: Hitoshi Yoshida <peria@chromium.org>
Reviewed-by: default avatarYuki Shiino <yukishiino@chromium.org>
Cr-Commit-Position: refs/heads/master@{#791744}
parent c6cffb06
...@@ -372,10 +372,21 @@ def make_dict_member_get(cg_context): ...@@ -372,10 +372,21 @@ def make_dict_member_get(cg_context):
member = cg_context.dict_member member = cg_context.dict_member
blink_member_name = _blink_member_name(member) blink_member_name = _blink_member_name(member)
name = blink_member_name.get_api name = blink_member_name.get_api
blink_type = blink_type_info(member.idl_type) idl_type = member.idl_type
blink_type = blink_type_info(idl_type)
const_ref_t = blink_type.const_ref_t const_ref_t = blink_type.const_ref_t
ref_t = blink_type.ref_t ref_t = blink_type.ref_t
# Since Blink conventionally prefers non-const references to const
# references for the certain types, makes const member's getters return a
# non-const reference. For example, "Node* foo() const;" is preferable to
# "const Node* foo() const;".
if (idl_type.unwrap().is_interface
or idl_type.unwrap().is_callback_interface
or idl_type.unwrap().is_callback_function
or idl_type.unwrap().is_buffer_source_type):
const_ref_t = ref_t
decls = ListNode() decls = ListNode()
defs = ListNode() defs = ListNode()
......
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