[dawn][webgpu.h] Remove generator support for strlen

This is no longer used anywhere in dawn*.json so we can remove support
and simplify a bunch of code in WireCmd and Kotlin templates.

Bug: 42241188
Change-Id: I127bf2040f9d1b6fe5541f595404954265dfdd85
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/209498
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
diff --git a/docs/dawn/codegen.md b/docs/dawn/codegen.md
index 0998f28..aee76af 100644
--- a/docs/dawn/codegen.md
+++ b/docs/dawn/codegen.md
@@ -43,7 +43,7 @@
  - `"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*"`
- - `"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`.
+ - `"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).
  - `"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` (unless `"no_default"` is set to `true`).
  - `"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.
    - Dawn implements "trivial defaulting" for enums, similarly to the upstream WebGPU spec's WebIDL: if a zero-valued enum (usually called `Undefined`) is passed in, Dawn applies the default value specified here. See `WithTrivialFrontendDefaults()` in `api_structs.h` for how this works.
diff --git a/generator/dawn_json_generator.py b/generator/dawn_json_generator.py
index 2e11159..9f66565 100644
--- a/generator/dawn_json_generator.py
+++ b/generator/dawn_json_generator.py
@@ -417,8 +417,6 @@
                     member.constant_length = 1
                 else:
                     assert False
-            elif m['length'] == 'strlen':
-                member.length = 'strlen'
             elif isinstance(m['length'], int):
                 assert m['length'] > 0
                 member.length = "constant"
diff --git a/generator/templates/art/api_jni_types.cpp b/generator/templates/art/api_jni_types.cpp
index d62ce37..4d4e654 100644
--- a/generator/templates/art/api_jni_types.cpp
+++ b/generator/templates/art/api_jni_types.cpp
@@ -26,9 +26,7 @@
 //* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 {% macro arg_to_jni_type(arg) %}
-    {%- if arg.length == 'strlen' -%}
-        jstring
-    {%- elif arg.length and arg.length != 'constant' -%}
+    {%- if arg.length and arg.length != 'constant' -%}
         {%- if arg.type.category in ['bitmask', 'enum', 'function pointer', 'object', 'structure'] -%}
             jobjectArray
         {%- elif arg.type.name.get() == 'void' -%}
@@ -56,7 +54,7 @@
 {% endmacro %}
 
 {% macro jni_signature(member) %}
-    {%- if member.length == 'strlen' or member.type.name.get() == 'string view' -%}
+    {%- if member.type.name.get() == 'string view' -%}
         Ljava/lang/String;
     {%- elif member.length and member.length != 'constant' -%}
         {%- if member.type.category in ['bitmask', 'enum'] -%}
@@ -124,8 +122,6 @@
         jobject {{ output }} = ToKotlin(env, {{ '&' if member.annotation not in ['*', 'const*'] }}{{ input }});
     {% elif member.type.name.get() == 'void *' %}
         jlong {{ output }} = reinterpret_cast<jlong>({{ input }});
-    {% elif member.type.name.get() == 'char' %}
-        jstring {{ output }} = {{ input }} ? env->NewStringUTF({{ input }}) : nullptr;
     {% elif member.type.category in ['bitmask', 'enum', 'native'] %}
         //* We use Kotlin value classes for bitmask and enum, and they get inlined as lone values.
         {{ to_jni_type(member.type) }} {{ output }} = static_cast<{{ to_jni_type(member.type) }}>({{ input }});
diff --git a/generator/templates/art/api_kotlin_types.kt b/generator/templates/art/api_kotlin_types.kt
index 9c34345..f666094 100644
--- a/generator/templates/art/api_kotlin_types.kt
+++ b/generator/templates/art/api_kotlin_types.kt
@@ -29,10 +29,9 @@
     {%- set type = arg.type %}
     {%- set optional = arg.optional %}
     {%- set default_value = arg.default_value %}
-    {%- if arg.length == 'strlen' or arg.type.name.get() == 'string view' -%}
-        {%- set optional_string = optional or default_value == 'nullptr' -%}
-        String{{ '?' if optional_string }}
-        {%- if emit_defaults and optional_string -%}
+    {%- if arg.type.name.get() == 'string view' -%}
+        String{{ '?' if optional }}
+        {%- if emit_defaults and optional-%}
             {{ ' ' }}= null
         {%- endif %}
     {% elif type.name.get() == 'void' %}
diff --git a/generator/templates/art/kotlin_record_conversion.cpp b/generator/templates/art/kotlin_record_conversion.cpp
index 7d5ced7..46d799d 100644
--- a/generator/templates/art/kotlin_record_conversion.cpp
+++ b/generator/templates/art/kotlin_record_conversion.cpp
@@ -50,13 +50,7 @@
             {
                 auto& in = inStruct.{{member.name.camelCase()}};
                 auto& out = outStruct->{{member.name.camelCase()}};
-                {% if member.length == 'strlen' %}
-                    if (in != nullptr) {
-                        out = c->GetStringUTFChars(in);
-                    } else {
-                        out = nullptr;
-                    }
-                {% elif member.constant_length == 1 %}
+                {% if member.constant_length == 1 %}
                     {% if member.type.category == 'structure' %}
                         if (in != nullptr) {
                             auto converted = c->Alloc<{{as_cType(member.type.name)}}>();
diff --git a/generator/templates/dawn/native/api_StreamImpl.cpp b/generator/templates/dawn/native/api_StreamImpl.cpp
index 68b5e4e..5eae419 100644
--- a/generator/templates/dawn/native/api_StreamImpl.cpp
+++ b/generator/templates/dawn/native/api_StreamImpl.cpp
@@ -53,8 +53,6 @@
     {%- set name = member.name.camelCase() -%}
     {% if member.length == None %}
         StreamIn(sink, t.{{name}});
-    {% elif member.length == "strlen" %}
-        StreamIn(sink, Iterable(t.{{name}}, strlen(t.{{name}})));
     {% else %}
         StreamIn(sink, Iterable(t.{{name}}, t.{{member.length.name.camelCase()}}));
     {% endif %}
diff --git a/generator/templates/dawn/wire/WireCmd.cpp b/generator/templates/dawn/wire/WireCmd.cpp
index 8f78f69..46db0c0 100644
--- a/generator/templates/dawn/wire/WireCmd.cpp
+++ b/generator/templates/dawn/wire/WireCmd.cpp
@@ -152,10 +152,6 @@
                 {{member_transfer_type(member)}} {{as_varName(member.name)}};
                 {% continue %}
             {% endif %}
-            //* Members of type "const char *" have their length embedded directly in the command.
-            {% if member.length == "strlen" %}
-                uint64_t {{as_varName(member.name)}}Strlen;
-            {% endif %}
             //* Optional members additionally come with a boolean to indicate whether they were set.
             {% if member.optional and member.type.category != "object" %}
                 WGPUBool has_{{as_varName(member.name)}};
@@ -189,18 +185,6 @@
             {% if member.skip_serialize %}
                 {% continue %}
             {% endif %}
-            //* Special handling of const char* that have their length embedded directly in the command.
-            {% if member.length == "strlen" %}
-                {% if member.optional %}
-                    if (record.{{memberName}} != nullptr) {
-                        result += Align(std::strlen(record.{{memberName}}), kWireBufferAlignment);
-                    }
-                {% else %}
-                    DAWN_ASSERT(record.{{memberName}} != nullptr);
-                    result += Align(std::strlen(record.{{memberName}}), kWireBufferAlignment);
-                {% endif %}
-                {% continue %}
-            {% endif %}
             //* Normal handling for pointer members and structs.
             {% if member.annotation != "value" %}
                 {% if member.type.category != "object" and member.optional %}
@@ -273,23 +257,6 @@
                 {{serialize_member(member, "record." + memberName, "transfer->" + memberName)}}
                 {% continue %}
             {% endif %}
-            //* Special handling of const char* that have their length embedded directly in the command.
-            {% if member.length == "strlen" %}
-                {% if member.optional %}
-                    bool has_{{memberName}} = record.{{memberName}} != nullptr;
-                    transfer->has_{{memberName}} = has_{{memberName}};
-                    if (has_{{memberName}}) {
-                {% else %}
-                    {
-                {% endif %}
-                    transfer->{{memberName}}Strlen = std::strlen(record.{{memberName}});
-
-                    char* stringInBuffer;
-                    WIRE_TRY(buffer->NextN(transfer->{{memberName}}Strlen, &stringInBuffer));
-                    memcpy(stringInBuffer, record.{{memberName}}, transfer->{{memberName}}Strlen);
-                }
-                {% continue %}
-            {% endif %}
             //* Allocate space and write the non-value arguments in it.
             {% do assert(member.annotation != "const*const*") %}
             {% if member.type.category != "object" and member.optional %}
@@ -371,38 +338,6 @@
                 {{deserialize_member(member, "transfer->" + memberName, "record->" + memberName)}}
                 {% continue %}
             {% endif %}
-            //* Special handling of const char* that have their length embedded directly in the command.
-            {% if member.length == "strlen" %}
-                {% if member.optional %}
-                    bool has_{{memberName}} = transfer->has_{{memberName}};
-                    record->{{memberName}} = nullptr;
-                    if (has_{{memberName}}) {
-                {% else %}
-                    {
-                {% endif %}
-                    uint64_t stringLength64 = transfer->{{memberName}}Strlen;
-                    if (stringLength64 >= std::numeric_limits<size_t>::max()) {
-                        //* Cannot allocate space for the string. It can be at most
-                        //* size_t::max() - 1. We need 1 byte for the null-terminator.
-                        return WireResult::FatalError;
-                    }
-                    size_t stringLength = static_cast<size_t>(stringLength64);
-
-                    const volatile char* stringInBuffer;
-                    WIRE_TRY(deserializeBuffer->ReadN(stringLength, &stringInBuffer));
-
-                    char* copiedString;
-                    WIRE_TRY(GetSpace(allocator, stringLength + 1, &copiedString));
-                    //* We can cast away the volatile qualifier because DeserializeBuffer::ReadN already
-                    //* validated that the range [stringInBuffer, stringInBuffer + stringLength) is valid.
-                    //* memcpy may have an unknown access pattern, but this is fine since the string is only
-                    //* data and won't affect control flow of this function.
-                    memcpy(copiedString, const_cast<const char*>(stringInBuffer), stringLength);
-                    copiedString[stringLength] = '\0';
-                    record->{{memberName}} = copiedString;
-                }
-                {% continue %}
-            {% endif %}
             //* Get extra buffer data, and copy pointed to values in extra allocated space. Note that
             //* currently, there is an implicit restriction that "skip_serialize" members must not be be
             //* a "value" type, and that they are the last non-"value" type specified in the list in