mirror of
https://github.com/profanity-im/profanity.git
synced 2025-01-03 14:57:42 -05:00
Lua timed callbacks
This commit is contained in:
parent
939b84ad18
commit
0884f3480d
@ -72,20 +72,14 @@ lua_api_register_command(lua_State *L)
|
|||||||
static int
|
static int
|
||||||
lua_api_register_timed(lua_State *L)
|
lua_api_register_timed(lua_State *L)
|
||||||
{
|
{
|
||||||
/*
|
int interval_seconds = lua_tonumber(L, -1);
|
||||||
PyObject *p_callback = NULL;
|
cons_show("interval seconds = %d", interval_seconds);
|
||||||
int interval_seconds = 0;
|
lua_pop(L, 1);
|
||||||
|
int *p_callback_ref = malloc(sizeof(int));
|
||||||
|
*p_callback_ref = luaL_ref(L, LUA_REGISTRYINDEX);
|
||||||
|
|
||||||
if (!PyArg_ParseTuple(args, "Oi", &p_callback, &interval_seconds)) {
|
api_register_timed(p_callback_ref, interval_seconds, lua_timed_callback);
|
||||||
return Py_BuildValue("");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (p_callback && PyCallable_Check(p_callback)) {
|
|
||||||
api_register_timed(p_callback, interval_seconds, python_timed_callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
return Py_BuildValue("");
|
|
||||||
*/
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -267,9 +261,11 @@ lua_command_callback(PluginCommand *command, gchar **args)
|
|||||||
void
|
void
|
||||||
lua_timed_callback(PluginTimedFunction *timed_function)
|
lua_timed_callback(PluginTimedFunction *timed_function)
|
||||||
{
|
{
|
||||||
/*
|
int *p_ref = (int *)timed_function->callback;
|
||||||
PyObject_CallObject(timed_function->callback, NULL);
|
lua_State *L = lua_get_state();
|
||||||
*/
|
|
||||||
|
lua_rawgeti(L, LUA_REGISTRYINDEX, *p_ref);
|
||||||
|
lua_pcall(L, 0, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
Loading…
Reference in New Issue
Block a user