public static void Initialize(ILuaEnvironment E) { ILuaTable io = new LuaValues.LuaTable(); io.SetItemRaw(new LuaString("close"), new close(E)); io.SetItemRaw(new LuaString("flush"), new flush(E)); io.SetItemRaw(new LuaString("input"), new input(E)); io.SetItemRaw(new LuaString("lines"), new lines(E)); io.SetItemRaw(new LuaString("open"), new open(E)); io.SetItemRaw(new LuaString("output"), new output(E)); io.SetItemRaw(new LuaString("read"), new read(E)); io.SetItemRaw(new LuaString("tmpfile"), new tmpfile(E)); io.SetItemRaw(new LuaString("type"), new type(E)); io.SetItemRaw(new LuaString("write"), new write(E)); _input = E.Settings.Stdin; _output = E.Settings.Stdout; var _globals = E.GlobalsTable; _globals.SetItemRaw(new LuaString("io"), io); _globals.SetItemRaw(new LuaString("dofile"), new dofile(E)); _globals.SetItemRaw(new LuaString("load"), new load(E)); _globals.SetItemRaw(new LuaString("loadfile"), new loadfile(E)); _globals.SetItemRaw(new LuaString("_STDIN"), _CreateFile(E.Settings.Stdin, E)); _globals.SetItemRaw(new LuaString("_STDOUT"), _CreateFile(E.Settings.Stdout, E)); }
static ILuaTable _CreateFile(Stream backing, ILuaEnvironment E) { ILuaTable ret = new LuaValues.LuaTable(); ret.SetItemRaw(_stream, new LuaValues.LuaUserData<Stream>(backing)); ret.SetItemRaw(new LuaString("close"), new close(E)); ret.SetItemRaw(new LuaString("flush"), new flush(E)); ret.SetItemRaw(new LuaString("lines"), new lines(E)); ret.SetItemRaw(new LuaString("read"), new read(E)); ret.SetItemRaw(new LuaString("seek"), new seek(E)); ret.SetItemRaw(new LuaString("write"), new write(E)); return ret; }