Skip to content

Commit

Permalink
Implemented bit32.bxor for #319
Browse files Browse the repository at this point in the history
  • Loading branch information
hymkor committed Jun 11, 2018
1 parent 8a3886d commit c05e3ee
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions functions/builtinfunc.go
Original file line number Diff line number Diff line change
Expand Up @@ -489,3 +489,7 @@ func CmdBitAnd(args []any_t) []any_t {
func CmdBitOr(args []any_t) []any_t {
return bitOperators(args, 0, func(r, v int) int { return r | v })
}

func CmdBitXor(args []any_t) []any_t {
return bitOperators(args, 0, func(r, v int) int { return r ^ v })
}
1 change: 1 addition & 0 deletions mains/bit32lua.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ func SetupBit32Table(L *lua.LState) {
table := L.NewTable()
L.SetField(table, "band", L.NewFunction(lua2cmd(functions.CmdBitAnd)))
L.SetField(table, "bor", L.NewFunction(lua2cmd(functions.CmdBitOr)))
L.SetField(table, "bxor", L.NewFunction(lua2cmd(functions.CmdBitXor)))
L.SetGlobal("bit32", table)
}
1 change: 1 addition & 0 deletions t/tst_bit32.lua
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
print( "bit32.band(1,3) ==" , bit32.band(1,3) )
print( "bit32.bor(1,2) ==" ,bit32.bor(1,2))
print( "bit32.bxor(1,3) ==" ,bit32.bxor(1,3))

0 comments on commit c05e3ee

Please sign in to comment.