aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/ClientHamr
diff options
context:
space:
mode:
authorDavid Walter Seikel2014-04-09 13:41:38 +1000
committerDavid Walter Seikel2014-04-09 13:41:38 +1000
commite4e750b9a749899f1eaa3b666381c39e9dc4bd7b (patch)
tree53559782b479e88b697a4b2ba4691ab269428367 /ClientHamr
parentMore notes! (diff)
downloadSledjHamr-e4e750b9a749899f1eaa3b666381c39e9dc4bd7b.zip
SledjHamr-e4e750b9a749899f1eaa3b666381c39e9dc4bd7b.tar.gz
SledjHamr-e4e750b9a749899f1eaa3b666381c39e9dc4bd7b.tar.bz2
SledjHamr-e4e750b9a749899f1eaa3b666381c39e9dc4bd7b.tar.xz
Make GuiLua an actual shared library, plus some minor clean ups.
Diffstat (limited to 'ClientHamr')
-rw-r--r--ClientHamr/GuiLua/GuiLua.c89
-rw-r--r--ClientHamr/GuiLua/GuiLua.h70
-rwxr-xr-xClientHamr/GuiLua/build.sh12
-rw-r--r--ClientHamr/GuiLua/skang.c11
-rw-r--r--ClientHamr/GuiLua/skang.lua12
-rw-r--r--ClientHamr/GuiLua/test.lua1
-rw-r--r--ClientHamr/GuiLua/test.properties2
-rwxr-xr-xClientHamr/GuiLua/test.sh3
-rw-r--r--ClientHamr/GuiLua/test_c.c9
9 files changed, 108 insertions, 101 deletions
diff --git a/ClientHamr/GuiLua/GuiLua.c b/ClientHamr/GuiLua/GuiLua.c
index 47b46ca..47f63d5 100644
--- a/ClientHamr/GuiLua/GuiLua.c
+++ b/ClientHamr/GuiLua/GuiLua.c
@@ -2,10 +2,8 @@
2 2
3Provides the skang and widget Lua packages. 3Provides the skang and widget Lua packages.
4 4
5This should be a library in the end, but for now it's just an 5In the initial intended use case, several applications will be using
6application that is a test bed for what goes into the library. In the 6this all at once, with one central app hosting all the GUIs.
7initial intended use case, several applications will be using this all at
8once, with one central app hosting all the GUIs.
9 7
10Basically this should deal with "windows" and their contents. A 8Basically this should deal with "windows" and their contents. A
11"window" in this case is hosted in the central app as some sort of 9"window" in this case is hosted in the central app as some sort of
@@ -43,10 +41,7 @@ Lua scripts do -
43 Seems simplest. 41 Seems simplest.
44 42
45 Also - 43 Also -
46 Most of what is in here becomes a library for dynamic linking to C code.
47 Pretty much just leaving main(), though most of what is in there right now should become another function.
48 Some of this gets shared with LuaSL, since it came from there anyway. 44 Some of this gets shared with LuaSL, since it came from there anyway.
49 Perhaps GuiLua.so will work, and I don't have to think of another name. lol
50 45
51 Finally - 46 Finally -
52 Add a --gui command line option, that runs foo.skang. 47 Add a --gui command line option, that runs foo.skang.
@@ -144,68 +139,15 @@ and ordinary elementary widgets. Proper introspection can come later.
144 139
145 140
146 141
147#include <Eet.h> 142#include "GuiLua.h"
148#include <Ecore.h>
149#include <Ecore_Evas.h>
150#include <Edje.h>
151#include <stdio.h>
152#include <ctype.h>
153
154#include <lua.h>
155#include <luajit.h>
156#include <lualib.h>
157#include <lauxlib.h>
158
159typedef struct _globals globals;
160
161
162#define WIDTH (300)
163#define HEIGHT (300)
164
165#define PC(...) EINA_LOG_DOM_CRIT(ourGlobals->logDom, __VA_ARGS__)
166#define PE(...) EINA_LOG_DOM_ERR(ourGlobals->logDom, __VA_ARGS__)
167#define PW(...) EINA_LOG_DOM_WARN(ourGlobals->logDom, __VA_ARGS__)
168#define PD(...) EINA_LOG_DOM_DBG(ourGlobals->logDom, __VA_ARGS__)
169#define PI(...) EINA_LOG_DOM_INFO(ourGlobals->logDom, __VA_ARGS__)
170
171#define PCm(...) EINA_LOG_DOM_CRIT(ourGlobals.logDom, __VA_ARGS__)
172#define PEm(...) EINA_LOG_DOM_ERR(ourGlobals.logDom, __VA_ARGS__)
173#define PWm(...) EINA_LOG_DOM_WARN(ourGlobals.logDom, __VA_ARGS__)
174#define PDm(...) EINA_LOG_DOM_DBG(ourGlobals.logDom, __VA_ARGS__)
175#define PIm(...) EINA_LOG_DOM_INFO(ourGlobals.logDom, __VA_ARGS__)
176
177#define D() PD("DEBUG")
178
179// "01:03:52 01-01-1973\n\0"
180#define DATE_TIME_LEN 21
181
182
183#ifndef FALSE
184// NEVER change this
185typedef enum
186{
187 FALSE = 0,
188 TRUE = 1
189} boolean;
190#endif
191
192struct _globals
193{
194 Ecore_Evas *ee; // Our window.
195 Evas *canvas; // The canvas for drawing directly onto.
196 Evas_Object *bg; // Our background edje.
197 lua_State *L; // Our Lua state.
198 int eina, logDom, ecore_evas, edje;
199};
200
201 globals ourGlobals;
202 143
144globals ourGlobals;
203 145
204static const char *ourName = "widget"; 146static const char *ourName = "widget";
205int skang, _M; 147static int skang, _M;
148
206 149
207/* 150void dumpStack(lua_State *L, int i)
208static void dumpStack(lua_State *L, int i)
209{ 151{
210 int type = lua_type(L, i); 152 int type = lua_type(L, i);
211 153
@@ -224,15 +166,8 @@ static void dumpStack(lua_State *L, int i)
224 default : printf("Stack %d is unknown\n", i); break; 166 default : printf("Stack %d is unknown\n", i); break;
225 } 167 }
226} 168}
227*/
228
229
230 169
231char *getDateTime(struct tm **nowOut, char *dateOut, time_t *tiemOut); 170static char dateTime[DATE_TIME_LEN];
232
233# define DATE_TIME_LEN 21
234
235char dateTime[DATE_TIME_LEN];
236 171
237static 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) 172static 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)
238{ 173{
@@ -307,13 +242,11 @@ char *getDateTime(struct tm **nowOut, char *dateOut, time_t *timeOut)
307} 242}
308 243
309 244
310
311static void _on_delete(Ecore_Evas *ee /*__UNUSED__*/) 245static void _on_delete(Ecore_Evas *ee /*__UNUSED__*/)
312{ 246{
313 ecore_main_loop_quit(); 247 ecore_main_loop_quit();
314} 248}
315 249
316
317static int openWindow(lua_State *L) 250static int openWindow(lua_State *L)
318{ 251{
319 globals *ourGlobals; 252 globals *ourGlobals;
@@ -487,10 +420,8 @@ int luaopen_widget(lua_State *L)
487 return 1; 420 return 1;
488} 421}
489 422
490 423void GuiLuaDo(int argc, char **argv)
491int main(int argc, char **argv)
492{ 424{
493 int result = EXIT_FAILURE;
494 lua_Number i; 425 lua_Number i;
495 426
496 memset(&ourGlobals, 0, sizeof(globals)); 427 memset(&ourGlobals, 0, sizeof(globals));
@@ -532,6 +463,4 @@ int main(int argc, char **argv)
532 } 463 }
533 else 464 else
534 fprintf(stderr, "Failed to start Lua!\n"); 465 fprintf(stderr, "Failed to start Lua!\n");
535
536 return result;
537} 466}
diff --git a/ClientHamr/GuiLua/GuiLua.h b/ClientHamr/GuiLua/GuiLua.h
new file mode 100644
index 0000000..1813966
--- /dev/null
+++ b/ClientHamr/GuiLua/GuiLua.h
@@ -0,0 +1,70 @@
1
2#include <Eet.h>
3#include <Ecore.h>
4#include <Ecore_Evas.h>
5#include <Edje.h>
6#include <stdio.h>
7#include <ctype.h>
8
9#include <lua.h>
10#include <luajit.h>
11#include <lualib.h>
12#include <lauxlib.h>
13
14typedef struct _globals globals;
15
16
17#define WIDTH (300)
18#define HEIGHT (300)
19
20#define PC(...) EINA_LOG_DOM_CRIT(ourGlobals->logDom, __VA_ARGS__)
21#define PE(...) EINA_LOG_DOM_ERR(ourGlobals->logDom, __VA_ARGS__)
22#define PW(...) EINA_LOG_DOM_WARN(ourGlobals->logDom, __VA_ARGS__)
23#define PD(...) EINA_LOG_DOM_DBG(ourGlobals->logDom, __VA_ARGS__)
24#define PI(...) EINA_LOG_DOM_INFO(ourGlobals->logDom, __VA_ARGS__)
25
26#define PCm(...) EINA_LOG_DOM_CRIT(ourGlobals.logDom, __VA_ARGS__)
27#define PEm(...) EINA_LOG_DOM_ERR(ourGlobals.logDom, __VA_ARGS__)
28#define PWm(...) EINA_LOG_DOM_WARN(ourGlobals.logDom, __VA_ARGS__)
29#define PDm(...) EINA_LOG_DOM_DBG(ourGlobals.logDom, __VA_ARGS__)
30#define PIm(...) EINA_LOG_DOM_INFO(ourGlobals.logDom, __VA_ARGS__)
31
32#define D() PD("DEBUG")
33
34// "01:03:52 01-01-1973\n\0"
35#define DATE_TIME_LEN 21
36
37
38#ifndef FALSE
39// NEVER change this
40typedef enum
41{
42 FALSE = 0,
43 TRUE = 1
44} boolean;
45#endif
46
47struct _globals
48{
49 Ecore_Evas *ee; // Our window.
50 Evas *canvas; // The canvas for drawing directly onto.
51 Evas_Object *bg; // Our background edje.
52 lua_State *L; // Our Lua state.
53 int eina, logDom, ecore_evas, edje;
54};
55
56// globals ourGlobals;
57
58
59void dumpStack(lua_State *L, int i);
60
61
62# define DATE_TIME_LEN 21
63
64//char dateTime[DATE_TIME_LEN];
65
66void loggingStartup(globals *ourGlobals);
67char *getDateTime(struct tm **nowOut, char *dateOut, time_t *tiemOut);
68
69int luaopen_widget(lua_State *L);
70void GuiLuaDo(int argc, char **argv);
diff --git a/ClientHamr/GuiLua/build.sh b/ClientHamr/GuiLua/build.sh
index 5c111e4..0ef46b9 100755
--- a/ClientHamr/GuiLua/build.sh
+++ b/ClientHamr/GuiLua/build.sh
@@ -12,7 +12,7 @@ else
12 export E17DIR="/usr" 12 export E17DIR="/usr"
13fi 13fi
14 14
15CFLAGS="-g -Wall -Wunreachable-code -I include -I $LOCALDIR" 15CFLAGS="-g -Wall -I include -I $LOCALDIR"
16CFLAGS="$CFLAGS -I ../../libraries" 16CFLAGS="$CFLAGS -I ../../libraries"
17#CFLAGS="$CFLAGS -I ../../libraries/LuaJIT-2.0.2/src" 17#CFLAGS="$CFLAGS -I ../../libraries/LuaJIT-2.0.2/src"
18CFLAGS="$CFLAGS $(pkg-config --cflags luajit)" 18CFLAGS="$CFLAGS $(pkg-config --cflags luajit)"
@@ -34,7 +34,7 @@ CFLAGS="$CFLAGS -DPACKAGE_DATA_DIR=\"$LOCALDIR\" $CFLAGOPTS"
34 34
35#LDFLAGS="-L ../../libraries/LuaJIT-2.0.2/src -L lib -L /usr/lib -L /lib -L $E17DIR/lib" 35#LDFLAGS="-L ../../libraries/LuaJIT-2.0.2/src -L lib -L /usr/lib -L /lib -L $E17DIR/lib"
36#libs="-leo -lecore -levas -ledje -lembryo -leet -leina -lluajit -lpthread -lm" 36#libs="-leo -lecore -levas -ledje -lembryo -leet -leina -lluajit -lpthread -lm"
37LDFLAGS="$(pkg-config --libs-only-L luajit) -L lib -L /usr/lib -L /lib -L $E17DIR/lib" 37LDFLAGS="-L $LOCALDIR $(pkg-config --libs-only-L luajit) -L lib -L /usr/lib -L /lib -L $E17DIR/lib"
38libs="-leo -lecore -levas -ledje -lembryo -leet -leina $(pkg-config --libs luajit) -lpthread -lm -ldl" 38libs="-leo -lecore -levas -ledje -lembryo -leet -leina $(pkg-config --libs luajit) -lpthread -lm -ldl"
39#LDFLAGS="-L /usr/lib/lua/5.1 -L lib -L /usr/lib -L /lib -L $E17DIR/lib" 39#LDFLAGS="-L /usr/lib/lua/5.1 -L lib -L /usr/lib -L /lib -L $E17DIR/lib"
40#libs="-lecore -levas -ledje -lembryo -leet -leina -llua5.1 -lpthread -lm" 40#libs="-lecore -levas -ledje -lembryo -leet -leina -llua5.1 -lpthread -lm"
@@ -49,7 +49,11 @@ libs="-leo -lecore -levas -ledje -lembryo -leet -leina $(pkg-config --libs luaji
49#-lz 49#-lz
50 50
51echo "clean" 51echo "clean"
52rm -f test_c.so test_c.o 52rm -f test_c.so GuiLua.o libGuiLua.so skang
53echo "C modules" 53echo "C modules"
54gcc $CFLAGS -fPIC -shared -o test_c.so test_c.c 54gcc $CFLAGS -fPIC -shared -o test_c.so test_c.c
55gcc $CFLAGS -o GuiLua GuiLua.c $LDFLAGS $libs 55gcc $CFLAGS -fPIC -c GuiLua.c
56echo "C libraries"
57gcc $CFLAGS -shared -Wl,-soname,libGuiLua.so -o libGuiLua.so GuiLua.o
58echo "C apps"
59gcc $CFLAGS -Wl,-export-dynamic -o skang skang.c $LDFLAGS -lGuiLua $libs
diff --git a/ClientHamr/GuiLua/skang.c b/ClientHamr/GuiLua/skang.c
new file mode 100644
index 0000000..ed92ff9
--- /dev/null
+++ b/ClientHamr/GuiLua/skang.c
@@ -0,0 +1,11 @@
1#include "GuiLua.h"
2
3
4int main(int argc, char **argv)
5{
6 int result = EXIT_FAILURE;
7
8 GuiLuaDo(argc, argv);
9
10 return result;
11}
diff --git a/ClientHamr/GuiLua/skang.lua b/ClientHamr/GuiLua/skang.lua
index e738a50..dec8983 100644
--- a/ClientHamr/GuiLua/skang.lua
+++ b/ClientHamr/GuiLua/skang.lua
@@ -1,7 +1,7 @@
1--[[ TODO - This should be in C, but so far development has been quite rapid doing it in Lua. 1--[[ TODO - This should be in C, but so far development has been quite rapid doing it in Lua.
2
2C will let us - 3C will let us -
3 Actually do the widget stuff. 4 Actually do the widget stuff.
4 Use Ecore's main loop.
5 Slap meta tables on all value types. 5 Slap meta tables on all value types.
6 Which lets us put the meta table on the variable, instead of on the table, which I think is cleaner. 6 Which lets us put the meta table on the variable, instead of on the table, which I think is cleaner.
7 Figure out the directory separator. 7 Figure out the directory separator.
@@ -907,6 +907,9 @@ copy = function (parent, name)
907 return result 907 return result
908end 908end
909 909
910module = function (name)
911 return require(name)
912end
910 913
911stuff = function (aThingy, aStuff) 914stuff = function (aThingy, aStuff)
912 return getmetatable(aThingy).__self.stuff[aStuff] 915 return getmetatable(aThingy).__self.stuff[aStuff]
@@ -954,11 +957,11 @@ set = function (stuff, key, name, value)
954 end 957 end
955end 958end
956 959
960thingasm('module,l', 'Load a module.', module, 'file')
957thingasm('get', 'Get the current value of an existing Thing or metadata.', get, 'thing,key,name') 961thingasm('get', 'Get the current value of an existing Thing or metadata.', get, 'thing,key,name')
958thingasm('reset', 'Reset the current value of an existing Thing or metadata.', reset, 'thing,key,name') 962thingasm('reset', 'Reset the current value of an existing Thing or metadata.', reset, 'thing,key,name')
959thingasm('set', 'Set the current value of an existing Thing or metadata.', set, 'thing,key,name,data') 963thingasm('set', 'Set the current value of an existing Thing or metadata.', set, 'thing,key,name,data')
960 964
961
962thingasm('nada', 'Do nothing.', function () --[[ This function intentionally left blank. ]] end) 965thingasm('nada', 'Do nothing.', function () --[[ This function intentionally left blank. ]] end)
963 966
964 967
@@ -968,10 +971,6 @@ end
968window = function (width, height, title) 971window = function (width, height, title)
969end 972end
970 973
971module = function (name)
972 return require(name)
973end
974
975skang = function (name) 974skang = function (name)
976end 975end
977quit = function () 976quit = function ()
@@ -979,7 +978,6 @@ end
979 978
980thingasm('clear', 'The current skin is cleared of all widgets.', clear) 979thingasm('clear', 'The current skin is cleared of all widgets.', clear)
981thingasm{'window', 'The size and title of the application Frame.', window, 'x,y,name', acl='GGG'} 980thingasm{'window', 'The size and title of the application Frame.', window, 'x,y,name', acl='GGG'}
982thingasm('module,l', 'Load a module.', module, 'file')
983thingasm('skang', 'Parse the contents of a skang file or URL.', skang, 'URL') 981thingasm('skang', 'Parse the contents of a skang file or URL.', skang, 'URL')
984thingasm('quit', 'Quit, exit, remove thyself.', quit) 982thingasm('quit', 'Quit, exit, remove thyself.', quit)
985 983
diff --git a/ClientHamr/GuiLua/test.lua b/ClientHamr/GuiLua/test.lua
index f45aff9..d484cf2 100644
--- a/ClientHamr/GuiLua/test.lua
+++ b/ClientHamr/GuiLua/test.lua
@@ -46,6 +46,7 @@ print(test.DEFAULT_SKANG)
46print('') 46print('')
47 47
48print('foo = ' .. test.foo .. ' ->> ' .. skang.get(test, 'foo', 'help')) 48print('foo = ' .. test.foo .. ' ->> ' .. skang.get(test, 'foo', 'help'))
49print('fooble = ' .. test.fooble)
49print('cfooble = ' .. test_c.cfooble .. ' ->> ' .. skang.get(test_c, 'cfooble', 'help') .. '[' .. skang.get(test_c, 'cfooble', 'widget') .. ']') 50print('cfooble = ' .. test_c.cfooble .. ' ->> ' .. skang.get(test_c, 'cfooble', 'help') .. '[' .. skang.get(test_c, 'cfooble', 'widget') .. ']')
50print('cfunc ->> ' .. skang.get(test_c, 'cfunc', 'help')) 51print('cfunc ->> ' .. skang.get(test_c, 'cfunc', 'help'))
51test.ffunc('one', 2) 52test.ffunc('one', 2)
diff --git a/ClientHamr/GuiLua/test.properties b/ClientHamr/GuiLua/test.properties
index d6d29cb..71a371d 100644
--- a/ClientHamr/GuiLua/test.properties
+++ b/ClientHamr/GuiLua/test.properties
@@ -1 +1 @@
foo = 'forty two' fooble = 'forty two'
diff --git a/ClientHamr/GuiLua/test.sh b/ClientHamr/GuiLua/test.sh
new file mode 100755
index 0000000..4f72c52
--- /dev/null
+++ b/ClientHamr/GuiLua/test.sh
@@ -0,0 +1,3 @@
1#!/bin/bash
2
3export LD_LIBRARY_PATH="."; ./skang -l test -foo "argy bargy"
diff --git a/ClientHamr/GuiLua/test_c.c b/ClientHamr/GuiLua/test_c.c
index e4ca278..6faf928 100644
--- a/ClientHamr/GuiLua/test_c.c
+++ b/ClientHamr/GuiLua/test_c.c
@@ -1,14 +1,5 @@
1/* Should be a Lua skang module, roughly the same as test.lua 1/* Should be a Lua skang module, roughly the same as test.lua
2 2
3TODO - See if this still works if it's an app instead of a library.
4 I think the problem will be duplicate Lua library names.
5 The C app will be linked to one copy, the lua executable that require() this is linked to another, even if it's the same one.
6 Much hilarity ensues.
7 Not to mention linker flags being different.
8
9 Plan B -
10 Widget skang module runs the window app, and sends stuff to it.
11
12Seems to be several problems with linking in various OSes, here's some 3Seems to be several problems with linking in various OSes, here's some
13possibly helpful links - 4possibly helpful links -
14 5