static void dotty(Lua.LuaState L) { int status; Lua.CharPtr oldprogname = progname; progname = null; while ((status = loadline(L)) != -1) { if (status == 0) { status = docall(L, 0, 0); } report(L, status); if (status == 0 && Lua.lua_gettop(L) > 0) { /* any result to print? */ Lua.lua_getglobal(L, "print"); Lua.lua_insert(L, 1); if (Lua.lua_pcall(L, Lua.lua_gettop(L) - 1, 0, 0) != 0) { l_message(progname, Lua.lua_pushfstring(L, "error calling " + Lua.LUA_QL("print").ToString() + " (%s)", Lua.lua_tostring(L, -1))); } } } Lua.lua_settop(L, 0); /* clear stack */ Lua.fputs("\n", Lua.stdout); Lua.fflush(Lua.stdout); progname = oldprogname; }
public static void Main(string[] args) { //Console.WriteLine("Hello World!"); // TODO: Implement Functionality Here //Console.WriteLine("atof() = " + KopiLua.Lua.atof("12.34")); #if !TEST_LUA Lua.CharPtr[] argv; argv = new Lua.CharPtr[args.Length + 1]; argv[0] = new Lua.CharPtr("lua.exe"); for (int i = 0; i < args.Length; ++i) { argv[i + 1] = args[i]; } Lua.main(argv.Length, argv); #else Lua.CharPtr[] argv; argv = new Lua.CharPtr[] { "lua.exe", "print.lua" }; //ok // argv = new Lua.CharPtr[] {"lua.exe", "array.lua"}; //ok // argv = new Lua.CharPtr[] {"lua.exe", "globals.lua"}; //ok // argv = new Lua.CharPtr[] {"lua.exe", "save.lua"}; //ok // argv = new Lua.CharPtr[] {"lua.exe", "sort.lua", "main"}; //ok // argv = new Lua.CharPtr[] {"lua.exe", "test.lua", "retorno_multiplo"}; //ok // argv = new Lua.CharPtr[] {"lua.exe", "type.lua"}; //ok Lua.main(argv.Length, argv); Console.Write("Press any key to continue . . . "); Console.ReadKey(true); #endif }
public static int socket_recv(pSocket ps, Lua.CharPtr data, int count, out int got, pTimeout tm) { //p_socket ps, char *data, size_t count, size_t *got, p_timeout tm int err; got = 0; if (ps == null) { return(pIO.IO_CLOSED); } for (; ;) { int taken = ps.Recv(data, (int)count, 0); if (taken > 0) { got = taken; return(pIO.IO_DONE); } if (taken == 0 || taken == -1) { return(pIO.IO_CLOSED); } //if ((err = socket_waitfd(ps, WAITFD_R, tm)) != IO_DONE) return err; } }
static int pushline(Lua.LuaState L, int firstline) { Lua.CharPtr buffer = new char[Lua.LUA_MAXINPUT]; Lua.CharPtr b = new Lua.CharPtr(buffer); int l; Lua.CharPtr prmt = get_prompt(L, firstline); if (!Lua.lua_readline(L, b, prmt)) { return(0); /* no input */ } l = Lua.strlen(b); if (l > 0 && b[l - 1] == '\n') /* line ends with newline? */ { b[l - 1] = '\0'; /* remove it */ } if ((firstline != 0) && (b[0] == '=')) /* first line starts with `=' ? */ { Lua.lua_pushfstring(L, "return %s", b + 1); /* change it to `return' */ } else { Lua.lua_pushstring(L, b); } Lua.lua_freeline(L, b); return(1); }
void AssertFile(string path) { string error = string.Empty; int result = Lua.luaL_loadfile(state, path); if (result != 0) { Lua.CharPtr pstring = Lua.lua_tostring(state, 1); if (pstring != null) { error = pstring.ToString(); } } Assert.True(result == 0, "Fail loading file: " + path + "ERROR:" + error); result = Lua.lua_pcall(state, 0, -1, 0); if (result != 0) { Lua.CharPtr pstring = Lua.lua_tostring(state, 1); if (pstring != null) { error = pstring.ToString(); } } Assert.True(result == 0, "Fail calling file: " + path + " ERROR: " + error); }
public static int socket_send(pSocket ps, Lua.CharPtr data, int count, out int sent, pTimeout tm) { int err = 0; sent = 0; /* avoid making system calls on closed sockets */ if (ps == null) { return(pIO.IO_CLOSED); } /* loop until we send something or we give up on error */ for (; ;) { /* try to send something */ int put = ps.Send(data, (int)count, 0, out err); /* if we sent something, we are done */ if (put > 0) { sent = put; return(pIO.IO_DONE); } if (err > 0) { return(err); } else { return(0); } //if ((err = socket_waitfd(ps, WAITFD_W, tm)) != IO_DONE) return err; } /* can't reach here */ //return pIO.IO_UNKNOWN; }
static int getheader(LuaState L) { Proto f = getproto(L, 1); Lua.CharPtr s = f.source.str; if (s[0] == '@' || s[0] == '=') { s.index++; } else if (s[0] == Lua.LUA_SIGNATURE[0]) { s = "(binary string)"; } else { s = "(string)"; } Lua.lua_newtable(L); setsfield(L, "source", s); setifield(L, "line", f.linedefined); setifield(L, "lastline", f.lastlinedefined); setifield(L, "instructions", f.sizecode); setifield(L, "params", f.numparams); setbfield(L, "isvararg", f.is_vararg); setifield(L, "slots", f.maxstacksize); setifield(L, "upvalues", f.nups); setifield(L, "locals", f.sizelocvars); setifield(L, "constants", f.sizek); setifield(L, "functions", f.sizep); return(1); }
static int loadline(Lua.lua_State L) { int status; Lua.lua_settop(L, 0); if (pushline(L, 1) == 0) { return(-1); /* no input */ } for (; ;) { /* repeat until gets a complete line */ Lua.CharPtr line = Lua.lua_tostring(L, 1); Lua.WriteLog(line.ToString()); status = Lua.luaL_loadbuffer(L, Lua.lua_tostring(L, 1), Lua.lua_strlen(L, 1), "=stdin"); if (incomplete(L, status) == 0) { break; /* cannot try to add lines? */ } if (pushline(L, 0) == 0) /* no more input? */ { return(-1); } Lua.lua_pushliteral(L, "\n"); /* add a new line... */ Lua.lua_insert(L, -2); /* ...between the two lines */ Lua.lua_concat(L, 3); /* join them */ } Lua.lua_saveline(L, 1); Lua.lua_remove(L, 1); /* remove line */ return(status); }
private static void errorlimit(FuncState fs, int limit, CharPtr what) { CharPtr msg = (fs.f.linedefined == 0) ? Lua.luaO_pushfstring(fs.L, "main function has more than %d %s", limit, what) : Lua.luaO_pushfstring(fs.L, "function at line %d has more than %d %s", fs.f.linedefined, limit, what); Lua.luaX_lexerror(fs.ls, msg, 0); }
static void l_message(Lua.CharPtr pname, Lua.CharPtr msg) { if (pname != null) { Lua.fprintf(Lua.stderr, "%s: ", pname); } Lua.fprintf(Lua.stderr, "%s\n", msg); Lua.fflush(Lua.stderr); }
public Lua.CharPtr Connect(Lua.CharPtr address, int port, pTimeout tm) { if (tcpSocket != null) { try { int timeout = (int)tm.block * 1000; if (timeout < 0) { timeout = 0; } #if !NETFX_CORE tcpSocket.Connect(new DnsEndPoint(address.ToString(), port), timeout); #else //TODO: #endif } catch (Exception e) { return(address); } } /*else if(tcpSocketChannel != null) * { * try * { * int timeout = (int) tm.block * 1000; * if(timeout < 0) * timeout = 0; * tcpSocketChannel.configureBlocking(true); * boolean connected = tcpSocketChannel.connect(new InetSocketAddress(InetAddress.getByName(address.toString()), port)); * while(!tcpSocketChannel.finishConnect()) * { * Thread.sleep(50); * } * tcpSocketChannel.socket().setSoTimeout(timeout); * tcpSocketChannel.socket().setKeepAlive(true); * tcpSocketChannel.socket().setTcpNoDelay(true); * //tcpSocketWriter = new BufferedWriter(new OutputStreamWriter(tcpSocketChannel.socket().getOutputStream())); * if(cantSetNonBlocking) * { * SetNonBlocking(cantSetNonBlockingValue); * cantSetNonBlocking = false; * } * } * catch (Exception e) * { * return address; * } * }*/ return(null); }
static int report(Lua.LuaState L, int status) { if ((status != 0) && !Lua.lua_isnil(L, -1)) { Lua.CharPtr msg = Lua.lua_tostring(L, -1); if (msg == null) { msg = "(error object is not a string)"; } l_message(progname, msg); Lua.lua_pop(L, 1); } return(status); }
static int incomplete(Lua.LuaState L, int status) { if (status == Lua.LUA_ERRSYNTAX) { uint lmsg; Lua.CharPtr msg = Lua.lua_tolstring(L, -1, out lmsg); Lua.CharPtr tp = msg + lmsg - (Lua.strlen(Lua.LUA_QL("<eof>"))); if (Lua.strstr(msg, Lua.LUA_QL("<eof>")) == tp) { Lua.lua_pop(L, 1); return(1); } } return(0); /* else... */ }
static int handle_luainit(Lua.LuaState L) { Lua.CharPtr init = Lua.getenv(Lua.LUA_INIT); if (init == null) { return(0); /* status OK */ } else if (init[0] == '@') { return(dofile(L, init + 1)); } else { return(dostring(L, init, "=" + Lua.LUA_INIT)); } }
static int pmain(Lua.LuaState L) { Smain s = (Smain)Lua.lua_touserdata(L, 1); int argc = s.argc; string[] argv = s.argv; Lua.Proto f; int i; if (Lua.lua_checkstack(L, argc) == 0) { fatal("too many input files"); } for (i = 0; i < argc; i++) { Lua.CharPtr filename = (Lua.strcmp(argv[i], "-") == 0) ? null : argv[i]; if (Lua.luaL_loadfile(L, filename) != 0) { fatal(Lua.lua_tostring(L, -1)); } } f = combine(L, argc); if (listing != 0) { Lua.luaU_print(f, (listing > 1) ? 1 : 0); } if (dumping != 0) { Stream D = (output == null) ? Lua.stdout : Lua.fopen(output, "wb"); if (D == null) { cannot("open"); } Lua.lua_lock(L); Lua.luaU_dump(L, f, writer, D, stripping); Lua.lua_unlock(L); if (Lua.ferror(D) != 0) { cannot("write"); } if (Lua.fclose(D) != 0) { cannot("close"); } } return(0); }
//#define IS(s) (strcmp(argv[i],s)==0) static int doargs(int argc, string[] argv) { int i; int version = 0; if ((argv.Length > 0) && (argv[0] != "")) progname = argv[0]; for (i = 1; i < argc; i++) { if (argv[i][0] != '-') /* end of options; keep it */ break; else if (Lua.strcmp(argv[i], "--") == 0) /* end of options; skip it */ { ++i; if (version != 0) ++version; break; } else if (Lua.strcmp(argv[i], "-") == 0) /* end of options; use stdin */ break; else if (Lua.strcmp(argv[i], "-l") == 0) /* list */ ++listing; else if (Lua.strcmp(argv[i], "-o") == 0) /* output file */ { output = argv[++i]; if (output == null || (output[0] == 0)) usage(Lua.LUA_QL("-o") + " needs argument"); if (Lua.strcmp(argv[i], "-") == 0) output = null; } else if (Lua.strcmp(argv[i], "-p") == 0) /* parse only */ dumping = 0; else if (Lua.strcmp(argv[i], "-s") == 0) /* strip debug information */ stripping = 1; else if (Lua.strcmp(argv[i], "-v") == 0) /* show version */ ++version; else /* unknown option */ usage(argv[i]); } if (i == argc && ((listing != 0) || (dumping == 0))) { dumping = 0; argv[--i] = Output.ToString(); } if (version != 0) { Lua.printf("%s %s\n", Lua.LUA_RELEASE, Lua.LUA_COPYRIGHT); if (version == argc - 1) Environment.Exit(Lua.EXIT_SUCCESS); } return i; }
public Lua.CharPtr Bind(Lua.CharPtr address, int port) { if (tcpSocket != null) { try { #if !NETFX_CORE tcpSocket.Bind(new DnsEndPoint(address.ToString(), port)); #else //TODO: #endif } catch (Exception e) { return(address); } } return(null); }
public int Recv(Lua.CharPtr data, int count, int flag) { if (tcpSocket != null) { byte[] arr = new byte[count]; try { #if !NETFX_CORE int read = tcpSocket.Read(ref arr); data.setByteArray(arr); return(read); #else //TODO: #endif } catch (Exception e) { //Tools.LogException("pSocket", e); } } /*else if(tcpSocketChannel != null) * { * byte[] arr = new byte[count]; * try * { * int read = 0; * read = tcpSocketChannel.read(ByteBuffer.wrap(arr)); * data.setByteArray(arr); * return read; * } * catch (Exception e) * { * Tools.LogException("pSocket", e); * } * } * else if(tcpSocketAndroid != null) * { * tcpSocketAndroid.Recv(data, count, null); * }*/ return(0); }
public override void Write(byte[] array, int offset, int count) { try { Lua.CharPtr ptr = new Lua.CharPtr(); ptr.setByteArray(array); if (type == 0) { Log.i("LuaLogStream", ptr.toString()); } else { Log.e("LuaLogStream", ptr.toString()); } } catch (Exception e) { Log.d("LuaLogStream.cs", e.Message); } }
public int Send(Lua.CharPtr data, int count, int flag, out int errP) { if (tcpSocket != null) { try { #if !NETFX_CORE tcpSocket.Send(data.toByteArray(), count, out errP); #else //TODO: errP = 0; #endif return(count); } catch (Exception e) { errP = 1; } } errP = 0; return(0); }
static void usage(Lua.CharPtr message) { if (message[0] == '-') { Lua.fprintf(Lua.stderr, "%s: unrecognized option " + Lua.LUA_QS + "\n", progname, message); } else { Lua.fprintf(Lua.stderr, "%s: %s\n", progname, message); } Lua.fprintf(Lua.stderr, "usage: %s [options] [filenames].\n" + "Available options are:\n" + " - process stdin\n" + " -l list\n" + " -o name output to file " + Lua.LUA_QL("name") + " (default is \"%s\")\n" + " -p parse only\n" + " -s strip debug information\n" + " -v show version information\n" + " -- stop handling options\n", progname, Output); Environment.Exit(Lua.EXIT_FAILURE); }
static int pmain(Lua.LuaState L) { Smain s = (Smain)Lua.lua_touserdata(L, 1); int argc = s.argc; string[] argv = s.argv; Lua.Proto f; int i; if (Lua.lua_checkstack(L, argc) == 0) { fatal("too many input files"); } for (i = 0; i < argc; i++) { Lua.CharPtr filename = (Lua.strcmp(argv[i], "-") == 0) ? null : argv[i]; //try //{ // Lexer l = new Lexer(); // Parser p = new Parser(l.Lex(System.IO.File.ReadAllText(filename))); // Ast.Chunk c = p.Parse(); //Console.WriteLine(vars.Count); //foreach (Tuple<Ast.Variable, Ast.Variable> v in Refactoring.FindMisspelledVariables(c)) //{ // Console.WriteLine("Warning: Possible misspelled variable: " + v.Item1.Name + " is close to " + v.Item2.Name); // Console.Write("\t"); // if (v.Item1.References > v.Item2.References) // Console.WriteLine(v.Item1.Name + " is the best match with" + v.Item1.References + " references"); // else if (v.Item1.References < v.Item2.References) // Console.WriteLine(v.Item2.Name + " is the best match with" + v.Item2.References + " references"); // else // Console.WriteLine("Both have the same amount of references (" + v.Item1.References + ")!"); // //} //foreach (Ast.Variable v in Refactoring.FindUnusedVariables(c)) // Console.WriteLine("Warning: Unused variable '" + v.Name + "'"); //Refactoring.FindReferencesBeforeDefinition(c); //} //catch (System.Exception ex) //{ // System.Diagnostics.Debug.WriteLine(ex.ToString()); //} if (Lua.luaL_loadfile(L, filename) != 0) { fatal(Lua.lua_tostring(L, -1)); } } f = combine(L, argc); if (listing != 0) { Lua.luaU_print(f, (listing > 1) ? 1 : 0); } if (dumping != 0) { Stream D = (output == null) ? Lua.stdout : Lua.fopen(output, "wb"); if (D == null) { cannot("open"); } Lua.lua_lock(L); Lua.luaU_dump(L, f, writer, D, stripping); Lua.lua_unlock(L); if (Lua.ferror(D) != 0) { cannot("write"); } if (Lua.fclose(D) != 0) { cannot("close"); } } return(0); }
static int writer(Lua.LuaState L, Lua.CharPtr p, uint size, object u) { //UNUSED(L); return(((Lua.fwrite(p, (int)size, 1, (Stream)u) != 1) && (size != 0)) ? 1 : 0); }
public static void new_localvarliteral(LexState ls, CharPtr v, int n) { new_localvar(ls, Lua.luaX_newstring(ls, "" + v, (uint)(v.chars.Length - 1)), n); }
static void setbfield(LuaState L, Lua.CharPtr n, int v) { Lua.lua_pushboolean(L, v); Lua.lua_setfield(L, -2, n); }
static int pmain(Lua.lua_State L) { Smain s = (Smain)Lua.lua_touserdata(L, 1); string[] argv = s.argv; int script; int has_i = 0, has_v = 0, has_e = 0; globalL = L; if ((argv.Length>0) && (argv[0]!="")) progname = argv[0]; Lua.lua_gc(L, Lua.LUA_GCSTOP, 0); /* stop collector during initialization */ Lua.luaL_openlibs(L); /* open libraries */ Lua.lua_gc(L, Lua.LUA_GCRESTART, 0); s.status = handle_luainit(L); if (s.status != 0) return 0; script = collectargs(argv, ref has_i, ref has_v, ref has_e); if (script < 0) { /* invalid args? */ print_usage(); s.status = 1; return 0; } if (has_v!=0) print_version(); s.status = runargs(L, argv, (script > 0) ? script : s.argc); if (s.status != 0) return 0; if (script!=0) s.status = handle_script(L, argv, script); if (s.status != 0) return 0; if (has_i!=0) dotty(L); else if ((script==0) && (has_e==0) && (has_v==0)) { if (Lua.lua_stdin_is_tty()!=0) { print_version(); dotty(L); } else dofile(L, null); /* executes stdin as a file */ } return 0; }
public RegType(Lua.CharPtr name, Lua.lua_CFunction func) { this.name = name; this.mfunc = func; }
public static Proto luaY_parser(LuaState L, ZIO z, Mbuffer buff, CharPtr name) { LexState lexstate = new LexState(); FuncState funcstate = new FuncState(); lexstate.buff = buff; Lua.luaX_setinput(L, lexstate, z, Lua.luaS_new(L, name)); open_func(lexstate, funcstate); funcstate.f.is_vararg = Lua.VARARG_ISVARARG; /* main func. is always vararg */ Lua.luaX_next(lexstate); /* read first token */ System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture; chunk(lexstate); check(lexstate, (int)RESERVED.TK_EOS); close_func(lexstate); Lua.lua_assert(funcstate.prev == null); Lua.lua_assert(funcstate.f.nups == 0); Lua.lua_assert(lexstate.fs == null); return funcstate.f; }
public static void check_condition(LexState ls, bool c, CharPtr msg) { if (!(c)) Lua.luaX_syntaxerror(ls, msg); }
static int pushline(Lua.lua_State L, int firstline) { Lua.CharPtr buffer = new char[Lua.LUA_MAXINPUT]; Lua.CharPtr b = new Lua.CharPtr(buffer); int l; Lua.CharPtr prmt = get_prompt(L, firstline); if (!Lua.lua_readline(L, b, prmt)) return 0; /* no input */ l = Lua.strlen(b); if (l > 0 && b[l - 1] == '\n') /* line ends with newline? */ b[l - 1] = '\0'; /* remove it */ if ((firstline!=0) && (b[0] == '=')) /* first line starts with `=' ? */ Lua.lua_pushfstring(L, "return %s", b + 1); /* change it to `return' */ else Lua.lua_pushstring(L, b); Lua.lua_freeline(L, b); return 1; }
static int pmain(Lua.LuaState L) { Smain s = (Smain)Lua.lua_touserdata(L, 1); string[] argv = s.argv; int script; int has_i = 0, has_v = 0, has_e = 0; globalL = L; if ((argv.Length > 0) && (argv[0] != "")) { progname = argv[0]; } Lua.lua_gc(L, Lua.LUA_GCSTOP, 0); /* stop collector during initialization */ Lua.luaL_openlibs(L); /* open libraries */ Lua.lua_gc(L, Lua.LUA_GCRESTART, 0); s.status = handle_luainit(L); if (s.status != 0) { return(0); } script = collectargs(argv, ref has_i, ref has_v, ref has_e); if (script < 0) { /* invalid args? */ print_usage(); s.status = 1; return(0); } if (has_v != 0) { print_version(); } s.status = runargs(L, argv, (script > 0) ? script : s.argc); if (s.status != 0) { return(0); } if (script != 0) { s.status = handle_script(L, argv, script); } if (s.status != 0) { return(0); } if (has_i != 0) { dotty(L); } else if ((script == 0) && (has_e == 0) && (has_v == 0)) { if (Lua.lua_stdin_is_tty() != 0) { print_version(); dotty(L); } else { dofile(L, null); /* executes stdin as a file */ } } return(0); }
static void dotty(Lua.lua_State L) { int status; Lua.CharPtr oldprogname = progname; progname = null; while ((status = loadline(L)) != -1) { if (status == 0) status = docall(L, 0, 0); report(L, status); if (status == 0 && Lua.lua_gettop(L) > 0) { /* any result to print? */ Lua.lua_getglobal(L, "print"); Lua.lua_insert(L, 1); if (Lua.lua_pcall(L, Lua.lua_gettop(L) - 1, 0, 0) != 0) l_message(progname, Lua.lua_pushfstring(L, "error calling " + Lua.LUA_QL("print").ToString() + " (%s)", Lua.lua_tostring(L, -1))); } } Lua.lua_settop(L, 0); /* clear stack */ Lua.fputs("\n", Lua.stdout); Lua.fflush(Lua.stdout); progname = oldprogname; }
static Lua.CharPtr progname = PROGNAME; /* actual program name */ static void fatal(Lua.CharPtr message) { Lua.fprintf(Lua.stderr, "%s: %s\n", progname, message); Environment.Exit(Lua.EXIT_FAILURE); }
public static void luaY_checklimit(FuncState fs, int v, int l, CharPtr m) { if ((v) > (l)) errorlimit(fs, l, m); }
static void cannot(Lua.CharPtr what) { Lua.fprintf(Lua.stderr, "%s: cannot %s %s: %s\n", progname, what, output, Lua.strerror(Lua.errno())); Environment.Exit(Lua.EXIT_FAILURE); }
static void setsfield(LuaState L, Lua.CharPtr n, Lua.CharPtr v) { Lua.lua_pushstring(L, v); Lua.lua_setfield(L, -2, n); }
//#define IS(s) (strcmp(argv[i],s)==0) static int doargs(int argc, string[] argv) { int i; int version = 0; if ((argv.Length > 0) && (argv[0] != "")) { progname = argv[0]; } for (i = 1; i < argc; i++) { if (argv[i][0] != '-') /* end of options; keep it */ { break; } else if (Lua.strcmp(argv[i], "--") == 0) /* end of options; skip it */ { ++i; if (version != 0) { ++version; } break; } else if (Lua.strcmp(argv[i], "-") == 0) /* end of options; use stdin */ { break; } else if (Lua.strcmp(argv[i], "-l") == 0) /* list */ { ++listing; } else if (Lua.strcmp(argv[i], "-o") == 0) /* output file */ { output = argv[++i]; if (output == null || (output[0] == 0)) { usage(Lua.LUA_QL("-o") + " needs argument"); } if (Lua.strcmp(argv[i], "-") == 0) { output = null; } } else if (Lua.strcmp(argv[i], "-p") == 0) /* parse only */ { dumping = 0; } else if (Lua.strcmp(argv[i], "-s") == 0) /* strip debug information */ { stripping = 1; } else if (Lua.strcmp(argv[i], "-v") == 0) /* show version */ { ++version; } else /* unknown option */ { usage(argv[i]); } } if (i == argc && ((listing != 0) || (dumping == 0))) { dumping = 0; argv[--i] = Output.ToString(); } if (version != 0) { Lua.printf("%s %s\n", Lua.LUA_RELEASE, Lua.LUA_COPYRIGHT); if (version == argc - 1) { Environment.Exit(Lua.EXIT_SUCCESS); } } return(i); }
static void setifield(LuaState L, Lua.CharPtr n, int v) { Lua.lua_pushinteger(L, v); Lua.lua_setfield(L, -2, n); }
public Lua.CharPtr data; /* storage space for buffer data */ public pBuffer() { data = new Lua.CharPtr(new char[BUF_SIZE]); }
static int dolibrary(Lua.LuaState L, Lua.CharPtr name) { Lua.lua_getglobal(L, "require"); Lua.lua_pushstring(L, name); return(report(L, docall(L, 1, 1))); }