mirror of
https://github.com/scp-fs2open/fs2open.github.com.git
synced 2026-11-07 22:56:30 -10:00
Adds the standard Lua extension library for bit operations in Lua 5.1. http://bitop.luajit.org/ Note that this library is normally called "bit", but it is added here as "luabit" because there is already a FSO scripting library called "bit".
26 lines
484 B
C
26 lines
484 B
C
#include "lua_ext.h"
|
|
|
|
#define linit_c
|
|
#define LUA_LIB
|
|
|
|
#include "lua.h"
|
|
|
|
#include "lualib.h"
|
|
#include "lauxlib.h"
|
|
|
|
|
|
// NOTE: The last item in this array MUST be {NULL, NULL}.
|
|
static const luaL_Reg lualibs_ext[] = {
|
|
{LUA_BITLIBNAME, luaopen_bit},
|
|
{NULL, NULL}
|
|
};
|
|
|
|
LUALIB_API void luaL_openlibs_ext (lua_State *L) {
|
|
const luaL_Reg *lib = lualibs_ext;
|
|
for (; lib->func; lib++) {
|
|
lua_pushcfunction(L, lib->func);
|
|
lua_pushstring(L, lib->name);
|
|
lua_call(L, 1, 0);
|
|
}
|
|
}
|