1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
#ifndef __LUA_INT64_H___
#define __LUA_INT64_H___
#ifdef __cplusplus
extern "C" {
#endif
#include <windows.h>
#include <stdlib.h> //lua_push?INT64
#include <lua.h>
#include <lualib.h>
#include <lauxlib.h>
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___
|