feat: add toString, equals and hashCode overrides to wrappers and objects

This commit is contained in:
TopchetoEU 2023-11-25 18:44:55 +02:00
parent e1ce384815
commit 8b743f49d1
Signed by: topchetoeu
GPG Key ID: 6531B8583E5F6ED4
2 changed files with 14 additions and 1 deletions

View File

@ -12,6 +12,19 @@ public class NativeWrapper extends ObjectValue {
else return super.getPrototype(ctx);
}
@Override
public String toString() {
return wrapped.toString();
}
@Override
public boolean equals(Object obj) {
return wrapped.equals(obj);
}
@Override
public int hashCode() {
return wrapped.hashCode();
}
public NativeWrapper(Object wrapped) {
this.wrapped = wrapped;
prototype = NATIVE_PROTO;

View File

@ -140,7 +140,7 @@ import me.topchetoeu.jscript.interop.NativeConstructor;
@Native public static ObjectValue fromEntries(Context ctx, Object iterable) {
var res = new ObjectValue();
for (var el : Values.toJavaIterable(ctx, iterable)) {
for (var el : Values.fromJSIterator(ctx, iterable)) {
if (el instanceof ArrayValue) {
res.defineProperty(ctx, ((ArrayValue)el).get(0), ((ArrayValue)el).get(1));
}