Exemple #1
0
 public static void RemoveDelgate(IntPtr ptr, int r)
 {
     LuaNativeMethods.lua_getglobal(ptr, DelgateTable);
     LuaNativeMethods.lua_getref(ptr, r);    // push key
     LuaNativeMethods.lua_pushnil(ptr);      // push nil value
     LuaNativeMethods.lua_settable(ptr, -3); // remove function from __LuaDelegate table
     LuaNativeMethods.lua_pop(ptr, 1);       // pop __LuaDelegate
 }
Exemple #2
0
        public void SetObject(int reference, object field, object o)
        {
            int oldTop = LuaNativeMethods.lua_gettop(statePointer);

            LuaNativeMethods.lua_getref(statePointer, reference);
            LuaObject.PushObject(statePointer, field);
            LuaObject.PushObject(statePointer, o);
            LuaNativeMethods.lua_settable(statePointer, -3);
            LuaNativeMethods.lua_settop(statePointer, oldTop);
        }
Exemple #3
0
        public void SetObject(string[] remainingPath, object o)
        {
            int top = LuaNativeMethods.lua_gettop(statePointer);

            for (int i = 0; i < remainingPath.Length - 1; i++)
            {
                LuaNativeMethods.lua_pushstring(statePointer, remainingPath[i]);
                LuaNativeMethods.lua_gettable(statePointer, -2);
            }

            LuaNativeMethods.lua_pushstring(statePointer, remainingPath[remainingPath.Length - 1]);
            LuaObject.PushVar(statePointer, o);
            LuaNativeMethods.lua_settable(statePointer, -3);
            LuaNativeMethods.lua_settop(statePointer, top);
        }
Exemple #4
0
        public static LuaDelegate NewDelegate(IntPtr ptr, int p)
        {
            LuaState state = LuaState.Get(ptr);

            LuaNativeMethods.lua_pushvalue(ptr, p);                                         // push function

            int         fref = LuaNativeMethods.luaL_ref(ptr, LuaIndexes.LUARegistryIndex); // new ref function
            LuaDelegate f    = new LuaDelegate(ptr, fref);

            LuaNativeMethods.lua_pushvalue(ptr, p);
            LuaNativeMethods.lua_pushinteger(ptr, fref);
            LuaNativeMethods.lua_settable(ptr, -3); // __LuaDelegate[func]= fref
            state.DelegateMap[fref] = f;
            return(f);
        }
Exemple #5
0
 public void SetObject(int reference, int index, object o)
 {
     if (index >= 1)
     {
         LuaNativeMethods.lua_getref(statePointer, reference);
         LuaObject.PushVar(statePointer, o);
         LuaNativeMethods.lua_rawseti(statePointer, -2, index);
         LuaNativeMethods.lua_pop(statePointer, 1);
     }
     else
     {
         LuaNativeMethods.lua_getref(statePointer, reference);
         LuaNativeMethods.lua_pushinteger(statePointer, index);
         LuaObject.PushVar(statePointer, o);
         LuaNativeMethods.lua_settable(statePointer, -3);
         LuaNativeMethods.lua_pop(statePointer, 1);
     }
 }
 public static void lua_setglobal(IntPtr luaState, string name)
 {
     LuaNativeMethods.lua_pushstring(luaState, name);
     LuaNativeMethods.lua_insert(luaState, -2);
     LuaNativeMethods.lua_settable(luaState, LuaIndexes.LUAGlobalIndex);
 }