From 969f1968f2f74f8f09c4788bc7f7b1c9655ad354 Mon Sep 17 00:00:00 2001 From: David Walter Seikel Date: Mon, 5 May 2014 20:04:08 +1000 Subject: Call skang modules from extantz. Needs some clean up. --- extantz.sh | 7 +++++++ lib/skang.lua | 4 +++- src/GuiLua/GuiLua.c | 33 ++++++++++++++++++++------------- src/GuiLua/GuiLua.h | 10 ++-------- src/GuiLua/skang.c | 4 ++++ src/GuiLua/test.lua | 5 +++-- src/GuiLua/test.skang | 2 +- src/GuiLua/test_c.c | 4 ++++ src/extantz/build.lua | 7 ++++--- src/extantz/chat.c | 2 +- src/extantz/extantz.c | 7 +++++++ src/extantz/extantz.h | 2 ++ src/extantz/woMan.c | 2 +- 13 files changed, 59 insertions(+), 30 deletions(-) create mode 100755 extantz.sh diff --git a/extantz.sh b/extantz.sh new file mode 100755 index 0000000..8149926 --- /dev/null +++ b/extantz.sh @@ -0,0 +1,7 @@ +#! /bin/bash + +wd=$(pwd) + +export LUA_PATH="$wd/lib/?.lua;$wd/src/GuiLua/?.lua" +export LUA_CPATH="$wd/lib/lib?.so;$wd/src/GuiLua/?.so" +./extantz diff --git a/lib/skang.lua b/lib/skang.lua index 880af17..33ae895 100644 --- a/lib/skang.lua +++ b/lib/skang.lua @@ -135,7 +135,9 @@ moduleBegin = function (name, author, copyright, version, timestamp, skin, isLua end _M.VERSION = version .. versionName .. timestamp _M.VERSION_DESC = versionDesc + -- If there is a .skang file, read that in and override the passed in skin. + -- TODO - At this point it would be nice if we knew where the module came from, so we can search for the skin file in THAT directory. local f = io.open(name .. '.skang') if f then skin = f:read('*l') @@ -1010,7 +1012,7 @@ end -- Get our C functions installed into skang. -- This has to be after thingasm is defined. -package.cpath = package.cpath .. ';../../lib/lib?.so' +package.cpath = package.cpath .. ';./lib/lib?.so;../lib/lib?.so;../../lib/lib?.so' local GuiLua = require 'GuiLua' diff --git a/src/GuiLua/GuiLua.c b/src/GuiLua/GuiLua.c index 2b09675..4bed9ca 100644 --- a/src/GuiLua/GuiLua.c +++ b/src/GuiLua/GuiLua.c @@ -139,8 +139,12 @@ and ordinary elementary widgets. Proper introspection can come later. */ - +#include "SledjHamr.h" +#include "LumbrJack.h" +#include "Runnr.h" +#include "winFang.h" #include "GuiLua.h" +//#include static int logDom; // Our logging domain. @@ -232,17 +236,20 @@ static int colour(lua_State *L) static int window(lua_State *L) { winFang *win = NULL; + Evas_Object *parent = NULL; char *name = "GuiLua"; char *title = "GuiLua test harness"; int w = WIDTH, h = HEIGHT; GuiLua *gl; + pull_lua(L, 1, "%w %h $title $name", &w, &h, &title, &name); + lua_getfield(L, LUA_REGISTRYINDEX, glName); gl = lua_touserdata(L, -1); lua_pop(L, 1); + if (gl && gl->parent) parent = gl->parent; - pull_lua(L, 1, "%w %h $title $name", &w, &h, &title, &name); - win = winFangAdd(NULL, 0, 0, w, h, title, name); + win = winFangAdd(parent, 25, 25, w, h, title, name); eina_clist_add_head(&gl->winFangs, &win->node); lua_pushlightuserdata(L, win); @@ -285,15 +292,6 @@ static int closeWindow(lua_State *L) winFangDel(win); } - if (logDom >= 0) - { - eina_log_domain_unregister(logDom); - logDom = -1; - } - - // This shuts down Elementary, but keeps the main loop running until all ecore_evas are freed. - elm_shutdown(); - return 0; } @@ -313,6 +311,7 @@ int luaopen_GuiLua(lua_State *L) { int skang; +printf("**********************require GuiLua\n"); // In theory this function only ever gets called once. logDom = loggingStartup("GuiLua", logDom); @@ -362,7 +361,7 @@ PD("GuiLua 3"); return 1; } -GuiLua *GuiLuaDo(int argc, char **argv, winFang *parent) +GuiLua *GuiLuaDo(int argc, char **argv, Evas_Object *parent) { GuiLua *result; lua_State *L; @@ -409,6 +408,14 @@ GuiLua *GuiLuaDo(int argc, char **argv, winFang *parent) PE("Error running - skang.loopWindow()"); lua_pop(L, closeWindow(L)); lua_close(L); + if (logDom >= 0) + { + eina_log_domain_unregister(logDom); + logDom = -1; + } + + // This shuts down Elementary, but keeps the main loop running until all ecore_evas are freed. + elm_shutdown(); } } else diff --git a/src/GuiLua/GuiLua.h b/src/GuiLua/GuiLua.h index fd766e6..c0fa9c7 100644 --- a/src/GuiLua/GuiLua.h +++ b/src/GuiLua/GuiLua.h @@ -1,9 +1,3 @@ -#include "SledjHamr.h" -#include "LumbrJack.h" -#include "Runnr.h" -#include "winFang.h" - - #define WIDTH (300) #define HEIGHT (300) @@ -16,7 +10,7 @@ typedef struct _GuiLua { lua_State *L; - winFang *parent; // Our parent window, if it exists. + Evas_Object *parent; // Our parent window, if it exists. Eina_Clist winFangs; // The windows we might open. Eina_Clist node; @@ -24,4 +18,4 @@ typedef struct _GuiLua Evas_Smart_Cb on_del; } GuiLua; -GuiLua *GuiLuaDo(int argc, char **argv, winFang *parent); +GuiLua *GuiLuaDo(int argc, char **argv, Evas_Object *parent); diff --git a/src/GuiLua/skang.c b/src/GuiLua/skang.c index c15108b..a0dca5c 100644 --- a/src/GuiLua/skang.c +++ b/src/GuiLua/skang.c @@ -1,3 +1,7 @@ +#include "SledjHamr.h" +#include "LumbrJack.h" +#include "Runnr.h" +#include "winFang.h" #include "GuiLua.h" diff --git a/src/GuiLua/test.lua b/src/GuiLua/test.lua index 705f7ad..aa7235a 100644 --- a/src/GuiLua/test.lua +++ b/src/GuiLua/test.lua @@ -4,9 +4,10 @@ do -- Only I'm not gonna indent this. local skang = require 'skang' local _M = skang.moduleBegin('test', nil, 'Copyright 2014 David Seikel', '0.1', '2014-03-27 03:57:00', [[ - local win = skang.window(500, 500, "G'day planet.", 'testWindow') + local win = skang.window(200, 100, "G'day planet.", 'testWindow') skang.thingasm{win, 'quitter', 'Quits the skang window', types = 'widget', widget='"button", "Quit", 10, 10, 100, 30'} - win.W.quitter.action = 'skang.quit()' -- TODO Should look it up in ThingSpace.commands, and translat 'quit' into the Lua 'skang.quit()'? + win.W.quitter.action = 'skang.quit()' -- TODO Should look it up in ThingSpace.commands, and translate 'quit' into the Lua 'skang.quit()'? + skang.thingasm{win, 'ffuncer', 'Calls ffunc', types = 'widget', widget='"button", "ffunc()", 10, 40, 100, 30', action='test.ffunc(3, 4)'} ]]) print('code') diff --git a/src/GuiLua/test.skang b/src/GuiLua/test.skang index 337b75f..e3b303b 100644 --- a/src/GuiLua/test.skang +++ b/src/GuiLua/test.skang @@ -4,7 +4,7 @@ -- There's an implied local test = require 'test' -- This is a bit more verbose than I wanted. lol -local win = skang.window(512, 512, "G'day planet.", 'testWindow') +local win = skang.window(200, 100, "G'day planet.", 'testWindow') skang.thingasm{win, 'quitter', 'Quits the skang window', types = 'widget', widget='"button", "Quit", 10, 10, 100, 30'} win.W.quitter.action = 'skang.quit()' -- TODO Should look it up in ThingSpace.commands, and translate 'quit' into the Lua 'skang.quit()'? diff --git a/src/GuiLua/test_c.c b/src/GuiLua/test_c.c index 5328bda..6421d24 100644 --- a/src/GuiLua/test_c.c +++ b/src/GuiLua/test_c.c @@ -10,6 +10,10 @@ http://lua-users.org/lists/lua-l/2008-01/msg00671.html */ +#include "SledjHamr.h" +#include "LumbrJack.h" +#include "Runnr.h" +#include "winFang.h" #include "GuiLua.h" diff --git a/src/extantz/build.lua b/src/extantz/build.lua index d3c983a..5ea2029 100755 --- a/src/extantz/build.lua +++ b/src/extantz/build.lua @@ -13,9 +13,9 @@ if 'nil' == type(dir) then dir = workingDir end -CFLAGS = CFLAGS .. ' -I../../libraries/irrlicht-1.8.1/include -I/usr/X11R6/include' +CFLAGS = CFLAGS .. ' -I../../libraries/irrlicht-1.8.1/include -I/usr/X11R6/include -I../GuiLua' LDFLAGS = LDFLAGS .. ' -L../../libraries/irrlicht-1.8.1/lib/Linux' -libs = libs .. ' -lIrrlicht -lGL -lbz2' +libs = libs .. ' -lIrrlicht -lGL -lbz2 -lGuiLua -lwinFang -lRunnr' removeFiles(dir, {'crappisspuke.o', 'CDemo.o', 'extantzCamera.o', 'gears.o', 'ephysics_demo.o', 'Evas_3D_demo.o', '../../media/extantz.edj'}) removeFiles(dir, {'../../extantz', 'camera.o', 'chat.o', 'files.o', 'woMan.o'}) @@ -24,4 +24,5 @@ runCommand('edje_cc', dir, 'edje_cc ' .. EDJE_FLAGS .. ' extantz.edc ../../medi runCommand('Irrlicht files', dir, 'g++ ' .. CFLAGS .. ' -ffast-math -c crappisspuke.cpp -o crappisspuke.o ' .. LDFLAGS) runCommand(nil, dir, 'g++ ' .. CFLAGS .. ' -ffast-math -c CDemo.cpp -o CDemo.o ' .. LDFLAGS) runCommand(nil, dir, 'g++ ' .. CFLAGS .. ' -ffast-math -c extantzCamera.cpp -o extantzCamera.o ' .. LDFLAGS) -compileFiles('../../extantz', dir, {'gears', 'ephysics_demo', 'camera', 'Evas_3D_demo', 'chat', 'files', 'woMan', 'extantz'}, 'crappisspuke.o CDemo.o extantzCamera.o -lwinFang') +CFLAGS = CFLAGS .. ' -Wl,-export-dynamic' +compileFiles('../../extantz', dir, {'gears', 'ephysics_demo', 'camera', 'Evas_3D_demo', 'chat', 'files', 'woMan', 'extantz'}, 'crappisspuke.o CDemo.o extantzCamera.o') diff --git a/src/extantz/chat.c b/src/extantz/chat.c index d608620..d060cb1 100644 --- a/src/extantz/chat.c +++ b/src/extantz/chat.c @@ -16,7 +16,7 @@ winFang *chat_add(globals *ourGlobals) Widget *wid; Evas_Object *bx, *en; - me = winFangAdd(ourGlobals->win, 30, 500, ourGlobals->win_w / 3, ourGlobals->win_h / 3, "chatter box", "chat"); + me = winFangAdd(ourGlobals->win, 30, 520, ourGlobals->win_w / 3, ourGlobals->win_h / 3, "chatter box", "chat"); eina_clist_add_head(&ourGlobals->winFangs, &me->node); bx = eo_add(ELM_OBJ_BOX_CLASS, me->win, diff --git a/src/extantz/extantz.c b/src/extantz/extantz.c index e8683f8..7346aea 100644 --- a/src/extantz/extantz.c +++ b/src/extantz/extantz.c @@ -472,6 +472,8 @@ EAPI_MAIN int elm_main(int argc, char **argv) woMan_add(&ourGlobals); chat_add(&ourGlobals); ourGlobals.files = filesAdd(&ourGlobals, (char *) elm_app_data_dir_get(), EINA_TRUE, EINA_FALSE); + char *args[] = {"extantz", "-l", "test", "-foo", "COMBINED!", NULL}; + GuiLua *test = GuiLuaDo(5, args, ourGlobals.win); // Gotta do this after adding the windows, otherwise the menu renders under the window. // This sucks, gotta redefine this menu each time we create a new window? @@ -509,6 +511,11 @@ EAPI_MAIN int elm_main(int argc, char **argv) Evas_3D_Demo_fini(&ourGlobals); eo_unref(ourGlobals.tb); + EINA_CLIST_FOR_EACH_ENTRY(win, &test->winFangs, winFang, node) + { + winFangDel(win); + } + EINA_CLIST_FOR_EACH_ENTRY(win, &ourGlobals.winFangs, winFang, node) { winFangDel(win); diff --git a/src/extantz/extantz.h b/src/extantz/extantz.h index 7d969b1..969ac98 100644 --- a/src/extantz/extantz.h +++ b/src/extantz/extantz.h @@ -11,6 +11,8 @@ #include #include "extantzCamera.h" #include "winFang.h" +#include "Runnr.h" +#include "GuiLua.h" #ifdef GL_GLES diff --git a/src/extantz/woMan.c b/src/extantz/woMan.c index f0a2ed4..ee0cc02 100644 --- a/src/extantz/woMan.c +++ b/src/extantz/woMan.c @@ -159,7 +159,7 @@ winFang *woMan_add(globals *ourGlobals) char buf[PATH_MAX]; int i; - me = winFangAdd(ourGlobals->win, 30, 30, ourGlobals->win_w / 3, ourGlobals->win_h / 3, "virtual world manager", "woMan"); + me = winFangAdd(ourGlobals->win, 30, 150, ourGlobals->win_w / 3, ourGlobals->win_h / 3, "virtual world manager", "woMan"); eina_clist_add_head(&ourGlobals->winFangs, &me->node); bx = elm_box_add(me->win); -- cgit v1.1