diff options
Diffstat (limited to 'src/LuaSL')
-rw-r--r-- | src/LuaSL/LuaSL.edc | 205 | ||||
-rw-r--r-- | src/LuaSL/LuaSL_test.c | 468 | ||||
-rwxr-xr-x | src/LuaSL/build.lua | 5 | ||||
-rwxr-xr-x | src/LuaSL/test.sh | 4 |
4 files changed, 3 insertions, 679 deletions
diff --git a/src/LuaSL/LuaSL.edc b/src/LuaSL/LuaSL.edc deleted file mode 100644 index 844fc8e..0000000 --- a/src/LuaSL/LuaSL.edc +++ /dev/null | |||
@@ -1,205 +0,0 @@ | |||
1 | color_classes { | ||
2 | color_class { name: "test_colour"; color: 255 255 255 255; } | ||
3 | } | ||
4 | |||
5 | //fonts { | ||
6 | // font: "Vera.ttf" "default"; | ||
7 | //} | ||
8 | |||
9 | images { | ||
10 | image: "bubble.png" COMP; | ||
11 | image: "test.png" COMP; | ||
12 | } | ||
13 | |||
14 | collections { | ||
15 | group { | ||
16 | name: "main"; | ||
17 | lua_script_only: 1; | ||
18 | lua_script { | ||
19 | --// stick object private/local vars here | ||
20 | local D; | ||
21 | local text_geom; | ||
22 | |||
23 | --// init object here | ||
24 | D = {}; --// data is empty table to start | ||
25 | |||
26 | --// send some random edje message | ||
27 | edje.messagesend(7, "none" ); | ||
28 | edje.messagesend(7, "sig", "signal", "source"); | ||
29 | edje.messagesend(7, "str", "hello world"); | ||
30 | edje.messagesend(7, "int", 987); | ||
31 | edje.messagesend(7, "float", 987.321); | ||
32 | edje.messagesend(7, "strset", {"hello", "there", "world"}); | ||
33 | edje.messagesend(7, "intset", {1, 2, 3}); | ||
34 | edje.messagesend(7, "floatset", {1.1, 2.2, 3.3}); | ||
35 | edje.messagesend(7, "strint", "hello world", 7); | ||
36 | edje.messagesend(7, "strfloat", "hello world", 7.654); | ||
37 | edje.messagesend(7, "strintset","hello world", {1, 2, 3}); | ||
38 | |||
39 | D.edje = edje.edje(); | ||
40 | D.edje:file("plain/edje/group"); | ||
41 | D.edje:show(); | ||
42 | |||
43 | D.text = edje.text(); | ||
44 | D.text:geom (50, 5, 150, 50); | ||
45 | D.text:color (255, 0, 0, 255); | ||
46 | D.text:font("Sans:style=Bold", 32); | ||
47 | D.text:text("Lua rocks!"); | ||
48 | text_geom = D.text:geom(); | ||
49 | --// print(D.text:text()); | ||
50 | D.text:show(); | ||
51 | |||
52 | |||
53 | --// shutdown func - generally empty or not there. everything garbage collected for you | ||
54 | function shutdown () | ||
55 | --// print("lua::shutdown"); | ||
56 | end | ||
57 | |||
58 | function show () | ||
59 | --// print("lua::show"); | ||
60 | end | ||
61 | |||
62 | function hide () | ||
63 | --// print("lua::hide"); | ||
64 | end | ||
65 | |||
66 | function move (x, y) | ||
67 | --// print("lua::move x=" .. x .. " x=" .. y); | ||
68 | D.edje:move(0, 0); | ||
69 | end | ||
70 | |||
71 | function resize (w, h) | ||
72 | --// print("lua::resize w=" .. w .. " h=" .. h); | ||
73 | D.text:move((w - text_geom.w) / 2, (h - text_geom.h) / 8); | ||
74 | D.edje:resize(w, h); | ||
75 | end | ||
76 | |||
77 | function message (id, type, ...) | ||
78 | print("lua::message id=" .. id .. " type=" .. type); | ||
79 | --// handle your message type here. check id + type then use the | ||
80 | --// vararg appropriately. they are the same as the params passed | ||
81 | --// to edje:messagesend() (if any are passed at all). Any array | ||
82 | --// arguments are passed as a single table. | ||
83 | |||
84 | if ("none" == type) then | ||
85 | print("lua::message no args"); | ||
86 | elseif ("strset" == type) then | ||
87 | strs = ... ; | ||
88 | print_table_start(strs, "", "lua::message strings"); | ||
89 | elseif ("intset" == type) then | ||
90 | ints = ... ; | ||
91 | print_table_start(ints, "", "lua::message ints"); | ||
92 | elseif ("floatset" == type) then | ||
93 | floats = ... ; | ||
94 | print_table_start(floats, "", "lua::message floats"); | ||
95 | elseif ("strintset" == type) then | ||
96 | str, ints = ... ; | ||
97 | print("lua::message " .. str); | ||
98 | print_table_start(ints, "", "lua::message ints"); | ||
99 | elseif ("strfloatset" == type) then | ||
100 | str, floats = ... ; | ||
101 | print("lua::message " .. str); | ||
102 | print_table_start(floats, "", "lua::message floats"); | ||
103 | else | ||
104 | print("lua::message " .. ... ); | ||
105 | end | ||
106 | end | ||
107 | |||
108 | function signal (sig, src) | ||
109 | print("lua::signal sig= " .. sig .. " src= " .. src); | ||
110 | end | ||
111 | } | ||
112 | } | ||
113 | |||
114 | // The group name NEEDS a / in it, | ||
115 | // or the part below that tries to swallow it won't work. | ||
116 | // Leaving just the lua part visible. | ||
117 | group { | ||
118 | name: "bubbles/lua"; | ||
119 | lua_script_only: 1; | ||
120 | lua_script { | ||
121 | local bubbles = { }; | ||
122 | local bubbleCols = 8; | ||
123 | local bubbleRows = 6; | ||
124 | |||
125 | for i = 1, bubbleRows do | ||
126 | row = { }; | ||
127 | for j = 1, bubbleCols do | ||
128 | image = edje.image(); | ||
129 | image:image("bubble.png"); | ||
130 | image:show(); | ||
131 | table.insert(row, image); | ||
132 | end | ||
133 | table.insert(bubbles, row); | ||
134 | end | ||
135 | |||
136 | function resize (w, h) | ||
137 | for i = 1, bubbleRows do | ||
138 | for j = 1, bubbleCols do | ||
139 | w1 = w / bubbleCols; | ||
140 | h1 = h / bubbleRows; | ||
141 | bubbles[i][j]:geom((j - 1) * w1, (i - 1) * h1, w1, h1); | ||
142 | if ((1 == i) or (1 == j) or (bubbleRows == i) or (bubbleCols == j)) then | ||
143 | bubbles[i][j]:color(0, 255, 0, 200); | ||
144 | else | ||
145 | bubbles[i][j]:color(math.random(200) + 55, 0, math.random(255) + 55, 200); | ||
146 | end | ||
147 | end | ||
148 | end | ||
149 | end | ||
150 | } | ||
151 | } | ||
152 | |||
153 | group { | ||
154 | name: "plain/edje/group"; | ||
155 | parts { | ||
156 | part { | ||
157 | name: "background"; | ||
158 | type: RECT; | ||
159 | mouse_events: 0; | ||
160 | description { | ||
161 | state: "default" 0.0; | ||
162 | color: 0 0 0 255; | ||
163 | } | ||
164 | } | ||
165 | |||
166 | // A lua group embedded in an edje group. | ||
167 | part { | ||
168 | name: "bubbles_lua"; | ||
169 | type: GROUP; | ||
170 | source: "bubbles/lua"; | ||
171 | mouse_events: 0; | ||
172 | description { state: "default" 0.0; } | ||
173 | } | ||
174 | |||
175 | part { | ||
176 | name: "background_image"; | ||
177 | type: IMAGE; | ||
178 | mouse_events: 0; | ||
179 | description { | ||
180 | state: "default" 0.0; | ||
181 | aspect_preference: HORIZONTAL; | ||
182 | color_class: "test_colour"; | ||
183 | image { normal: "test.png"; } | ||
184 | } | ||
185 | } | ||
186 | |||
187 | part { | ||
188 | name: "some_text"; | ||
189 | type: TEXT; | ||
190 | mouse_events: 0; | ||
191 | description { | ||
192 | state: "default" 0; | ||
193 | text | ||
194 | { | ||
195 | text: "This is test text."; | ||
196 | text_class: "test_text_class"; | ||
197 | } | ||
198 | } | ||
199 | } | ||
200 | |||
201 | } | ||
202 | } | ||
203 | |||
204 | } | ||
205 | |||
diff --git a/src/LuaSL/LuaSL_test.c b/src/LuaSL/LuaSL_test.c deleted file mode 100644 index 8fc86c0..0000000 --- a/src/LuaSL/LuaSL_test.c +++ /dev/null | |||
@@ -1,468 +0,0 @@ | |||
1 | |||
2 | #include "LuaSL.h" | ||
3 | |||
4 | |||
5 | int logDom; // Our logging domain. | ||
6 | static Eina_Strbuf *clientStream; | ||
7 | static int scriptCount = 0; | ||
8 | static int compiledCount = 0; | ||
9 | static float compileTime = 0.0; | ||
10 | static struct timeval startTime; | ||
11 | static int timedEvent = 0; | ||
12 | static char *ownerKey = "12345678-1234-4321-abcd-0123456789ab"; | ||
13 | static char *ownerName = "onefang rejected"; | ||
14 | |||
15 | static const char *names[] = | ||
16 | { | ||
17 | "bub1", "sh1", | ||
18 | "bub2", "sh2", | ||
19 | "bub3", "sh3", | ||
20 | }; | ||
21 | |||
22 | |||
23 | static void | ||
24 | _edje_signal_cb(void *data, Evas_Object *obj __UNUSED__, const char *emission, const char *source) | ||
25 | { | ||
26 | // gameGlobals *ourGlobals = data; | ||
27 | } | ||
28 | |||
29 | static | ||
30 | Eina_Bool anim(void *data) | ||
31 | { | ||
32 | gameGlobals *ourGlobals = data; | ||
33 | Evas_Object *bub, *sh; | ||
34 | Evas_Coord x, y, w, h, vw, vh; | ||
35 | double t, xx, yy, zz, r, fac; | ||
36 | double lx, ly; | ||
37 | unsigned int i; | ||
38 | |||
39 | evas_output_viewport_get(ourGlobals->canvas, 0, 0, &vw, &vh); | ||
40 | r = 48; | ||
41 | t = ecore_loop_time_get(); | ||
42 | fac = 2.0 / (double)((sizeof(names) / sizeof(char *) / 2)); | ||
43 | evas_pointer_canvas_xy_get(ourGlobals->canvas, &x, &y); | ||
44 | lx = x; | ||
45 | ly = y; | ||
46 | |||
47 | for (i = 0; i < (sizeof(names) / sizeof(char *) / 2); i++) | ||
48 | { | ||
49 | bub = evas_object_data_get(ourGlobals->bg, names[i * 2]); | ||
50 | sh = evas_object_data_get(ourGlobals->bg, names[(i * 2) + 1]); | ||
51 | zz = (((2 + sin(t * 6 + (M_PI * (i * fac)))) / 3) * 64) * 2; | ||
52 | xx = (cos(t * 4 + (M_PI * (i * fac))) * r) * 2; | ||
53 | yy = (sin(t * 6 + (M_PI * (i * fac))) * r) * 2; | ||
54 | |||
55 | w = zz; | ||
56 | h = zz; | ||
57 | x = (vw / 2) + xx - (w / 2); | ||
58 | y = (vh / 2) + yy - (h / 2); | ||
59 | |||
60 | evas_object_move(bub, x, y); | ||
61 | evas_object_resize(bub, w, h); | ||
62 | |||
63 | x = x - ((lx - (x + (w / 2))) / 4); | ||
64 | y = y - ((ly - (y + (h / 2))) / 4); | ||
65 | |||
66 | evas_object_move(sh, x, y); | ||
67 | evas_object_resize(sh, w, h); | ||
68 | evas_object_raise(sh); | ||
69 | evas_object_raise(bub); | ||
70 | } | ||
71 | return ECORE_CALLBACK_RENEW; | ||
72 | } | ||
73 | |||
74 | static void | ||
75 | _on_delete(Ecore_Evas *ee __UNUSED__) | ||
76 | { | ||
77 | ecore_main_loop_quit(); | ||
78 | } | ||
79 | |||
80 | static void dirList_compile(const char *name, const char *path, void *data) | ||
81 | { | ||
82 | gameGlobals *ourGlobals = data; | ||
83 | |||
84 | char *ext = rindex(name, '.'); | ||
85 | |||
86 | if (ext) | ||
87 | { | ||
88 | if (0 == strcmp(ext, ".lsl")) | ||
89 | { | ||
90 | script *me = calloc(1, sizeof(script)); | ||
91 | |||
92 | scriptCount++; | ||
93 | gettimeofday(&me->startTime, NULL); | ||
94 | snprintf(me->SID, sizeof(me->SID), "%08lx-%04lx-%04lx-%04lx-%012lx", random(), random() % 0xFFFF, random() % 0xFFFF, random() % 0xFFFF, random()); | ||
95 | snprintf(me->fileName, sizeof(me->fileName), "%s/%s", path, name); | ||
96 | eina_hash_add(ourGlobals->scripts, me->SID, me); | ||
97 | sendForth(ourGlobals, me->SID, "compile(%s)", me->fileName); | ||
98 | } | ||
99 | } | ||
100 | } | ||
101 | |||
102 | static Eina_Bool _timer_cb(void *data) | ||
103 | { | ||
104 | gameGlobals *ourGlobals = data; | ||
105 | Eina_Iterator *scripts; | ||
106 | script *me; | ||
107 | boolean exit = FALSE; | ||
108 | |||
109 | scripts = eina_hash_iterator_data_new(ourGlobals->scripts); | ||
110 | while(eina_iterator_next(scripts, (void **) &me)) | ||
111 | { | ||
112 | switch (timedEvent) | ||
113 | { | ||
114 | case 5 : | ||
115 | { | ||
116 | sendForth(ourGlobals, me->SID, "events.detectedKeys({\"%s\"})", ownerKey); | ||
117 | sendForth(ourGlobals, me->SID, "events.detectedNames({\"%s\"})", ownerName); | ||
118 | sendForth(ourGlobals, me->SID, "events.touch_start(1)"); | ||
119 | break; | ||
120 | } | ||
121 | case 9 : | ||
122 | { | ||
123 | sendForth(ourGlobals, me->SID, "quit()"); | ||
124 | break; | ||
125 | } | ||
126 | case 11 : | ||
127 | { | ||
128 | exit = TRUE; | ||
129 | break; | ||
130 | } | ||
131 | } | ||
132 | } | ||
133 | timedEvent++; | ||
134 | |||
135 | if (exit) | ||
136 | { | ||
137 | sendForth(ourGlobals, ownerKey, "exit()"); | ||
138 | ecore_main_loop_quit(); | ||
139 | return ECORE_CALLBACK_CANCEL; | ||
140 | } | ||
141 | return ECORE_CALLBACK_RENEW; | ||
142 | } | ||
143 | |||
144 | static Eina_Bool _add(void *data, int type __UNUSED__, Ecore_Con_Event_Server_Add *ev) | ||
145 | { | ||
146 | gameGlobals *ourGlobals = data; | ||
147 | char buf[PATH_MAX]; | ||
148 | |||
149 | ourGlobals->server = ev->server; | ||
150 | gettimeofday(&startTime, NULL); | ||
151 | snprintf(buf, sizeof(buf), "%s/Test sim/objects", PACKAGE_DATA_DIR); | ||
152 | eina_file_dir_list(buf, EINA_TRUE, dirList_compile, ourGlobals); | ||
153 | // Wait awhile, then start sending events for testing. | ||
154 | ecore_timer_add(0.5, _timer_cb, ourGlobals); | ||
155 | return ECORE_CALLBACK_RENEW; | ||
156 | } | ||
157 | |||
158 | static Eina_Bool _data(void *data, int type __UNUSED__, Ecore_Con_Event_Server_Data *ev) | ||
159 | { | ||
160 | gameGlobals *ourGlobals = data; | ||
161 | |||
162 | char buf[PATH_MAX]; | ||
163 | char SID[PATH_MAX]; | ||
164 | const char *command; | ||
165 | char *ext; | ||
166 | |||
167 | eina_strbuf_append_length(clientStream, ev->data, ev->size); | ||
168 | command = eina_strbuf_string_get(clientStream); | ||
169 | while ((ext = index(command, '\n'))) | ||
170 | { | ||
171 | int length = ext - command; | ||
172 | |||
173 | strncpy(SID, command, length + 1); | ||
174 | SID[length] = '\0'; | ||
175 | eina_strbuf_remove(clientStream, 0, length + 1); | ||
176 | ext = index(SID, '.'); | ||
177 | if (ext) | ||
178 | { | ||
179 | script *me; | ||
180 | |||
181 | ext[0] = '\0'; | ||
182 | command = ext + 1; | ||
183 | me = eina_hash_find(ourGlobals->scripts, SID); | ||
184 | if (0 == strncmp(command, "compilerWarning(", 16)) | ||
185 | { | ||
186 | char *temp; | ||
187 | char *line; | ||
188 | char *column; | ||
189 | char *text; | ||
190 | |||
191 | strcpy(buf, &command[16]); | ||
192 | temp = buf; | ||
193 | line = temp; | ||
194 | while (',' != temp[0]) | ||
195 | temp++; | ||
196 | temp[0] = '\0'; | ||
197 | column = ++temp; | ||
198 | while (',' != temp[0]) | ||
199 | temp++; | ||
200 | temp[0] = '\0'; | ||
201 | text = ++temp; | ||
202 | while (')' != temp[0]) | ||
203 | temp++; | ||
204 | temp[0] = '\0'; | ||
205 | PW("%s @ line %s, column %s.", text, line, column); | ||
206 | if (me) | ||
207 | me->warnings++; | ||
208 | } | ||
209 | else if (0 == strncmp(command, "compilerError(", 14)) | ||
210 | { | ||
211 | char *temp; | ||
212 | char *line; | ||
213 | char *column; | ||
214 | char *text; | ||
215 | |||
216 | strcpy(buf, &command[14]); | ||
217 | temp = buf; | ||
218 | line = temp; | ||
219 | while (',' != temp[0]) | ||
220 | temp++; | ||
221 | temp[0] = '\0'; | ||
222 | column = ++temp; | ||
223 | while (',' != temp[0]) | ||
224 | temp++; | ||
225 | temp[0] = '\0'; | ||
226 | text = ++temp; | ||
227 | while (')' != temp[0]) | ||
228 | temp++; | ||
229 | temp[0] = '\0'; | ||
230 | PE("%s @ line %s, column %s.", text, line, column); | ||
231 | if (me) | ||
232 | me->bugs++; | ||
233 | } | ||
234 | else if (0 == strcmp(command, "compiled(false)")) | ||
235 | PE("The compile of %s failed!", SID); | ||
236 | else if (0 == strcmp(command, "compiled(true)")) | ||
237 | { | ||
238 | if (me) | ||
239 | { | ||
240 | struct timeval now; | ||
241 | |||
242 | me->compileTime = timeDiff(&now, &me->startTime); | ||
243 | me->running = TRUE; | ||
244 | compiledCount++; | ||
245 | compileTime += me->compileTime; | ||
246 | // PD("Average compile speed is %f scripts per second", compiledCount / compileTime); | ||
247 | if (compiledCount == scriptCount) | ||
248 | PD("TOTAL compile speed is %f scripts per second", compiledCount / timeDiff(&now, &startTime)); | ||
249 | } | ||
250 | // PD("The compile of %s worked, running it now.", SID); | ||
251 | sendForth(ourGlobals, SID, "run()"); | ||
252 | } | ||
253 | else | ||
254 | { | ||
255 | // Send back some random or fixed values for testing. | ||
256 | if (0 == strcmp(command, "llGetKey()")) | ||
257 | sendForth(ourGlobals, SID, "return \"%08lx-%04lx-%04lx-%04lx-%012lx\"", random(), random() % 0xFFFF, random() % 0xFFFF, random() % 0xFFFF, random()); | ||
258 | else if (0 == strcmp(command, "llGetOwner()")) | ||
259 | sendForth(ourGlobals, SID, "return \"%s\"", ownerKey); | ||
260 | else if (0 == strcmp(command, "llGetPos()")) | ||
261 | sendForth(ourGlobals, SID, "return {x=128.0, y=128.0, z=128.0}"); | ||
262 | else if (0 == strcmp(command, "llGetRot()")) | ||
263 | sendForth(ourGlobals, SID, "return {x=0.0, y=0.0, z=0.0, s=1.0}"); | ||
264 | else if (0 == strcmp(command, "llGetObjectDesc()")) | ||
265 | sendForth(ourGlobals, SID, "return \"\""); | ||
266 | else if (0 == strncmp(command, "llGetAlpha(", 11)) | ||
267 | sendForth(ourGlobals, SID, "return 1.0"); | ||
268 | else if (0 == strcmp(command, "llGetInventoryNumber(7)")) | ||
269 | sendForth(ourGlobals, SID, "return 3"); | ||
270 | else if (0 == strcmp(command, "llGetInventoryName(7, 2)")) | ||
271 | sendForth(ourGlobals, SID, "return \".readme\""); | ||
272 | else if (0 == strcmp(command, "llGetInventoryName(7, 1)")) | ||
273 | sendForth(ourGlobals, SID, "return \".POSITIONS\""); | ||
274 | else if (0 == strcmp(command, "llGetInventoryName(7, 0)")) | ||
275 | sendForth(ourGlobals, SID, "return \".MENUITEMS\""); | ||
276 | else | ||
277 | PI("Script %s sent command %s", SID, command); | ||
278 | } | ||
279 | } | ||
280 | |||
281 | // Get the next blob to check it. | ||
282 | command = eina_strbuf_string_get(clientStream); | ||
283 | } | ||
284 | |||
285 | return ECORE_CALLBACK_RENEW; | ||
286 | } | ||
287 | |||
288 | static Eina_Bool _del(void *data, int type __UNUSED__, Ecore_Con_Event_Server_Del *ev) | ||
289 | { | ||
290 | gameGlobals *ourGlobals = data; | ||
291 | |||
292 | if (ev->server) | ||
293 | { | ||
294 | ourGlobals->server = NULL; | ||
295 | ecore_con_server_del(ev->server); | ||
296 | if (!ourGlobals->ui) | ||
297 | ecore_main_loop_quit(); | ||
298 | } | ||
299 | |||
300 | return ECORE_CALLBACK_RENEW; | ||
301 | } | ||
302 | |||
303 | int main(int argc, char **argv) | ||
304 | { | ||
305 | /* put here any init specific to this app like parsing args etc. */ | ||
306 | gameGlobals ourGlobals; | ||
307 | char *programName = argv[0]; | ||
308 | boolean badArgs = FALSE; | ||
309 | int result = EXIT_FAILURE; | ||
310 | |||
311 | memset(&ourGlobals, 0, sizeof(gameGlobals)); | ||
312 | ourGlobals.address = "127.0.0.1"; | ||
313 | ourGlobals.port = 8211; | ||
314 | |||
315 | if (eina_init()) | ||
316 | { | ||
317 | logDom = loggingStartup("LuaSL_test", logDom); | ||
318 | ourGlobals.scripts = eina_hash_string_superfast_new(NULL); | ||
319 | |||
320 | if (ecore_con_init()) | ||
321 | { | ||
322 | if ((ourGlobals.server = ecore_con_server_connect(ECORE_CON_REMOTE_TCP, ourGlobals.address, ourGlobals.port, &ourGlobals))) | ||
323 | { | ||
324 | ecore_event_handler_add(ECORE_CON_EVENT_SERVER_ADD, (Ecore_Event_Handler_Cb) _add, &ourGlobals); | ||
325 | ecore_event_handler_add(ECORE_CON_EVENT_SERVER_DATA, (Ecore_Event_Handler_Cb) _data, &ourGlobals); | ||
326 | ecore_event_handler_add(ECORE_CON_EVENT_SERVER_DEL, (Ecore_Event_Handler_Cb) _del, &ourGlobals); | ||
327 | clientStream = eina_strbuf_new(); | ||
328 | |||
329 | if (ecore_evas_init()) | ||
330 | { | ||
331 | if (edje_init()) | ||
332 | { | ||
333 | // get the arguments passed in | ||
334 | while (--argc > 0 && *++argv != '\0') | ||
335 | { | ||
336 | if (*argv[0] == '-') | ||
337 | { | ||
338 | // point to the characters after the '-' sign | ||
339 | char *s = argv[0] + 1; | ||
340 | |||
341 | switch (*s) | ||
342 | { | ||
343 | case 'u': | ||
344 | { | ||
345 | ourGlobals.ui = TRUE; | ||
346 | break; | ||
347 | } | ||
348 | default: | ||
349 | badArgs = TRUE; | ||
350 | } | ||
351 | } | ||
352 | else | ||
353 | badArgs = TRUE; | ||
354 | } | ||
355 | |||
356 | if (badArgs) | ||
357 | { | ||
358 | // display the program usage to the user as they have it wrong | ||
359 | printf("Usage: %s [-u]\n", programName); | ||
360 | printf(" -u: Show the test UI.\n"); | ||
361 | } | ||
362 | else | ||
363 | // else if ((ourGlobals.config) && (ourGlobals.data)) | ||
364 | { | ||
365 | unsigned int i; | ||
366 | Evas_Object *bub, *sh; | ||
367 | Ecore_Animator *ani; | ||
368 | char *group = "main"; | ||
369 | char buf[PATH_MAX]; | ||
370 | |||
371 | if (ourGlobals.ui) | ||
372 | { | ||
373 | /* this will give you a window with an Evas canvas under the first engine available */ | ||
374 | ourGlobals.ee = ecore_evas_new(NULL, 0, 0, WIDTH, HEIGHT, NULL); | ||
375 | if (!ourGlobals.ee) | ||
376 | { | ||
377 | PE("You got to have at least one evas engine built and linked up to ecore-evas for this example to run properly."); | ||
378 | edje_shutdown(); | ||
379 | ecore_evas_shutdown(); | ||
380 | return -1; | ||
381 | } | ||
382 | ourGlobals.canvas = ecore_evas_get(ourGlobals.ee); | ||
383 | ecore_evas_title_set(ourGlobals.ee, "LuaSL test harness"); | ||
384 | ecore_evas_show(ourGlobals.ee); | ||
385 | |||
386 | ourGlobals.bg = evas_object_rectangle_add(ourGlobals.canvas); | ||
387 | evas_object_color_set(ourGlobals.bg, 255, 255, 255, 255); /* white bg */ | ||
388 | evas_object_move(ourGlobals.bg, 0, 0); /* at canvas' origin */ | ||
389 | evas_object_size_hint_weight_set(ourGlobals.bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); | ||
390 | evas_object_resize(ourGlobals.bg, WIDTH, HEIGHT); /* covers full canvas */ | ||
391 | evas_object_show(ourGlobals.bg); | ||
392 | ecore_evas_object_associate(ourGlobals.ee, ourGlobals.bg, ECORE_EVAS_OBJECT_ASSOCIATE_BASE); | ||
393 | evas_object_focus_set(ourGlobals.bg, EINA_TRUE); | ||
394 | |||
395 | ourGlobals.edje = edje_object_add(ourGlobals.canvas); | ||
396 | snprintf(buf, sizeof(buf), "%s/%s.edj", PACKAGE_DATA_DIR, "LuaSL"); | ||
397 | if (!edje_object_file_set(ourGlobals.edje, buf, group)) | ||
398 | { | ||
399 | int err = edje_object_load_error_get(ourGlobals.edje); | ||
400 | const char *errmsg = edje_load_error_str(err); | ||
401 | PE("Could not load '%s' from %s: %s\n", group, buf, errmsg); | ||
402 | |||
403 | evas_object_del(ourGlobals.edje); | ||
404 | ecore_evas_free(ourGlobals.ee); | ||
405 | edje_shutdown(); | ||
406 | ecore_evas_shutdown(); | ||
407 | return -2; | ||
408 | } | ||
409 | evas_object_move(ourGlobals.edje, 0, 0); | ||
410 | evas_object_resize(ourGlobals.edje, WIDTH, HEIGHT); | ||
411 | evas_object_show(ourGlobals.edje); | ||
412 | |||
413 | snprintf(buf, sizeof(buf), "%s/bubble_sh.png", PACKAGE_DATA_DIR); | ||
414 | for (i = 0; i < (sizeof(names) / sizeof(char *) / 2); i++) | ||
415 | { | ||
416 | sh = evas_object_image_filled_add(ourGlobals.canvas); | ||
417 | evas_object_image_file_set(sh, buf, NULL); | ||
418 | evas_object_resize(sh, 64, 64); | ||
419 | evas_object_show(sh); | ||
420 | evas_object_data_set(ourGlobals.bg, names[(i * 2) + 1], sh); | ||
421 | } | ||
422 | |||
423 | snprintf(buf, sizeof(buf), "%s/bubble.png", PACKAGE_DATA_DIR); | ||
424 | for (i = 0; i < (sizeof(names) / sizeof(char *) / 2); i++) | ||
425 | { | ||
426 | bub = evas_object_image_filled_add(ourGlobals.canvas); | ||
427 | evas_object_image_file_set(bub, buf, NULL); | ||
428 | evas_object_resize(bub, 64, 64); | ||
429 | evas_object_show(bub); | ||
430 | evas_object_data_set(ourGlobals.bg, names[(i * 2)], bub); | ||
431 | } | ||
432 | ani = ecore_animator_add(anim, &ourGlobals); | ||
433 | evas_object_data_set(ourGlobals.bg, "animator", ani); | ||
434 | |||
435 | // Setup our callbacks. | ||
436 | ecore_evas_callback_delete_request_set(ourGlobals.ee, _on_delete); | ||
437 | edje_object_signal_callback_add(ourGlobals.edje, "*", "game_*", _edje_signal_cb, &ourGlobals); | ||
438 | } | ||
439 | |||
440 | ecore_main_loop_begin(); | ||
441 | if (ourGlobals.ui) | ||
442 | { | ||
443 | ecore_animator_del(ani); | ||
444 | ecore_evas_free(ourGlobals.ee); | ||
445 | } | ||
446 | } | ||
447 | |||
448 | edje_shutdown(); | ||
449 | } | ||
450 | else | ||
451 | PC("Failed to init edje!"); | ||
452 | ecore_evas_shutdown(); | ||
453 | } | ||
454 | else | ||
455 | PC("Failed to init ecore_evas!"); | ||
456 | } | ||
457 | else | ||
458 | PC("Failed to connect to server!"); | ||
459 | ecore_con_shutdown(); | ||
460 | } | ||
461 | else | ||
462 | PC("Failed to init ecore_con!"); | ||
463 | } | ||
464 | else | ||
465 | fprintf(stderr, "Failed to init eina!"); | ||
466 | |||
467 | return result; | ||
468 | } | ||
diff --git a/src/LuaSL/build.lua b/src/LuaSL/build.lua index 4bf0c09..0efcca3 100755 --- a/src/LuaSL/build.lua +++ b/src/LuaSL/build.lua | |||
@@ -14,19 +14,16 @@ if 'nil' == type(dir) then | |||
14 | end | 14 | end |
15 | 15 | ||
16 | 16 | ||
17 | removeFiles(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 | removeFiles(dir, {'../../LuaSL', '*.o', '*.output', '*.backup', 'LuaSL_lexer.h', 'LuaSL_lexer.c', 'LuaSL_lemon_yaccer.h', 'LuaSL_lemon_yaccer.c', 'LuaSL_lemon_yaccer.out'}) |
18 | 18 | ||
19 | -- 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. |
20 | runCommand('lemon', dir, '../../libraries/lemon/lemon -s -T../../libraries/lemon/lempar.c LuaSL_lemon_yaccer.y') | 20 | runCommand('lemon', dir, '../../libraries/lemon/lemon -s -T../../libraries/lemon/lempar.c LuaSL_lemon_yaccer.y') |
21 | runCommand('flex', dir, 'flex -C --outfile=LuaSL_lexer.c --header-file=LuaSL_lexer.h LuaSL_lexer.l') | 21 | runCommand('flex', dir, 'flex -C --outfile=LuaSL_lexer.c --header-file=LuaSL_lexer.h LuaSL_lexer.l') |
22 | runCommand('edje_cc', dir, 'edje_cc ' .. EDJE_FLAGS .. ' LuaSL.edc ../../media/LuaSL.edj') | ||
23 | 22 | ||
24 | -- While SledHamr.c does this, we can't use that here, coz LuaSL is not an Elm app. | 23 | -- While SledHamr.c does this, we can't use that here, coz LuaSL is not an Elm app. |
25 | -- Neither is LuaSL_test actually. | ||
26 | CFLAGS = CFLAGS .. ' -DPACKAGE_BIN_DIR=\\"' .. bin_d .. '\\"' | 24 | CFLAGS = CFLAGS .. ' -DPACKAGE_BIN_DIR=\\"' .. bin_d .. '\\"' |
27 | CFLAGS = CFLAGS .. ' -DPACKAGE_LIB_DIR=\\"' .. lib_d .. '\\"' | 25 | CFLAGS = CFLAGS .. ' -DPACKAGE_LIB_DIR=\\"' .. lib_d .. '\\"' |
28 | CFLAGS = CFLAGS .. ' -DPACKAGE_DATA_DIR=\\"' .. data_d .. '\\"' | 26 | CFLAGS = CFLAGS .. ' -DPACKAGE_DATA_DIR=\\"' .. data_d .. '\\"' |
29 | CFLAGS = CFLAGS .. ' -DPACKAGE_LOCALE_DIR=\\"' .. locale_d .. '\\"' | 27 | CFLAGS = CFLAGS .. ' -DPACKAGE_LOCALE_DIR=\\"' .. locale_d .. '\\"' |
30 | 28 | ||
31 | compileFiles('../../LuaSL', dir, {'LuaSL_main', 'LuaSL_compile', 'LuaSL_threads', 'LuaSL_utilities', 'LuaSL_lexer', 'LuaSL_lemon_yaccer'}, '') | 29 | compileFiles('../../LuaSL', dir, {'LuaSL_main', 'LuaSL_compile', 'LuaSL_threads', 'LuaSL_utilities', 'LuaSL_lexer', 'LuaSL_lemon_yaccer'}, '') |
32 | compileFiles('LuaSL_test', dir, {'LuaSL_test', 'LuaSL_utilities'}, '') | ||
diff --git a/src/LuaSL/test.sh b/src/LuaSL/test.sh index 435c5e2..e8471c8 100755 --- a/src/LuaSL/test.sh +++ b/src/LuaSL/test.sh | |||
@@ -20,8 +20,8 @@ case $@ in | |||
20 | echo "_______________ STARTING LuaSL _______________" | 20 | echo "_______________ STARTING LuaSL _______________" |
21 | ../../LuaSL & | 21 | ../../LuaSL & |
22 | sleep 1 | 22 | sleep 1 |
23 | echo "_______________ STARTING LuaSL_test _______________" | 23 | echo "_______________ STARTING love _______________" |
24 | ./LuaSL_test | 24 | ../../love |
25 | ;; | 25 | ;; |
26 | 26 | ||
27 | esac | 27 | esac |