feat: add toString, equals and hashCode overrides to wrappers and objects
This commit is contained in:
parent
e1ce384815
commit
8b743f49d1
@ -12,6 +12,19 @@ public class NativeWrapper extends ObjectValue {
|
|||||||
else return super.getPrototype(ctx);
|
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) {
|
public NativeWrapper(Object wrapped) {
|
||||||
this.wrapped = wrapped;
|
this.wrapped = wrapped;
|
||||||
prototype = NATIVE_PROTO;
|
prototype = NATIVE_PROTO;
|
||||||
|
@ -140,7 +140,7 @@ import me.topchetoeu.jscript.interop.NativeConstructor;
|
|||||||
@Native public static ObjectValue fromEntries(Context ctx, Object iterable) {
|
@Native public static ObjectValue fromEntries(Context ctx, Object iterable) {
|
||||||
var res = new ObjectValue();
|
var res = new ObjectValue();
|
||||||
|
|
||||||
for (var el : Values.toJavaIterable(ctx, iterable)) {
|
for (var el : Values.fromJSIterator(ctx, iterable)) {
|
||||||
if (el instanceof ArrayValue) {
|
if (el instanceof ArrayValue) {
|
||||||
res.defineProperty(ctx, ((ArrayValue)el).get(0), ((ArrayValue)el).get(1));
|
res.defineProperty(ctx, ((ArrayValue)el).get(0), ((ArrayValue)el).get(1));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user