lua: add g_get_real/monotonic_time() bindings
Useful to tag objects with their creation time
This commit is contained in:
@@ -38,6 +38,28 @@ get_wp_export_core (lua_State *L)
|
|||||||
return core;
|
return core;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* GLib */
|
||||||
|
|
||||||
|
static int
|
||||||
|
glib_get_monotonic_time (lua_State *L)
|
||||||
|
{
|
||||||
|
lua_pushinteger (L, g_get_monotonic_time ());
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
glib_get_real_time (lua_State *L)
|
||||||
|
{
|
||||||
|
lua_pushinteger (L, g_get_real_time ());
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static const luaL_Reg glib_methods[] = {
|
||||||
|
{ "get_monotonic_time", glib_get_monotonic_time },
|
||||||
|
{ "get_real_time", glib_get_real_time },
|
||||||
|
{ NULL, NULL }
|
||||||
|
};
|
||||||
|
|
||||||
/* GSource */
|
/* GSource */
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@@ -1218,6 +1240,9 @@ wp_lua_scripting_api_init (lua_State *L)
|
|||||||
{
|
{
|
||||||
g_autoptr (GError) error = NULL;
|
g_autoptr (GError) error = NULL;
|
||||||
|
|
||||||
|
luaL_newlib (L, glib_methods);
|
||||||
|
lua_setglobal (L, "GLib");
|
||||||
|
|
||||||
luaL_newlib (L, log_funcs);
|
luaL_newlib (L, log_funcs);
|
||||||
lua_setglobal (L, "WpDebug");
|
lua_setglobal (L, "WpDebug");
|
||||||
|
|
||||||
|
@@ -141,6 +141,7 @@ SANDBOX_EXPORT = {
|
|||||||
Id = Id,
|
Id = Id,
|
||||||
Features = Features,
|
Features = Features,
|
||||||
Feature = Feature,
|
Feature = Feature,
|
||||||
|
GLib = GLib,
|
||||||
Log = WpDebug,
|
Log = WpDebug,
|
||||||
Core = WpCore,
|
Core = WpCore,
|
||||||
Plugin = WpPlugin_find,
|
Plugin = WpPlugin_find,
|
||||||
|
Reference in New Issue
Block a user