mirror of
https://github.com/lxsang/antd-lua-plugin
synced 2025-02-22 02:32:48 +01:00
fix some stuff
This commit is contained in:
parent
55f298d249
commit
6314055d6f
@ -541,6 +541,20 @@ static int l_ffi_byte_at(lua_State* L)
|
|||||||
lua_pushnil(L);
|
lua_pushnil(L);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
static int l_ffi_byte_at_put(lua_State* L)
|
||||||
|
{
|
||||||
|
void* ptr = lua_touserdata(L, 1);
|
||||||
|
int off = luaL_checkinteger(L,2);
|
||||||
|
uint8_t v = (uint8_t)luaL_checknumber(L,3);
|
||||||
|
if(ptr)
|
||||||
|
{
|
||||||
|
*((uint8_t*)(ptr + off)) = v;
|
||||||
|
lua_pushboolean(L,1);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
lua_pushboolean(L,0);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
static int l_ffi_string(lua_State* L)
|
static int l_ffi_string(lua_State* L)
|
||||||
{
|
{
|
||||||
void* ptr = lua_touserdata(L,1);
|
void* ptr = lua_touserdata(L,1);
|
||||||
@ -579,6 +593,7 @@ static const struct luaL_Reg _lib [] = {
|
|||||||
{"meta", l_ffi_meta},
|
{"meta", l_ffi_meta},
|
||||||
{"at", l_ffi_offset},
|
{"at", l_ffi_offset},
|
||||||
{"byteAt", l_ffi_byte_at},
|
{"byteAt", l_ffi_byte_at},
|
||||||
|
{"byteAtPut", l_ffi_byte_at_put},
|
||||||
// special case: pointer to string
|
// special case: pointer to string
|
||||||
{"string", l_ffi_string},
|
{"string", l_ffi_string},
|
||||||
// pointer to byte array
|
// pointer to byte array
|
||||||
|
Loading…
x
Reference in New Issue
Block a user