#ifndef __LUA_INT64_H___ #define __LUA_INT64_H___ #ifdef __cplusplus extern "C" { #endif #include #include //lua_push?INT64 #include #include #include UINT64 lua_checkUINT64(lua_State *L, int i); INT64 lua_checkINT64(lua_State *L, int i); int atoUINT64(const char* s, UINT64 * pv); int atoINT64(const char* s, INT64 *pv); #ifndef MINGW_HAS_SECURE_API #define _ui64toa_s(val, buf, sz, radix) !_ui64toa(val, buf, radix) #endif #ifdef __GNUC__ #define CONST_9007199254740992 0x20000000000000LL #else #define CONST_9007199254740992 9007199254740992 #endif #define lua_pushUINT64(L,n) \ if( n > CONST_9007199254740992 ){ \ char buf[24]; \ if(_ui64toa_s(n, buf, _countof(buf), 10)){ \ lua_pushnil(L);return; \ }else{ \ lua_pushstring(L, buf); \ } \ }else{ \ lua_pushnumber(L, (lua_Number)(__int64)n); \ } #define lua_pushINT64(L,n) \ if(n > 9007199254740992 || n < -9007199254740992){ \ char buf[24]; \ lua_pushstring(L, _i64toa(n, buf, 10)); \ }else{ \ lua_pushnumber(L, (lua_Number)n); \ } #ifdef __cplusplus } #endif #endif //__LUA_INT64_H___