public static void LuaSetAllocF(LuaState L, lua_Alloc f, object ud) { LuaLock(L); G(L).ud = ud; G(L).frealloc = f; LuaUnlock(L); }
public static void lua_setallocf(lua_State L, lua_Alloc f, object ud) { lua_lock(L); G(L).ud = ud; G(L).frealloc = f; lua_unlock(L); }
public static lua_State lua_newstate(lua_Alloc f, object ud) { int i; lua_State L; global_State g; LG l = (LG)f(typeof(LG)); //FIXME:(LG)(f(ud, null, 0, (uint)(GetUnmanagedSize(typeof(LG))))); if (l == null) { return(null); } L = l.l.l; g = l.g; L.next = null; L.tt = LUA_TTHREAD; g.currentwhite = (lu_byte)bit2mask(WHITE0BIT, FIXEDBIT); L.marked = luaC_white(g); g.gckind = KGC_NORMAL; g.nCcalls = 0; lu_byte marked = L.marked; // can't pass properties in as ref ???//FIXME:??? set2bits(ref marked, FIXEDBIT, SFIXEDBIT); L.marked = marked; //remove this //FIXME:??? preinit_state(L, g); g.frealloc = f; g.ud = ud; g.mainthread = L; g.uvhead.u.l.prev = g.uvhead; g.uvhead.u.l.next = g.uvhead; g.GCthreshold = MAX_LUMEM; /* mark it as unfinished state */ g.strt.size = 0; g.strt.nuse = 0; g.strt.hash = null; setnilvalue(g.l_registry); g.l_gt = null; luaZ_initbuffer(L, g.buff); g.panic = null; g.version = lua_version(null); g.gcstate = GCSpause; g.rootgc = obj2gco(L); g.tobefnz = null; g.totalbytes = (uint)GetUnmanagedSize(typeof(LG)); g.gcpause = LUAI_GCPAUSE; g.gcstepmul = LUAI_GCMUL; for (i = 0; i < NUM_TAGS; i++) { g.mt[i] = null; } if (luaD_rawrunprotected(L, f_luaopen, null) != LUA_OK) { /* memory allocation error: free partial state */ close_state(L); L = null; } else { luai_userstateopen(L); } return(L); }
public static lua_State lua_newstate(lua_Alloc f, object ud) { int i; lua_State L; global_State g; LG l = (LG)f(typeof(LG)); //FIXME:(LG)(f(ud, null, LUA_TTHREAD, (uint)(GetUnmanagedSize(typeof(LG))))); //FIXME:???not sync, LUA_TTHREAD if (l == null) { return(null); } L = l.l.l; g = l.g; L.next = null; L.tt = LUA_TTHREAD; g.currentwhite = (lu_byte)bitmask(WHITE0BIT); L.marked = luaC_white(g); lu_byte marked = L.marked; // can't pass properties in as ref ???//FIXME:??? //FIXME:added L.marked = marked; //remove this //FIXME:??? //FIXME:added preinit_thread(L, g); g.frealloc = f; g.ud = ud; g.mainthread = L; g.seed = makeseed(L); g.gcrunning = 0; /* no GC while building state */ g.GCestimate = 0; g.strt.size = g.strt.nuse = 0; g.strt.hash = null; setnilvalue(g.l_registry); luaZ_initbuffer(L, g.buff); g.panic = null; g.version = null; g.gcstate = GCSpause; g.gckind = KGC_NORMAL; g.allgc = g.finobj = g.tobefnz = g.fixedgc = null; g.sweepgc = null; g.gray = g.grayagain = null; g.weak = g.ephemeron = g.allweak = null; g.twups = null; g.totalbytes = (uint)GetUnmanagedSize(typeof(LG)); g.GCdebt = 0; g.gcfinnum = 0; g.gcpause = LUAI_GCPAUSE; g.gcstepmul = LUAI_GCMUL; for (i = 0; i < LUA_NUMTAGS; i++) { g.mt[i] = null; } if (luaD_rawrunprotected(L, f_luaopen, null) != LUA_OK) { /* memory allocation error: free partial state */ close_state(L); L = null; } return(L); }
public static lua_Alloc lua_getallocf(lua_State L, ref object ud) { lua_lock(L); if (ud != null) { ud = imp.G(L).ud; } lua_Alloc f = imp.G(L).frealloc; lua_unlock(L); return(f); }
/* assume that CIST_OAH has offset 0 and that 'v' is strictly 0/1 */ #define setoah(st, v) ((st) = ((st) & ~CIST_OAH) | (v)) #define getoah(st) ((st) & CIST_OAH) public static lua_State lua_newstate(lua_Alloc f, object ud) { int i; lua_State L; global_State g; LG l = (LG)f(ud, null, lua.LUA_TTHREAD, 0 /*sizeof(LG)*/); if (l == null) { return(null); } L = l.l.l; g = l.g; L.next = null; L.tt = lua.LUA_TTHREAD; g.currentwhite = (byte)lgc.bitmask(lgc.WHITE0BIT); L.marked = (byte)lgc.luaC_white(g); preinit_thread(L, g); g.frealloc = f; g.ud = ud; g.mainthread = L; g.seed = makeseed(L); g.gcrunning = 0; /* no GC while building state */ g.GCestimate = 0; g.strt.size = g.strt.nuse = 0; g.strt.hash = null; lobject.setnilvalue(g.l_registry); g.panic = null; g.version = 0 /*null*/; g.gcstate = lgc.GCSpause; g.gckind = KGC_NORMAL; g.allgc = g.finobj = g.tobefnz = g.fixedgc = null; g.sweepgc = null; g.gray = g.grayagain = null; g.weak = g.ephemeron = g.allweak = null; g.twups = null; g.totalbytes = 0 /*sizeof(LG)*/; g.GCdebt = 0; g.gcfinnum = 0; g.gcpause = LUAI_GCPAUSE; g.gcstepmul = LUAI_GCMUL; for (i = 0; i < lua.LUA_NUMTAGS; i++) { g.mt[i] = null; } //if (luaD_rawrunprotected(L, f_luaopen, NULL) != LUA_OK) { // /* memory allocation error: free partial state */ // close_state(L); // L = NULL; //} return(L); }
public static unsafe void lua_setallocf(lua_Alloc f, void* ud) => lua_setallocf(_state, f, ud);
public static extern unsafe LuaState lua_newstate(lua_Alloc f, void *ud);
public static extern unsafe void lua_setallocf(LuaState luaState, lua_Alloc f, void *ud);
public static extern lua_Alloc lua_setallocf(lua_State L, lua_Alloc f, IntPtr ud);
public static extern void lua_setallocf(lua_StatePtr L, lua_Alloc f, IntPtr ud);
public static LuaState LuaNewState(lua_Alloc f, object ud) { int i; LuaState L; GlobalState g; //object l = f(ud, null, 0, (uint)state_size(typeof(LG))); object l = f(typeof(LG)); if (l == null) { return(null); } L = tostate(l); g = (L as LG).g; L.next = null; L.tt = LUA_TTHREAD; g.currentwhite = (lu_byte)Bit2Mask(WHITE0BIT, FIXEDBIT); L.marked = LuaCWhite(g); lu_byte marked = L.marked; // can't pass properties in as ref Set2Bits(ref marked, FIXEDBIT, SFIXEDBIT); L.marked = marked; preinit_state(L, g); g.frealloc = f; g.ud = ud; g.mainthread = L; g.uvhead.u.l.prev = g.uvhead; g.uvhead.u.l.next = g.uvhead; g.GCthreshold = 0; /* mark it as unfinished state */ g.strt.size = 0; g.strt.nuse = 0; g.strt.hash = null; SetNilValue(Registry(L)); luaZ_initbuffer(L, g.buff); g.panic = null; g.gcstate = GCSpause; g.rootgc = obj2gco(L); g.sweepstrgc = 0; g.sweepgc = new RootGCRef(g); g.gray = null; g.grayagain = null; g.weak = null; g.tmudata = null; g.totalbytes = (uint)GetUnmanagedSize(typeof(LG)); g.gcpause = LUAI_GCPAUSE; g.gcstepmul = LUAI_GCMUL; g.gcdept = 0; for (i = 0; i < NUMTAGS; i++) { g.mt[i] = null; } if (LuaDRawRunProtected(L, f_luaopen, null) != 0) { /* memory allocation error: free partial state */ close_state(L); L = null; } else { luai_userstateopen(L); } return(L); }
public static lua_State lua_newstate(lua_Alloc f, object ud) { int i; lua_State L; global_State g; //object l = f(ud, null, 0, (uint)state_size(typeof(LG))); object l = f(typeof(LG)); if (l == null) return null; L = tostate(l); g = (L as LG).g; L.next = null; L.tt = LUA_TTHREAD; g.currentwhite = (lu_byte)bit2mask(WHITE0BIT, FIXEDBIT); L.marked = luaC_white(g); lu_byte marked = L.marked; // can't pass properties in as ref set2bits(ref marked, FIXEDBIT, SFIXEDBIT); L.marked = marked; preinit_state(L, g); g.frealloc = f; g.ud = ud; g.mainthread = L; g.uvhead.u.l.prev = g.uvhead; g.uvhead.u.l.next = g.uvhead; g.GCthreshold = 0; /* mark it as unfinished state */ g.strt.size = 0; g.strt.nuse = 0; g.strt.hash = null; setnilvalue(registry(L)); luaZ_initbuffer(L, g.buff); g.panic = null; g.gcstate = GCSpause; g.rootgc = obj2gco(L); g.sweepstrgc = 0; g.sweepgc = new RootGCRef(g); g.gray = null; g.grayagain = null; g.weak = null; g.tmudata = null; g.totalbytes = (uint)GetUnmanagedSize(typeof(LG)); g.gcpause = LUAI_GCPAUSE; g.gcstepmul = LUAI_GCMUL; g.gcdept = 0; for (i=0; i<NUM_TAGS; i++) g.mt[i] = null; if (luaD_rawrunprotected(L, f_luaopen, null) != 0) { /* memory allocation error: free partial state */ close_state(L); L = null; } else luai_userstateopen(L); return L; }
public extern static lua_State lua_newstate(lua_Alloc f, IntPtr ud);
public static unsafe void lua_setallocf(lua_Alloc f, void *ud) => lua_setallocf(_state, f, ud);
public static extern void lua_setallocf(LuaState L, lua_Alloc f, IntPtr ud);
public static IntPtr lua_newstate(lua_Alloc f, IntPtr ud) { IntPtr funcAlloc = f == null ? IntPtr.Zero : Marshal.GetFunctionPointerForDelegate(f); return(NativeMethods.lua_newstate(funcAlloc, ud)); }
public static unsafe LuaState lua_newstate(this lua_Alloc f, void *ud) => Lua.lua_newstate(f, ud);
public extern static void lua_setallocf(lua_State L, lua_Alloc f, IntPtr ud);
public static unsafe void lua_setallocf(this LuaState luaState, lua_Alloc f, void *ud) => Lua.lua_setallocf(luaState, f, ud);
public static extern void lua_setallocf(IntPtr L, lua_Alloc f, IntPtr ud);
[DllImport("lua")] extern public static void lua_setallocf(IntPtr L, lua_Alloc f, /* void* */ IntPtr ud);
public static extern lua_StatePtr lua_newstate(lua_Alloc f, IntPtr ud);
public static lua_State lua_newstate(lua_Alloc f, object ud) { int i; lua_State L; global_State g; //object l = f(ud, null, 0, (uint)state_size(typeof(LG))); object l = f(typeof(LG)); if (l == null) { return(null); } L = tostate(l); g = (L as LG).g; L.next = null; L.tt = LUA_TTHREAD; g.currentwhite = (lu_byte)bit2mask(WHITE0BIT, FIXEDBIT); L.marked = luaC_white(g); g.emergencygc = 0; g.nCcalls = 0; lu_byte marked = L.marked; // can't pass properties in as ref ???//FIXME:??? set2bits(ref marked, FIXEDBIT, SFIXEDBIT); L.marked = marked; //remove this //FIXME:??? preinit_state(L, g); g.frealloc = f; g.ud = ud; g.mainthread = L; g.uvhead.u.l.prev = g.uvhead; g.uvhead.u.l.next = g.uvhead; g.GCthreshold = MAX_LUMEM; /* mark it as unfinished state */ g.strt.size = 0; g.strt.nuse = 0; g.strt.hash = null; setnilvalue(registry(L)); luaZ_initbuffer(L, g.buff); g.panic = null; g.gcstate = GCSpause; g.rootgc = obj2gco(L); g.sweepstrgc = 0; g.sweepgc = new RootGCRef(g); g.gray = null; g.grayagain = null; g.weak = g.ephemeron = g.allweak = null; g.tmudata = null; g.totalbytes = (uint)GetUnmanagedSize(typeof(LG)); g.gcpause = LUAI_GCPAUSE; g.gcstepmul = LUAI_GCMUL; g.gcdept = 0; for (i = 0; i < NUM_TAGS; i++) { g.mt[i] = null; } if (luaD_rawrunprotected(L, f_luaopen, null) != LUA_OK) { /* memory allocation error: free partial state */ close_state(L); L = null; } else { luai_userstateopen(L); } return(L); }
public static extern void lua_setallocf(IntPtr state, lua_Alloc f, IntPtr ud);
public static unsafe void lua_setallocf(this LuaState luaState, lua_Alloc f, void* ud) => Lua.lua_setallocf(luaState, f, ud);
[DllImport("lua")] extern public static IntPtr lua_newstate(lua_Alloc f, /* void* */ IntPtr ud); // lua_State*
static extern IntPtr lua_newstate(lua_Alloc f, IntPtr ud);
public static extern IntPtr lua_newstate(lua_Alloc f, IntPtr ud);
public static extern unsafe LuaState lua_newstate(lua_Alloc f, void* ud);
public static void lua_setallocf(lua_State L, lua_Alloc f, IntPtr ud) => lua_setallocf(L, f == null ? IntPtr.Zero : Marshal.GetFunctionPointerForDelegate(f), ud);
public static extern unsafe void lua_setallocf(LuaState luaState, lua_Alloc f, void* ud);