Skip to content

Commit

Permalink
Fixed 0-arg methods with Context param
Browse files Browse the repository at this point in the history
  • Loading branch information
LatvianModder committed Jun 26, 2024
1 parent 6f24336 commit 42a8211
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/main/java/dev/latvian/mods/rhino/Context.java
Original file line number Diff line number Diff line change
Expand Up @@ -1858,13 +1858,15 @@ public String defaultObjectToSource(Scriptable scope, Scriptable thisObj, Object
}

public Object[] insertContextArg(Object[] args) {
if (!(args[0] instanceof Context)) {
if (args.length == 0) {
return new Object[]{this};
} else if (!(args[0] instanceof Context)) {
Object[] newArgs = new Object[args.length + 1];
newArgs[0] = this;
System.arraycopy(args, 0, newArgs, 1, args.length);
return newArgs;
} else {
return args;
}

return args;
}
}

0 comments on commit 42a8211

Please sign in to comment.