mirror of
https://github.com/libguestfs/libguestfs.git
synced 2026-03-21 22:53:37 +00:00
lua: Replace internal lua_guestfs_* functions with guestfs_lua_*.
This is just code motion. It just ensures there is no possible conflict with lua_* symbols.
This commit is contained in:
@@ -50,11 +50,11 @@ let generate_lua_c () =
|
||||
|
||||
#include <guestfs.h>
|
||||
|
||||
#define LUA_GUESTFS_HANDLE \"guestfs handle\"
|
||||
#define GUESTFS_LUA_HANDLE \"guestfs handle\"
|
||||
|
||||
/* This struct is managed on the Lua heap. If the GC collects it,
|
||||
* the Lua '__gc' function is called which ends up calling
|
||||
* lua_guestfs_finalizer.
|
||||
* guestfs_lua_finalizer.
|
||||
*
|
||||
* There is also an entry in the Lua registry, indexed by 'g'
|
||||
* (allocated on demand) which stores per-handle Lua data. See
|
||||
@@ -121,7 +121,7 @@ static void push_event (lua_State *L, uint64_t event);
|
||||
|
||||
/* Create a new connection. */
|
||||
static int
|
||||
lua_guestfs_create (lua_State *L)
|
||||
guestfs_lua_create (lua_State *L)
|
||||
{
|
||||
guestfs_h *g;
|
||||
struct userdata *u;
|
||||
@@ -148,7 +148,7 @@ lua_guestfs_create (lua_State *L)
|
||||
guestfs_set_error_handler (g, NULL, NULL);
|
||||
|
||||
u = lua_newuserdata (L, sizeof (struct userdata));
|
||||
luaL_getmetatable (L, LUA_GUESTFS_HANDLE);
|
||||
luaL_getmetatable (L, GUESTFS_LUA_HANDLE);
|
||||
assert (lua_type (L, -1) == LUA_TTABLE);
|
||||
lua_setmetatable (L, -2);
|
||||
|
||||
@@ -167,7 +167,7 @@ close_handle (lua_State *L, guestfs_h *g)
|
||||
|
||||
/* Finalizer. */
|
||||
static int
|
||||
lua_guestfs_finalizer (lua_State *L)
|
||||
guestfs_lua_finalizer (lua_State *L)
|
||||
{
|
||||
struct userdata *u = get_handle (L, 1);
|
||||
struct event_state *es, *es_next;
|
||||
@@ -187,7 +187,7 @@ lua_guestfs_finalizer (lua_State *L)
|
||||
|
||||
/* Explicit close. */
|
||||
static int
|
||||
lua_guestfs_close (lua_State *L)
|
||||
guestfs_lua_close (lua_State *L)
|
||||
{
|
||||
struct userdata *u = get_handle (L, 1);
|
||||
|
||||
@@ -284,7 +284,7 @@ free_per_handle_table (lua_State *L, guestfs_h *g)
|
||||
|
||||
/* User cancel. */
|
||||
static int
|
||||
lua_guestfs_user_cancel (lua_State *L)
|
||||
guestfs_lua_user_cancel (lua_State *L)
|
||||
{
|
||||
struct userdata *u = get_handle (L, 1);
|
||||
|
||||
@@ -296,7 +296,7 @@ lua_guestfs_user_cancel (lua_State *L)
|
||||
|
||||
/* Set an event callback. */
|
||||
static int
|
||||
lua_guestfs_set_event_callback (lua_State *L)
|
||||
guestfs_lua_set_event_callback (lua_State *L)
|
||||
{
|
||||
struct userdata *u = get_handle (L, 1);
|
||||
guestfs_h *g = u->g;
|
||||
@@ -401,7 +401,7 @@ event_callback_wrapper (guestfs_h *g,
|
||||
|
||||
/* Delete an event callback. */
|
||||
static int
|
||||
lua_guestfs_delete_event_callback (lua_State *L)
|
||||
guestfs_lua_delete_event_callback (lua_State *L)
|
||||
{
|
||||
struct userdata *u = get_handle (L, 1);
|
||||
guestfs_h *g = u->g;
|
||||
@@ -425,7 +425,7 @@ lua_guestfs_delete_event_callback (lua_State *L)
|
||||
fun { name = name; style = (ret, args, optargs as style);
|
||||
c_function = c_function; c_optarg_prefix = c_optarg_prefix } ->
|
||||
pr "static int\n";
|
||||
pr "lua_guestfs_%s (lua_State *L)\n" name;
|
||||
pr "guestfs_lua_%s (lua_State *L)\n" name;
|
||||
pr "{\n";
|
||||
|
||||
(match ret with
|
||||
@@ -616,7 +616,7 @@ get_handle (lua_State *L, int index)
|
||||
{
|
||||
struct userdata *u;
|
||||
|
||||
u = luaL_checkudata (L, index, LUA_GUESTFS_HANDLE);
|
||||
u = luaL_checkudata (L, index, GUESTFS_LUA_HANDLE);
|
||||
return u;
|
||||
}
|
||||
|
||||
@@ -852,27 +852,27 @@ push_event (lua_State *L, uint64_t event)
|
||||
* See: http://article.gmane.org/gmane.comp.lang.lua.general/95065
|
||||
*/
|
||||
static luaL_Reg metamethods[] = {
|
||||
{ \"__gc\", lua_guestfs_finalizer },
|
||||
{ \"__gc\", guestfs_lua_finalizer },
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
/* Module functions. */
|
||||
static luaL_Reg functions[] = {
|
||||
{ \"create\", lua_guestfs_create },
|
||||
{ \"create\", guestfs_lua_create },
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
/* Methods. */
|
||||
static luaL_Reg methods[] = {
|
||||
{ \"close\", lua_guestfs_close },
|
||||
{ \"user_cancel\", lua_guestfs_user_cancel },
|
||||
{ \"set_event_callback\", lua_guestfs_set_event_callback },
|
||||
{ \"delete_event_callback\", lua_guestfs_delete_event_callback },
|
||||
{ \"close\", guestfs_lua_close },
|
||||
{ \"user_cancel\", guestfs_lua_user_cancel },
|
||||
{ \"set_event_callback\", guestfs_lua_set_event_callback },
|
||||
{ \"delete_event_callback\", guestfs_lua_delete_event_callback },
|
||||
|
||||
";
|
||||
|
||||
List.iter (
|
||||
fun { name = name } -> pr " { \"%s\", lua_guestfs_%s },\n" name name
|
||||
fun { name = name } -> pr " { \"%s\", guestfs_lua_%s },\n" name name
|
||||
) all_functions_sorted;
|
||||
|
||||
pr "\
|
||||
@@ -903,7 +903,7 @@ luaopen_guestfs (lua_State *L)
|
||||
char v[256];
|
||||
|
||||
/* Create metatable. */
|
||||
luaL_newmetatable (L, LUA_GUESTFS_HANDLE);
|
||||
luaL_newmetatable (L, GUESTFS_LUA_HANDLE);
|
||||
luaL_register (L, NULL, metamethods);
|
||||
|
||||
/* Create methods table. */
|
||||
|
||||
Reference in New Issue
Block a user