From f8f84eb3d12c1913fa342871cf1a6568ac3a75c0 Mon Sep 17 00:00:00 2001 From: Peng Wu Date: Tue, 12 Jun 2018 16:47:44 +0800 Subject: rename ibus_engine_plugin_get_result_string to ibus_engine_plugin_get_first_result --- lua/lua-plugin.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'lua/lua-plugin.c') diff --git a/lua/lua-plugin.c b/lua/lua-plugin.c index 2300930..88a5309 100644 --- a/lua/lua-plugin.c +++ b/lua/lua-plugin.c @@ -413,9 +413,9 @@ static const lua_command_candidate_t * ibus_engine_plugin_get_candidate(lua_Stat } /** - * retrieve the string value. (value has been copied.) + * retrieve the first string value. (value has been copied.) */ -const char * ibus_engine_plugin_get_result_string(IBusEnginePlugin * plugin){ +const char * ibus_engine_plugin_get_first_result(IBusEnginePlugin * plugin){ IBusEnginePluginPrivate * priv = IBUS_ENGINE_PLUGIN_GET_PRIVATE(plugin); const char * result = NULL; int type; lua_State * L = priv->L; @@ -424,6 +424,13 @@ const char * ibus_engine_plugin_get_result_string(IBusEnginePlugin * plugin){ if ( LUA_TNUMBER == type || LUA_TBOOLEAN == type || LUA_TSTRING == type) { result = g_strdup(lua_tostring(L, -1)); lua_pop(L, 1); + } else if( LUA_TTABLE == type ){ + lua_pushinteger(L, 1); + lua_gettable(L, -2); + int type = lua_type(L, -1); + if ( LUA_TNUMBER == type || LUA_TBOOLEAN == type || LUA_TSTRING == type ) + result = g_strdup(lua_tostring(L, -1)); + lua_pop(L, 2); } return (const char *)result; -- cgit