The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Macros | Typedefs | Functions | Variables
lbitlib.cpp File Reference
#include "lua.h"
#include "lauxlib.h"
#include "lualib.h"
Include dependency graph for lbitlib.cpp:

Go to the source code of this file.

Macros

#define lbitlib_c
 
#define LUA_LIB
 
#define LUA_NBITS   32
 
#define ALLONES   (~(((~(lua_Unsigned)0) << (LUA_NBITS - 1)) << 1))
 
#define trim(x)   ((x) & ALLONES)
 
#define mask(n)   (~((ALLONES << 1) << ((n) - 1)))
 

Typedefs

typedef lua_Unsigned b_uint
 

Functions

static b_uint andaux (lua_State *L)
 
static int b_and (lua_State *L)
 
static int b_test (lua_State *L)
 
static int b_or (lua_State *L)
 
static int b_xor (lua_State *L)
 
static int b_not (lua_State *L)
 
static int b_shift (lua_State *L, b_uint r, int i)
 
static int b_lshift (lua_State *L)
 
static int b_rshift (lua_State *L)
 
static int b_arshift (lua_State *L)
 
static int b_rot (lua_State *L, int i)
 
static int b_lrot (lua_State *L)
 
static int b_rrot (lua_State *L)
 
static int fieldargs (lua_State *L, int farg, int *width)
 
static int b_extract (lua_State *L)
 
static int b_replace (lua_State *L)
 
LUAMOD_API int luaopen_bit32 (lua_State *L)
 

Variables

static const luaL_Reg bitlib []
 

Macro Definition Documentation

#define ALLONES   (~(((~(lua_Unsigned)0) << (LUA_NBITS - 1)) << 1))

Definition at line 21 of file lbitlib.cpp.

Referenced by b_arshift().

#define lbitlib_c

Definition at line 6 of file lbitlib.cpp.

#define LUA_LIB

Definition at line 7 of file lbitlib.cpp.

#define LUA_NBITS   32

Definition at line 17 of file lbitlib.cpp.

Referenced by b_arshift(), b_rot(), b_shift(), and fieldargs().

#define mask (   n)    (~((ALLONES << 1) << ((n) - 1)))
#define trim (   x)    ((x) & ALLONES)

Definition at line 24 of file lbitlib.cpp.

Referenced by andaux(), b_arshift(), b_not(), b_or(), b_rot(), b_shift(), and b_xor().

Typedef Documentation

Definition at line 31 of file lbitlib.cpp.

Function Documentation

static b_uint andaux ( lua_State L)
static

Definition at line 35 of file lbitlib.cpp.

References i, lua_gettop(), luaL_checkunsigned(), and trim.

Referenced by b_and(), and b_test().

static int b_and ( lua_State L)
static

Definition at line 44 of file lbitlib.cpp.

References andaux(), and lua_pushunsigned().

static int b_arshift ( lua_State L)
static
static int b_extract ( lua_State L)
static

Definition at line 166 of file lbitlib.cpp.

References fieldargs(), lua_pushunsigned(), luaL_checkunsigned(), and mask.

static int b_lrot ( lua_State L)
static

Definition at line 138 of file lbitlib.cpp.

References b_rot(), and luaL_checkint.

static int b_lshift ( lua_State L)
static

Definition at line 102 of file lbitlib.cpp.

References b_shift(), luaL_checkint, and luaL_checkunsigned().

static int b_not ( lua_State L)
static

Definition at line 78 of file lbitlib.cpp.

References lua_pushunsigned(), luaL_checkunsigned(), and trim.

static int b_or ( lua_State L)
static

Definition at line 58 of file lbitlib.cpp.

References i, lua_gettop(), lua_pushunsigned(), luaL_checkunsigned(), and trim.

static int b_replace ( lua_State L)
static

Definition at line 176 of file lbitlib.cpp.

References fieldargs(), lua_pushunsigned(), luaL_checkunsigned(), and mask.

static int b_rot ( lua_State L,
int  i 
)
static

Definition at line 127 of file lbitlib.cpp.

References i, LUA_NBITS, lua_pushunsigned(), luaL_checkunsigned(), and trim.

Referenced by b_lrot(), and b_rrot().

static int b_rrot ( lua_State L)
static

Definition at line 143 of file lbitlib.cpp.

References b_rot(), and luaL_checkint.

static int b_rshift ( lua_State L)
static

Definition at line 107 of file lbitlib.cpp.

References b_shift(), luaL_checkint, and luaL_checkunsigned().

static int b_shift ( lua_State L,
b_uint  r,
int  i 
)
static

Definition at line 85 of file lbitlib.cpp.

References i, LUA_NBITS, lua_pushunsigned(), and trim.

Referenced by b_arshift(), b_lshift(), and b_rshift().

static int b_test ( lua_State L)
static

Definition at line 51 of file lbitlib.cpp.

References andaux(), and lua_pushboolean().

static int b_xor ( lua_State L)
static

Definition at line 68 of file lbitlib.cpp.

References i, lua_gettop(), lua_pushunsigned(), luaL_checkunsigned(), and trim.

static int fieldargs ( lua_State L,
int  farg,
int width 
)
static

Definition at line 154 of file lbitlib.cpp.

References LUA_NBITS, luaL_argcheck, luaL_checkint, luaL_error(), and luaL_optint.

Referenced by b_extract(), and b_replace().

LUAMOD_API int luaopen_bit32 ( lua_State L)

Definition at line 207 of file lbitlib.cpp.

References luaL_newlib.

Referenced by lua_kernel_base::lua_kernel_base().

Variable Documentation

const luaL_Reg bitlib[]
static
Initial value:
= {
{"arshift", b_arshift},
{"band", b_and},
{"bnot", b_not},
{"bor", b_or},
{"bxor", b_xor},
{"btest", b_test},
{"extract", b_extract},
{"lrotate", b_lrot},
{"lshift", b_lshift},
{"replace", b_replace},
{"rrotate", b_rrot},
{"rshift", b_rshift},
{NULL, NULL}
}
static int b_lshift(lua_State *L)
Definition: lbitlib.cpp:102
static int b_not(lua_State *L)
Definition: lbitlib.cpp:78
static int b_and(lua_State *L)
Definition: lbitlib.cpp:44
static int b_rrot(lua_State *L)
Definition: lbitlib.cpp:143
static int b_test(lua_State *L)
Definition: lbitlib.cpp:51
static int b_xor(lua_State *L)
Definition: lbitlib.cpp:68
static int b_arshift(lua_State *L)
Definition: lbitlib.cpp:112
static int b_or(lua_State *L)
Definition: lbitlib.cpp:58
static int b_replace(lua_State *L)
Definition: lbitlib.cpp:176
static int b_lrot(lua_State *L)
Definition: lbitlib.cpp:138
static int b_rshift(lua_State *L)
Definition: lbitlib.cpp:107
static int b_extract(lua_State *L)
Definition: lbitlib.cpp:166

Definition at line 189 of file lbitlib.cpp.