}
}
+void lua_plugin_store_plugin(lua_State * L, IBusEnginePlugin * plugin){
+ luaL_newmetatable(L, LUA_IMELIBNAME);
+ lua_pushliteral(L, LUA_IMELIB_CONTEXT);
+ lua_pushlightuserdata(L, plugin);
+ lua_rawset(L, -3);
+ lua_pop(L, 1);
+}
+
+IBusEnginePlugin * lua_plugin_retrieve_plugin(lua_State * L) {
+ luaL_newmetatable(L, LUA_IMELIBNAME);
+ lua_pushliteral(L, LUA_IMELIB_CONTEXT);
+ lua_rawget(L, -2);
+ luaL_checktype(L, -1, LUA_TLIGHTUSERDATA);
+ IBusEnginePlugin * plugin = lua_touserdata(L, -1);
+ g_assert(IBUS_IS_ENGINE_PLUGIN(plugin));
+ lua_pop(L, 2);
+ return plugin;
+}
+
static int ime_get_last_commit(lua_State* L){
/*TODO: not implemented. */
fprintf(stderr, "TODO: ime_get_last_commit unimplemented.\n");
memset(priv, 0, sizeof(IBusEnginePluginPrivate));
lua_plugin_init(priv);
+
+ lua_plugin_store_plugin(priv->L, self);
}
IBusEnginePlugin * ibus_engine_plugin_new(){
#define LUA_IMELIBNAME "ime"
LUALIB_API int (luaopen_ime) (lua_State * L);
-
-void lua_plugin_openlibs (lua_State *L);
+#define LUA_IMELIB_CONTEXT "__context"
typedef struct{
const char * command_name;
typedef struct _IBusEnginePluginClass IBusEnginePluginClass;
typedef struct _IBusEnginePluginPrivate IBusEnginePluginPrivate;
+void lua_plugin_openlibs (lua_State *L);
+void lua_plugin_store_plugin(lua_State * L, IBusEnginePlugin * plugin);
+IBusEnginePlugin * lua_plugin_retrieve_plugin(lua_State * L);
+
struct _IBusEnginePlugin
{
GObject parent_instance;