Comparison

net/websocket/frames.lua @ 6895:f04fadabd5d9

net.websocket.frames: Simplify import of bitlib
author Kim Alvefur <zash@zash.se>
date Tue, 06 Oct 2015 16:06:22 +0200
parent 6455:b6514e691a70
child 6896:c11776f85552
comparison
equal deleted inserted replaced
6894:f7203c7cb7ff 6895:f04fadabd5d9
8 8
9 local softreq = require "util.dependencies".softreq; 9 local softreq = require "util.dependencies".softreq;
10 local log = require "util.logger".init "websocket.frames"; 10 local log = require "util.logger".init "websocket.frames";
11 local random_bytes = require "util.random".bytes; 11 local random_bytes = require "util.random".bytes;
12 12
13 local bit; 13 local bit = softreq"bit" or softreq"bit32";
14 pcall(function() bit = require"bit"; end);
15 bit = bit or softreq"bit32"
16 if not bit then log("error", "No bit module found. Either LuaJIT 2, lua-bitop or Lua 5.2 is required"); end 14 if not bit then log("error", "No bit module found. Either LuaJIT 2, lua-bitop or Lua 5.2 is required"); end
17 local band = bit.band; 15 local band = bit.band;
18 local bor = bit.bor; 16 local bor = bit.bor;
19 local bxor = bit.bxor; 17 local bxor = bit.bxor;
20 local lshift = bit.lshift; 18 local lshift = bit.lshift;