Пример #1
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);
        }
Пример #2
0
        public object GetObject(int reference, object field)
        {
            int oldTop = LuaNativeMethods.lua_gettop(statePointer);

            LuaNativeMethods.lua_getref(statePointer, reference);
            LuaObject.PushObject(statePointer, field);
            LuaNativeMethods.lua_gettable(statePointer, -2);
            object returnValue = GetObject(statePointer, -1);

            LuaNativeMethods.lua_settop(statePointer, oldTop);
            return(returnValue);
        }
Пример #3
0
 public static int ToBytes(IntPtr ptr)
 {
     try
     {
         byte[] bytes = null;
         LuaObject.CheckBinaryString(ptr, 1, out bytes);
         LuaObject.PushValue(ptr, true);
         LuaObject.PushObject(ptr, bytes);
         return(2);
     }
     catch (System.Exception e)
     {
         return(Error(ptr, e));
     }
 }
Пример #4
0
        public static int GetClass(IntPtr ptr)
        {
            try
            {
                string cls;
                CheckType(ptr, 1, out cls);
                Type t = LuaObject.FindType(cls);
                if (t == null)
                {
                    return(Error(ptr, "Can't find {0} to create", cls));
                }

                LuaClassObject co = new LuaClassObject(t);
                LuaObject.PushValue(ptr, true);
                LuaObject.PushObject(ptr, co);
                return(2);
            }
            catch (Exception e)
            {
                return(Error(ptr, e));
            }
        }