summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard W.M. Jones <rjones@redhat.com>2012-11-19 17:06:21 +0000
committerRichard W.M. Jones <rjones@redhat.com>2012-11-19 17:11:27 +0000
commitbc03a48c7132c75072003fcdd54930db3b70721e (patch)
tree80fdb8fdce7b759e1a7b9074143358cce60e6dd6
parent36e71e0cf45b5515d8447d959d9a1642223f2dc7 (diff)
downloadlibguestfs-bc03a48c7132c75072003fcdd54930db3b70721e.tar.gz
libguestfs-bc03a48c7132c75072003fcdd54930db3b70721e.tar.xz
libguestfs-bc03a48c7132c75072003fcdd54930db3b70721e.zip
lua: Add global Guestfs.event_all (list of all events).
-rw-r--r--generator/lua.ml15
-rwxr-xr-xlua/tests/400-events.lua4
2 files changed, 19 insertions, 0 deletions
diff --git a/generator/lua.ml b/generator/lua.ml
index fbb4e93a..2b3e4a57 100644
--- a/generator/lua.ml
+++ b/generator/lua.ml
@@ -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.\");
diff --git a/lua/tests/400-events.lua b/lua/tests/400-events.lua
index c29cc62d..47a86a5e 100755
--- a/lua/tests/400-events.lua
+++ b/lua/tests/400-events.lua
@@ -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)