MCPcopy Create free account
hub / github.com/TASEmulators/fceux / barg

Function barg

src/lua-engine.cpp:5767–5794  ·  view source on GitHub ↗

Convert argument to bit type. */

Source from the content-addressed store, hash-verified

5765
5766/* Convert argument to bit type. */
5767static UBits barg(lua_State *L, int idx)
5768{
5769 BitNum bn;
5770 UBits b;
5771 bn.n = lua_tonumber(L, idx);
5772#if defined(LUA_NUMBER_DOUBLE)
5773 bn.n += 6755399441055744.0; /* 2^52+2^51 */
5774#ifdef SWAPPED_DOUBLE
5775 b = (UBits)(bn.b >> 32);
5776#else
5777 b = (UBits)bn.b;
5778#endif
5779#elif defined(LUA_NUMBER_INT) || defined(LUA_NUMBER_LONG) || \
5780 defined(LUA_NUMBER_LONGLONG) || defined(LUA_NUMBER_LONG_LONG) || \
5781 defined(LUA_NUMBER_LLONG)
5782 if (sizeof(UBits) == sizeof(lua_Number))
5783 b = bn.b;
5784 else
5785 b = (UBits)(SBits)bn.n;
5786#elif defined(LUA_NUMBER_FLOAT)
5787#error "A 'float' lua_Number type is incompatible with this library"
5788#else
5789#error "Unknown number type, check LUA_NUMBER_* in luaconf.h"
5790#endif
5791 if (b == 0 && !lua_isnumber(L, idx))
5792 luaL_typerror(L, idx, "number");
5793 return b;
5794}
5795
5796/* Return bit type. */
5797#define BRET(b) lua_pushnumber(L, (lua_Number)(SBits)(b)); return 1;

Callers 4

lua-engine.cppFile · 0.85
bit_bswapFunction · 0.85
bit_tohexFunction · 0.85
luabitop_validateFunction · 0.85

Calls 3

lua_tonumberFunction · 0.85
lua_isnumberFunction · 0.85
luaL_typerrorFunction · 0.85

Tested by

no test coverage detected