From a1897f6eb64f037d39c67e035cf4cfd2046ba012 Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Mon, 21 Jan 2013 00:40:39 +0000 Subject: [PATCH] Port to new grub_pci_iterate signature as of 2013-01-13, removing nested functions. --- grub_lib.c | 44 +++++++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/grub_lib.c b/grub_lib.c index 055d620..328a18d 100644 --- a/grub_lib.c +++ b/grub_lib.c @@ -255,35 +255,37 @@ grub_lua_enum_file (lua_State *state) } #ifdef ENABLE_LUA_PCI +/* Helper for grub_lua_enum_pci. */ static int -grub_lua_enum_pci (lua_State *state) +grub_lua_enum_pci_iter (grub_pci_device_t dev, grub_pci_id_t pciid, void *data) { - auto int NESTED_FUNC_ATTR enum_pci (grub_pci_device_t dev, grub_pci_id_t pciid); - int NESTED_FUNC_ATTR enum_pci (grub_pci_device_t dev, grub_pci_id_t pciid) - { - int result; - grub_pci_address_t addr; - grub_uint32_t class; + lua_State *state = data; + int result; + grub_pci_address_t addr; + grub_uint32_t class; - lua_pushvalue (state, 1); - lua_pushinteger (state, grub_pci_get_bus (dev)); - lua_pushinteger (state, grub_pci_get_device (dev)); - lua_pushinteger (state, grub_pci_get_function (dev)); - lua_pushinteger (state, pciid); + lua_pushvalue (state, 1); + lua_pushinteger (state, grub_pci_get_bus (dev)); + lua_pushinteger (state, grub_pci_get_device (dev)); + lua_pushinteger (state, grub_pci_get_function (dev)); + lua_pushinteger (state, pciid); - addr = grub_pci_make_address (dev, GRUB_PCI_REG_CLASS); - class = grub_pci_read (addr); - lua_pushinteger (state, class); + addr = grub_pci_make_address (dev, GRUB_PCI_REG_CLASS); + class = grub_pci_read (addr); + lua_pushinteger (state, class); - lua_call (state, 5, 1); - result = lua_tointeger (state, -1); - lua_pop (state, 1); + lua_call (state, 5, 1); + result = lua_tointeger (state, -1); + lua_pop (state, 1); - return result; - } + return result; +} +static int +grub_lua_enum_pci (lua_State *state) +{ luaL_checktype (state, 1, LUA_TFUNCTION); - grub_pci_iterate (enum_pci); + grub_pci_iterate (grub_lua_enum_pci_iter, state); return push_result (state); } #endif -- 2.11.4.GIT