Пример #1
0
        public static void PushObject(IntPtr L, object o)
        {
            LuaState state = LuaState.Get(L);

            if (o == null)
            {
                LuaDLL.lua_pushnil(L);
                return;
            }

            int reference = state.GetMetaReference(o.GetType());

            if (reference > 0)
            {
                PushUserData(L, o, reference);
            }
            else
            {
                //可进入反射流程
                LuaDLL.luaL_error(L, string.Format("Type {0} not register to lua", o.GetType()));
            }
        }
Пример #2
0
        public static void PushValue(IntPtr L, ValueType v)
        {
            if (v == null)
            {
                LuaDLL.lua_pushnil(L);
                return;
            }

            LuaState state     = LuaState.Get(L);
            int      reference = state.GetMetaReference(v.GetType());

            if (reference > 0)
            {
                ObjectTranslator translator = state.translator;
                int index = translator.AddObject(v);
                LuaDLL.tolua_pushnewudata(L, reference, index);
            }
            else
            {
                //可进入反射流程
                LuaDLL.luaL_error(L, string.Format("Type {0} not register to lua", v.GetType()));
            }
        }
Пример #3
0
        public static int GetMetaReference(IntPtr L, Type t)
        {
            LuaState state = LuaState.Get(L);

            return(state.GetMetaReference(t));
        }