[SCM] Development fot GoFind! branch, master, updated. b2d02130c5b2a48c45222d6c2b46efba6db865a3
Miriam Ruiz
miriam at debian.org
Tue Nov 25 00:38:18 UTC 2008
The following commit has been merged in the master branch:
commit b2d02130c5b2a48c45222d6c2b46efba6db865a3
Author: Miriam Ruiz <miriam at debian.org>
Date: Tue Nov 25 01:40:58 2008 +0100
make lua plugin depends on lua-gtk
diff --git a/Makefile b/Makefile
index b6888eb..a5e4237 100644
--- a/Makefile
+++ b/Makefile
@@ -56,7 +56,7 @@ fltk/ui.h fltk/ui.cpp: fltk/ui.fld
cd fltk && fluid -c -o ui.cpp -h ui.h ui.fld
gui_lua.so : gui_lua.o
- g++ $(LDFLAGS) -shared $^ -o $@ `pkg-config lua5.1 --libs` $(LIBS)
+ g++ $(LDFLAGS) -shared $^ -o $@ `pkg-config lua5.1 --libs` $(LIBS) -llua5.1-gtk
gui_lua.o: gui_lua.cpp
g++ -o $@ -c $+ $(CFLAGS) `pkg-config lua5.1 --cflags`
diff --git a/gui_lua.cpp b/gui_lua.cpp
index 44941fc..1cfe69a 100644
--- a/gui_lua.cpp
+++ b/gui_lua.cpp
@@ -270,56 +270,52 @@ static int pmain (lua_State *L)
{
struct Smain *s = (struct Smain *)lua_touserdata(L, 1);
globalL = L;
+
lua_gc(L, LUA_GCSTOP, 0); /* stop collector during initialization */
luaL_openlibs(L); /* open libraries */
lua_gc(L, LUA_GCRESTART, 0);
+
s->status = handle_luainit(L);
if (s->status != 0) return 0;
+
printf("Starting LUA Script\n");
if (s->script)
s->status = handle_script(L, s->script, s->argv);
printf("Finished LUA Script\n");
+
if (s->status != 0) return 0;
return 0;
}
+/* Declare the Lua libraries we wish to use. */
+/* Note: If you are opening and running a file containing Lua code */
+/* using 'lua_dofile(l, "myfile.lua") - you must delcare all the libraries */
+/* used in that file here also. */
+
+extern "C" int luaopen_base(lua_State *L);
+extern "C" int luaopen_gtk(lua_State *L);
+
+static const luaL_reg lualibs[] =
+{
+ { "base", luaopen_base },
+ { "gtk", luaopen_gtk },
+};
+
extern "C" int go(PackageData &pkgdata)
{
int status;
- struct Smain s(argc, argv);
+
lua_State *L = lua_open(); /* create state */
if (L == NULL)
{
l_message("cannot create state: not enough memory");
return EXIT_FAILURE;
}
+
+ struct Smain s(argc, argv);
status = lua_cpcall(L, &pmain, &s);
report(L, status);
lua_close(L);
return (status || s.status) ? 0 /* FAILURE */ : 1 /* SUCCESS */;
}
-
-
-
-/* Declare the Lua libraries we wish to use. */
-/* Note: If you are opening and running a file containing Lua code */
-/* using 'lua_dofile(l, "myfile.lua") - you must delcare all the libraries */
-/* used in that file here also. */
-static const luaL_reg lualibs[] =
-{
- { "base", luaopen_base },
- { NULL, NULL }
-};
-
-/* A function to open up all the Lua libraries you declared above. */
-static void openlualibs(lua_State *l)
-{
- const luaL_reg *lib;
-
- for (lib = lualibs; lib->func != NULL; lib++)
- {
- lib->func(l);
- lua_settop(l, 0);
- }
-}
diff --git a/lua/script.lua b/lua/script.lua
index 62c813a..a896b0c 100644
--- a/lua/script.lua
+++ b/lua/script.lua
@@ -1 +1,12 @@
-print "Hello world"
+#! /usr/bin/env lua
+
+-- The simplest possible Lua-Gtk application.
+
+require "gtk"
+
+win = gtk.window_new(gtk.GTK_WINDOW_TOPLEVEL)
+win:connect('destroy', function() gtk.main_quit() end)
+win:set_title("Demo Program")
+win:show()
+gtk.main()
+
--
Development fot GoFind!
More information about the Pkg-games-commits
mailing list