diff options
author | David Walter Seikel | 2014-05-05 20:04:08 +1000 |
---|---|---|
committer | David Walter Seikel | 2014-05-05 20:04:08 +1000 |
commit | 969f1968f2f74f8f09c4788bc7f7b1c9655ad354 (patch) | |
tree | 90d1d572f57c03b65c105cdcc47e9b79640a617d | |
parent | GuiLuaDo() now returns astructure, and has that structure in Lua's C registry... (diff) | |
download | SledjHamr-969f1968f2f74f8f09c4788bc7f7b1c9655ad354.zip SledjHamr-969f1968f2f74f8f09c4788bc7f7b1c9655ad354.tar.gz SledjHamr-969f1968f2f74f8f09c4788bc7f7b1c9655ad354.tar.bz2 SledjHamr-969f1968f2f74f8f09c4788bc7f7b1c9655ad354.tar.xz |
Call skang modules from extantz. Needs some clean up.
-rwxr-xr-x | extantz.sh | 7 | ||||
-rw-r--r-- | lib/skang.lua | 4 | ||||
-rw-r--r-- | src/GuiLua/GuiLua.c | 33 | ||||
-rw-r--r-- | src/GuiLua/GuiLua.h | 10 | ||||
-rw-r--r-- | src/GuiLua/skang.c | 4 | ||||
-rw-r--r-- | src/GuiLua/test.lua | 5 | ||||
-rw-r--r-- | src/GuiLua/test.skang | 2 | ||||
-rw-r--r-- | src/GuiLua/test_c.c | 4 | ||||
-rwxr-xr-x | src/extantz/build.lua | 7 | ||||
-rw-r--r-- | src/extantz/chat.c | 2 | ||||
-rw-r--r-- | src/extantz/extantz.c | 7 | ||||
-rw-r--r-- | src/extantz/extantz.h | 2 | ||||
-rw-r--r-- | src/extantz/woMan.c | 2 |
13 files changed, 59 insertions, 30 deletions
diff --git a/extantz.sh b/extantz.sh new file mode 100755 index 0000000..8149926 --- /dev/null +++ b/extantz.sh | |||
@@ -0,0 +1,7 @@ | |||
1 | #! /bin/bash | ||
2 | |||
3 | wd=$(pwd) | ||
4 | |||
5 | export LUA_PATH="$wd/lib/?.lua;$wd/src/GuiLua/?.lua" | ||
6 | export LUA_CPATH="$wd/lib/lib?.so;$wd/src/GuiLua/?.so" | ||
7 | ./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 | |||
135 | end | 135 | end |
136 | _M.VERSION = version .. versionName .. timestamp | 136 | _M.VERSION = version .. versionName .. timestamp |
137 | _M.VERSION_DESC = versionDesc | 137 | _M.VERSION_DESC = versionDesc |
138 | |||
138 | -- If there is a .skang file, read that in and override the passed in skin. | 139 | -- If there is a .skang file, read that in and override the passed in skin. |
140 | -- 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. | ||
139 | local f = io.open(name .. '.skang') | 141 | local f = io.open(name .. '.skang') |
140 | if f then | 142 | if f then |
141 | skin = f:read('*l') | 143 | skin = f:read('*l') |
@@ -1010,7 +1012,7 @@ end | |||
1010 | 1012 | ||
1011 | -- Get our C functions installed into skang. | 1013 | -- Get our C functions installed into skang. |
1012 | -- This has to be after thingasm is defined. | 1014 | -- This has to be after thingasm is defined. |
1013 | package.cpath = package.cpath .. ';../../lib/lib?.so' | 1015 | package.cpath = package.cpath .. ';./lib/lib?.so;../lib/lib?.so;../../lib/lib?.so' |
1014 | local GuiLua = require 'GuiLua' | 1016 | local GuiLua = require 'GuiLua' |
1015 | 1017 | ||
1016 | 1018 | ||
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. | |||
139 | */ | 139 | */ |
140 | 140 | ||
141 | 141 | ||
142 | 142 | #include "SledjHamr.h" | |
143 | #include "LumbrJack.h" | ||
144 | #include "Runnr.h" | ||
145 | #include "winFang.h" | ||
143 | #include "GuiLua.h" | 146 | #include "GuiLua.h" |
147 | //#include <stdio.h> | ||
144 | 148 | ||
145 | 149 | ||
146 | static int logDom; // Our logging domain. | 150 | static int logDom; // Our logging domain. |
@@ -232,17 +236,20 @@ static int colour(lua_State *L) | |||
232 | static int window(lua_State *L) | 236 | static int window(lua_State *L) |
233 | { | 237 | { |
234 | winFang *win = NULL; | 238 | winFang *win = NULL; |
239 | Evas_Object *parent = NULL; | ||
235 | char *name = "GuiLua"; | 240 | char *name = "GuiLua"; |
236 | char *title = "GuiLua test harness"; | 241 | char *title = "GuiLua test harness"; |
237 | int w = WIDTH, h = HEIGHT; | 242 | int w = WIDTH, h = HEIGHT; |
238 | GuiLua *gl; | 243 | GuiLua *gl; |
239 | 244 | ||
245 | pull_lua(L, 1, "%w %h $title $name", &w, &h, &title, &name); | ||
246 | |||
240 | lua_getfield(L, LUA_REGISTRYINDEX, glName); | 247 | lua_getfield(L, LUA_REGISTRYINDEX, glName); |
241 | gl = lua_touserdata(L, -1); | 248 | gl = lua_touserdata(L, -1); |
242 | lua_pop(L, 1); | 249 | lua_pop(L, 1); |
250 | if (gl && gl->parent) parent = gl->parent; | ||
243 | 251 | ||
244 | pull_lua(L, 1, "%w %h $title $name", &w, &h, &title, &name); | 252 | win = winFangAdd(parent, 25, 25, w, h, title, name); |
245 | win = winFangAdd(NULL, 0, 0, w, h, title, name); | ||
246 | eina_clist_add_head(&gl->winFangs, &win->node); | 253 | eina_clist_add_head(&gl->winFangs, &win->node); |
247 | lua_pushlightuserdata(L, win); | 254 | lua_pushlightuserdata(L, win); |
248 | 255 | ||
@@ -285,15 +292,6 @@ static int closeWindow(lua_State *L) | |||
285 | winFangDel(win); | 292 | winFangDel(win); |
286 | } | 293 | } |
287 | 294 | ||
288 | if (logDom >= 0) | ||
289 | { | ||
290 | eina_log_domain_unregister(logDom); | ||
291 | logDom = -1; | ||
292 | } | ||
293 | |||
294 | // This shuts down Elementary, but keeps the main loop running until all ecore_evas are freed. | ||
295 | elm_shutdown(); | ||
296 | |||
297 | return 0; | 295 | return 0; |
298 | } | 296 | } |
299 | 297 | ||
@@ -313,6 +311,7 @@ int luaopen_GuiLua(lua_State *L) | |||
313 | { | 311 | { |
314 | int skang; | 312 | int skang; |
315 | 313 | ||
314 | printf("**********************require GuiLua\n"); | ||
316 | // In theory this function only ever gets called once. | 315 | // In theory this function only ever gets called once. |
317 | logDom = loggingStartup("GuiLua", logDom); | 316 | logDom = loggingStartup("GuiLua", logDom); |
318 | 317 | ||
@@ -362,7 +361,7 @@ PD("GuiLua 3"); | |||
362 | return 1; | 361 | return 1; |
363 | } | 362 | } |
364 | 363 | ||
365 | GuiLua *GuiLuaDo(int argc, char **argv, winFang *parent) | 364 | GuiLua *GuiLuaDo(int argc, char **argv, Evas_Object *parent) |
366 | { | 365 | { |
367 | GuiLua *result; | 366 | GuiLua *result; |
368 | lua_State *L; | 367 | lua_State *L; |
@@ -409,6 +408,14 @@ GuiLua *GuiLuaDo(int argc, char **argv, winFang *parent) | |||
409 | PE("Error running - skang.loopWindow()"); | 408 | PE("Error running - skang.loopWindow()"); |
410 | lua_pop(L, closeWindow(L)); | 409 | lua_pop(L, closeWindow(L)); |
411 | lua_close(L); | 410 | lua_close(L); |
411 | if (logDom >= 0) | ||
412 | { | ||
413 | eina_log_domain_unregister(logDom); | ||
414 | logDom = -1; | ||
415 | } | ||
416 | |||
417 | // This shuts down Elementary, but keeps the main loop running until all ecore_evas are freed. | ||
418 | elm_shutdown(); | ||
412 | } | 419 | } |
413 | } | 420 | } |
414 | else | 421 | 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 @@ | |||
1 | #include "SledjHamr.h" | ||
2 | #include "LumbrJack.h" | ||
3 | #include "Runnr.h" | ||
4 | #include "winFang.h" | ||
5 | |||
6 | |||
7 | #define WIDTH (300) | 1 | #define WIDTH (300) |
8 | #define HEIGHT (300) | 2 | #define HEIGHT (300) |
9 | 3 | ||
@@ -16,7 +10,7 @@ | |||
16 | typedef struct _GuiLua | 10 | typedef struct _GuiLua |
17 | { | 11 | { |
18 | lua_State *L; | 12 | lua_State *L; |
19 | winFang *parent; // Our parent window, if it exists. | 13 | Evas_Object *parent; // Our parent window, if it exists. |
20 | Eina_Clist winFangs; // The windows we might open. | 14 | Eina_Clist winFangs; // The windows we might open. |
21 | 15 | ||
22 | Eina_Clist node; | 16 | Eina_Clist node; |
@@ -24,4 +18,4 @@ typedef struct _GuiLua | |||
24 | Evas_Smart_Cb on_del; | 18 | Evas_Smart_Cb on_del; |
25 | } GuiLua; | 19 | } GuiLua; |
26 | 20 | ||
27 | GuiLua *GuiLuaDo(int argc, char **argv, winFang *parent); | 21 | 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 @@ | |||
1 | #include "SledjHamr.h" | ||
2 | #include "LumbrJack.h" | ||
3 | #include "Runnr.h" | ||
4 | #include "winFang.h" | ||
1 | #include "GuiLua.h" | 5 | #include "GuiLua.h" |
2 | 6 | ||
3 | 7 | ||
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. | |||
4 | 4 | ||
5 | local skang = require 'skang' | 5 | local skang = require 'skang' |
6 | local _M = skang.moduleBegin('test', nil, 'Copyright 2014 David Seikel', '0.1', '2014-03-27 03:57:00', [[ | 6 | local _M = skang.moduleBegin('test', nil, 'Copyright 2014 David Seikel', '0.1', '2014-03-27 03:57:00', [[ |
7 | local win = skang.window(500, 500, "G'day planet.", 'testWindow') | 7 | local win = skang.window(200, 100, "G'day planet.", 'testWindow') |
8 | skang.thingasm{win, 'quitter', 'Quits the skang window', types = 'widget', widget='"button", "Quit", 10, 10, 100, 30'} | 8 | skang.thingasm{win, 'quitter', 'Quits the skang window', types = 'widget', widget='"button", "Quit", 10, 10, 100, 30'} |
9 | win.W.quitter.action = 'skang.quit()' -- TODO Should look it up in ThingSpace.commands, and translat 'quit' into the Lua 'skang.quit()'? | 9 | win.W.quitter.action = 'skang.quit()' -- TODO Should look it up in ThingSpace.commands, and translate 'quit' into the Lua 'skang.quit()'? |
10 | skang.thingasm{win, 'ffuncer', 'Calls ffunc', types = 'widget', widget='"button", "ffunc()", 10, 40, 100, 30', action='test.ffunc(3, 4)'} | ||
10 | ]]) | 11 | ]]) |
11 | 12 | ||
12 | print('code') | 13 | 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 @@ | |||
4 | -- There's an implied local test = require 'test' | 4 | -- There's an implied local test = require 'test' |
5 | 5 | ||
6 | -- This is a bit more verbose than I wanted. lol | 6 | -- This is a bit more verbose than I wanted. lol |
7 | local win = skang.window(512, 512, "G'day planet.", 'testWindow') | 7 | local win = skang.window(200, 100, "G'day planet.", 'testWindow') |
8 | skang.thingasm{win, 'quitter', 'Quits the skang window', types = 'widget', widget='"button", "Quit", 10, 10, 100, 30'} | 8 | skang.thingasm{win, 'quitter', 'Quits the skang window', types = 'widget', widget='"button", "Quit", 10, 10, 100, 30'} |
9 | win.W.quitter.action = 'skang.quit()' -- TODO Should look it up in ThingSpace.commands, and translate 'quit' into the Lua 'skang.quit()'? | 9 | win.W.quitter.action = 'skang.quit()' -- TODO Should look it up in ThingSpace.commands, and translate 'quit' into the Lua 'skang.quit()'? |
10 | 10 | ||
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 | |||
10 | */ | 10 | */ |
11 | 11 | ||
12 | 12 | ||
13 | #include "SledjHamr.h" | ||
14 | #include "LumbrJack.h" | ||
15 | #include "Runnr.h" | ||
16 | #include "winFang.h" | ||
13 | #include "GuiLua.h" | 17 | #include "GuiLua.h" |
14 | 18 | ||
15 | 19 | ||
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 | |||
13 | dir = workingDir | 13 | dir = workingDir |
14 | end | 14 | end |
15 | 15 | ||
16 | CFLAGS = CFLAGS .. ' -I../../libraries/irrlicht-1.8.1/include -I/usr/X11R6/include' | 16 | CFLAGS = CFLAGS .. ' -I../../libraries/irrlicht-1.8.1/include -I/usr/X11R6/include -I../GuiLua' |
17 | LDFLAGS = LDFLAGS .. ' -L../../libraries/irrlicht-1.8.1/lib/Linux' | 17 | LDFLAGS = LDFLAGS .. ' -L../../libraries/irrlicht-1.8.1/lib/Linux' |
18 | libs = libs .. ' -lIrrlicht -lGL -lbz2' | 18 | libs = libs .. ' -lIrrlicht -lGL -lbz2 -lGuiLua -lwinFang -lRunnr' |
19 | 19 | ||
20 | removeFiles(dir, {'crappisspuke.o', 'CDemo.o', 'extantzCamera.o', 'gears.o', 'ephysics_demo.o', 'Evas_3D_demo.o', '../../media/extantz.edj'}) | 20 | removeFiles(dir, {'crappisspuke.o', 'CDemo.o', 'extantzCamera.o', 'gears.o', 'ephysics_demo.o', 'Evas_3D_demo.o', '../../media/extantz.edj'}) |
21 | removeFiles(dir, {'../../extantz', 'camera.o', 'chat.o', 'files.o', 'woMan.o'}) | 21 | 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 | |||
24 | runCommand('Irrlicht files', dir, 'g++ ' .. CFLAGS .. ' -ffast-math -c crappisspuke.cpp -o crappisspuke.o ' .. LDFLAGS) | 24 | runCommand('Irrlicht files', dir, 'g++ ' .. CFLAGS .. ' -ffast-math -c crappisspuke.cpp -o crappisspuke.o ' .. LDFLAGS) |
25 | runCommand(nil, dir, 'g++ ' .. CFLAGS .. ' -ffast-math -c CDemo.cpp -o CDemo.o ' .. LDFLAGS) | 25 | runCommand(nil, dir, 'g++ ' .. CFLAGS .. ' -ffast-math -c CDemo.cpp -o CDemo.o ' .. LDFLAGS) |
26 | runCommand(nil, dir, 'g++ ' .. CFLAGS .. ' -ffast-math -c extantzCamera.cpp -o extantzCamera.o ' .. LDFLAGS) | 26 | runCommand(nil, dir, 'g++ ' .. CFLAGS .. ' -ffast-math -c extantzCamera.cpp -o extantzCamera.o ' .. LDFLAGS) |
27 | compileFiles('../../extantz', dir, {'gears', 'ephysics_demo', 'camera', 'Evas_3D_demo', 'chat', 'files', 'woMan', 'extantz'}, 'crappisspuke.o CDemo.o extantzCamera.o -lwinFang') | 27 | CFLAGS = CFLAGS .. ' -Wl,-export-dynamic' |
28 | 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) | |||
16 | Widget *wid; | 16 | Widget *wid; |
17 | Evas_Object *bx, *en; | 17 | Evas_Object *bx, *en; |
18 | 18 | ||
19 | me = winFangAdd(ourGlobals->win, 30, 500, ourGlobals->win_w / 3, ourGlobals->win_h / 3, "chatter box", "chat"); | 19 | me = winFangAdd(ourGlobals->win, 30, 520, ourGlobals->win_w / 3, ourGlobals->win_h / 3, "chatter box", "chat"); |
20 | eina_clist_add_head(&ourGlobals->winFangs, &me->node); | 20 | eina_clist_add_head(&ourGlobals->winFangs, &me->node); |
21 | 21 | ||
22 | bx = eo_add(ELM_OBJ_BOX_CLASS, me->win, | 22 | 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) | |||
472 | woMan_add(&ourGlobals); | 472 | woMan_add(&ourGlobals); |
473 | chat_add(&ourGlobals); | 473 | chat_add(&ourGlobals); |
474 | ourGlobals.files = filesAdd(&ourGlobals, (char *) elm_app_data_dir_get(), EINA_TRUE, EINA_FALSE); | 474 | ourGlobals.files = filesAdd(&ourGlobals, (char *) elm_app_data_dir_get(), EINA_TRUE, EINA_FALSE); |
475 | char *args[] = {"extantz", "-l", "test", "-foo", "COMBINED!", NULL}; | ||
476 | GuiLua *test = GuiLuaDo(5, args, ourGlobals.win); | ||
475 | 477 | ||
476 | // Gotta do this after adding the windows, otherwise the menu renders under the window. | 478 | // Gotta do this after adding the windows, otherwise the menu renders under the window. |
477 | // This sucks, gotta redefine this menu each time we create a new window? | 479 | // 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) | |||
509 | Evas_3D_Demo_fini(&ourGlobals); | 511 | Evas_3D_Demo_fini(&ourGlobals); |
510 | eo_unref(ourGlobals.tb); | 512 | eo_unref(ourGlobals.tb); |
511 | 513 | ||
514 | EINA_CLIST_FOR_EACH_ENTRY(win, &test->winFangs, winFang, node) | ||
515 | { | ||
516 | winFangDel(win); | ||
517 | } | ||
518 | |||
512 | EINA_CLIST_FOR_EACH_ENTRY(win, &ourGlobals.winFangs, winFang, node) | 519 | EINA_CLIST_FOR_EACH_ENTRY(win, &ourGlobals.winFangs, winFang, node) |
513 | { | 520 | { |
514 | winFangDel(win); | 521 | 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 @@ | |||
11 | #include <EPhysics.h> | 11 | #include <EPhysics.h> |
12 | #include "extantzCamera.h" | 12 | #include "extantzCamera.h" |
13 | #include "winFang.h" | 13 | #include "winFang.h" |
14 | #include "Runnr.h" | ||
15 | #include "GuiLua.h" | ||
14 | 16 | ||
15 | 17 | ||
16 | #ifdef GL_GLES | 18 | #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) | |||
159 | char buf[PATH_MAX]; | 159 | char buf[PATH_MAX]; |
160 | int i; | 160 | int i; |
161 | 161 | ||
162 | me = winFangAdd(ourGlobals->win, 30, 30, ourGlobals->win_w / 3, ourGlobals->win_h / 3, "virtual world manager", "woMan"); | 162 | me = winFangAdd(ourGlobals->win, 30, 150, ourGlobals->win_w / 3, ourGlobals->win_h / 3, "virtual world manager", "woMan"); |
163 | eina_clist_add_head(&ourGlobals->winFangs, &me->node); | 163 | eina_clist_add_head(&ourGlobals->winFangs, &me->node); |
164 | 164 | ||
165 | bx = elm_box_add(me->win); | 165 | bx = elm_box_add(me->win); |