lua: Add global Guestfs.event_all (list of all events).

This commit is contained in:
Richard W.M. Jones
2012-11-19 17:06:21 +00:00
parent 36e71e0cf4
commit bc03a48c71
2 changed files with 19 additions and 0 deletions

View File

@@ -729,6 +729,16 @@ push_event (lua_State *L, uint64_t event)
pr " abort (); /* should never happen */
}
static const char *event_all[] = {
";
List.iter (
fun (event, _) -> pr " \"%s\",\n" event
) events;
pr " NULL
};
";
(* Code to push structs. *)
@@ -839,6 +849,11 @@ luaopen_guestfs (lua_State *L)
lua_pushvalue (L, -1);
lua_setfield (L, -1, \"__index\");
/* Globals in the Guestfs.* namespace. */
lua_pushliteral (L, \"event_all\");
push_string_list (L, (char **) event_all);
lua_settable (L, -3);
/* Add _COPYRIGHT, etc. fields to the metatable. */
lua_pushliteral (L, \"_COPYRIGHT\");
lua_pushliteral (L, \"Copyright (C) %s Red Hat Inc.\");

View File

@@ -18,6 +18,10 @@
require "guestfs"
for i, v in ipairs (Guestfs.event_all) do
print (i, v)
end
g = Guestfs.create ()
function log_callback (g, event, eh, flags, buf, array)