diff --git a/core/src/xmake/base64/encode.c b/core/src/xmake/base64/encode.c index ce9fc8a2ac2..acf0b7c2546 100644 --- a/core/src/xmake/base64/encode.c +++ b/core/src/xmake/base64/encode.c @@ -41,14 +41,15 @@ tb_int_t xm_base64_encode(lua_State* lua) // get data and size tb_size_t size = 0; tb_byte_t const* data = tb_null; - if (lua_isnumber(lua, 1)) data = (tb_byte_t const*)(tb_size_t)(tb_long_t)lua_tonumber(lua, 1); - if (lua_isnumber(lua, 2)) size = (tb_size_t)lua_tonumber(lua, 2); + if (xm_lua_isinteger(lua, 1)) data = (tb_byte_t const*)(tb_size_t)(tb_long_t)lua_tointeger(lua, 1); + if (xm_lua_isinteger(lua, 2)) size = (tb_size_t)lua_tointeger(lua, 2); if (!data || !size) { lua_pushnil(lua); lua_pushfstring(lua, "invalid data(%p) and size(%d)!", data, (tb_int_t)size); return 2; } + tb_assert_static(sizeof(lua_Integer) >= sizeof(tb_pointer_t)); // encode it tb_char_t buff[8192]; diff --git a/core/src/xmake/bloom_filter/bloom_filter_data_set.c b/core/src/xmake/bloom_filter/bloom_filter_data_set.c index 330ba393e13..6de4a5d4aef 100644 --- a/core/src/xmake/bloom_filter/bloom_filter_data_set.c +++ b/core/src/xmake/bloom_filter/bloom_filter_data_set.c @@ -49,14 +49,15 @@ tb_int_t xm_bloom_filter_data_set(lua_State* lua) // get data and size tb_size_t size = 0; tb_byte_t const* data = tb_null; - if (lua_isnumber(lua, 2)) data = (tb_byte_t const*)(tb_size_t)(tb_long_t)lua_tonumber(lua, 2); - if (lua_isnumber(lua, 3)) size = (tb_size_t)lua_tonumber(lua, 3); + if (xm_lua_isinteger(lua, 2)) data = (tb_byte_t const*)(tb_size_t)(tb_long_t)lua_tointeger(lua, 2); + if (xm_lua_isinteger(lua, 3)) size = (tb_size_t)lua_tointeger(lua, 3); if (!data || !size) { lua_pushinteger(lua, -1); lua_pushfstring(lua, "invalid data(%p) and size(%d)!", data, (tb_int_t)size); return 2; } + tb_assert_static(sizeof(lua_Integer) >= sizeof(tb_pointer_t)); // set data tb_bool_t ok = tb_bloom_filter_data_set(filter, data, size); diff --git a/core/src/xmake/hash/md5.c b/core/src/xmake/hash/md5.c index d392ae670fa..c9ec2fb369f 100644 --- a/core/src/xmake/hash/md5.c +++ b/core/src/xmake/hash/md5.c @@ -39,16 +39,17 @@ tb_int_t xm_hash_md5(lua_State* lua) tb_assert_and_check_return_val(lua, 0); // is bytes? get data and size - if (lua_isnumber(lua, 1) && lua_isnumber(lua, 2)) + if (xm_lua_isinteger(lua, 1) && xm_lua_isinteger(lua, 2)) { - tb_byte_t const* data = (tb_byte_t const*)(tb_size_t)(tb_long_t)lua_tonumber(lua, 1); - tb_size_t size = (tb_size_t)lua_tonumber(lua, 2); + tb_byte_t const* data = (tb_byte_t const*)(tb_size_t)(tb_long_t)lua_tointeger(lua, 1); + tb_size_t size = (tb_size_t)lua_tointeger(lua, 2); if (!data || !size) { lua_pushnil(lua); lua_pushfstring(lua, "invalid data(%p) and size(%d)!", data, (tb_int_t)size); return 2; } + tb_assert_static(sizeof(lua_Integer) >= sizeof(tb_pointer_t)); // compute md5 tb_byte_t buffer[16]; diff --git a/core/src/xmake/hash/sha.c b/core/src/xmake/hash/sha.c index a89ee5df7ad..720647cdf84 100644 --- a/core/src/xmake/hash/sha.c +++ b/core/src/xmake/hash/sha.c @@ -39,19 +39,20 @@ tb_int_t xm_hash_sha(lua_State* lua) tb_assert_and_check_return_val(lua, 0); // get mode - tb_size_t mode = (tb_size_t)lua_tonumber(lua, 1); + tb_size_t mode = (tb_size_t)lua_tointeger(lua, 1); // is bytes? get data and size - if (lua_isnumber(lua, 2) && lua_isnumber(lua, 3)) + if (xm_lua_isinteger(lua, 2) && xm_lua_isinteger(lua, 3)) { - tb_byte_t const* data = (tb_byte_t const*)(tb_size_t)(tb_long_t)lua_tonumber(lua, 2); - tb_size_t size = (tb_size_t)lua_tonumber(lua, 3); + tb_byte_t const* data = (tb_byte_t const*)(tb_size_t)(tb_long_t)lua_tointeger(lua, 2); + tb_size_t size = (tb_size_t)lua_tointeger(lua, 3); if (!data || !size) { lua_pushnil(lua); lua_pushfstring(lua, "invalid data(%p) and size(%d)!", data, (tb_int_t)size); return 2; } + tb_assert_static(sizeof(lua_Integer) >= sizeof(tb_pointer_t)); // compute sha tb_sha_t sha; diff --git a/core/src/xmake/hash/xxhash.c b/core/src/xmake/hash/xxhash.c index 9901f58f671..12dd3ba1084 100644 --- a/core/src/xmake/hash/xxhash.c +++ b/core/src/xmake/hash/xxhash.c @@ -43,7 +43,7 @@ tb_int_t xm_hash_xxhash(lua_State* lua) tb_assert_and_check_return_val(lua, 0); // get mode - tb_size_t mode = (tb_size_t)lua_tonumber(lua, 1); + tb_size_t mode = (tb_size_t)lua_tointeger(lua, 1); if (mode != 64 && mode != 128) { lua_pushnil(lua); @@ -52,16 +52,17 @@ tb_int_t xm_hash_xxhash(lua_State* lua) } // is bytes? get data and size - if (lua_isnumber(lua, 2) && lua_isnumber(lua, 3)) + if (xm_lua_isinteger(lua, 2) && xm_lua_isinteger(lua, 3)) { - tb_byte_t const* data = (tb_byte_t const*)(tb_size_t)(tb_long_t)lua_tonumber(lua, 2); - tb_size_t size = (tb_size_t)lua_tonumber(lua, 3); + tb_byte_t const* data = (tb_byte_t const*)(tb_size_t)(tb_long_t)lua_tointeger(lua, 2); + tb_size_t size = (tb_size_t)lua_tointeger(lua, 3); if (!data || !size) { lua_pushnil(lua); lua_pushfstring(lua, "invalid data(%p) and size(%d)!", data, (tb_int_t)size); return 2; } + tb_assert_static(sizeof(lua_Integer) >= sizeof(tb_pointer_t)); // compuate hash tb_byte_t const* buffer; diff --git a/core/src/xmake/io/file_write.c b/core/src/xmake/io/file_write.c index 97285dca777..9411efc318b 100644 --- a/core/src/xmake/io/file_write.c +++ b/core/src/xmake/io/file_write.c @@ -166,14 +166,15 @@ tb_int_t xm_io_file_write(lua_State* lua) // get bytes data lua_pushstring(lua, "data"); lua_gettable(lua, i); - if (lua_isnumber(lua, -1)) - data = (tb_byte_t const*)(tb_size_t)(tb_long_t)lua_tonumber(lua, -1); + if (xm_lua_isinteger(lua, -1)) + data = (tb_byte_t const*)(tb_size_t)(tb_long_t)lua_tointeger(lua, -1); lua_pop(lua, 1); + tb_assert_static(sizeof(lua_Integer) >= sizeof(tb_pointer_t)); lua_pushstring(lua, "size"); lua_gettable(lua, i); - if (lua_isnumber(lua, -1)) - datasize = (tb_size_t)lua_tonumber(lua, -1); + if (xm_lua_isinteger(lua, -1)) + datasize = (tb_size_t)lua_tointeger(lua, -1); lua_pop(lua, 1); // mark as binary data diff --git a/core/src/xmake/io/pipe_read.c b/core/src/xmake/io/pipe_read.c index 72a931f5c53..9644e9e1429 100644 --- a/core/src/xmake/io/pipe_read.c +++ b/core/src/xmake/io/pipe_read.c @@ -54,18 +54,19 @@ tb_int_t xm_io_pipe_read(lua_State* lua) // get data tb_byte_t* data = tb_null; - if (lua_isnumber(lua, 2)) - data = (tb_byte_t*)(tb_size_t)(tb_long_t)lua_tonumber(lua, 2); + if (xm_lua_isinteger(lua, 2)) + data = (tb_byte_t*)(tb_size_t)(tb_long_t)lua_tointeger(lua, 2); if (!data) { lua_pushinteger(lua, -1); lua_pushfstring(lua, "invalid data(%p)!", data); return 2; } + tb_assert_static(sizeof(lua_Integer) >= sizeof(tb_pointer_t)); // get size tb_long_t size = 0; - if (lua_isnumber(lua, 3)) size = (tb_long_t)lua_tonumber(lua, 3); + if (xm_lua_isinteger(lua, 3)) size = (tb_long_t)lua_tointeger(lua, 3); if (size <= 0) { lua_pushinteger(lua, -1); diff --git a/core/src/xmake/io/pipe_write.c b/core/src/xmake/io/pipe_write.c index 0c8c2bd1221..847e5754453 100644 --- a/core/src/xmake/io/pipe_write.c +++ b/core/src/xmake/io/pipe_write.c @@ -55,14 +55,15 @@ tb_int_t xm_io_pipe_write(lua_State* lua) // get data and size tb_size_t size = 0; tb_byte_t const* data = tb_null; - if (lua_isnumber(lua, 2)) data = (tb_byte_t const*)(tb_size_t)(tb_long_t)lua_tonumber(lua, 2); - if (lua_isnumber(lua, 3)) size = (tb_size_t)lua_tonumber(lua, 3); + if (xm_lua_isinteger(lua, 2)) data = (tb_byte_t const*)(tb_size_t)(tb_long_t)lua_tointeger(lua, 2); + if (xm_lua_isinteger(lua, 3)) size = (tb_size_t)lua_tointeger(lua, 3); if (!data || !size) { lua_pushinteger(lua, -1); lua_pushfstring(lua, "invalid data(%p) and size(%d)!", data, (tb_int_t)size); return 2; } + tb_assert_static(sizeof(lua_Integer) >= sizeof(tb_pointer_t)); // write data tb_long_t real = tb_pipe_file_write(pipefile, data, size); diff --git a/core/src/xmake/io/socket_recv.c b/core/src/xmake/io/socket_recv.c index e3bd2dfed42..efe8f9612df 100644 --- a/core/src/xmake/io/socket_recv.c +++ b/core/src/xmake/io/socket_recv.c @@ -54,18 +54,19 @@ tb_int_t xm_io_socket_recv(lua_State* lua) // get data tb_byte_t* data = tb_null; - if (lua_isnumber(lua, 2)) - data = (tb_byte_t*)(tb_size_t)(tb_long_t)lua_tonumber(lua, 2); + if (xm_lua_isinteger(lua, 2)) + data = (tb_byte_t*)(tb_size_t)(tb_long_t)lua_tointeger(lua, 2); if (!data) { lua_pushinteger(lua, -1); lua_pushfstring(lua, "invalid data(%p)!", data); return 2; } + tb_assert_static(sizeof(lua_Integer) >= sizeof(tb_pointer_t)); // get size tb_long_t size = 0; - if (lua_isnumber(lua, 3)) size = (tb_long_t)lua_tonumber(lua, 3); + if (xm_lua_isinteger(lua, 3)) size = (tb_long_t)lua_tointeger(lua, 3); if (size <= 0) { lua_pushinteger(lua, -1); diff --git a/core/src/xmake/io/socket_recvfrom.c b/core/src/xmake/io/socket_recvfrom.c index 2a6ed7a1665..cec34847eda 100644 --- a/core/src/xmake/io/socket_recvfrom.c +++ b/core/src/xmake/io/socket_recvfrom.c @@ -54,18 +54,19 @@ tb_int_t xm_io_socket_recvfrom(lua_State* lua) // get data tb_byte_t* data = tb_null; - if (lua_isnumber(lua, 2)) - data = (tb_byte_t*)(tb_size_t)(tb_long_t)lua_tonumber(lua, 2); + if (xm_lua_isinteger(lua, 2)) + data = (tb_byte_t*)(tb_size_t)(tb_long_t)lua_tointeger(lua, 2); if (!data) { lua_pushinteger(lua, -1); lua_pushfstring(lua, "invalid data(%p)!", data); return 2; } + tb_assert_static(sizeof(lua_Integer) >= sizeof(tb_pointer_t)); // get size tb_long_t size = 0; - if (lua_isnumber(lua, 3)) size = (tb_long_t)lua_tonumber(lua, 3); + if (xm_lua_isinteger(lua, 3)) size = (tb_long_t)lua_tointeger(lua, 3); if (size <= 0) { lua_pushinteger(lua, -1); diff --git a/core/src/xmake/io/socket_send.c b/core/src/xmake/io/socket_send.c index ecf3421ff4f..0f8656c6cac 100644 --- a/core/src/xmake/io/socket_send.c +++ b/core/src/xmake/io/socket_send.c @@ -55,14 +55,15 @@ tb_int_t xm_io_socket_send(lua_State* lua) // get data and size tb_size_t size = 0; tb_byte_t const* data = tb_null; - if (lua_isnumber(lua, 2)) data = (tb_byte_t const*)(tb_size_t)(tb_long_t)lua_tonumber(lua, 2); - if (lua_isnumber(lua, 3)) size = (tb_size_t)lua_tonumber(lua, 3); + if (xm_lua_isinteger(lua, 2)) data = (tb_byte_t const*)(tb_size_t)(tb_long_t)lua_tointeger(lua, 2); + if (xm_lua_isinteger(lua, 3)) size = (tb_size_t)lua_tointeger(lua, 3); if (!data || !size) { lua_pushinteger(lua, -1); lua_pushfstring(lua, "invalid data(%p) and size(%d)!", data, (tb_int_t)size); return 2; } + tb_assert_static(sizeof(lua_Integer) >= sizeof(tb_pointer_t)); // send data tb_long_t real = tb_socket_send(sock, data, size); diff --git a/core/src/xmake/io/socket_sendto.c b/core/src/xmake/io/socket_sendto.c index de3b39b752a..cd236cdcf50 100644 --- a/core/src/xmake/io/socket_sendto.c +++ b/core/src/xmake/io/socket_sendto.c @@ -55,14 +55,15 @@ tb_int_t xm_io_socket_sendto(lua_State* lua) // get data and size tb_size_t size = 0; tb_byte_t const* data = tb_null; - if (lua_isnumber(lua, 2)) data = (tb_byte_t const*)(tb_size_t)(tb_long_t)lua_tonumber(lua, 2); - if (lua_isnumber(lua, 3)) size = (tb_size_t)lua_tonumber(lua, 3); + if (xm_lua_isinteger(lua, 2)) data = (tb_byte_t const*)(tb_size_t)(tb_long_t)lua_tointeger(lua, 2); + if (xm_lua_isinteger(lua, 3)) size = (tb_size_t)lua_tointeger(lua, 3); if (!data || !size) { lua_pushinteger(lua, -1); lua_pushfstring(lua, "invalid data(%p) and size(%d)!", data, (tb_int_t)size); return 2; } + tb_assert_static(sizeof(lua_Integer) >= sizeof(tb_pointer_t)); // get address tb_char_t const* addr = lua_tostring(lua, 4); diff --git a/core/src/xmake/lz4/block_compress.c b/core/src/xmake/lz4/block_compress.c index 206f22c1789..36238ff8b63 100644 --- a/core/src/xmake/lz4/block_compress.c +++ b/core/src/xmake/lz4/block_compress.c @@ -41,14 +41,15 @@ tb_int_t xm_lz4_block_compress(lua_State* lua) // get data and size tb_int_t size = 0; tb_byte_t const* data = tb_null; - if (lua_isnumber(lua, 1)) data = (tb_byte_t const*)(tb_size_t)(tb_long_t)lua_tonumber(lua, 1); - if (lua_isnumber(lua, 2)) size = (tb_int_t)lua_tointeger(lua, 2); + if (xm_lua_isinteger(lua, 1)) data = (tb_byte_t const*)(tb_size_t)(tb_long_t)lua_tointeger(lua, 1); + if (xm_lua_isinteger(lua, 2)) size = (tb_int_t)lua_tointeger(lua, 2); if (!data || !size || size > LZ4_MAX_INPUT_SIZE) { lua_pushnil(lua); lua_pushfstring(lua, "invalid data(%p) and size(%d)!", data, (tb_int_t)size); return 2; } + tb_assert_static(sizeof(lua_Integer) >= sizeof(tb_pointer_t)); // do compress tb_bool_t ok = tb_false; diff --git a/core/src/xmake/lz4/block_decompress.c b/core/src/xmake/lz4/block_decompress.c index d9972f595af..23795f003e0 100644 --- a/core/src/xmake/lz4/block_decompress.c +++ b/core/src/xmake/lz4/block_decompress.c @@ -41,14 +41,15 @@ tb_int_t xm_lz4_block_decompress(lua_State* lua) // get data and size tb_size_t size = 0; tb_byte_t const* data = tb_null; - if (lua_isnumber(lua, 1)) data = (tb_byte_t const*)(tb_size_t)(tb_long_t)lua_tonumber(lua, 1); - if (lua_isnumber(lua, 2)) size = (tb_size_t)lua_tonumber(lua, 2); + if (xm_lua_isinteger(lua, 1)) data = (tb_byte_t const*)(tb_size_t)(tb_long_t)lua_tointeger(lua, 1); + if (xm_lua_isinteger(lua, 2)) size = (tb_size_t)lua_tointeger(lua, 2); if (!data || !size) { lua_pushnil(lua); lua_pushfstring(lua, "invalid data(%p) and size(%d)!", data, (tb_int_t)size); return 2; } + tb_assert_static(sizeof(lua_Integer) >= sizeof(tb_pointer_t)); // get real size tb_int_t real = (tb_int_t)lua_tointeger(lua, 3); diff --git a/core/src/xmake/lz4/compress.c b/core/src/xmake/lz4/compress.c index 298023b0b31..7706128318e 100644 --- a/core/src/xmake/lz4/compress.c +++ b/core/src/xmake/lz4/compress.c @@ -41,14 +41,15 @@ tb_int_t xm_lz4_compress(lua_State* lua) // get data and size tb_size_t size = 0; tb_byte_t const* data = tb_null; - if (lua_isnumber(lua, 1)) data = (tb_byte_t const*)(tb_size_t)(tb_long_t)lua_tonumber(lua, 1); - if (lua_isnumber(lua, 2)) size = (tb_size_t)lua_tonumber(lua, 2); + if (xm_lua_isinteger(lua, 1)) data = (tb_byte_t const*)(tb_size_t)(tb_long_t)lua_tointeger(lua, 1); + if (xm_lua_isinteger(lua, 2)) size = (tb_size_t)lua_tointeger(lua, 2); if (!data || !size) { lua_pushnil(lua); lua_pushfstring(lua, "invalid data(%p) and size(%d)!", data, (tb_int_t)size); return 2; } + tb_assert_static(sizeof(lua_Integer) >= sizeof(tb_pointer_t)); // do compress tb_bool_t ok = tb_false; diff --git a/core/src/xmake/lz4/compress_stream_read.c b/core/src/xmake/lz4/compress_stream_read.c index cf5e6b8e370..9cf665921e7 100644 --- a/core/src/xmake/lz4/compress_stream_read.c +++ b/core/src/xmake/lz4/compress_stream_read.c @@ -53,18 +53,19 @@ tb_int_t xm_lz4_compress_stream_read(lua_State* lua) // get data tb_byte_t* data = tb_null; - if (lua_isnumber(lua, 2)) - data = (tb_byte_t*)(tb_size_t)(tb_long_t)lua_tonumber(lua, 2); + if (xm_lua_isinteger(lua, 2)) + data = (tb_byte_t*)(tb_size_t)(tb_long_t)lua_tointeger(lua, 2); if (!data) { lua_pushinteger(lua, -1); lua_pushfstring(lua, "invalid data(%p)!", data); return 2; } + tb_assert_static(sizeof(lua_Integer) >= sizeof(tb_pointer_t)); // get size tb_long_t size = 0; - if (lua_isnumber(lua, 3)) size = (tb_long_t)lua_tonumber(lua, 3); + if (xm_lua_isinteger(lua, 3)) size = (tb_long_t)lua_tointeger(lua, 3); if (size <= 0) { lua_pushinteger(lua, -1); diff --git a/core/src/xmake/lz4/compress_stream_write.c b/core/src/xmake/lz4/compress_stream_write.c index 066839bab78..2b467073d46 100644 --- a/core/src/xmake/lz4/compress_stream_write.c +++ b/core/src/xmake/lz4/compress_stream_write.c @@ -54,14 +54,15 @@ tb_int_t xm_lz4_compress_stream_write(lua_State* lua) // get data and size tb_size_t size = 0; tb_byte_t const* data = tb_null; - if (lua_isnumber(lua, 2)) data = (tb_byte_t const*)(tb_size_t)(tb_long_t)lua_tonumber(lua, 2); - if (lua_isnumber(lua, 3)) size = (tb_size_t)lua_tonumber(lua, 3); + if (xm_lua_isinteger(lua, 2)) data = (tb_byte_t const*)(tb_size_t)(tb_long_t)lua_tointeger(lua, 2); + if (xm_lua_isinteger(lua, 3)) size = (tb_size_t)lua_tointeger(lua, 3); if (!data || !size) { lua_pushinteger(lua, -1); lua_pushfstring(lua, "invalid data(%p) and size(%d)!", data, (tb_int_t)size); return 2; } + tb_assert_static(sizeof(lua_Integer) >= sizeof(tb_pointer_t)); // is end? tb_bool_t end = tb_false; diff --git a/core/src/xmake/lz4/decompress.c b/core/src/xmake/lz4/decompress.c index 44cdf79d4e2..1f979c16e45 100644 --- a/core/src/xmake/lz4/decompress.c +++ b/core/src/xmake/lz4/decompress.c @@ -41,14 +41,15 @@ tb_int_t xm_lz4_decompress(lua_State* lua) // get data and size tb_size_t size = 0; tb_byte_t const* data = tb_null; - if (lua_isnumber(lua, 1)) data = (tb_byte_t const*)(tb_size_t)(tb_long_t)lua_tonumber(lua, 1); - if (lua_isnumber(lua, 2)) size = (tb_size_t)lua_tonumber(lua, 2); + if (xm_lua_isinteger(lua, 1)) data = (tb_byte_t const*)(tb_size_t)(tb_long_t)lua_tointeger(lua, 1); + if (xm_lua_isinteger(lua, 2)) size = (tb_size_t)lua_tointeger(lua, 2); if (!data || !size) { lua_pushnil(lua); lua_pushfstring(lua, "invalid data(%p) and size(%d)!", data, (tb_int_t)size); return 2; } + tb_assert_static(sizeof(lua_Integer) >= sizeof(tb_pointer_t)); // do decompress tb_bool_t ok = tb_false; diff --git a/core/src/xmake/lz4/decompress_stream_read.c b/core/src/xmake/lz4/decompress_stream_read.c index 61f9203545c..75eda17e9cf 100644 --- a/core/src/xmake/lz4/decompress_stream_read.c +++ b/core/src/xmake/lz4/decompress_stream_read.c @@ -53,18 +53,19 @@ tb_int_t xm_lz4_decompress_stream_read(lua_State* lua) // get data tb_byte_t* data = tb_null; - if (lua_isnumber(lua, 2)) - data = (tb_byte_t*)(tb_size_t)(tb_long_t)lua_tonumber(lua, 2); + if (xm_lua_isinteger(lua, 2)) + data = (tb_byte_t*)(tb_size_t)(tb_long_t)lua_tointeger(lua, 2); if (!data) { lua_pushinteger(lua, -1); lua_pushfstring(lua, "invalid data(%p)!", data); return 2; } + tb_assert_static(sizeof(lua_Integer) >= sizeof(tb_pointer_t)); // get size tb_long_t size = 0; - if (lua_isnumber(lua, 3)) size = (tb_long_t)lua_tonumber(lua, 3); + if (xm_lua_isinteger(lua, 3)) size = (tb_long_t)lua_tointeger(lua, 3); if (size <= 0) { lua_pushinteger(lua, -1); diff --git a/core/src/xmake/lz4/decompress_stream_write.c b/core/src/xmake/lz4/decompress_stream_write.c index 00a652349f7..2f5e491a1f7 100644 --- a/core/src/xmake/lz4/decompress_stream_write.c +++ b/core/src/xmake/lz4/decompress_stream_write.c @@ -54,14 +54,15 @@ tb_int_t xm_lz4_decompress_stream_write(lua_State* lua) // get data and size tb_size_t size = 0; tb_byte_t const* data = tb_null; - if (lua_isnumber(lua, 2)) data = (tb_byte_t const*)(tb_size_t)(tb_long_t)lua_tonumber(lua, 2); - if (lua_isnumber(lua, 3)) size = (tb_size_t)lua_tonumber(lua, 3); + if (xm_lua_isinteger(lua, 2)) data = (tb_byte_t const*)(tb_size_t)(tb_long_t)lua_tointeger(lua, 2); + if (xm_lua_isinteger(lua, 3)) size = (tb_size_t)lua_tointeger(lua, 3); if (!data || !size) { lua_pushinteger(lua, -1); lua_pushfstring(lua, "invalid data(%p) and size(%d)!", data, (tb_int_t)size); return 2; } + tb_assert_static(sizeof(lua_Integer) >= sizeof(tb_pointer_t)); // write data tb_long_t real = xm_lz4_dstream_write(stream, data, size, tb_false); diff --git a/core/src/xmake/prefix.h b/core/src/xmake/prefix.h index fabb775fb38..5d6fba58236 100644 --- a/core/src/xmake/prefix.h +++ b/core/src/xmake/prefix.h @@ -130,6 +130,15 @@ static __tb_inline__ tb_void_t xm_lua_register(lua_State *lua, tb_char_t const* #endif } +static __tb_inline__ tb_int_t xm_lua_isinteger(lua_State* lua, int idx) +{ +#ifdef USE_LUAJIT + return lua_isnumber(lua, idx); +#else + return lua_isinteger(lua, idx); +#endif +} + #endif diff --git a/xmake/modules/private/service/remote_build/action.lua b/xmake/modules/private/service/remote_build/action.lua index f3a919f14e7..fcf3fff8936 100644 --- a/xmake/modules/private/service/remote_build/action.lua +++ b/xmake/modules/private/service/remote_build/action.lua @@ -29,5 +29,5 @@ end function main() config.load() - remote_build_client.singleton():runcmd(os.programfile(), xmake.argv()) + remote_build_client.singleton():runcmd("xmake", xmake.argv()) end