bit32 for GopherLua
A native Go implementation of bit32 for the GopherLua VM.
Using
Loading Module
import (
"github.com/nubix-io/gluabit32"
)
// Bring up a GopherLua VM
L := lua.NewState()
defer L.Close()
// Preload bit32 module
gluabit32.Preload(L)
Invoking functions
script := `
local bit32 = require 'bit32'
return bit32.rshift(5, 1), bit32.rshift(0xffffffff, 0)`
L.DoString(script)
assert.equal(2, L.ToString(-2))
assert.equal(4294967295, L.ToString(-1))
Testing
$ go test