/** Perform one-time initialization on the library by creating a table * containing the library functions, adding that table to the supplied environment, * adding the table to package.loaded, and returning table as the return value. * <P>Specifically, extend the library loading to set the default value for {@link Globals#STDIN} * @param modname the module name supplied if this is loaded via 'require'. * @param env the environment to load into, which must be a Globals instance. */ public LuaValue call(LuaValue modname, LuaValue env) { super.call(modname, env); env.checkglobals().STDIN = System.in; return env; }
/** Perform one-time initialization on the library by creating a table * containing the library functions, adding that table to the supplied environment, * adding the table to package.loaded, and returning table as the return value. * <P>Specifically, extend the library loading to set the default value for {@link Globals#STDIN} * @param modname the module name supplied if this is loaded via 'require'. * @param env the environment to load into, which must be a Globals instance. */ public LuaValue call(LuaValue modname, LuaValue env) { super.call(modname, env); env.checkglobals().STDIN = System.in; return env; }
public LuaValue call(LuaValue modname, LuaValue env) { globals = env.checkglobals(); env.set("assert", new _assert()); env.set("collectgarbage", new collectgarbage()); env.set("dofile", new dofile()); .... return env; }
@Override public LuaValue call(LuaValue modname, LuaValue env) { globals = env.checkglobals(); LuaTable os = new LuaTable(); for (int i = 0; i < NAMES.length; ++i) os.set(NAMES[i], new OsLibFunc(i, NAMES[i])); env.set("os", os); env.get("package").get("loaded").set("os", os); return os; }
/** Perform one-time initialization on the library by creating a table * containing the library functions, adding that table to the supplied environment, * adding the table to package.loaded, and returning table as the return value. * @param modname the module name supplied if this is loaded via 'require'. * @param env the environment to load into, typically a Globals instance. */ public LuaValue call(LuaValue modname, LuaValue env) { globals = env.checkglobals(); LuaTable os = new LuaTable(); for (int i = 0; i < NAMES.length; ++i) os.set(NAMES[i], new OsLibFunc(i, NAMES[i])); env.set("os", os); env.get("package").get("loaded").set("os", os); return os; }
/** Perform one-time initialization on the library by creating a table * containing the library functions, adding that table to the supplied environment, * adding the table to package.loaded, and returning table as the return value. * @param modname the module name supplied if this is loaded via 'require'. * @param env the environment to load into, typically a Globals instance. */ public LuaValue call(LuaValue modname, LuaValue env) { globals = env.checkglobals(); LuaTable os = new LuaTable(); for (int i = 0; i < NAMES.length; ++i) os.set(NAMES[i], new OsLibFunc(i, NAMES[i])); env.set("os", os); env.get("package").get("loaded").set("os", os); return os; }
public LuaValue call(LuaValue modname, LuaValue env) { globals = env.checkglobals(); // io lib functions LuaTable t = new LuaTable(); bind(t, IoLibV.class, IO_NAMES ); // create file methods table filemethods = new LuaTable(); bind(filemethods, IoLibV.class, FILE_NAMES, FILE_CLOSE ); // set up file metatable LuaTable mt = new LuaTable(); bind(mt, IoLibV.class, new String[] { "__index" }, IO_INDEX ); t.setmetatable( mt ); // all functions link to library instance setLibInstance( t ); setLibInstance( filemethods ); setLibInstance( mt ); // return the table env.set("io", t); env.get("package").get("loaded").set("io", t); return t; }
public LuaValue call(LuaValue modname, LuaValue env) { globals = env.checkglobals(); // io lib functions LuaTable t = new LuaTable(); bind(t, IoLibV.class, IO_NAMES ); // create file methods table filemethods = new LuaTable(); bind(filemethods, IoLibV.class, FILE_NAMES, FILE_CLOSE ); // set up file metatable LuaTable mt = new LuaTable(); bind(mt, IoLibV.class, new String[] { "__index" }, IO_INDEX ); t.setmetatable( mt ); // all functions link to library instance setLibInstance( t ); setLibInstance( filemethods ); setLibInstance( mt ); // return the table env.set("io", t); env.get("package").get("loaded").set("io", t); return t; }
/** Perform one-time initialization on the library by creating a table * containing the library functions, adding that table to the supplied environment, * adding the table to package.loaded, and returning table as the return value. * @param modname the module name supplied if this is loaded via 'require'. * @param env the environment to load into, which must be a Globals instance. */ public LuaValue call(LuaValue modname, LuaValue env) { globals = env.checkglobals(); LuaTable coroutine = new LuaTable(); coroutine.set("create", new create()); coroutine.set("resume", new resume()); coroutine.set("running", new running()); coroutine.set("status", new status()); coroutine.set("yield", new yield()); coroutine.set("wrap", new wrap()); env.set("coroutine", coroutine); env.get("package").get("loaded").set("coroutine", coroutine); return coroutine; }
/** Perform one-time initialization on the library by creating a table * containing the library functions, adding that table to the supplied environment, * adding the table to package.loaded, and returning table as the return value. * @param modname the module name supplied if this is loaded via 'require'. * @param env the environment to load into, which must be a Globals instance. */ public LuaValue call(LuaValue modname, LuaValue env) { globals = env.checkglobals(); LuaTable coroutine = new LuaTable(); coroutine.set("create", new create()); coroutine.set("resume", new resume()); coroutine.set("running", new running()); coroutine.set("status", new status()); coroutine.set("yield", new yield()); coroutine.set("wrap", new wrap()); env.set("coroutine", coroutine); env.get("package").get("loaded").set("coroutine", coroutine); return coroutine; }
/** Perform one-time initialization on the library by adding package functions * to the supplied environment, and returning it as the return value. * It also creates the package.preload and package.loaded tables for use by * other libraries. * @param modname the module name supplied if this is loaded via 'require'. * @param env the environment to load into, typically a Globals instance. */ public LuaValue call(LuaValue modname, LuaValue env) { globals = env.checkglobals(); globals.set("require", new require()); package_ = new LuaTable(); package_.set(_LOADED, new LuaTable()); package_.set(_PRELOAD, new LuaTable()); package_.set(_PATH, LuaValue.valueOf(DEFAULT_LUA_PATH)); package_.set(_LOADLIB, new loadlib()); package_.set(_SEARCHPATH, new searchpath()); LuaTable searchers = new LuaTable(); searchers.set(1, preload_searcher = new preload_searcher()); searchers.set(2, lua_searcher = new lua_searcher()); searchers.set(3, java_searcher = new java_searcher()); package_.set(_SEARCHERS, searchers); package_.get(_LOADED).set("package", package_); env.set("package", package_); globals.package_ = this; return env; }
/** Perform one-time initialization on the library by adding package functions * to the supplied environment, and returning it as the return value. * It also creates the package.preload and package.loaded tables for use by * other libraries. * @param modname the module name supplied if this is loaded via 'require'. * @param env the environment to load into, typically a Globals instance. */ public LuaValue call(LuaValue modname, LuaValue env) { globals = env.checkglobals(); globals.set("require", new require()); package_ = new LuaTable(); package_.set(_LOADED, new LuaTable()); package_.set(_PRELOAD, new LuaTable()); package_.set(_PATH, LuaValue.valueOf(DEFAULT_LUA_PATH)); package_.set(_LOADLIB, new loadlib()); package_.set(_SEARCHPATH, new searchpath()); LuaTable searchers = new LuaTable(); searchers.set(1, preload_searcher = new preload_searcher()); searchers.set(2, lua_searcher = new lua_searcher()); searchers.set(3, java_searcher = new java_searcher()); package_.set(_SEARCHERS, searchers); package_.get(_LOADED).set("package", package_); env.set("package", package_); globals.package_ = this; return env; }
@Override public LuaValue call(LuaValue modname, LuaValue env) { globals = env.checkglobals(); globals.debuglib = this; LuaTable debug = new LuaTable(); debug.set("debug", new debug()); debug.set("gethook", new gethook()); debug.set("getinfo", new getinfo()); debug.set("getlocal", new getlocal()); debug.set("getmetatable", new getmetatable()); debug.set("getregistry", new getregistry()); debug.set("getupvalue", new getupvalue()); debug.set("getuservalue", new getuservalue()); debug.set("sethook", new sethook()); debug.set("setlocal", new setlocal()); debug.set("setmetatable", new setmetatable()); debug.set("setupvalue", new setupvalue()); debug.set("setuservalue", new setuservalue()); debug.set("traceback", new traceback()); debug.set("upvalueid", new upvalueid()); debug.set("upvaluejoin", new upvaluejoin()); env.set("debug", debug); env.get("package").get("loaded").set("debug", debug); return debug; }
/** Perform one-time initialization on the library by creating a table * containing the library functions, adding that table to the supplied environment, * adding the table to package.loaded, and returning table as the return value. * @param modname the module name supplied if this is loaded via 'require'. * @param env the environment to load into, which must be a Globals instance. */ public LuaValue call(LuaValue modname, LuaValue env) { globals = env.checkglobals(); globals.debuglib = this; LuaTable debug = new LuaTable(); debug.set("debug", new debug()); debug.set("gethook", new gethook()); debug.set("getinfo", new getinfo()); debug.set("getlocal", new getlocal()); debug.set("getmetatable", new getmetatable()); debug.set("getregistry", new getregistry()); debug.set("getupvalue", new getupvalue()); debug.set("getuservalue", new getuservalue()); debug.set("sethook", new sethook()); debug.set("setlocal", new setlocal()); debug.set("setmetatable", new setmetatable()); debug.set("setupvalue", new setupvalue()); debug.set("setuservalue", new setuservalue()); debug.set("traceback", new traceback()); debug.set("upvalueid", new upvalueid()); debug.set("upvaluejoin", new upvaluejoin()); env.set("debug", debug); env.get("package").get("loaded").set("debug", debug); return debug; }
/** Perform one-time initialization on the library by creating a table * containing the library functions, adding that table to the supplied environment, * adding the table to package.loaded, and returning table as the return value. * @param modname the module name supplied if this is loaded via 'require'. * @param env the environment to load into, which must be a Globals instance. */ public LuaValue call(LuaValue modname, LuaValue env) { globals = env.checkglobals(); globals.debuglib = this; LuaTable debug = new LuaTable(); debug.set("debug", new debug()); debug.set("gethook", new gethook()); debug.set("getinfo", new getinfo()); debug.set("getlocal", new getlocal()); debug.set("getmetatable", new getmetatable()); debug.set("getregistry", new getregistry()); debug.set("getupvalue", new getupvalue()); debug.set("getuservalue", new getuservalue()); debug.set("sethook", new sethook()); debug.set("setlocal", new setlocal()); debug.set("setmetatable", new setmetatable()); debug.set("setupvalue", new setupvalue()); debug.set("setuservalue", new setuservalue()); debug.set("traceback", new traceback()); debug.set("upvalueid", new upvalueid()); debug.set("upvaluejoin", new upvaluejoin()); env.set("debug", debug); env.get("package").get("loaded").set("debug", debug); return debug; }
@Override public LuaValue call(LuaValue modname, LuaValue env) { globals = env.checkglobals(); globals.baselib = this; env.set( "_G", env ); env.set( "_VERSION", Lua._VERSION ); env.set("assert", new _assert()); env.set("error", new error()); env.set("getmetatable", new getmetatable()); env.set("pcall", new pcall()); env.set("print", new print(this)); env.set("rawequal", new rawequal()); env.set("rawget", new rawget()); env.set("rawlen", new rawlen()); env.set("rawset", new rawset()); env.set("select", new select()); env.set("setmetatable", new setmetatable()); env.set("tonumber", new tonumber()); env.set("tostring", new tostring()); env.set("type", new type()); env.set("xpcall", new xpcall()); next next; env.set("next", next = new next()); env.set("pairs", new pairs(next)); env.set("ipairs", new ipairs()); return env; }
globals = env.checkglobals(); globals.finder = this; globals.baselib = this;
globals = env.checkglobals(); globals.finder = this; globals.baselib = this;