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

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