mirror of
https://github.com/neovim/neovim.git
synced 2026-05-02 12:04:58 +00:00
Merge pull request #15516 from bfredl/keyset
refactor(api): Represent option dicts as a structs in C and reduce conversion overhead from lua
This commit is contained in:
@@ -1299,3 +1299,25 @@ void nlua_init_types(lua_State *const lstate)
|
||||
|
||||
lua_rawset(lstate, -3);
|
||||
}
|
||||
|
||||
|
||||
void nlua_pop_keydict(lua_State *L, void *retval, field_hash hashy, Error *err)
|
||||
{
|
||||
lua_pushnil(L); // [dict, nil]
|
||||
while (lua_next(L, -2)) {
|
||||
// [dict, key, value]
|
||||
size_t len;
|
||||
const char *s = lua_tolstring(L, -2, &len);
|
||||
Object *field = hashy(retval, s, len);
|
||||
if (!field) {
|
||||
api_set_error(err, kErrorTypeValidation, "invalid key: %.*s", (int)len, s);
|
||||
lua_pop(L, 3); // []
|
||||
return;
|
||||
}
|
||||
|
||||
*field = nlua_pop_Object(L, true, err);
|
||||
}
|
||||
// [dict]
|
||||
lua_pop(L, 1);
|
||||
// []
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user