Пример #1
0
        /*
         * Gets an object from the Lua stack according to its Lua type.
         */
        internal object GetObject(LuaState luaState, int index)
        {
            LuaType type = luaState.Type(index);

            switch (type)
            {
            case LuaType.Number:
            {
                if (luaState.IsInteger(index))
                {
                    return(luaState.ToInteger(index));
                }

                return(luaState.ToNumber(index));
            }

            case LuaType.String:
                return(luaState.ToString(index, false));

            case LuaType.Boolean:
                return(luaState.ToBoolean(index));

            case LuaType.Table:
                return(GetTable(luaState, index));

            case LuaType.Function:
                return(GetFunction(luaState, index));

            case LuaType.UserData:
            {
                int udata = luaState.ToNetObject(index, Tag);
                return(udata != -1 ? _objects[udata] : GetUserData(luaState, index));
            }

            case LuaType.Thread:
                return(GetThread(luaState, index));

            default:
                return(null);
            }
        }