From f0ad936e5ba79befb9a5ac8f50edd62f65c5ed48 Mon Sep 17 00:00:00 2001 From: TopchetoEU <36534413+TopchetoEU@users.noreply.github.com> Date: Sat, 25 Nov 2023 18:43:43 +0200 Subject: [PATCH] refactor: use new iterable names --- src/me/topchetoeu/jscript/lib/MapLib.java | 8 ++++---- src/me/topchetoeu/jscript/lib/RegExpLib.java | 2 +- src/me/topchetoeu/jscript/lib/SetLib.java | 8 ++++---- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/me/topchetoeu/jscript/lib/MapLib.java b/src/me/topchetoeu/jscript/lib/MapLib.java index 53acc2a..f7762c5 100644 --- a/src/me/topchetoeu/jscript/lib/MapLib.java +++ b/src/me/topchetoeu/jscript/lib/MapLib.java @@ -35,15 +35,15 @@ import me.topchetoeu.jscript.interop.NativeGetter; var res = map.entrySet().stream().map(v -> { return new ArrayValue(ctx, v.getKey(), v.getValue()); }).collect(Collectors.toList()); - return Values.fromJavaIterator(ctx, res.iterator()); + return Values.toJSIterator(ctx, res.iterator()); } @Native public ObjectValue keys(Context ctx) { var res = new ArrayList<>(map.keySet()); - return Values.fromJavaIterator(ctx, res.iterator()); + return Values.toJSIterator(ctx, res.iterator()); } @Native public ObjectValue values(Context ctx) { var res = new ArrayList<>(map.values()); - return Values.fromJavaIterator(ctx, res.iterator()); + return Values.toJSIterator(ctx, res.iterator()); } @Native public Object get(Object key) { @@ -68,7 +68,7 @@ import me.topchetoeu.jscript.interop.NativeGetter; } @Native public MapLib(Context ctx, Object iterable) { - for (var el : Values.toJavaIterable(ctx, iterable)) { + for (var el : Values.fromJSIterator(ctx, iterable)) { try { set(Values.getMember(ctx, el, 0), Values.getMember(ctx, el, 1)); } diff --git a/src/me/topchetoeu/jscript/lib/RegExpLib.java b/src/me/topchetoeu/jscript/lib/RegExpLib.java index f8efa93..cea6970 100644 --- a/src/me/topchetoeu/jscript/lib/RegExpLib.java +++ b/src/me/topchetoeu/jscript/lib/RegExpLib.java @@ -153,7 +153,7 @@ import me.topchetoeu.jscript.interop.NativeGetter; @Native("@@Symbol.matchAll") public Object matchAll(Context ctx, String target) { var pattern = new RegExpLib(this.source, this.flags() + "g"); - return Values.fromJavaIterator(ctx, new Iterator() { + return Values.toJSIterator(ctx, new Iterator() { private Object val = null; private boolean updated = false; diff --git a/src/me/topchetoeu/jscript/lib/SetLib.java b/src/me/topchetoeu/jscript/lib/SetLib.java index 0afc096..90ab717 100644 --- a/src/me/topchetoeu/jscript/lib/SetLib.java +++ b/src/me/topchetoeu/jscript/lib/SetLib.java @@ -22,15 +22,15 @@ import me.topchetoeu.jscript.interop.NativeGetter; @Native public ObjectValue entries(Context ctx) { var res = set.stream().map(v -> new ArrayValue(ctx, v, v)).collect(Collectors.toList()); - return Values.fromJavaIterator(ctx, res.iterator()); + return Values.toJSIterator(ctx, res.iterator()); } @Native public ObjectValue keys(Context ctx) { var res = new ArrayList<>(set); - return Values.fromJavaIterator(ctx, res.iterator()); + return Values.toJSIterator(ctx, res.iterator()); } @Native public ObjectValue values(Context ctx) { var res = new ArrayList<>(set); - return Values.fromJavaIterator(ctx, res.iterator()); + return Values.toJSIterator(ctx, res.iterator()); } @Native public Object add(Object key) { @@ -58,6 +58,6 @@ import me.topchetoeu.jscript.interop.NativeGetter; } @Native public SetLib(Context ctx, Object iterable) { - for (var el : Values.toJavaIterable(ctx, iterable)) add(el); + for (var el : Values.fromJSIterator(ctx, iterable)) add(el); } }