diff options
author | Peng Wu <epico@dhcp-65-116.nay.redhat.com> | 2010-03-09 18:38:14 +0800 |
---|---|---|
committer | Peng Wu <alexepico@gmail.com> | 2010-05-19 10:09:31 +0800 |
commit | a00e941af1ecef13149d8ca2adfbfca3b6725f26 (patch) | |
tree | e179adf13ba0a47eed7b1d45c0a41dcfb254362f /lua | |
parent | dd2ae1fb20d75f8f248effc6803f833ad80d0d3a (diff) | |
download | ibus-libpinyin-a00e941af1ecef13149d8ca2adfbfca3b6725f26.tar.gz ibus-libpinyin-a00e941af1ecef13149d8ca2adfbfca3b6725f26.tar.xz ibus-libpinyin-a00e941af1ecef13149d8ca2adfbfca3b6725f26.zip |
initial code for lua plugin.
Diffstat (limited to 'lua')
-rw-r--r-- | lua/lua-plugin-init.c | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/lua/lua-plugin-init.c b/lua/lua-plugin-init.c new file mode 100644 index 0000000..4dcd5a6 --- /dev/null +++ b/lua/lua-plugin-init.c @@ -0,0 +1,53 @@ +#include <stdio.h> +#include <glib.h> + +#include "lua.h" +#include "lualib.h" +#include "lauxlib.h" + +/* the Lua interpreter */ +static lua_State * L = NULL; + +static int lua_plugin_init(){ + /* initialize Lua */ + L = lua_open(); + + /* enable libs in sandbox */ + luaopen_base(L); + luaopen_io(L); + luaopen_string(L); + luaopen_math(L); + luaopen_table(L); + + +} + +static const luaL_Reg imelib[] = { + {"get_last_commit", ime_get_last_commit}, + {"get_version", ime_get_version}, +#if 0 + {"join_string"}, ime_join_string}, + {"parse_mapping", ime_parse_mapping}, + {"register_command", ime_register_command}, + /* Note: the register_trigger function is dropped for ibus-pinyin. */ + {"register_trigger", ime_register_trigger}, + {"split_string", ime_split_string}, + {"trim_string_left", ime_trim_string_left}, + {"trim_string_right", ime_trim_string_right}, + {"trim_string", ime_trim_string}, +#endif + {NULL, NULL} +}; + +static int ime_get_last_commit(lua_State* L){ + /*TODO: not implemented. */ + g_assert_not_reached(); + lua_pushstring(L, ""); + return 1; +} + +static int ime_get_version(lua_State* L){ + /* TODO: replace this with C macros. */ + lua_pushstring(L, "ibus-pinyin 1.2.99"); + return 1; +} |