m-lua-scripting/api: allow EventDispatcher.push_event() to accept event objects
This commit is contained in:

committed by
Julian Bouzas

parent
d46d54f261
commit
73b6b90a35
@@ -1837,9 +1837,9 @@ event_dispatcher_push_event (lua_State *L)
|
|||||||
WpProperties *properties = NULL;
|
WpProperties *properties = NULL;
|
||||||
GObject *source = NULL;
|
GObject *source = NULL;
|
||||||
GObject *subject = NULL;
|
GObject *subject = NULL;
|
||||||
|
WpEvent *event = NULL;
|
||||||
|
|
||||||
luaL_checktype (L, 1, LUA_TTABLE);
|
if (lua_type (L, 1) == LUA_TTABLE) {
|
||||||
|
|
||||||
lua_pushliteral (L, "type");
|
lua_pushliteral (L, "type");
|
||||||
if (lua_gettable (L, 1) != LUA_TSTRING)
|
if (lua_gettable (L, 1) != LUA_TSTRING)
|
||||||
luaL_error (L, "EventDispatcher.push_event: expected 'type' as string");
|
luaL_error (L, "EventDispatcher.push_event: expected 'type' as string");
|
||||||
@@ -1869,9 +1869,13 @@ event_dispatcher_push_event (lua_State *L)
|
|||||||
subject = wplua_checkobject (L, -1, G_TYPE_OBJECT);
|
subject = wplua_checkobject (L, -1, G_TYPE_OBJECT);
|
||||||
lua_pop (L, 1);
|
lua_pop (L, 1);
|
||||||
|
|
||||||
|
event = wp_event_new (type, priority, properties, source, subject);
|
||||||
|
} else {
|
||||||
|
event = wp_event_ref (wplua_checkboxed (L, 1, WP_TYPE_EVENT));
|
||||||
|
}
|
||||||
|
|
||||||
g_autoptr (WpEventDispatcher) dispatcher =
|
g_autoptr (WpEventDispatcher) dispatcher =
|
||||||
wp_event_dispatcher_get_instance (get_wp_core (L));
|
wp_event_dispatcher_get_instance (get_wp_core (L));
|
||||||
WpEvent *event = wp_event_new (type, priority, properties, source, subject);
|
|
||||||
wp_event_dispatcher_push_event (dispatcher, wp_event_ref (event));
|
wp_event_dispatcher_push_event (dispatcher, wp_event_ref (event));
|
||||||
wplua_pushboxed (L, WP_TYPE_EVENT, event);
|
wplua_pushboxed (L, WP_TYPE_EVENT, event);
|
||||||
return 1;
|
return 1;
|
||||||
|
Reference in New Issue
Block a user