public static string luaL_checkstring(lua_State L, int n) { int i = 0; return(luaL_checklstring(L, n, ref i)); }
/* these are quite standard operations */ public static double luai_numadd(cc.lua_State L, double a, double b) { return(a + b); }
public static double luai_nummul(cc.lua_State L, double a, double b) { return(a * b); }
public static int luaopen_package(lua_State L) { return(1); }
public static void luaT_trybinTM(lua_State L, int p1, int p2, int res, TMS ev) { luaT_trybinTM(L, L.stack[p1], L.stack[p2], res, ev); }
/* ** new zero-terminated string */ public static TString luaS_new(lua_State L, string str) { byte[] buf = str2byte(str); return(luaS_newlstr(L, buf, buf.Length)); }
public static TString internshrstr(lua_State L, byte[] str, int l) { return(internshrstr(L, str, 0, l)); }
public static int luaL_error(lua_State L, string fmt, params object[] args) { // TODO return(lua_error(L)); }
public static void luaL_setmetatable(lua_State L, string tname) { luaL_getmetatable(L, tname); lua_setmetatable(L, -2); }
public static int luaL_getmetatable(lua_State L, string n) { return(lua_getfield(L, LUA_REGISTRYINDEX, n)); }
public static int luaL_loadbuffer(lua_State L, byte[] s, int sz, string n) { return(luaL_loadbufferx(L, s, sz, n, null)); }
public static void luaL_dofile(lua_State L, string fn) { luaL_loadfile(L, fn); lua_pcall(L, 0, LUA_MULTRET, 0); }
public static string luaL_typename(lua_State L, int i) { return(lua_typename(L, lua_type(L, i))); }
public static string luaL_optstring(lua_State L, int n, string d) { int i = 0; return(luaL_optlstring(L, n, d, ref i)); }
/* ** Open string library */ public static int luaopen_string(lua_State L) { cc.luaL_newlib(L, imp.strlib); imp.createmetatable(L); return(1); }
public static double luaL_optnumber(lua_State L, int arg, double def) { return(lua_isnoneornil(L, arg) != 0 ? def : luaL_checknumber(L, arg)); }
public static TString luaS_newlstr(lua_State L, byte[] str, int len) { return(luaS_newlstr(L, str, 0, len)); }
public static long luaL_optinteger(lua_State L, int arg, long def) { return(lua_isnoneornil(L, arg) != 0 ? def : luaL_checkinteger(L, arg)); }
public static TString createstrobj(lua_State L, byte[] str, int l, int tag, uint h) { return(createstrobj(L, str, 0, l, tag, h)); }
public static int luaL_loadstring(lua_State L, string s) { byte[] b = imp.str2byte(s); return(luaL_loadbuffer(L, b, b.Length, s)); }
public static TString luaS_newliteral(lua_State L, string str) { return(luaS_new(L, str)); }
public static void luaH_resizearray(lua_State L, Table t, long nasize) { long nsize = ltable.isdummy(t.node) ? 0 : sizenode(t); luaH_resize(L, t, nasize, nsize); }
public static TValue luaT_gettmbyobj(lua_State L, int o, TMS ev) { return(luaT_gettmbyobj(L, L.stack[o], ev)); }
/* ** inserts a new key into a hash table; first, check whether key's main ** position is free. If not, check whether colliding node is in its main ** position or not: if it is not, move colliding node to an empty place and ** put new key in its main position; otherwise (colliding node is in its main ** position), new key goes to an empty position. */ public static TValue luaH_newkey(lua_State L, Table t, TValue key) { TValue aux; if (ttisnil(key)) { luaG_runerror(L, "table index is nil"); } else if (ttisfloat(key)) { double n = fltvalue(key); long k = 0; if (luai_numisnan(n)) { luaG_runerror(L, "table index is NaN"); } if (ltable.numisinteger(n, ref k)) /* index is int? */ { aux = luaM_newobject <TValue> (L); setivalue(aux, k); key = aux; /* insert it as an integer */ } } Node mp = ltable.mainposition(t, key); if ((ttisnil(mp.i_val) == false) || ltable.isdummy(mp)) /* main position is taken? */ { Node f = ltable.getfreepos(t); /* get a free place */ if (f == null) /* cannot find a free place? */ { ltable.rehash(L, t, key); /* grow table */ /* whatever called 'newkey' takes care of TM cache and GC barrier */ return(luaH_set(L, t, key)); /* insert key into grown table */ } lua_assert(ltable.isdummy(f) == false); Node othern = ltable.mainposition(t, mp.i_key.tvk); if (othern != mp) /* is colliding node out of its main position? */ /* yes; move colliding node into free position */ { while (othern.i_key.next != mp) /* find previous */ { othern = othern.i_key.next; } othern.i_key.next = f; ltable.nodecopy(f, mp); /* copy colliding node into free pos. (mp->next also goes) */ setnilvalue(mp.i_val); setnilvalue(mp.i_key.tvk); mp.i_key.next = null; } else /* colliding node is in its own main position */ /* new node will go into free position */ { if (mp.i_key.next != null) { f.i_key.next = mp.i_key.next; } else { lua_assert(f.i_key.next == null); } mp.i_key.next = f; mp = f; } } setnodekey(L, mp.i_key, key); luaC_barrierback(L, t, key); lua_assert(ttisnil(mp.i_val)); return(mp.i_val); }
public static TValue fasttm(lua_State L, Table et, TMS e) { return(gfasttm(G(L), et, e)); }
public static TValue luaH_set(lua_State L, Table t, int key) { return(luaH_set(L, t, L.stack[key])); }
public static double luai_numsub(cc.lua_State L, double a, double b) { return(a - b); }
public static void luaH_setint(lua_State L, Table t, long key, int value) { luaH_setint(L, t, key, L.stack[value]); }
public static double luai_numdiv(cc.lua_State L, double a, double b) { return(a / b); }
public static void luaL_newlib(lua_State L, luaL_Reg[] l) { luaL_checkversion(L); luaL_newlibtable(L, l); luaL_setfuncs(L, l, 0); }