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

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