summaryrefslogtreecommitdiffstats
path: root/lua/lua-plugin.h
diff options
context:
space:
mode:
authorPeng Wu <epico@dhcp-65-116.nay.redhat.com>2010-04-11 15:01:11 +0800
committerPeng Wu <alexepico@gmail.com>2010-05-19 10:09:32 +0800
commit7505cd8f7c7298f6db1dc1ad665b082810234944 (patch)
tree37c8b313588b274a672a5c3a21cc18236c365357 /lua/lua-plugin.h
parent07351a7e974d192a1b93679d518be75cb764fdd2 (diff)
downloadibus-libpinyin-7505cd8f7c7298f6db1dc1ad665b082810234944.tar.gz
ibus-libpinyin-7505cd8f7c7298f6db1dc1ad665b082810234944.tar.xz
ibus-libpinyin-7505cd8f7c7298f6db1dc1ad665b082810234944.zip
add gobject interface for lua-plugin.
Diffstat (limited to 'lua/lua-plugin.h')
-rw-r--r--lua/lua-plugin.h52
1 files changed, 42 insertions, 10 deletions
diff --git a/lua/lua-plugin.h b/lua/lua-plugin.h
index 3aa73d6..1964101 100644
--- a/lua/lua-plugin.h
+++ b/lua/lua-plugin.h
@@ -1,8 +1,7 @@
#ifndef LUA_PLUGIN_H
#define LUA_PLUGIN_H
-int lua_plugin_init(lua_State * L);
-int lua_plugin_fini(lua_State * L);
+#include <glib-object.h>
#define LUA_IMELIBNAME "ime"
LUALIB_API int (luaopen_ime) (lua_State * L);
@@ -15,29 +14,62 @@ typedef struct{
const char * help; /* optional. */
} lua_command_t;
-typedef struct{
- lua_State * L;
- GArray * lua_commands; /* Array of lua_command_t. */
-} lua_plugin_context_t;
+/*
+ * Type macros.
+ */
+
+#define IBUS_TYPE_ENGINE_PLUGIN (ibus_engine_plugin_get_type ())
+#define IBUS_ENGINE_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), IBUS_TYPE_ENGINE_PLUGIN, IBusEnginePlugin))
+#define IBUS_IS_ENGINE_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), IBUS_TYPE_ENGINE_PLUGIN))
+#define IBUS_ENGINE_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), IBUS_TYPE_ENGINE_PLUGIN, IBusEnginePluginClass))
+#define IBUS_IS_ENGINE_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS ((klass), IBUS_TYPE_ENGINE_PLUGIN))
+#define IBUS_ENGINE_PLUGIN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), IBUS_TYPE_ENGINE_PLUGIN, IBusEnginePluginClass))
+
+typedef struct _IBusEnginePlugin IBusEnginePlugin;
+typedef struct _IBusEnginePluginClass IBusEnginePluginClass;
+typedef struct _IBusEnginePluginPrivate IBusEnginePluginPrivate;
+
+struct _IBusEnginePlugin
+{
+ GObject parent_instance;
+
+ /*< private >*/
+ IBusEnginePluginPrivate *priv;
+};
+
+struct _IBusEnginePluginClass
+{
+ GObjectClass parent_class;
+};
+
+GType ibus_engine_plugin_get_type(void);
/**
* retrieve all available lua plugin commands.
* return array of command informations of type lua_command_t.
*/
-GArray * lua_plugin_ime_get_available_commands(lua_State * L);
+GArray * lua_plugin_ime_get_available_commands(IBusEnginePlugin * plugin);
/**
* retval int: only support string or string array.
*/
-int lua_plugin_ime_call(lua_State * L, const lua_command_t * command, const char * argument /*optional, maybe NULL.*/);
+int lua_plugin_ime_call(IBusEnginePlugin * plugin, const lua_command_t * command, const char * argument /*optional, maybe NULL.*/);
/**
* retrieve the retval string value. (value has been copied.)
*/
-const char * lua_plugin_ime_get_retval(lua_State * L);
+const char * lua_plugin_ime_get_retval(IBusEnginePlugin * plugin);
/**
* retrieve the array of string values. (string values have been copied.)
*/
-GArray * lua_plugin_ime_get_retvals(lua_State * L);
+GArray * lua_plugin_ime_get_retvals(IBusEnginePlugin * plugin);
+/*< private >*/
+int lua_plugin_init(IBusEnginePluginPrivate * private);
+int lua_plugin_fini(IBusEnginePluginPrivate * private);
+
+struct _IBusEnginePluginPrivate{
+ lua_State * L;
+ GArray * lua_commands; /* Array of lua_command_t. */
+};
#endif