File tree Expand file tree Collapse file tree 4 files changed +14
-12
lines changed
Expand file tree Collapse file tree 4 files changed +14
-12
lines changed Original file line number Diff line number Diff line change 1- # stats [ ![ GoDoc] ( https://godoc.org/github.com/vadv/gopher-lua-libs/bit?bit.svg )] ( https://godoc.org/github.com/vadv/gopher-lua-libs/stats )
1+ # stats [ ![ GoDoc] ( https://godoc.org/github.com/vadv/gopher-lua-libs/bit?bit.svg )] ( https://godoc.org/github.com/vadv/gopher-lua-libs/bit )
22
33## Usage
44
55``` lua
6- local stats = require (" bit" )
6+ local bit = require (" bit" )
77
88local result , _ = bit .band (1 , 0 )
99print (result )
1010-- Output: 0
1111
12- local result , _ = stats .lshift (10 , 5 )
12+ local result , _ = bit .lshift (10 , 5 )
1313print (result )
1414-- Output: 320
1515```
Original file line number Diff line number Diff line change 1- // Package strings implements golang package montanaflynn/stats functionality for lua .
2- package stats
1+ // Package bit implements Go bitwise operations functionality for Lua .
2+ package bit
33
44import (
55 "fmt"
@@ -19,7 +19,7 @@ const (
1919 rs
2020)
2121
22- // ShiftLeft
22+ // Bitwise returns a Lua function used for bitwise operations.
2323func Bitwise (kind op ) lua.LGFunction {
2424 return func (l * lua.LState ) int {
2525 if kind > rs {
@@ -49,6 +49,7 @@ func Bitwise(kind op) lua.LGFunction {
4949 }
5050}
5151
52+ // Not implements bitwise not.
5253func Not (l * lua.LState ) int {
5354 val , err := intToU32 (l .CheckInt (1 ))
5455 if err != nil {
@@ -59,12 +60,12 @@ func Not(l *lua.LState) int {
5960 return 1
6061}
6162
62- func prepareParams (l * lua.LState ) (val , pos uint32 , err error ) {
63- val , err = intToU32 (l .CheckInt (1 ))
63+ func prepareParams (l * lua.LState ) (val1 , val2 uint32 , err error ) {
64+ val1 , err = intToU32 (l .CheckInt (1 ))
6465 if err != nil {
6566 return 0 , 0 , err
6667 }
67- pos , err = intToU32 (l .CheckInt (2 ))
68+ val2 , err = intToU32 (l .CheckInt (2 ))
6869 if err != nil {
6970 return 0 , 0 , err
7071 }
Original file line number Diff line number Diff line change 1- package stats
1+ package bit
22
33import (
4+ "testing"
5+
46 "github.com/stretchr/testify/assert"
57 "github.com/vadv/gopher-lua-libs/tests"
6- "testing"
78)
89
910func TestApi (t * testing.T ) {
Original file line number Diff line number Diff line change 1- package stats
1+ package bit
22
33import lua "github.com/yuin/gopher-lua"
44
You can’t perform that action at this time.
0 commit comments