dawn_wire: Remove unused support of "const*const*"

This patch removes the support of annotation "const*const*" in
the template WireCmd.cpp as it is not used in current Dawn wire
implementation.

BUG=chromium:1266727

Change-Id: I4c4d68ccc050edb5f855094910440e90aef2bc4a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/72040
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
This commit is contained in:
Jiawei Shao 2021-12-09 02:43:28 +00:00 committed by Dawn LUCI CQ
parent b6d80e027d
commit 264f239259
5 changed files with 7 additions and 30 deletions

View File

@ -38,7 +38,7 @@ Most items and sub-items can include a list of `"tags"`, which, if specified, co
A **record** is a list of **record members**, each of which is a dictionary with the following schema:
- `"name"` a string
- `"type"` a string, the name of the base type for this member
- `"annotation"` a string, default to "value". Define the C annotation to apply to the base type. Allowed annotations are `"value"` (the default), `"*"`, `"const*"`, `"const*const*"`
- `"annotation"` a string, default to "value". Define the C annotation to apply to the base type. Allowed annotations are `"value"` (the default), `"*"`, `"const*"`
- `"length"` (default to 1 if not set), a string. Defines length of the array pointed to for pointer arguments. If not set the length is implicitly 1 (so not an array), but otherwise it can be set to the name of another member in the same record that will contain the length of the array (this is heavily used in the `fooCount` `foos` pattern in the API). As a special case `"strlen"` can be used for `const char*` record members to denote that the length should be determined with `strlen`.
- `"optional"` (default to false) a boolean that says whether this member is optional. Member records can be optional if they are pointers (otherwise dawn_wire will always try to dereference them), objects (otherwise dawn_wire will always try to encode their ID and crash), or if they have a `"default"` key. Optional pointers and objects will always default to `nullptr`.
- `"default"` (optional) a number or string. If set the record member will use that value as default value. Depending on the member's category it can be a number, a string containing a number, or the name of an enum/bitmask value.

View File

@ -594,8 +594,6 @@ def decorate(name, typ, arg):
return typ + ' * ' + name
elif arg.annotation == 'const*':
return typ + ' const * ' + name
elif arg.annotation == 'const*const*':
return 'const ' + typ + '* const * ' + name
else:
assert False

View File

@ -140,7 +140,7 @@ namespace {{metadata.namespace}} {
};
{% macro render_cpp_default_value(member, is_struct=True) -%}
{%- if member.annotation in ["*", "const*", "const*const*"] and member.optional -%}
{%- if member.annotation in ["*", "const*"] and member.optional -%}
{{" "}}= nullptr
{%- elif member.type.category == "object" and member.optional and is_struct -%}
{{" "}}= nullptr

View File

@ -21,7 +21,7 @@
namespace dawn_native {
{% macro render_cpp_default_value(member) -%}
{%- if member.annotation in ["*", "const*", "const*const*"] and member.optional -%}
{%- if member.annotation in ["*", "const*"] and member.optional -%}
{{" "}}= nullptr
{%- elif member.type.category == "object" and member.optional -%}
{{" "}}= nullptr

View File

@ -65,11 +65,7 @@
WIRE_TRY(provider.Get{{Optional}}Id({{in}}, &{{out}}));
{% elif member.type.category == "structure"%}
{%- set Provider = ", provider" if member.type.may_have_dawn_object else "" -%}
{% if member.annotation == "const*const*" %}
WIRE_TRY({{as_cType(member.type.name)}}Serialize(*{{in}}, &{{out}}, buffer{{Provider}}));
{% else %}
WIRE_TRY({{as_cType(member.type.name)}}Serialize({{in}}, &{{out}}, buffer{{Provider}}));
{% endif %}
WIRE_TRY({{as_cType(member.type.name)}}Serialize({{in}}, &{{out}}, buffer{{Provider}}));
{%- else -%}
{{out}} = {{in}};
{%- endif -%}
@ -178,12 +174,8 @@
//* Structures might contain more pointers so we need to add their extra size as well.
{% if member.type.category == "structure" %}
for (decltype(memberLength) i = 0; i < memberLength; ++i) {
{% if member.annotation == "const*const*" %}
result += {{as_cType(member.type.name)}}GetExtraRequiredSize(*record.{{as_varName(member.name)}}[i]);
{% else %}
{{assert(member.annotation == "const*")}}
result += {{as_cType(member.type.name)}}GetExtraRequiredSize(record.{{as_varName(member.name)}}[i]);
{% endif %}
{{assert(member.annotation == "const*")}}
result += {{as_cType(member.type.name)}}GetExtraRequiredSize(record.{{as_varName(member.name)}}[i]);
}
{% endif %}
{% elif member.type.category == "structure" %}
@ -383,20 +375,7 @@
{{as_cType(member.type.name)}}* copiedMembers;
WIRE_TRY(GetSpace(allocator, memberLength, &copiedMembers));
{% if member.annotation == "const*const*" %}
{{as_cType(member.type.name)}}** pointerArray;
WIRE_TRY(GetSpace(allocator, memberLength, &pointerArray));
//* This loop cannot overflow because it iterates up to |memberLength|. Even if
//* memberLength were the maximum integer value, |i| would become equal to it just before
//* exiting the loop, but not increment past or wrap around.
for (decltype(memberLength) i = 0; i < memberLength; ++i) {
pointerArray[i] = &copiedMembers[i];
}
record->{{memberName}} = pointerArray;
{% else %}
record->{{memberName}} = copiedMembers;
{% endif %}
record->{{memberName}} = copiedMembers;
{% if member.type.is_wire_transparent %}
//* memcpy is not allowed to copy from volatile objects. However, these arrays