Fix Globals.load() to call the library with an empty modname and the globals as the environment. Change standard libraries to be called with two arguments, a modname and an environment.
This commit is contained in:
@@ -68,8 +68,8 @@ import org.luaj.vm2.lib.ResourceFinder;
|
||||
public class JseBaseLib extends org.luaj.vm2.lib.BaseLib {
|
||||
|
||||
/** Extend the library loading to set the default value for {@link Globals.STDIN} */
|
||||
public LuaValue call(LuaValue env) {
|
||||
super.call(env);
|
||||
public LuaValue call(LuaValue modname, LuaValue env) {
|
||||
super.call(modname, env);
|
||||
env.checkglobals().STDIN = System.in;
|
||||
return env;
|
||||
}
|
||||
|
||||
@@ -58,8 +58,8 @@ public class JseMathLib extends org.luaj.vm2.lib.MathLib {
|
||||
|
||||
public JseMathLib() {}
|
||||
|
||||
public LuaValue call(LuaValue env) {
|
||||
super.call(env);
|
||||
public LuaValue call(LuaValue modname, LuaValue env) {
|
||||
super.call(modname, env);
|
||||
LuaValue math = env.get("math");
|
||||
math.set("acos", new acos());
|
||||
math.set("asin", new asin());
|
||||
|
||||
@@ -98,7 +98,8 @@ public class LuajavaLib extends VarArgFunction {
|
||||
try {
|
||||
switch ( opcode ) {
|
||||
case INIT: {
|
||||
LuaValue env = args.arg1();
|
||||
// LuaValue modname = args.arg1();
|
||||
LuaValue env = args.arg(2);
|
||||
LuaTable t = new LuaTable();
|
||||
bind( t, LuajavaLib.class, NAMES, BINDCLASS );
|
||||
env.set("luajava", t);
|
||||
|
||||
Reference in New Issue
Block a user