示例#1
0
    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);
    }
示例#2
0
文件: Lua.cs 项目: JumpNotZero/NLua
        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);
        }
示例#3
0
 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();
     }
 }
示例#4
0
		public static void Requiref(LuaStatePtr l, string modname, LuaCFunction openf, int glb) {
			GC.KeepAlive(openf);
			LuaLDelegates.luaL_requiref(l, modname, openf, glb);
		}
示例#5
0
 public static void lua_register(LuaState state, string name, LuaCFunction func)
 {
     lua_pushcclosure(state, func, 0);
     lua_setglobal(state, name);
 }
示例#6
0
		internal extern static void luaL_requiref(LuaStatePtr l, [MarshalAs(UnmanagedType.LPStr)] string modname, LuaCFunction openf, int glb);
示例#7
0
    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);
    }
示例#8
0
 public static void lua_pushcclosure(LuaState state, LuaCFunction function, int functionArgCount)
 {
     IntPtr funcPtr = Marshal.GetFunctionPointerForDelegate(function);
     LuaNativeBinding.lua_pushcclosure(state, funcPtr, functionArgCount);
 }
示例#9
0
		internal static extern void lua_pushcclosure(LuaStatePtr l, LuaCFunction fn, int n);
示例#10
0
 public static extern IntPtr XLLRT_SetClassFunctionHook(IntPtr hEnv, string className, string name, LuaCFunction func, [MarshalAs(UnmanagedType.Bool)] bool pre);
示例#11
0
 /// <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);
 }
示例#12
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);
 }
示例#13
0
 private static extern LuaError lua_pcallk(IntPtr luaState, int nArgs, int nRet, int errFunc, int context,
                                           LuaCFunction hook);
示例#14
0
 /// <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);
 }
示例#15
0
		public static void PushCFunction(LuaStatePtr l, LuaCFunction f) {
			Lua.PushCClosure(l, f, 0);
		}
示例#16
0
		public static void Register(LuaStatePtr l, string n, LuaCFunction f) {
			Lua.PushCFunction(l, f);
			Lua.SetGlobal(l, n);
		}
示例#17
0
    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);
    }
示例#18
0
 public static void lua_pushcfunction(LuaState state, LuaCFunction func)
 {
     lua_pushcclosure(state, func, 0);
 }
示例#19
0
文件: Func53.cs 项目: nhtha/LuNari
 /// <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);
 }
示例#20
0
		internal static extern int lua_pcallk(LuaStatePtr l, int nargs, int nresults, int errfunc, int ctx, LuaCFunction k);
示例#21
0
 public static extern IntPtr XLLRT_SetGlobalObjectFunctionHook(IntPtr hEnv, string objName, string name, LuaCFunction func, [MarshalAs(UnmanagedType.Bool)] bool pre);
示例#22
0
 public static void PushCFunction(LuaStatePtr l, LuaCFunction f)
 {
     Lua.PushCClosure(l, f, 0);
 }
示例#23
0
 public static extern IntPtr XLLRT_SetClassFunctionHook(IntPtr hEnv, string className, string name, LuaCFunction func, [MarshalAs(UnmanagedType.Bool)] bool pre);
示例#24
0
 public static void RegisterFunc(string funcname, LuaCFunction funccallback)
 {
     LuaAPI.RegisterFunc(LuaEnv.L, funcname, Marshal.GetFunctionPointerForDelegate(funccallback));
 }
示例#25
0
 public static extern LuaCFunction XLLRT_GetFunctionAddress(LuaCFunction lpFun);
示例#26
0
 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);
 }
示例#27
0
 public ValueUnion(LuaCFunction value) : this()
 {
     CFunction = value;
 }
示例#28
0
 public static void lua_pushcfunction(LuaState state, LuaCFunction func)
 {
     lua_pushcclosure(state, func, 0);
 }
示例#29
0
 internal static extern LuaCFunction lua_atpanic(LuaStatePtr l, LuaCFunction panicf);
示例#30
0
 //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);
 }
示例#31
0
 internal static extern int lua_pcallk(LuaStatePtr l, int nargs, int nresults, int errfunc, int ctx, LuaCFunction k);
示例#32
0
    //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));
    }
示例#33
0
		internal static extern LuaCFunction lua_atpanic(LuaStatePtr l, LuaCFunction panicf);
示例#34
0
 internal static extern void lua_pushcclosure(LuaStatePtr l, LuaCFunction fn, int n);
示例#35
0
 public static void lua_register(LuaState state, string name, LuaCFunction func)
 {
     lua_pushcclosure(state, func, 0);
     lua_setglobal(state, name);
 }
示例#36
0
 internal static extern void lua_callk(LuaStatePtr l, int nargs, int nresults, int ctx, LuaCFunction k);
示例#37
0
 public static void Requiref(LuaStatePtr l, string modname, LuaCFunction openf, int glb)
 {
     GC.KeepAlive(openf);
     LuaLDelegates.luaL_requiref(l, modname, openf, glb);
 }
示例#38
0
 internal static extern int lua_yieldk(LuaStatePtr l, int nresults, int ctx, LuaCFunction k);
示例#39
0
 public static void PushCClosure(LuaStatePtr l, LuaCFunction fn, int n)
 {
     System.GC.KeepAlive(fn);
     LuaDelegates.lua_pushcclosure(l, fn, n);
 }
示例#40
0
		internal static extern void lua_callk(LuaStatePtr l, int nargs, int nresults, int ctx, LuaCFunction k);
示例#41
0
 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);
 }
示例#42
0
		internal static extern int lua_yieldk(LuaStatePtr l, int nresults, int ctx, LuaCFunction k);
示例#43
0
 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));
 }
示例#44
0
 public static void Register(LuaStatePtr l, string n, LuaCFunction f)
 {
     Lua.PushCFunction(l, f);
     Lua.SetGlobal(l, n);
 }
示例#45
0
 public static int Yieldk(LuaStatePtr l, int nresults, int ctx, LuaCFunction k)
 {
     System.GC.KeepAlive(k);
     return(LuaDelegates.lua_yieldk(l, nresults, ctx, k));
 }
示例#46
0
 public static extern LuaCFunction XLLRT_GetFunctionAddress(LuaCFunction lpFun);
示例#47
0
 public static LuaCFunction AtPanic(LuaStatePtr l, LuaCFunction panicf)
 {
     System.GC.KeepAlive(panicf);
     return(LuaDelegates.lua_atpanic(l, panicf));
 }
示例#48
0
 public static extern IntPtr XLLRT_SetGlobalObjectFunctionHook(IntPtr hEnv, string objName, string name, LuaCFunction func, [MarshalAs(UnmanagedType.Bool)] bool pre);
示例#49
0
 public static void PushFunction(IntPtr state, LuaCFunction function)
 {
     LuaCore.PushClosure(state, function, 0);
 }
示例#50
0
 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);
 }
示例#51
0
    public static void lua_pushcclosure(LuaState state, LuaCFunction function, int functionArgCount)
    {
        IntPtr funcPtr = Marshal.GetFunctionPointerForDelegate(function);

        LuaNativeBinding.lua_pushcclosure(state, funcPtr, functionArgCount);
    }