lua: implement metadata:set()

This commit is contained in:
George Kiagiadakis
2021-06-08 13:38:48 +03:00
parent 77454243bc
commit 892129bd08

View File

@@ -745,9 +745,22 @@ metadata_find (lua_State *L)
return 2;
}
static int
metadata_set (lua_State *L)
{
WpMetadata *metadata = wplua_checkobject (L, 1, WP_TYPE_METADATA);
lua_Integer subject = luaL_checkinteger (L, 2);
const char *key = luaL_opt (L, luaL_checkstring, 3, NULL);
const char *type = luaL_opt (L, luaL_checkstring, 4, NULL);
const char *value = luaL_opt (L, luaL_checkstring, 5, NULL);
wp_metadata_set (metadata, subject, key, type, value);
return 0;
}
static const luaL_Reg metadata_methods[] = {
{ "iterate", metadata_iterate },
{ "find", metadata_find },
{ "set", metadata_set },
{ NULL, NULL }
};