public static void RegisterVar(string varname, LuaCFunction getcallback, LuaCFunction setcallback) { IntPtr getptr = getcallback != null?Marshal.GetFunctionPointerForDelegate(getcallback) : IntPtr.Zero; IntPtr setptr = setcallback != null?Marshal.GetFunctionPointerForDelegate(setcallback) : IntPtr.Zero; LuaAPI.RegisterVar(LuaEnv.L, varname, getptr, setptr); }
public Lua() { LuaAllocator allocateCallback = new LuaAllocator(this.Allocate); this.allocateHandle = GCHandle.Alloc(allocateCallback); LuaCFunction panicCallback = new LuaCFunction(this.Panic); this.panicHandle = GCHandle.Alloc(panicCallback); this.state = LuaCore.NewState(allocateCallback, IntPtr.Zero); LuaCore.SetPanicCallback(this.state, panicCallback); }
public LuaValue(LuaCFunction value) { if (value != null) { m_type = LuaValueType.CFunction; m_value = new ValueUnion(value); } else { m_type = LuaValueType.Nil; m_value = new ValueUnion(); } }
public static void Requiref(LuaStatePtr l, string modname, LuaCFunction openf, int glb) { GC.KeepAlive(openf); LuaLDelegates.luaL_requiref(l, modname, openf, glb); }
public static void lua_register(LuaState state, string name, LuaCFunction func) { lua_pushcclosure(state, func, 0); lua_setglobal(state, name); }
internal extern static void luaL_requiref(LuaStatePtr l, [MarshalAs(UnmanagedType.LPStr)] string modname, LuaCFunction openf, int glb);
public static void lua_pcallk(LuaState state, int argCount, int resultCount, int errFunc, int ctx, LuaCFunction function) { IntPtr funcPtr = Marshal.GetFunctionPointerForDelegate(function); LuaNativeBinding.lua_pcallk(state, argCount, resultCount, errFunc, ctx, funcPtr); }
public static void lua_pushcclosure(LuaState state, LuaCFunction function, int functionArgCount) { IntPtr funcPtr = Marshal.GetFunctionPointerForDelegate(function); LuaNativeBinding.lua_pushcclosure(state, funcPtr, functionArgCount); }
internal static extern void lua_pushcclosure(LuaStatePtr l, LuaCFunction fn, int n);
public static extern IntPtr XLLRT_SetClassFunctionHook(IntPtr hEnv, string className, string name, LuaCFunction func, [MarshalAs(UnmanagedType.Bool)] bool pre);
/// <summary> /// [-0, +1, m] void lua_pushcfunction (lua_State *L, lua_CFunction f); /// /// Pushes a C function onto the stack. This function receives a pointer to a C function /// and pushes onto the stack a Lua value of type function that, when called, invokes the corresponding C function. /// /// Defined as a macro: /// #define lua_pushcfunction(L,f) lua_pushcclosure(L,f,0) /// </summary> /// <param name="L"></param> /// <param name="f"></param> public virtual void pushcfunction(LuaState L, LuaCFunction f) { pushcclosure(L, f, 0); }
/// <summary> /// [-0, +0, e] void lua_register (lua_State *L, const char *name, lua_CFunction f); /// /// Sets the C function f as the new value of global name. /// /// Defined as a macro: /// #define lua_register(L,n,f) (lua_pushcfunction(L, f), lua_setglobal(L, n)) /// </summary> /// <param name="L"></param> /// <param name="name"></param> /// <param name="f"></param> public void register(LuaState L, string name, LuaCFunction f) { pushcfunction(L, f); setglobal(L, name); }
private static extern LuaError lua_pcallk(IntPtr luaState, int nArgs, int nRet, int errFunc, int context, LuaCFunction hook);
/// <summary> /// [-n, +1, m] void lua_pushcclosure (lua_State *L, lua_CFunction fn, int n); /// /// Pushes a new C closure onto the stack. /// When a C function is created, it is possible to associate some values with it, thus creating a C closure; /// these values are then accessible to the function whenever it is called. /// /// To associate values with a C function, first these values should be pushed onto the stack /// (when there are multiple values, the first value is pushed first). /// Then lua_pushcclosure is called to create and push the C function onto the stack, /// with the argument n telling how many values should be associated with the function. /// /// lua_pushcclosure also pops these values from the stack. /// </summary> /// <param name="L"></param> /// <param name="fn"></param> /// <param name="n">The maximum value is 255.</param> public void pushcclosure(LuaState L, LuaCFunction fn, int n) { bind <Action <LuaState, LuaCFunction, int> >("pushcclosure")(L, fn, n); }
public static void PushCFunction(LuaStatePtr l, LuaCFunction f) { Lua.PushCClosure(l, f, 0); }
public static void Register(LuaStatePtr l, string n, LuaCFunction f) { Lua.PushCFunction(l, f); Lua.SetGlobal(l, n); }
public static void luaL_requiref(LuaState state, string moduleName, LuaCFunction openFunc, int glb) { IntPtr funcPtr = Marshal.GetFunctionPointerForDelegate(openFunc); LuaNativeBinding.luaL_requiref(state, moduleName, funcPtr, glb); }
public static void lua_pushcfunction(LuaState state, LuaCFunction func) { lua_pushcclosure(state, func, 0); }
/// <summary> /// [-0, +1, –] void lua_pushcfunction (lua_State *L, lua_CFunction f); /// /// Pushes a C function onto the stack. This function receives a pointer to a C function /// and pushes onto the stack a Lua value of type function that, when called, invokes the corresponding C function. /// </summary> /// <param name="L"></param> /// <param name="f"></param> public override void pushcfunction(LuaState L, LuaCFunction f) { bind <Action <LuaState, LuaCFunction> >("pushcfunction")(L, f); }
internal static extern int lua_pcallk(LuaStatePtr l, int nargs, int nresults, int errfunc, int ctx, LuaCFunction k);
public static extern IntPtr XLLRT_SetGlobalObjectFunctionHook(IntPtr hEnv, string objName, string name, LuaCFunction func, [MarshalAs(UnmanagedType.Bool)] bool pre);
public static void RegisterFunc(string funcname, LuaCFunction funccallback) { LuaAPI.RegisterFunc(LuaEnv.L, funcname, Marshal.GetFunctionPointerForDelegate(funccallback)); }
public static extern LuaCFunction XLLRT_GetFunctionAddress(LuaCFunction lpFun);
public ValueUnion(LuaCFunction value) : this() { CFunction = value; }
internal static extern LuaCFunction lua_atpanic(LuaStatePtr l, LuaCFunction panicf);
//TODO: lua_load //TODO: lua_dump // Coroutine Functions public static int lua_yieldk(LuaState state, int resultCount, int ctx, LuaCFunction function) { IntPtr funcPtr = Marshal.GetFunctionPointerForDelegate(function); return LuaNativeBinding.lua_yieldk(state, resultCount, ctx, funcPtr); }
//TODO: lua_load //TODO: lua_dump // Coroutine Functions public static int lua_yieldk(LuaState state, int resultCount, int ctx, LuaCFunction function) { IntPtr funcPtr = Marshal.GetFunctionPointerForDelegate(function); return(LuaNativeBinding.lua_yieldk(state, resultCount, ctx, funcPtr)); }
internal static extern void lua_callk(LuaStatePtr l, int nargs, int nresults, int ctx, LuaCFunction k);
internal static extern int lua_yieldk(LuaStatePtr l, int nresults, int ctx, LuaCFunction k);
public static void PushCClosure(LuaStatePtr l, LuaCFunction fn, int n) { System.GC.KeepAlive(fn); LuaDelegates.lua_pushcclosure(l, fn, n); }
public static void Callk(LuaStatePtr l, int nargs, int nresults, int ctx, LuaCFunction k) { System.GC.KeepAlive(k); LuaDelegates.lua_callk(l, nargs, nresults, ctx, k); }
public static int PCallk(LuaStatePtr l, int nargs, int nresults, int errfunc, int ctx, LuaCFunction k) { System.GC.KeepAlive(k); return(LuaDelegates.lua_pcallk(l, nargs, nresults, errfunc, ctx, k)); }
public static int Yieldk(LuaStatePtr l, int nresults, int ctx, LuaCFunction k) { System.GC.KeepAlive(k); return(LuaDelegates.lua_yieldk(l, nresults, ctx, k)); }
public static LuaCFunction AtPanic(LuaStatePtr l, LuaCFunction panicf) { System.GC.KeepAlive(panicf); return(LuaDelegates.lua_atpanic(l, panicf)); }
public static void PushFunction(IntPtr state, LuaCFunction function) { LuaCore.PushClosure(state, function, 0); }