Skip to content
This repository was archived by the owner on Dec 31, 2024. It is now read-only.

Commit 8b743f4

Browse files
committed
feat: add toString, equals and hashCode overrides to wrappers and objects
1 parent e1ce384 commit 8b743f4

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/me/topchetoeu/jscript/engine/values/NativeWrapper.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,19 @@ public ObjectValue getPrototype(Context ctx) {
1212
else return super.getPrototype(ctx);
1313
}
1414

15+
@Override
16+
public String toString() {
17+
return wrapped.toString();
18+
}
19+
@Override
20+
public boolean equals(Object obj) {
21+
return wrapped.equals(obj);
22+
}
23+
@Override
24+
public int hashCode() {
25+
return wrapped.hashCode();
26+
}
27+
1528
public NativeWrapper(Object wrapped) {
1629
this.wrapped = wrapped;
1730
prototype = NATIVE_PROTO;

src/me/topchetoeu/jscript/lib/ObjectLib.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@
140140
@Native public static ObjectValue fromEntries(Context ctx, Object iterable) {
141141
var res = new ObjectValue();
142142

143-
for (var el : Values.toJavaIterable(ctx, iterable)) {
143+
for (var el : Values.fromJSIterator(ctx, iterable)) {
144144
if (el instanceof ArrayValue) {
145145
res.defineProperty(ctx, ((ArrayValue)el).get(0), ((ArrayValue)el).get(1));
146146
}

0 commit comments

Comments
 (0)