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:
James Roseborough
2013-07-04 15:54:36 +00:00
parent 120ac758c4
commit 9b59234327
18 changed files with 52 additions and 53 deletions

View File

@@ -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;
}

View File

@@ -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());

View File

@@ -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);