From 6477e0b991e38ccc98bd8cafddcb1ee0266571ec Mon Sep 17 00:00:00 2001 From: Ekaterina Zaytseva Date: Tue, 9 Sep 2025 08:30:37 +0300 Subject: [PATCH] [ArkTS][Std] iterator: escompat->std.core Issue: #ICX0C3 Signed-off-by: Ekaterina Zaytseva --- static_core/plugins/ets/runtime/ets_panda_file_items.h | 2 +- .../ets/runtime/interop_js/ets_proxy/ets_class_wrapper.h | 2 +- .../ets/runtime/interop_js/js_refconvert_builtin.cpp | 4 ++-- static_core/plugins/ets/stdlib/escompat/Array.ets | 1 + static_core/plugins/ets/stdlib/escompat/TypedArrays.ets | 1 + .../plugins/ets/stdlib/{escompat => std/core}/Iterator.ets | 6 +++--- static_core/plugins/ets/templates/stdlib/Array_escompat.erb | 1 + static_core/plugins/ets/templates/stdlib/typedArray.ets.j2 | 1 + .../{escompat => std/core}/IteratorArrayTest.ets | 0 .../test-lists/ets-func-tests/ets-func-tests-excluded.txt | 2 +- 10 files changed, 12 insertions(+), 8 deletions(-) rename static_core/plugins/ets/stdlib/{escompat => std/core}/Iterator.ets (91%) rename static_core/plugins/ets/tests/ets_func_tests/{escompat => std/core}/IteratorArrayTest.ets (100%) diff --git a/static_core/plugins/ets/runtime/ets_panda_file_items.h b/static_core/plugins/ets/runtime/ets_panda_file_items.h index abbda9808c..707c6026c2 100644 --- a/static_core/plugins/ets/runtime/ets_panda_file_items.h +++ b/static_core/plugins/ets/runtime/ets_panda_file_items.h @@ -229,7 +229,7 @@ static constexpr std::string_view INTERFACE_OBJ_LITERAL = "Lstd/a // escompat static constexpr std::string_view DATE = "Lescompat/Date;"; static constexpr std::string_view ARRAY_ENTRIES_ITERATOR_T = "Lescompat/ArrayEntriesIterator_T;"; -static constexpr std::string_view ITERATOR_RESULT = "Lescompat/IteratorResult;"; +static constexpr std::string_view ITERATOR_RESULT = "Lstd/core/IteratorResult;"; static constexpr std::string_view ARRAY_KEYS_ITERATOR = "Lescompat/ArrayKeysIterator;"; static constexpr std::string_view ARRAY_VALUES_ITERATOR_T = "Lescompat/ArrayValuesIterator_T;"; static constexpr std::string_view MAP = "Lescompat/Map;"; diff --git a/static_core/plugins/ets/runtime/interop_js/ets_proxy/ets_class_wrapper.h b/static_core/plugins/ets/runtime/interop_js/ets_proxy/ets_class_wrapper.h index 4dce043411..887eea9a08 100644 --- a/static_core/plugins/ets/runtime/interop_js/ets_proxy/ets_class_wrapper.h +++ b/static_core/plugins/ets/runtime/interop_js/ets_proxy/ets_class_wrapper.h @@ -184,7 +184,7 @@ private: napi_ref jsProxyCtorRef_ {}; napi_ref jsProxyHandlerRef_ {}; - static constexpr const char *INTERFACE_ITERABLE_NAME = "escompat.IterableIterator"; + static constexpr const char *INTERFACE_ITERABLE_NAME = "std.core.IterableIterator"; }; class JSRefConvertJSProxy : public JSRefConvert { diff --git a/static_core/plugins/ets/runtime/interop_js/js_refconvert_builtin.cpp b/static_core/plugins/ets/runtime/interop_js/js_refconvert_builtin.cpp index 4bffa87553..158b49e204 100644 --- a/static_core/plugins/ets/runtime/interop_js/js_refconvert_builtin.cpp +++ b/static_core/plugins/ets/runtime/interop_js/js_refconvert_builtin.cpp @@ -253,7 +253,7 @@ private: { static const ets_proxy::EtsClassWrapper::OverloadsMap W_MAP_OVERLOADS = { {utf::CStringAsMutf8(""), - {"{ULescompat/Iterable;Lescompat/ReadonlyArray;Lstd/core/Null;}:V", 2, ""}}}; + {"{ULstd/core/Iterable;Lescompat/ReadonlyArray;Lstd/core/Null;}:V", 2, ""}}}; wMap_ = RegisterClassWithLeafMatcher(descriptors::MAP, "Map", &W_MAP_OVERLOADS); } @@ -261,7 +261,7 @@ private: { static const ets_proxy::EtsClassWrapper::OverloadsMap W_SET_OVERLOADS = { {utf::CStringAsMutf8(""), - {"{ULescompat/Iterable;Lstd/core/Null;[Lstd/core/Object;}:V", 2, ""}}}; + {"{ULstd/core/Iterable;Lstd/core/Null;[Lstd/core/Object;}:V", 2, ""}}}; wSet_ = RegisterClassWithLeafMatcher(descriptors::SET, "Set", &W_SET_OVERLOADS); } diff --git a/static_core/plugins/ets/stdlib/escompat/Array.ets b/static_core/plugins/ets/stdlib/escompat/Array.ets index 75e87d56f4..311e3115fb 100644 --- a/static_core/plugins/ets/stdlib/escompat/Array.ets +++ b/static_core/plugins/ets/stdlib/escompat/Array.ets @@ -14,6 +14,7 @@ */ package escompat; +import {iteratorForEach} from "std/core" // NOTE: autogenerated file diff --git a/static_core/plugins/ets/stdlib/escompat/TypedArrays.ets b/static_core/plugins/ets/stdlib/escompat/TypedArrays.ets index 1d7a7f47d6..c6c6fd9b7a 100644 --- a/static_core/plugins/ets/stdlib/escompat/TypedArrays.ets +++ b/static_core/plugins/ets/stdlib/escompat/TypedArrays.ets @@ -16,6 +16,7 @@ // Autogenerated file. DO NOT EDIT package escompat +import {iteratorForEach, tryGetIteratorLength} from "std/core" class Int8ArrayIteratorKeys implements IterableIterator { private length: int diff --git a/static_core/plugins/ets/stdlib/escompat/Iterator.ets b/static_core/plugins/ets/stdlib/std/core/Iterator.ets similarity index 91% rename from static_core/plugins/ets/stdlib/escompat/Iterator.ets rename to static_core/plugins/ets/stdlib/std/core/Iterator.ets index 5f13bdab6e..4a69297a47 100644 --- a/static_core/plugins/ets/stdlib/escompat/Iterator.ets +++ b/static_core/plugins/ets/stdlib/std/core/Iterator.ets @@ -13,7 +13,7 @@ * limitations under the License. */ -package escompat; +package std.core; export class IteratorResult { done: boolean @@ -49,7 +49,7 @@ export interface IterableIterator extends Iterator, Iterable { } } -function iteratorForEach(x: Iterator, fn: (x: V) => void): void { +export function iteratorForEach(x: Iterator, fn: (x: V) => void): void { while (true) { const v = x.next() if (v.done) { @@ -59,7 +59,7 @@ function iteratorForEach(x: Iterator, fn: (x: V) => void): void { } } -function tryGetIteratorLength (a: Object): int | null { +export function tryGetIteratorLength (a: Object): int | null { const aType = Type.of(a) as ClassType for (let i = 0; i < aType.getMethodsNum(); ++i) { let m = aType.getMethod(i) diff --git a/static_core/plugins/ets/templates/stdlib/Array_escompat.erb b/static_core/plugins/ets/templates/stdlib/Array_escompat.erb index 2afd21bed8..b0900db494 100644 --- a/static_core/plugins/ets/templates/stdlib/Array_escompat.erb +++ b/static_core/plugins/ets/templates/stdlib/Array_escompat.erb @@ -14,6 +14,7 @@ */ package escompat; +import {iteratorForEach} from "std/core" // NOTE: autogenerated file diff --git a/static_core/plugins/ets/templates/stdlib/typedArray.ets.j2 b/static_core/plugins/ets/templates/stdlib/typedArray.ets.j2 index 5ac995d860..02819eb7c5 100644 --- a/static_core/plugins/ets/templates/stdlib/typedArray.ets.j2 +++ b/static_core/plugins/ets/templates/stdlib/typedArray.ets.j2 @@ -16,6 +16,7 @@ // Autogenerated file. DO NOT EDIT package escompat +import {iteratorForEach, tryGetIteratorLength} from "std/core" {%- for N, U, T, BT, S in [ ('Int8', 'Uint8', 'byte', 'Byte', 1), diff --git a/static_core/plugins/ets/tests/ets_func_tests/escompat/IteratorArrayTest.ets b/static_core/plugins/ets/tests/ets_func_tests/std/core/IteratorArrayTest.ets similarity index 100% rename from static_core/plugins/ets/tests/ets_func_tests/escompat/IteratorArrayTest.ets rename to static_core/plugins/ets/tests/ets_func_tests/std/core/IteratorArrayTest.ets diff --git a/static_core/plugins/ets/tests/test-lists/ets-func-tests/ets-func-tests-excluded.txt b/static_core/plugins/ets/tests/test-lists/ets-func-tests/ets-func-tests-excluded.txt index 785881df02..2f7f80e5b5 100644 --- a/static_core/plugins/ets/tests/test-lists/ets-func-tests/ets-func-tests-excluded.txt +++ b/static_core/plugins/ets/tests/test-lists/ets-func-tests/ets-func-tests-excluded.txt @@ -26,7 +26,7 @@ escompat/JsonStringifyTest.ets # extended escompat/ArrayProxyTest.ets escompat/ArrayTest7.ets -escompat/IteratorArrayTest.ets +std/core/IteratorArrayTest.ets escompat/escompat_Array_modifications_Test_escompat_Array_modifications.ets escompat/escompat_Array_modifications_Test_escompat_Array_modifications_001.ets escompat/escompat_Array_modifications_Test_escompat_Array_modifications_002.ets -- Gitee