aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src
diff options
context:
space:
mode:
authorDavid Walter Seikel2014-04-27 16:48:07 +1000
committerDavid Walter Seikel2014-04-27 16:48:07 +1000
commit568c8829db2f886921c7592cadbadbf4241127b6 (patch)
tree0af400526db683fa4ff5fb18a7eb2f685795fd04 /src
parentAdded stuff cut and pasted from the new Evas_3d examples, but they are broken... (diff)
downloadSledjHamr-568c8829db2f886921c7592cadbadbf4241127b6.zip
SledjHamr-568c8829db2f886921c7592cadbadbf4241127b6.tar.gz
SledjHamr-568c8829db2f886921c7592cadbadbf4241127b6.tar.bz2
SledjHamr-568c8829db2f886921c7592cadbadbf4241127b6.tar.xz
Centralise the PACKAGE_* stuff, move our libraries to lib, and shuffle stuff to suit.
Diffstat (limited to 'src')
-rw-r--r--src/GuiLua/GuiLua.h23
-rwxr-xr-xsrc/GuiLua/build.lua4
-rw-r--r--src/GuiLua/skang.c6
-rwxr-xr-xsrc/GuiLua/test.sh2
-rw-r--r--src/LuaSL/LuaSL_compile.c4
-rw-r--r--src/LuaSL/LuaSL_test.c8
-rwxr-xr-xsrc/LuaSL/build.lua9
-rwxr-xr-xsrc/LuaSL/test.sh2
-rw-r--r--src/extantz/extantz.c21
-rw-r--r--src/extantz/extantz.h8
-rw-r--r--src/libraries/LumbrJack.c85
-rw-r--r--src/libraries/LumbrJack.h38
-rw-r--r--src/libraries/Runnr.c318
-rw-r--r--src/libraries/Runnr.h15
-rw-r--r--src/libraries/SledjHamr.c23
-rw-r--r--src/libraries/SledjHamr.h14
-rwxr-xr-xsrc/libraries/build.lua33
17 files changed, 559 insertions, 54 deletions
diff --git a/src/GuiLua/GuiLua.h b/src/GuiLua/GuiLua.h
index 95353fb..2dd77ba 100644
--- a/src/GuiLua/GuiLua.h
+++ b/src/GuiLua/GuiLua.h
@@ -1,27 +1,8 @@
1 1#include "SledjHamr.h"
2#define EFL_API_OVERRIDE 1
3/* Enable access to unstable EFL API that are still in beta */
4#define EFL_BETA_API_SUPPORT 1
5/* Enable access to unstable EFL EO API. */
6#define EFL_EO_API_SUPPORT 1
7
8#include <stdio.h>
9#include <ctype.h>
10
11#include <Elementary.h>
12
13// This got left out.
14//EAPI Evas_3D_Scene *evas_3d_scene_add(Evas *e);
15
16
17#include <lua.h>
18#include <luajit.h>
19#include <lualib.h>
20#include <lauxlib.h>
21
22#include "LumbrJack.h" 2#include "LumbrJack.h"
23#include "Runnr.h" 3#include "Runnr.h"
24 4
5
25typedef struct _globals globals; 6typedef struct _globals globals;
26 7
27 8
diff --git a/src/GuiLua/build.lua b/src/GuiLua/build.lua
index 16f4153..169e198 100755
--- a/src/GuiLua/build.lua
+++ b/src/GuiLua/build.lua
@@ -15,9 +15,9 @@ end
15 15
16LDFLAGS = '-L ' .. dir .. ' ' .. LDFLAGS 16LDFLAGS = '-L ' .. dir .. ' ' .. LDFLAGS
17 17
18removeFiles(dir, {'test_c.so', 'GuiLua.o', '../../libraries/libGuiLua.so', '../../skang'}) 18removeFiles(dir, {'test_c.so', 'GuiLua.o', lib_d .. '/libGuiLua.so', '../../skang'})
19 19
20runCommand('C modules', dir, 'gcc ' .. CFLAGS .. ' -fPIC -shared -o test_c.so test_c.c') 20runCommand('C modules', dir, 'gcc ' .. CFLAGS .. ' -fPIC -shared -o test_c.so test_c.c')
21runCommand(nil, dir, 'gcc ' .. CFLAGS .. ' -fPIC -c GuiLua.c') 21runCommand(nil, dir, 'gcc ' .. CFLAGS .. ' -fPIC -c GuiLua.c')
22runCommand('C libraries', dir, 'gcc ' .. CFLAGS .. ' -shared -Wl,-soname,libGuiLua.so -o ../../libraries/libGuiLua.so GuiLua.o') 22runCommand('C libraries', dir, 'gcc ' .. CFLAGS .. ' -shared -Wl,-soname,libGuiLua.so -o ' .. lib_d .. '/libGuiLua.so GuiLua.o')
23runCommand('C apps', dir, 'gcc ' .. CFLAGS .. ' -Wl,-export-dynamic -o ../../skang skang.c ' .. LDFLAGS .. ' -lGuiLua ' .. libs) 23runCommand('C apps', dir, 'gcc ' .. CFLAGS .. ' -Wl,-export-dynamic -o ../../skang skang.c ' .. LDFLAGS .. ' -lGuiLua ' .. libs)
diff --git a/src/GuiLua/skang.c b/src/GuiLua/skang.c
index facc239..f78c1c5 100644
--- a/src/GuiLua/skang.c
+++ b/src/GuiLua/skang.c
@@ -3,11 +3,7 @@
3 3
4EAPI_MAIN int elm_main(int argc, char **argv) 4EAPI_MAIN int elm_main(int argc, char **argv)
5{ 5{
6 elm_app_compile_bin_dir_set(PACKAGE_BIN_DIR); 6 HamrTime(elm_main, "GuiLua");
7 elm_app_compile_data_dir_set(PACKAGE_DATA_DIR);
8 elm_app_compile_lib_dir_set(PACKAGE_LIB_DIR);
9 elm_app_info_set(elm_main, "GuiLua", "skang.lua");
10
11 GuiLuaDo(argc, argv); 7 GuiLuaDo(argc, argv);
12 8
13 return 0; 9 return 0;
diff --git a/src/GuiLua/test.sh b/src/GuiLua/test.sh
index bea2fc3..0cf39d9 100755
--- a/src/GuiLua/test.sh
+++ b/src/GuiLua/test.sh
@@ -2,5 +2,5 @@
2 2
3wd=$(pwd) 3wd=$(pwd)
4 4
5export LUA_PATH="$wd/../../libraries/?.lua;./?.lua" 5export LUA_PATH="$wd/../../lib/?.lua;./?.lua"
6../../skang -l test -foo "argy bargy" 6../../skang -l test -foo "argy bargy"
diff --git a/src/LuaSL/LuaSL_compile.c b/src/LuaSL/LuaSL_compile.c
index 771888e..f32e0c0 100644
--- a/src/LuaSL/LuaSL_compile.c
+++ b/src/LuaSL/LuaSL_compile.c
@@ -2119,9 +2119,9 @@ boolean compilerSetup(gameGlobals *ourGlobals)
2119 } 2119 }
2120 2120
2121 // Compile the constants. 2121 // Compile the constants.
2122 snprintf(buf, sizeof(buf), "lua -e 'require(\"LSL\").gimmeLSL()' > %s/libraries/constants.lsl", PACKAGE_DATA_DIR); 2122 snprintf(buf, sizeof(buf), "lua -e 'require(\"LSL\").gimmeLSL()' > %s/constants.lsl", PACKAGE_LIB_DIR);
2123 system(buf); 2123 system(buf);
2124 snprintf(buf, sizeof(buf), "%s/libraries/constants.lsl", PACKAGE_DATA_DIR); 2124 snprintf(buf, sizeof(buf), "%s/constants.lsl", PACKAGE_LIB_DIR);
2125 compileLSL(ourGlobals, NULL, "FAKE_SID", buf, TRUE); 2125 compileLSL(ourGlobals, NULL, "FAKE_SID", buf, TRUE);
2126 2126
2127 return TRUE; 2127 return TRUE;
diff --git a/src/LuaSL/LuaSL_test.c b/src/LuaSL/LuaSL_test.c
index 58d6225..27b9626 100644
--- a/src/LuaSL/LuaSL_test.c
+++ b/src/LuaSL/LuaSL_test.c
@@ -147,7 +147,7 @@ static Eina_Bool _add(void *data, int type __UNUSED__, Ecore_Con_Event_Server_Ad
147 147
148 ourGlobals->server = ev->server; 148 ourGlobals->server = ev->server;
149 gettimeofday(&startTime, NULL); 149 gettimeofday(&startTime, NULL);
150 snprintf(buf, sizeof(buf), "%s/media/Test sim/objects", PACKAGE_DATA_DIR); 150 snprintf(buf, sizeof(buf), "%s/Test sim/objects", PACKAGE_DATA_DIR);
151 eina_file_dir_list(buf, EINA_TRUE, dirList_compile, ourGlobals); 151 eina_file_dir_list(buf, EINA_TRUE, dirList_compile, ourGlobals);
152 // Wait awhile, then start sending events for testing. 152 // Wait awhile, then start sending events for testing.
153 ecore_timer_add(0.5, _timer_cb, ourGlobals); 153 ecore_timer_add(0.5, _timer_cb, ourGlobals);
@@ -392,7 +392,7 @@ int main(int argc, char **argv)
392 evas_object_focus_set(ourGlobals.bg, EINA_TRUE); 392 evas_object_focus_set(ourGlobals.bg, EINA_TRUE);
393 393
394 ourGlobals.edje = edje_object_add(ourGlobals.canvas); 394 ourGlobals.edje = edje_object_add(ourGlobals.canvas);
395 snprintf(buf, sizeof(buf), "%s/media/%s.edj", PACKAGE_DATA_DIR, "LuaSL"); 395 snprintf(buf, sizeof(buf), "%s/%s.edj", PACKAGE_DATA_DIR, "LuaSL");
396 if (!edje_object_file_set(ourGlobals.edje, buf, group)) 396 if (!edje_object_file_set(ourGlobals.edje, buf, group))
397 { 397 {
398 int err = edje_object_load_error_get(ourGlobals.edje); 398 int err = edje_object_load_error_get(ourGlobals.edje);
@@ -409,7 +409,7 @@ int main(int argc, char **argv)
409 evas_object_resize(ourGlobals.edje, WIDTH, HEIGHT); 409 evas_object_resize(ourGlobals.edje, WIDTH, HEIGHT);
410 evas_object_show(ourGlobals.edje); 410 evas_object_show(ourGlobals.edje);
411 411
412 snprintf(buf, sizeof(buf), "%s/media/bubble_sh.png", PACKAGE_DATA_DIR); 412 snprintf(buf, sizeof(buf), "%s/bubble_sh.png", PACKAGE_DATA_DIR);
413 for (i = 0; i < (sizeof(names) / sizeof(char *) / 2); i++) 413 for (i = 0; i < (sizeof(names) / sizeof(char *) / 2); i++)
414 { 414 {
415 sh = evas_object_image_filled_add(ourGlobals.canvas); 415 sh = evas_object_image_filled_add(ourGlobals.canvas);
@@ -419,7 +419,7 @@ int main(int argc, char **argv)
419 evas_object_data_set(ourGlobals.bg, names[(i * 2) + 1], sh); 419 evas_object_data_set(ourGlobals.bg, names[(i * 2) + 1], sh);
420 } 420 }
421 421
422 snprintf(buf, sizeof(buf), "%s/media/bubble.png", PACKAGE_DATA_DIR); 422 snprintf(buf, sizeof(buf), "%s/bubble.png", PACKAGE_DATA_DIR);
423 for (i = 0; i < (sizeof(names) / sizeof(char *) / 2); i++) 423 for (i = 0; i < (sizeof(names) / sizeof(char *) / 2); i++)
424 { 424 {
425 bub = evas_object_image_filled_add(ourGlobals.canvas); 425 bub = evas_object_image_filled_add(ourGlobals.canvas);
diff --git a/src/LuaSL/build.lua b/src/LuaSL/build.lua
index f86715c..6b34145 100755
--- a/src/LuaSL/build.lua
+++ b/src/LuaSL/build.lua
@@ -13,11 +13,20 @@ if 'nil' == type(dir) then
13 dir = workingDir 13 dir = workingDir
14end 14end
15 15
16
16removeFiles(dir, {'../../LuaSL', '*.o', '*.output', '*.backup', '../../media/LuaSL.edj', 'LuaSL_lexer.h', 'LuaSL_lexer.c', 'LuaSL_lemon_yaccer.h', 'LuaSL_lemon_yaccer.c', 'LuaSL_lemon_yaccer.out'}) 17removeFiles(dir, {'../../LuaSL', '*.o', '*.output', '*.backup', '../../media/LuaSL.edj', 'LuaSL_lexer.h', 'LuaSL_lexer.c', 'LuaSL_lemon_yaccer.h', 'LuaSL_lemon_yaccer.c', 'LuaSL_lemon_yaccer.out'})
17 18
18-- Run lemon first, flex depends on it to define the symbol values. 19-- Run lemon first, flex depends on it to define the symbol values.
19runCommand('lemon', dir, '../../libraries/lemon/lemon -s -T../../libraries/lemon/lempar.c LuaSL_lemon_yaccer.y') 20runCommand('lemon', dir, '../../libraries/lemon/lemon -s -T../../libraries/lemon/lempar.c LuaSL_lemon_yaccer.y')
20runCommand('flex', dir, 'flex -C --outfile=LuaSL_lexer.c --header-file=LuaSL_lexer.h LuaSL_lexer.l') 21runCommand('flex', dir, 'flex -C --outfile=LuaSL_lexer.c --header-file=LuaSL_lexer.h LuaSL_lexer.l')
21runCommand('edje_cc', dir, 'edje_cc ' .. EDJE_FLAGS .. ' LuaSL.edc ../../media/LuaSL.edj') 22runCommand('edje_cc', dir, 'edje_cc ' .. EDJE_FLAGS .. ' LuaSL.edc ../../media/LuaSL.edj')
23
24-- While SledHamr.c does this, we can't use that here, coz LuaSL is not an Elm app.
25-- Neither is LuaSL_test actually.
26CFLAGS = CFLAGS .. ' -DPACKAGE_BIN_DIR=\\"' .. bin_d .. '\\"'
27CFLAGS = CFLAGS .. ' -DPACKAGE_LIB_DIR=\\"' .. lib_d .. '\\"'
28CFLAGS = CFLAGS .. ' -DPACKAGE_DATA_DIR=\\"' .. data_d .. '\\"'
29CFLAGS = CFLAGS .. ' -DPACKAGE_LOCALE_DIR=\\"' .. locale_d .. '\\"'
30
22compileFiles('../../LuaSL', dir, {'LuaSL_main', 'LuaSL_compile', 'LuaSL_threads', 'LuaSL_utilities', 'LuaSL_lexer', 'LuaSL_lemon_yaccer'}) 31compileFiles('../../LuaSL', dir, {'LuaSL_main', 'LuaSL_compile', 'LuaSL_threads', 'LuaSL_utilities', 'LuaSL_lexer', 'LuaSL_lemon_yaccer'})
23compileFiles('LuaSL_test', dir, {'LuaSL_test', 'LuaSL_utilities'}) 32compileFiles('LuaSL_test', dir, {'LuaSL_test', 'LuaSL_utilities'})
diff --git a/src/LuaSL/test.sh b/src/LuaSL/test.sh
index 1c26ade..435c5e2 100755
--- a/src/LuaSL/test.sh
+++ b/src/LuaSL/test.sh
@@ -4,7 +4,7 @@ wd=$(pwd)
4 4
5# Kill any left overs. 5# Kill any left overs.
6killall -KILL LuaSL 6killall -KILL LuaSL
7export LUA_PATH="$wd/../../libraries/?.lua" 7export LUA_PATH="$wd/../../lib/?.lua"
8 8
9case $@ in 9case $@ in
10 10
diff --git a/src/extantz/extantz.c b/src/extantz/extantz.c
index 09b5196..ab09fd0 100644
--- a/src/extantz/extantz.c
+++ b/src/extantz/extantz.c
@@ -39,7 +39,7 @@ static Elm_Genlist_Item_Class *viewer_gic = NULL;
39 39
40//static const char *img1 = PACKAGE_DATA_DIR "/media/plant_01.jpg"; 40//static const char *img1 = PACKAGE_DATA_DIR "/media/plant_01.jpg";
41//static const char *img2 = PACKAGE_DATA_DIR "/media/sky_01.jpg"; 41//static const char *img2 = PACKAGE_DATA_DIR "/media/sky_01.jpg";
42static const char *img3 = PACKAGE_DATA_DIR "/media/rock_01.jpg"; 42static const char *img3 = "rock_01.jpg";
43 43
44 44
45#define EPHYSICS_TEST_THEME "extantz" 45#define EPHYSICS_TEST_THEME "extantz"
@@ -1240,7 +1240,7 @@ static void woMan_add(GLData *gld)
1240// Evas_Object *win, *bg, *bx, *ic, *bb, *av, *en, *bt, *nf, *tab, *tb, *gridList, *viewerList, *menu; 1240// Evas_Object *win, *bg, *bx, *ic, *bb, *av, *en, *bt, *nf, *tab, *tb, *gridList, *viewerList, *menu;
1241 Evas_Object *win, *bx, *bt, *nf, *tab, *tb, *gridList, *viewerList, *menu; 1241 Evas_Object *win, *bx, *bt, *nf, *tab, *tb, *gridList, *viewerList, *menu;
1242 Elm_Object_Item *tb_it, *menu_it, *tab_it; 1242 Elm_Object_Item *tb_it, *menu_it, *tab_it;
1243// char buf[PATH_MAX]; 1243 char buf[PATH_MAX];
1244 int i; 1244 int i;
1245 1245
1246 win = fang_win_add(gld); 1246 win = fang_win_add(gld);
@@ -1351,9 +1351,10 @@ static void woMan_add(GLData *gld)
1351 evas_object_size_hint_weight_set(nf, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 1351 evas_object_size_hint_weight_set(nf, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1352 evas_object_size_hint_align_set(nf, EVAS_HINT_FILL, EVAS_HINT_FILL); 1352 evas_object_size_hint_align_set(nf, EVAS_HINT_FILL, EVAS_HINT_FILL);
1353 evas_object_show(nf); 1353 evas_object_show(nf);
1354 1354
1355 sprintf(buf, "%s/%s", elm_app_data_dir_get(), img3);
1355 tab = viewerList; tab_it = elm_naviframe_item_push(nf, NULL, NULL, NULL, tab, NULL); elm_naviframe_item_title_enabled_set(tab_it, EINA_FALSE, EINA_TRUE); elm_toolbar_item_append(tb, NULL, "Viewers", _promote, tab_it); 1356 tab = viewerList; tab_it = elm_naviframe_item_push(nf, NULL, NULL, NULL, tab, NULL); elm_naviframe_item_title_enabled_set(tab_it, EINA_FALSE, EINA_TRUE); elm_toolbar_item_append(tb, NULL, "Viewers", _promote, tab_it);
1356 tab = _content_image_new(win, img3); tab_it = elm_naviframe_item_push(nf, NULL, NULL, NULL, tab, NULL); elm_naviframe_item_title_enabled_set(tab_it, EINA_FALSE, EINA_TRUE); elm_toolbar_item_append(tb, NULL, "Landmarks", _promote, tab_it); 1357 tab = _content_image_new(win, strdup(buf)); tab_it = elm_naviframe_item_push(nf, NULL, NULL, NULL, tab, NULL); elm_naviframe_item_title_enabled_set(tab_it, EINA_FALSE, EINA_TRUE); elm_toolbar_item_append(tb, NULL, "Landmarks", _promote, tab_it);
1357 tab = gridList; tab_it = elm_naviframe_item_push(nf, NULL, NULL, NULL, tab, NULL); elm_naviframe_item_title_enabled_set(tab_it, EINA_FALSE, EINA_TRUE); elm_toolbar_item_append(tb, NULL, "Grids", _promote, tab_it); 1358 tab = gridList; tab_it = elm_naviframe_item_push(nf, NULL, NULL, NULL, tab, NULL); elm_naviframe_item_title_enabled_set(tab_it, EINA_FALSE, EINA_TRUE); elm_toolbar_item_append(tb, NULL, "Grids", _promote, tab_it);
1358 elm_box_pack_end(bx, nf); 1359 elm_box_pack_end(bx, nf);
1359 1360
@@ -1393,7 +1394,7 @@ EAPI_MAIN int elm_main(int argc, char **argv)
1393 EPhysics_Body *box_body1, *box_body2; 1394 EPhysics_Body *box_body1, *box_body2;
1394 Evas_Object *box1, *box2; 1395 Evas_Object *box1, *box2;
1395 GLData *gld = NULL; 1396 GLData *gld = NULL;
1396// char buf[PATH_MAX]; 1397 char buf[PATH_MAX];
1397// int i; 1398// int i;
1398// Eina_Bool gotWebKit = elm_need_web(); // Initialise ewebkit if it exists, or return EINA_FALSE if it don't. 1399// Eina_Bool gotWebKit = elm_need_web(); // Initialise ewebkit if it exists, or return EINA_FALSE if it don't.
1399 1400
@@ -1401,10 +1402,7 @@ EAPI_MAIN int elm_main(int argc, char **argv)
1401 // Don't do this, we need to clean up other stuff to, so set a clean up function below. 1402 // Don't do this, we need to clean up other stuff to, so set a clean up function below.
1402 //elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED); 1403 //elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
1403 1404
1404 // If you want efl to handle finding your bin/lib/data dirs, you must do this below. 1405 HamrTime(elm_main, "extantz");
1405 elm_app_compile_bin_dir_set(PACKAGE_BIN_DIR);
1406 elm_app_compile_data_dir_set(PACKAGE_DATA_DIR);
1407 elm_app_info_set(elm_main, "datadir", "media/sky_03.jpg");
1408 fprintf(stdout, "prefix was set to: %s\n", elm_app_prefix_dir_get()); 1406 fprintf(stdout, "prefix was set to: %s\n", elm_app_prefix_dir_get());
1409 fprintf(stdout, "data directory is: %s\n", elm_app_data_dir_get()); 1407 fprintf(stdout, "data directory is: %s\n", elm_app_data_dir_get());
1410 fprintf(stdout, "library directory is: %s\n", elm_app_lib_dir_get()); 1408 fprintf(stdout, "library directory is: %s\n", elm_app_lib_dir_get());
@@ -1538,7 +1536,8 @@ EAPI_MAIN int elm_main(int argc, char **argv)
1538 ephysics_body_friction_set(boundary, 0); 1536 ephysics_body_friction_set(boundary, 0);
1539 1537
1540 box1 = elm_image_add(gld->win); 1538 box1 = elm_image_add(gld->win);
1541 elm_image_file_set(box1, PACKAGE_DATA_DIR "/media/" EPHYSICS_TEST_THEME ".edj", "blue-cube"); 1539 sprintf(buf, "%s/%s.edj", elm_app_data_dir_get(), EPHYSICS_TEST_THEME);
1540 elm_image_file_set(box1, strdup(buf), "blue-cube");
1542 evas_object_move(box1, gld->win_w / 2 - 80, gld->win_h - 200); 1541 evas_object_move(box1, gld->win_w / 2 - 80, gld->win_h - 200);
1543 evas_object_resize(box1, 70, 70); 1542 evas_object_resize(box1, 70, 70);
1544 evas_object_show(box1); 1543 evas_object_show(box1);
@@ -1552,7 +1551,7 @@ EAPI_MAIN int elm_main(int argc, char **argv)
1552 ephysics_body_sleeping_threshold_set(box_body1, 0.1, 0.1); 1551 ephysics_body_sleeping_threshold_set(box_body1, 0.1, 0.1);
1553 1552
1554 box2 = elm_image_add(gld->win); 1553 box2 = elm_image_add(gld->win);
1555 elm_image_file_set(box2, PACKAGE_DATA_DIR "/media/" EPHYSICS_TEST_THEME ".edj", "purple-cube"); 1554 elm_image_file_set(box2, strdup(buf), "purple-cube");
1556 evas_object_move(box2, gld->win_w / 2 + 10, gld->win_h - 200); 1555 evas_object_move(box2, gld->win_w / 2 + 10, gld->win_h - 200);
1557 evas_object_resize(box2, 70, 70); 1556 evas_object_resize(box2, 70, 70);
1558 evas_object_show(box2); 1557 evas_object_show(box2);
diff --git a/src/extantz/extantz.h b/src/extantz/extantz.h
index afb94af..25b78cf 100644
--- a/src/extantz/extantz.h
+++ b/src/extantz/extantz.h
@@ -6,14 +6,8 @@
6#define USE_DEMO 1 6#define USE_DEMO 1
7#define DO_GEARS 0 7#define DO_GEARS 0
8 8
9#if USE_EO
10 /* Enable access to unstable EFL API that are still in beta */
11 #define EFL_BETA_API_SUPPORT 1
12 /* Enable access to unstable EFL EO API. */
13 #define EFL_EO_API_SUPPORT 1
14#endif
15 9
16#include <Elementary.h> 10#include "SledjHamr.h"
17#include <elm_widget_glview.h> 11#include <elm_widget_glview.h>
18#include <Evas_GL.h> 12#include <Evas_GL.h>
19#include <EPhysics.h> 13#include <EPhysics.h>
diff --git a/src/libraries/LumbrJack.c b/src/libraries/LumbrJack.c
new file mode 100644
index 0000000..084d916
--- /dev/null
+++ b/src/libraries/LumbrJack.c
@@ -0,0 +1,85 @@
1/* LumbrJack - a logging library that wraps Eina logging.
2
3*/
4
5
6#include "LumbrJack.h"
7
8
9static char dateTime[DATE_TIME_LEN];
10
11static void _ggg_log_print_cb(const Eina_Log_Domain *d, Eina_Log_Level level, const char *file, const char *fnc, int line, const char *fmt, void *data, va_list args)
12{
13 FILE *f = data;
14 char dt[DATE_TIME_LEN + 1];
15 char fileTab[256], funcTab[256];
16
17 getDateTime(NULL, dt, NULL);
18 dt[19] = '\0';
19 if (12 > strlen(file))
20 snprintf(fileTab, sizeof(fileTab), "%s\t\t", file);
21 else
22 snprintf(fileTab, sizeof(fileTab), "%s\t", file);
23 snprintf(funcTab, sizeof(funcTab), "\t%s", fnc);
24 fprintf(f, "%s ", dt);
25 if (f == stderr)
26 eina_log_print_cb_stderr(d, level, fileTab, funcTab, line, fmt, data, args);
27 else if (f == stdout)
28 eina_log_print_cb_stdout(d, level, fileTab, funcTab, line, fmt, data, args);
29 fflush(f);
30}
31
32int loggingStartup(char *name, int logDom)
33{
34 if (logDom < 0)
35 {
36 logDom = eina_log_domain_register(name, NULL);
37 if (logDom < 0)
38 {
39 EINA_LOG_CRIT("could not register log domain '%s'", name);
40 return logDom;
41 }
42 }
43 eina_log_level_set(EINA_LOG_LEVEL_DBG);
44 eina_log_domain_level_set(name, EINA_LOG_LEVEL_DBG);
45 eina_log_print_cb_set(_ggg_log_print_cb, stderr);
46
47 // Shut up the excess debugging shit from EFL.
48 eina_log_domain_level_set("eo", EINA_LOG_LEVEL_WARN);
49 eina_log_domain_level_set("eldbus", EINA_LOG_LEVEL_WARN);
50 eina_log_domain_level_set("eet", EINA_LOG_LEVEL_WARN);
51 eina_log_domain_level_set("ecore", EINA_LOG_LEVEL_WARN);
52 eina_log_domain_level_set("ecore_audio", EINA_LOG_LEVEL_WARN);
53 eina_log_domain_level_set("ecore_con", EINA_LOG_LEVEL_WARN);
54 eina_log_domain_level_set("ecore_evas", EINA_LOG_LEVEL_WARN);
55 eina_log_domain_level_set("ecore_input_evas", EINA_LOG_LEVEL_WARN);
56 eina_log_domain_level_set("ecore_input_evas", EINA_LOG_LEVEL_WARN);
57 eina_log_domain_level_set("ecore_system_upower", EINA_LOG_LEVEL_WARN);
58 eina_log_domain_level_set("eio", EINA_LOG_LEVEL_WARN);
59 eina_log_domain_level_set("evas_main", EINA_LOG_LEVEL_WARN);
60
61 return logDom;
62}
63
64char *getDateTime(struct tm **nowOut, char *dateOut, time_t *timeOut)
65{
66 struct tm *newTime;
67 time_t szClock;
68 char *date = dateTime;
69
70 // Get time in seconds
71 time(&szClock);
72 // Convert time to struct tm form
73 newTime = localtime(&szClock);
74
75 if (nowOut)
76 *nowOut = newTime;
77 if (dateOut)
78 date = dateOut;
79 if (timeOut)
80 *timeOut = szClock;
81
82 // format
83 strftime(date, DATE_TIME_LEN, "%d/%m/%Y %H:%M:%S\r", newTime);
84 return (dateTime);
85}
diff --git a/src/libraries/LumbrJack.h b/src/libraries/LumbrJack.h
new file mode 100644
index 0000000..4a3290c
--- /dev/null
+++ b/src/libraries/LumbrJack.h
@@ -0,0 +1,38 @@
1
2#include <stdio.h>
3#include <ctype.h>
4
5#include <Eina.h>
6
7
8#define PC(...) EINA_LOG_DOM_CRIT(ourGlobals->logDom, __VA_ARGS__)
9#define PE(...) EINA_LOG_DOM_ERR(ourGlobals->logDom, __VA_ARGS__)
10#define PW(...) EINA_LOG_DOM_WARN(ourGlobals->logDom, __VA_ARGS__)
11#define PD(...) EINA_LOG_DOM_DBG(ourGlobals->logDom, __VA_ARGS__)
12#define PI(...) EINA_LOG_DOM_INFO(ourGlobals->logDom, __VA_ARGS__)
13
14#define PCm(...) EINA_LOG_DOM_CRIT(ourGlobals.logDom, __VA_ARGS__)
15#define PEm(...) EINA_LOG_DOM_ERR(ourGlobals.logDom, __VA_ARGS__)
16#define PWm(...) EINA_LOG_DOM_WARN(ourGlobals.logDom, __VA_ARGS__)
17#define PDm(...) EINA_LOG_DOM_DBG(ourGlobals.logDom, __VA_ARGS__)
18#define PIm(...) EINA_LOG_DOM_INFO(ourGlobals.logDom, __VA_ARGS__)
19
20#define D() PD("DEBUG")
21
22
23// "01:03:52 01-01-1973\n\0"
24#define DATE_TIME_LEN 21
25
26
27#ifndef FALSE
28// NEVER change this
29typedef enum
30{
31 FALSE = 0,
32 TRUE = 1
33} boolean;
34#endif
35
36
37int loggingStartup(char *name, int logDom);
38char *getDateTime(struct tm **nowOut, char *dateOut, time_t *tiemOut);
diff --git a/src/libraries/Runnr.c b/src/libraries/Runnr.c
new file mode 100644
index 0000000..a24e7f5
--- /dev/null
+++ b/src/libraries/Runnr.c
@@ -0,0 +1,318 @@
1/* Runnr - a library that deals with running Lua scripts.
2
3*/
4
5
6#include "Runnr.h"
7
8
9void dumpStack(lua_State *L, int i)
10{
11 int type = lua_type(L, i);
12
13 switch (type)
14 {
15 case LUA_TNONE : printf("Stack %d is empty\n", i); break;
16 case LUA_TNIL : printf("Stack %d is a nil\n", i); break;
17 case LUA_TBOOLEAN : printf("Stack %d is a boolean - %d\n", i, lua_toboolean(L, i)); break;
18 case LUA_TNUMBER : printf("Stack %d is a number\n - %f", i, lua_tonumber(L, i)); break;
19 case LUA_TSTRING : printf("Stack %d is a string - %s\n", i, lua_tostring(L, i)); break;
20 case LUA_TFUNCTION : printf("Stack %d is a function\n", i); break;
21 case LUA_TTHREAD : printf("Stack %d is a thread\n", i); break;
22 case LUA_TTABLE :
23 {
24 int j;
25
26 printf("Stack %d is a table", i);
27 lua_getfield(L, i, "_NAME");
28 j = lua_gettop(L);
29 if (lua_isstring(L, j))
30 printf(" - %s", lua_tostring(L, j));
31 lua_pop(L, 1);
32 printf("\n");
33 break;
34 }
35 case LUA_TUSERDATA : printf("Stack %d is a userdata\n", i); break;
36 case LUA_TLIGHTUSERDATA : printf("Stack %d is a light userdata\n", i); break;
37 default : printf("Stack %d is unknown\n", i); break;
38 }
39}
40
41
42// These are what the various symbols are for each type -
43// int %
44// num #
45// str $
46// bool !
47// C func &
48// table.field @ Expects an integer and a string.
49// nil ~
50// table {} Starts and stops filling up a new table.
51// ( Just syntax sugar for call.
52// call ) Expects an integer, the number of results left after the call.
53// FIXME: Still to do, if we ever use them -
54// stack = Get a value from the stack, expects a stack index.
55// userdata +
56// lightuserdata *
57// thread ^
58
59static char *_push_name(lua_State *L, char *q, int *idx) // Stack usage [-0, +1, e or m]
60{
61 char *p = q;
62 char temp = '\0';
63
64 // A simplistic scan through an identifier, it's wrong, but it's quick,
65 // and we don't mind that it's wrong, coz this is only internal.
66 while (isalnum((int)*q))
67 q++;
68 temp = *q;
69 *q = '\0';
70 if (*idx > 0)
71 lua_getfield(L, *idx, p); // Stack usage [-0, +1, e]
72 else
73 {
74 if (p != q)
75 lua_pushstring(L, p); // Stack usage [-0, +1, m]
76 else
77 {
78 lua_pushnumber(L, (lua_Number) (0 - (*idx)));
79 (*idx)--;
80 }
81 }
82 *q = temp;
83
84 return q;
85}
86
87int pull_lua(lua_State *L, int i, char *params, ...) // Stack usage -
88 // if i is a table
89 // [-n, +n, e]
90 // else
91 // [-0, +0, -]
92{
93 va_list vl;
94 char *f = strdup(params);
95 char *p = f;
96 int n = 0, j = i, count = 0;
97 Eina_Bool table = EINA_FALSE;
98
99 if (!f) return -1;
100 va_start(vl, params);
101
102 if (lua_istable(L, i)) // Stack usage [-0, +0, -]
103 {
104 j = -1;
105 table = EINA_TRUE;
106 }
107
108 while (*p)
109 {
110 char *q;
111 Eina_Bool get = EINA_TRUE;
112
113 while (isspace((int)*p))
114 p++;
115 q = p + 1;
116 switch (*p)
117 {
118 case '%':
119 {
120 if (table) q = _push_name(L, q, &i); // Stack usage [-0, +1, e]
121 if (lua_isnumber(L, j)) // Stack usage [-0, +0, -]
122 {
123 int *v = va_arg(vl, int *);
124 *v = lua_tointeger(L, j); // Stack usage [-0, +0, -]
125 n++;
126 }
127 break;
128 }
129 case '#':
130 {
131 if (table) q = _push_name(L, q, &i); // Stack usage [-0, +1, e]
132 if (lua_isnumber(L, j)) // Stack usage [-0, +0, -]
133 {
134 double *v = va_arg(vl, double *);
135 *v = lua_tonumber(L, j); // Stack usage [-0, +0, -]
136 n++;
137 }
138 break;
139 }
140 case '$':
141 {
142 if (table) q = _push_name(L, q, &i); // Stack usage [-0, +1, e]
143 if (lua_isstring(L, j)) // Stack usage [-0, +0, -]
144 {
145 char **v = va_arg(vl, char **);
146 size_t len;
147 char *temp = (char *) lua_tolstring(L, j, &len); // Stack usage [-0, +0, m]
148
149 len++; // Cater for the null at the end.
150 *v = malloc(len);
151 if (*v)
152 {
153 memcpy(*v, temp, len);
154 n++;
155 }
156 }
157 break;
158 }
159 case '!':
160 {
161 if (table) q = _push_name(L, q, &i); // Stack usage [-0, +1, e]
162 if (lua_isboolean(L, j)) // Stack usage [-0, +0, -]
163 {
164 int *v = va_arg(vl, int *);
165 *v = lua_toboolean(L, j); // Stack usage [-0, +0, -]
166 n++;
167 }
168 break;
169 }
170 default:
171 {
172 get = EINA_FALSE;
173 break;
174 }
175 }
176
177 if (get)
178 {
179 if (table)
180 {
181 // If this is a table, then we pushed a value on the stack, pop it off.
182 lua_pop(L, 1); // Stack usage [-n, +0, -]
183 }
184 else
185 j++;
186 count++;
187 }
188 p = q;
189 }
190
191 va_end(vl);
192 free(f);
193 if (count > n)
194 n = 0;
195 else if (table)
196 n = 1;
197 return n;
198}
199
200int push_lua(lua_State *L, char *params, ...) // Stack usage [-0, +n, em]
201{
202 va_list vl;
203 char *f = strdup(params);
204 char *p = f;
205 int n = 0, table = 0, i = -1;
206
207 if (!f) return -1;
208
209 va_start(vl, params);
210
211 while (*p)
212 {
213 char *q;
214 Eina_Bool set = EINA_TRUE;
215
216 while (isspace((int)*p))
217 p++;
218 q = p + 1;
219 switch (*p)
220 {
221 case '%':
222 {
223 if (table) q = _push_name(L, q, &i); // Stack usage [-0, +1, m]
224 lua_pushinteger(L, va_arg(vl, int)); // Stack usage [-0, +1, -]
225 break;
226 }
227 case '#':
228 {
229 if (table) q = _push_name(L, q, &i); // Stack usage [-0, +1, m]
230 lua_pushnumber(L, va_arg(vl, double)); // Stack usage [-0, +1, -]
231 break;
232 }
233 case '$':
234 {
235 if (table) q = _push_name(L, q, &i); // Stack usage [-0, +1, m]
236 lua_pushstring(L, va_arg(vl, char *)); // Stack usage [-0, +1, m]
237 break;
238 }
239 case '!':
240 {
241 if (table) q = _push_name(L, q, &i); // Stack usage [-0, +1, m]
242 lua_pushboolean(L, va_arg(vl, int)); // Stack usage [-0, +1, -]
243 break;
244 }
245 case '=':
246 {
247 if (table) q = _push_name(L, q, &i); // Stack usage [-0, +1, m]
248 lua_pushvalue(L, va_arg(vl, int)); // Stack usage [-0, +1, -]
249 break;
250 }
251 case '@':
252 {
253 int tabl = va_arg(vl, int);
254 char *field = va_arg(vl, char *);
255
256 if (table) q = _push_name(L, q, &i); // Stack usage [-0, +1, m]
257 lua_getfield(L, tabl, field); // Stack usage [-0, +1, e]
258 break;
259 }
260 case '&':
261 {
262 if (table) q = _push_name(L, q, &i); // Stack usage [-0, +1, m]
263 lua_pushcfunction(L, va_arg(vl, void *)); // Stack usage [-0, +1, m]
264 break;
265 }
266 case '~':
267 {
268 if (table) q = _push_name(L, q, &i); // Stack usage [-0, +1, m]
269 lua_pushnil(L); // Stack usage [-0, +1, -]
270 break;
271 }
272 case '(': // Just syntax sugar.
273 {
274 set = EINA_FALSE;
275 break;
276 }
277 case ')':
278 {
279 lua_call(L, n - 1, va_arg(vl, int));
280 n = 0;
281 set = EINA_FALSE;
282 break;
283 }
284 case '{':
285 {
286 lua_newtable(L);
287 table++;
288 n++;
289 set = EINA_FALSE;
290 break;
291 }
292 case '}':
293 {
294 table--;
295 set = EINA_FALSE;
296 break;
297 }
298 default:
299 {
300 set = EINA_FALSE;
301 break;
302 }
303 }
304
305 if (set)
306 {
307 if (table > 0)
308 lua_settable(L, -3); // Stack usage [-2, +0, e]
309 else
310 n++;
311 }
312 p = q;
313 }
314
315 va_end(vl);
316 free(f);
317 return n;
318}
diff --git a/src/libraries/Runnr.h b/src/libraries/Runnr.h
new file mode 100644
index 0000000..dc720ff
--- /dev/null
+++ b/src/libraries/Runnr.h
@@ -0,0 +1,15 @@
1
2#include <stdio.h>
3#include <ctype.h>
4
5#include <Eina.h>
6
7#include <lua.h>
8#include <luajit.h>
9#include <lualib.h>
10#include <lauxlib.h>
11
12
13void dumpStack(lua_State *L, int i);
14int pull_lua(lua_State *L, int i, char *params, ...);
15int push_lua(lua_State *L, char *params, ...);
diff --git a/src/libraries/SledjHamr.c b/src/libraries/SledjHamr.c
new file mode 100644
index 0000000..aa68774
--- /dev/null
+++ b/src/libraries/SledjHamr.c
@@ -0,0 +1,23 @@
1#include "SledjHamr.h"
2
3void HamrTime(void *elm_main, char *domain)
4{
5 elm_app_compile_bin_dir_set(PACKAGE_BIN_DIR);
6 elm_app_compile_data_dir_set(PACKAGE_DATA_DIR);
7 elm_app_compile_lib_dir_set(PACKAGE_LIB_DIR);
8 elm_app_compile_locale_set(PACKAGE_LOCALE_DIR);
9 // Do this after the above calls, but before changing the working directory, or screwing with argv[0].
10 // It tries to set up the package paths depending on where the executable is, so things are relocatable.
11 // First argument is the elm_main() function that Elementary starts us from.
12 // Second argument should be a lower case string used as the "domain", which is different from the log domain.
13 // It's used lower case as part of the data directory path.
14 // So, if prefix is /usr/local, then the system data dir is /usr/local/share,
15 // and this apps data dir is /usr/local/share/"domain".
16 // It's used upper case as part of environment variables to override directory paths at run time.
17 // So "DOMAIN"_PREFIX, "DOMAIN"_BIN_DIR, "DOMAIN"_LIB_DIR, "DOMAIN"_DATA_DIR, and "DOMAIN"_LOCALE_DIR
18 // Third argument is the name of a file it can check for to make sure it found the correct path.
19 // This file is looked for in the data dir.
20 elm_app_info_set(elm_main, domain, "checkme.txt");
21 // Once this is all setup, the code can do -
22 // elm_app_prefix_dir_get(); // or bin, lib, data, locale.
23}
diff --git a/src/libraries/SledjHamr.h b/src/libraries/SledjHamr.h
new file mode 100644
index 0000000..893d90e
--- /dev/null
+++ b/src/libraries/SledjHamr.h
@@ -0,0 +1,14 @@
1
2#define EFL_API_OVERRIDE 1
3/* Enable access to unstable EFL API that are still in beta */
4#define EFL_BETA_API_SUPPORT 1
5/* Enable access to unstable EFL EO API. */
6#define EFL_EO_API_SUPPORT 1
7
8#include <stdio.h>
9#include <ctype.h>
10
11#include <Elementary.h>
12
13
14void HamrTime(void *elm_main, char *domain);
diff --git a/src/libraries/build.lua b/src/libraries/build.lua
new file mode 100755
index 0000000..6566e66
--- /dev/null
+++ b/src/libraries/build.lua
@@ -0,0 +1,33 @@
1#!/usr/bin/env lua
2
3local dir = ...
4
5if 'nil' == type(dir) then
6 local build, err = loadfile('../../build.lua')
7 if build then
8 setfenv(build, getfenv(2))
9 build(2)
10 else
11 print("ERROR - " .. err)
12 end
13 dir = workingDir
14end
15
16LDFLAGS = '-L ' .. dir .. ' ' .. LDFLAGS
17
18removeFiles(dir, {'LumbrJack.o', lib_d .. '/libLumbrJack.so', 'Runnr.o', lib_d .. '/libRunnr.so', 'SledjHamr.o', lib_d .. '/libSledjHamr.so'})
19
20runCommand('C libraries', dir, 'gcc ' .. CFLAGS .. ' -fPIC -c LumbrJack.c')
21runCommand(nil, dir, 'gcc ' .. CFLAGS .. ' -shared -Wl,-soname,libLumbrJack.so -o ' .. lib_d .. '/libLumbrJack.so LumbrJack.o')
22
23runCommand(nil, dir, 'gcc ' .. CFLAGS .. ' -fPIC -c Runnr.c')
24runCommand(nil, dir, 'gcc ' .. CFLAGS .. ' -shared -Wl,-soname,libRunnr.so -o ' .. lib_d .. '/libRunnr.so Runnr.o')
25
26-- For Elm apps, these are all centrally controlled in libSledjHamr.
27CFLAGS = CFLAGS .. ' -DPACKAGE_BIN_DIR=\\"' .. bin_d .. '\\"'
28CFLAGS = CFLAGS .. ' -DPACKAGE_LIB_DIR=\\"' .. lib_d .. '\\"'
29CFLAGS = CFLAGS .. ' -DPACKAGE_DATA_DIR=\\"' .. data_d .. '\\"'
30CFLAGS = CFLAGS .. ' -DPACKAGE_LOCALE_DIR=\\"' .. locale_d .. '\\"'
31
32runCommand(nil, dir, 'gcc ' .. CFLAGS .. ' -fPIC -c SledjHamr.c')
33runCommand(nil, dir, 'gcc ' .. CFLAGS .. ' -shared -Wl,-soname,libSledjHamr.so -o ' .. lib_d .. '/libSledjHamr.so SledjHamr.o')