mirror of
https://github.com/cloudwu/skynet.git
synced 2026-07-25 12:43:09 +00:00
update to lua 5.3, remove lua unsigned api
This commit is contained in:
@@ -433,7 +433,7 @@ pack_dict(lua_State *L, struct bson *b, bool isarray) {
|
||||
luaL_error(L, "Invalid array key type : %s", lua_typename(L, kt));
|
||||
return;
|
||||
}
|
||||
sz = bson_numstr(numberkey, lua_tounsigned(L,-2)-1);
|
||||
sz = bson_numstr(numberkey, (unsigned int)lua_tointeger(L,-2)-1);
|
||||
key = numberkey;
|
||||
|
||||
append_one(b, L, key, sz);
|
||||
@@ -912,7 +912,7 @@ ltimestamp(lua_State *L) {
|
||||
luaL_addlstring(&b, (const char *)&inc, sizeof(inc));
|
||||
++inc;
|
||||
} else {
|
||||
uint32_t i = lua_tounsigned(L,2);
|
||||
uint32_t i = (uint32_t)lua_tointeger(L,2);
|
||||
luaL_addlstring(&b, (const char *)&i, sizeof(i));
|
||||
}
|
||||
luaL_addlstring(&b, (const char *)&d, sizeof(d));
|
||||
@@ -996,8 +996,8 @@ lsubtype(lua_State *L, int subtype, const uint8_t * buf, size_t sz) {
|
||||
}
|
||||
const uint32_t * ts = (const uint32_t *)buf;
|
||||
lua_pushvalue(L, lua_upvalueindex(8));
|
||||
lua_pushunsigned(L, ts[1]);
|
||||
lua_pushunsigned(L, ts[0]);
|
||||
lua_pushinteger(L, (lua_Integer)ts[1]);
|
||||
lua_pushinteger(L, (lua_Integer)ts[0]);
|
||||
return 3;
|
||||
}
|
||||
case BSON_REGEX: {
|
||||
|
||||
@@ -37,7 +37,7 @@ fill_header(lua_State *L, uint8_t *buf, int sz, void *msg) {
|
||||
|
||||
static void
|
||||
packreq_number(lua_State *L, int session, void * msg, size_t sz) {
|
||||
uint32_t addr = lua_tounsigned(L,1);
|
||||
uint32_t addr = (uint32_t)lua_tointeger(L,1);
|
||||
uint8_t buf[TEMP_LENGTH];
|
||||
fill_header(L, buf, sz+9, msg);
|
||||
buf[2] = 0;
|
||||
@@ -73,7 +73,7 @@ lpackrequest(lua_State *L) {
|
||||
if (msg == NULL) {
|
||||
return luaL_error(L, "Invalid request message");
|
||||
}
|
||||
size_t sz = luaL_checkunsigned(L,4);
|
||||
size_t sz = (size_t)luaL_checkinteger(L,4);
|
||||
int session = luaL_checkinteger(L,2);
|
||||
if (session <= 0) {
|
||||
return luaL_error(L, "Invalid request session %d", session);
|
||||
@@ -112,8 +112,8 @@ unpackreq_number(lua_State *L, const uint8_t * buf, size_t sz) {
|
||||
}
|
||||
uint32_t address = unpack_uint32(buf+1);
|
||||
uint32_t session = unpack_uint32(buf+5);
|
||||
lua_pushunsigned(L, address);
|
||||
lua_pushunsigned(L, session);
|
||||
lua_pushinteger(L, (uint32_t)address);
|
||||
lua_pushinteger(L, (uint32_t)session);
|
||||
lua_pushlstring(L, (const char *)buf+9, sz-9);
|
||||
|
||||
return 3;
|
||||
@@ -127,7 +127,7 @@ unpackreq_string(lua_State *L, const uint8_t * buf, size_t sz) {
|
||||
}
|
||||
lua_pushlstring(L, (const char *)buf+1, namesz);
|
||||
uint32_t session = unpack_uint32(buf + namesz + 1);
|
||||
lua_pushunsigned(L, session);
|
||||
lua_pushinteger(L, (uint32_t)session);
|
||||
lua_pushlstring(L, (const char *)buf+1+namesz+4, sz - namesz - 5);
|
||||
|
||||
return 3;
|
||||
@@ -153,7 +153,7 @@ lunpackrequest(lua_State *L) {
|
||||
*/
|
||||
static int
|
||||
lpackresponse(lua_State *L) {
|
||||
uint32_t session = luaL_checkunsigned(L,1);
|
||||
uint32_t session = (uint32_t)luaL_checkinteger(L,1);
|
||||
// clusterd.lua:command.socket call lpackresponse,
|
||||
// and the msg/sz is return by skynet.rawcall , so don't free(msg)
|
||||
int ok = lua_toboolean(L,2);
|
||||
@@ -167,7 +167,7 @@ lpackresponse(lua_State *L) {
|
||||
}
|
||||
} else {
|
||||
msg = lua_touserdata(L,3);
|
||||
sz = luaL_checkunsigned(L, 4);
|
||||
sz = (size_t)luaL_checkinteger(L, 4);
|
||||
}
|
||||
|
||||
uint8_t buf[TEMP_LENGTH];
|
||||
@@ -195,7 +195,7 @@ lunpackresponse(lua_State *L) {
|
||||
return 0;
|
||||
}
|
||||
uint32_t session = unpack_uint32((const uint8_t *)buf);
|
||||
lua_pushunsigned(L, session);
|
||||
lua_pushinteger(L, (lua_Integer)session);
|
||||
lua_pushboolean(L, buf[4]);
|
||||
lua_pushlstring(L, buf+5, sz-5);
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
static int
|
||||
ltotal(lua_State *L) {
|
||||
size_t t = malloc_used_memory();
|
||||
lua_pushunsigned(L, t);
|
||||
lua_pushinteger(L, (lua_Integer)t);
|
||||
|
||||
return 1;
|
||||
}
|
||||
@@ -14,7 +14,7 @@ ltotal(lua_State *L) {
|
||||
static int
|
||||
lblock(lua_State *L) {
|
||||
size_t t = malloc_memory_block();
|
||||
lua_pushunsigned(L, t);
|
||||
lua_pushinteger(L, (lua_Integer)t);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ pack(lua_State *L, void *data, size_t size) {
|
||||
static int
|
||||
mc_packlocal(lua_State *L) {
|
||||
void * data = lua_touserdata(L, 1);
|
||||
size_t size = luaL_checkunsigned(L, 2);
|
||||
size_t size = (size_t)luaL_checkinteger(L, 2);
|
||||
if (size != (uint32_t)size) {
|
||||
return luaL_error(L, "Size should be 32bit integer");
|
||||
}
|
||||
@@ -49,7 +49,7 @@ mc_packlocal(lua_State *L) {
|
||||
static int
|
||||
mc_packremote(lua_State *L) {
|
||||
void * data = lua_touserdata(L, 1);
|
||||
size_t size = luaL_checkunsigned(L, 2);
|
||||
size_t size = (size_t)luaL_checkinteger(L, 2);
|
||||
if (size != (uint32_t)size) {
|
||||
return luaL_error(L, "Size should be 32bit integer");
|
||||
}
|
||||
@@ -85,7 +85,7 @@ mc_unpacklocal(lua_State *L) {
|
||||
}
|
||||
lua_pushlightuserdata(L, *pack);
|
||||
lua_pushlightuserdata(L, (*pack)->data);
|
||||
lua_pushunsigned(L, (*pack)->size);
|
||||
lua_pushinteger(L, (lua_Integer)((*pack)->size));
|
||||
return 3;
|
||||
}
|
||||
|
||||
@@ -137,16 +137,16 @@ mc_remote(lua_State *L) {
|
||||
struct mc_package **ptr = lua_touserdata(L,1);
|
||||
struct mc_package *pack = *ptr;
|
||||
lua_pushlightuserdata(L, pack->data);
|
||||
lua_pushunsigned(L, pack->size);
|
||||
lua_pushinteger(L, (lua_Integer)(pack->size));
|
||||
skynet_free(pack);
|
||||
return 2;
|
||||
}
|
||||
|
||||
static int
|
||||
mc_nextid(lua_State *L) {
|
||||
uint32_t id = luaL_checkunsigned(L, 1);
|
||||
uint32_t id = (uint32_t)luaL_checkinteger(L, 1);
|
||||
id += 256;
|
||||
lua_pushunsigned(L, id);
|
||||
lua_pushinteger(L, (uint32_t)id);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -136,7 +136,7 @@ get_dest_string(lua_State *L, int index) {
|
||||
}
|
||||
|
||||
/*
|
||||
unsigned address
|
||||
uint32 address
|
||||
string address
|
||||
integer type
|
||||
integer session
|
||||
@@ -147,7 +147,7 @@ get_dest_string(lua_State *L, int index) {
|
||||
static int
|
||||
_send(lua_State *L) {
|
||||
struct skynet_context * context = lua_touserdata(L, lua_upvalueindex(1));
|
||||
uint32_t dest = lua_tounsigned(L, 1);
|
||||
uint32_t dest = (uint32_t)lua_tointeger(L, 1);
|
||||
const char * dest_string = NULL;
|
||||
if (dest == 0) {
|
||||
dest_string = get_dest_string(L, 1);
|
||||
@@ -201,12 +201,12 @@ _send(lua_State *L) {
|
||||
static int
|
||||
_redirect(lua_State *L) {
|
||||
struct skynet_context * context = lua_touserdata(L, lua_upvalueindex(1));
|
||||
uint32_t dest = lua_tounsigned(L,1);
|
||||
uint32_t dest = (uint32_t)lua_tointeger(L,1);
|
||||
const char * dest_string = NULL;
|
||||
if (dest == 0) {
|
||||
dest_string = get_dest_string(L, 1);
|
||||
}
|
||||
uint32_t source = luaL_checkunsigned(L,2);
|
||||
uint32_t source = (uint32_t)luaL_checkinteger(L,2);
|
||||
int type = luaL_checkinteger(L,3);
|
||||
int session = luaL_checkinteger(L,4);
|
||||
|
||||
@@ -262,7 +262,7 @@ _tostring(lua_State *L) {
|
||||
static int
|
||||
_harbor(lua_State *L) {
|
||||
struct skynet_context * context = lua_touserdata(L, lua_upvalueindex(1));
|
||||
uint32_t handle = luaL_checkunsigned(L,1);
|
||||
uint32_t handle = (uint32_t)luaL_checkinteger(L,1);
|
||||
int harbor = 0;
|
||||
int remote = skynet_isremote(context, handle, &harbor);
|
||||
lua_pushinteger(L,harbor);
|
||||
|
||||
@@ -215,7 +215,7 @@ lheader(lua_State *L) {
|
||||
sz |= s[i];
|
||||
}
|
||||
|
||||
lua_pushunsigned(L, sz);
|
||||
lua_pushinteger(L, (lua_Integer)sz);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -127,7 +127,7 @@ lcopy(lua_State *L) {
|
||||
static int
|
||||
lnewwriter(lua_State *L) {
|
||||
void * msg = lua_touserdata(L, 1);
|
||||
uint32_t sz = luaL_checkunsigned(L, 2);
|
||||
uint32_t sz = (uint32_t)luaL_checkinteger(L, 2);
|
||||
struct boxstm * box = lua_newuserdata(L, sizeof(*box));
|
||||
box->obj = stm_new(msg,sz);
|
||||
lua_pushvalue(L, lua_upvalueindex(1));
|
||||
@@ -149,7 +149,7 @@ static int
|
||||
lupdate(lua_State *L) {
|
||||
struct boxstm * box = lua_touserdata(L, 1);
|
||||
void * msg = lua_touserdata(L, 2);
|
||||
uint32_t sz = luaL_checkunsigned(L, 3);
|
||||
uint32_t sz = (uint32_t)luaL_checkinteger(L, 3);
|
||||
stm_update(box->obj, msg, sz);
|
||||
|
||||
return 0;
|
||||
@@ -199,7 +199,7 @@ lread(lua_State *L) {
|
||||
if (copy) {
|
||||
lua_settop(L, 2);
|
||||
lua_pushlightuserdata(L, copy->msg);
|
||||
lua_pushunsigned(L, copy->sz);
|
||||
lua_pushinteger(L, copy->sz);
|
||||
lua_call(L, 2, LUA_MULTRET);
|
||||
lua_pushboolean(L, 1);
|
||||
lua_replace(L, 1);
|
||||
|
||||
Reference in New Issue
Block a user