diff options
author | Peng Wu <alexepico@gmail.com> | 2018-06-12 16:47:44 +0800 |
---|---|---|
committer | Peng Wu <alexepico@gmail.com> | 2018-06-12 16:47:44 +0800 |
commit | f8f84eb3d12c1913fa342871cf1a6568ac3a75c0 (patch) | |
tree | 538d7156e1541423dc08d1920afb367278e4251e | |
parent | e7a6091b44fe4a932a2f4637313ff36ae03e119b (diff) | |
download | ibus-libpinyin-f8f84eb3d12c1913fa342871cf1a6568ac3a75c0.tar.gz ibus-libpinyin-f8f84eb3d12c1913fa342871cf1a6568ac3a75c0.tar.xz ibus-libpinyin-f8f84eb3d12c1913fa342871cf1a6568ac3a75c0.zip |
rename ibus_engine_plugin_get_result_string to ibus_engine_plugin_get_first_result
-rw-r--r-- | lua/lua-ext-console.c | 5 | ||||
-rw-r--r-- | lua/lua-plugin.c | 11 | ||||
-rw-r--r-- | lua/lua-plugin.h | 4 |
3 files changed, 13 insertions, 7 deletions
diff --git a/lua/lua-ext-console.c b/lua/lua-ext-console.c index 7dbb53b..81e07ef 100644 --- a/lua/lua-ext-console.c +++ b/lua/lua-ext-console.c @@ -59,8 +59,7 @@ void list_all_converters(IBusEnginePlugin * plugin){ size_t i; for ( i = 0; i < converters->len; ++i ){ lua_converter_t * converter = &g_array_index(converters, lua_converter_t, i); - printf("%s.%s >\t", converter->lua_function_name, - converter->description); + printf("%s %s >\t", converter->lua_function_name, converter->description); } printf("\n"); } @@ -105,7 +104,7 @@ int do_lua_call(IBusEnginePlugin * plugin, const char * command_name, const char int do_simple_lua_call(IBusEnginePlugin * plugin, const char * lua_function_name, const char * string){ int num = ibus_engine_plugin_call(plugin, lua_function_name, string); - printf("result: %s.\n", ibus_engine_plugin_get_result_string(plugin)); + printf("result: %s.\n", ibus_engine_plugin_get_first_result(plugin)); return 0; } 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; diff --git a/lua/lua-plugin.h b/lua/lua-plugin.h index c22ce37..fb5f5b9 100644 --- a/lua/lua-plugin.h +++ b/lua/lua-plugin.h @@ -172,9 +172,9 @@ const lua_command_t * ibus_engine_plugin_lookup_command(IBusEnginePlugin * plugi int ibus_engine_plugin_call(IBusEnginePlugin * plugin, const char * lua_function_name, const char * argument /*optional, maybe NULL.*/); /** - * 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); /** * retrieve the retval string value. (value has been copied.) |