[Kotlin] Fix methods that return containers
The returnAllocation logic was not wired up to the args struct.
I was also able to simplify the logic in the second call parameter loop.
Bug: 375591466
Test: FeaturesTest
Change-Id: I4da704dfec427fc96b0915fca4dd57c3d74cfcca
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/212414
Reviewed-by: Corentin Wallez <cwallez@google.com>
Auto-Submit: Jim Blackler <jimblackler@google.com>
Commit-Queue: Jim Blackler <jimblackler@google.com>
diff --git a/generator/templates/art/methods.cpp b/generator/templates/art/methods.cpp
index a9c9c0c..be896c9 100644
--- a/generator/templates/art/methods.cpp
+++ b/generator/templates/art/methods.cpp
@@ -126,15 +126,14 @@
{% endfor %}
);
//* Allocate the native container
- auto returnAllocation = std::make_unique<{{ as_cType(_kotlin_return.type.name) }}[]>(size);
+ args.{{ as_varName(_kotlin_return.name) }} = c.AllocArray<{{ as_cType(_kotlin_return.type.name) }}>(size);
if (env->ExceptionCheck()) { //* Early out if client (Kotlin) callback threw an exception.
return nullptr;
}
//* Second call completes the native container
wgpu{{ object.name.CamelCase() }}{{ method.name.CamelCase() }}(handle
{% for arg in method.arguments -%}
- {{- ', ' if object or not loop.first -}}
- {{- 'returnAllocation.get()' if arg == _kotlin_return else "args." + as_varName(arg.name) -}}
+ , {{- "args." + as_varName(arg.name) -}}
{% endfor %}
);
if (env->ExceptionCheck()) { //* Early out if client (Kotlin) callback threw an exception.