From 26df7205616dbcf80b60c1ed3c04ebea26975fe9 Mon Sep 17 00:00:00 2001 From: David Walter Seikel Date: Mon, 21 Apr 2014 18:28:19 +1000 Subject: Convert LuaSL to use LumbrJack. --- LuaSL/src/LuaSL_test.c | 162 ++++++++++++++++++++++++------------------------- 1 file changed, 81 insertions(+), 81 deletions(-) (limited to 'LuaSL/src/LuaSL_test.c') diff --git a/LuaSL/src/LuaSL_test.c b/LuaSL/src/LuaSL_test.c index 69cbf2c..51fd902 100644 --- a/LuaSL/src/LuaSL_test.c +++ b/LuaSL/src/LuaSL_test.c @@ -22,31 +22,31 @@ static const char *names[] = static void _edje_signal_cb(void *data, Evas_Object *obj __UNUSED__, const char *emission, const char *source) { -// gameGlobals *game = data; +// gameGlobals *ourGlobals = data; } static Eina_Bool anim(void *data) { - gameGlobals *game = data; + gameGlobals *ourGlobals = data; Evas_Object *bub, *sh; Evas_Coord x, y, w, h, vw, vh; double t, xx, yy, zz, r, fac; double lx, ly; unsigned int i; - evas_output_viewport_get(game->canvas, 0, 0, &vw, &vh); + evas_output_viewport_get(ourGlobals->canvas, 0, 0, &vw, &vh); r = 48; t = ecore_loop_time_get(); fac = 2.0 / (double)((sizeof(names) / sizeof(char *) / 2)); - evas_pointer_canvas_xy_get(game->canvas, &x, &y); + evas_pointer_canvas_xy_get(ourGlobals->canvas, &x, &y); lx = x; ly = y; for (i = 0; i < (sizeof(names) / sizeof(char *) / 2); i++) { - bub = evas_object_data_get(game->bg, names[i * 2]); - sh = evas_object_data_get(game->bg, names[(i * 2) + 1]); + bub = evas_object_data_get(ourGlobals->bg, names[i * 2]); + sh = evas_object_data_get(ourGlobals->bg, names[(i * 2) + 1]); zz = (((2 + sin(t * 6 + (M_PI * (i * fac)))) / 3) * 64) * 2; xx = (cos(t * 4 + (M_PI * (i * fac))) * r) * 2; yy = (sin(t * 6 + (M_PI * (i * fac))) * r) * 2; @@ -78,7 +78,7 @@ _on_delete(Ecore_Evas *ee __UNUSED__) static void dirList_compile(const char *name, const char *path, void *data) { - gameGlobals *game = data; + gameGlobals *ourGlobals = data; char *ext = rindex(name, '.'); @@ -92,34 +92,34 @@ static void dirList_compile(const char *name, const char *path, void *data) gettimeofday(&me->startTime, NULL); snprintf(me->SID, sizeof(me->SID), "%08lx-%04lx-%04lx-%04lx-%012lx", random(), random() % 0xFFFF, random() % 0xFFFF, random() % 0xFFFF, random()); snprintf(me->fileName, sizeof(me->fileName), "%s/%s", path, name); - eina_hash_add(game->scripts, me->SID, me); - sendForth(game, me->SID, "compile(%s)", me->fileName); + eina_hash_add(ourGlobals->scripts, me->SID, me); + sendForth(ourGlobals, me->SID, "compile(%s)", me->fileName); } } } static Eina_Bool _timer_cb(void *data) { - gameGlobals *game = data; + gameGlobals *ourGlobals = data; Eina_Iterator *scripts; script *me; boolean exit = FALSE; - scripts = eina_hash_iterator_data_new(game->scripts); + scripts = eina_hash_iterator_data_new(ourGlobals->scripts); while(eina_iterator_next(scripts, (void **) &me)) { switch (timedEvent) { case 5 : { - sendForth(game, me->SID, "events.detectedKeys({\"%s\"})", ownerKey); - sendForth(game, me->SID, "events.detectedNames({\"%s\"})", ownerName); - sendForth(game, me->SID, "events.touch_start(1)"); + sendForth(ourGlobals, me->SID, "events.detectedKeys({\"%s\"})", ownerKey); + sendForth(ourGlobals, me->SID, "events.detectedNames({\"%s\"})", ownerName); + sendForth(ourGlobals, me->SID, "events.touch_start(1)"); break; } case 9 : { - sendForth(game, me->SID, "quit()"); + sendForth(ourGlobals, me->SID, "quit()"); break; } case 11 : @@ -133,7 +133,7 @@ static Eina_Bool _timer_cb(void *data) if (exit) { - sendForth(game, ownerKey, "exit()"); + sendForth(ourGlobals, ownerKey, "exit()"); ecore_main_loop_quit(); return ECORE_CALLBACK_CANCEL; } @@ -142,21 +142,21 @@ static Eina_Bool _timer_cb(void *data) static Eina_Bool _add(void *data, int type __UNUSED__, Ecore_Con_Event_Server_Add *ev) { - gameGlobals *game = data; + gameGlobals *ourGlobals = data; char buf[PATH_MAX]; - game->server = ev->server; + ourGlobals->server = ev->server; gettimeofday(&startTime, NULL); snprintf(buf, sizeof(buf), "%s/Test sim/objects", PACKAGE_DATA_DIR); - eina_file_dir_list(buf, EINA_TRUE, dirList_compile, game); + eina_file_dir_list(buf, EINA_TRUE, dirList_compile, ourGlobals); // Wait awhile, then start sending events for testing. - ecore_timer_add(0.5, _timer_cb, game); + ecore_timer_add(0.5, _timer_cb, ourGlobals); return ECORE_CALLBACK_RENEW; } static Eina_Bool _data(void *data, int type __UNUSED__, Ecore_Con_Event_Server_Data *ev) { - gameGlobals *game = data; + gameGlobals *ourGlobals = data; char buf[PATH_MAX]; char SID[PATH_MAX]; @@ -179,7 +179,7 @@ static Eina_Bool _data(void *data, int type __UNUSED__, Ecore_Con_Event_Server_D ext[0] = '\0'; command = ext + 1; - me = eina_hash_find(game->scripts, SID); + me = eina_hash_find(ourGlobals->scripts, SID); if (0 == strncmp(command, "compilerWarning(", 16)) { char *temp; @@ -247,31 +247,31 @@ static Eina_Bool _data(void *data, int type __UNUSED__, Ecore_Con_Event_Server_D PD("TOTAL compile speed is %f scripts per second", compiledCount / timeDiff(&now, &startTime)); } // PD("The compile of %s worked, running it now.", SID); - sendForth(game, SID, "run()"); + sendForth(ourGlobals, SID, "run()"); } else { // Send back some random or fixed values for testing. if (0 == strcmp(command, "llGetKey()")) - sendForth(game, SID, "return \"%08lx-%04lx-%04lx-%04lx-%012lx\"", random(), random() % 0xFFFF, random() % 0xFFFF, random() % 0xFFFF, random()); + sendForth(ourGlobals, SID, "return \"%08lx-%04lx-%04lx-%04lx-%012lx\"", random(), random() % 0xFFFF, random() % 0xFFFF, random() % 0xFFFF, random()); else if (0 == strcmp(command, "llGetOwner()")) - sendForth(game, SID, "return \"%s\"", ownerKey); + sendForth(ourGlobals, SID, "return \"%s\"", ownerKey); else if (0 == strcmp(command, "llGetPos()")) - sendForth(game, SID, "return {x=128.0, y=128.0, z=128.0}"); + sendForth(ourGlobals, SID, "return {x=128.0, y=128.0, z=128.0}"); else if (0 == strcmp(command, "llGetRot()")) - sendForth(game, SID, "return {x=0.0, y=0.0, z=0.0, s=1.0}"); + sendForth(ourGlobals, SID, "return {x=0.0, y=0.0, z=0.0, s=1.0}"); else if (0 == strcmp(command, "llGetObjectDesc()")) - sendForth(game, SID, "return \"\""); + sendForth(ourGlobals, SID, "return \"\""); else if (0 == strncmp(command, "llGetAlpha(", 11)) - sendForth(game, SID, "return 1.0"); + sendForth(ourGlobals, SID, "return 1.0"); else if (0 == strcmp(command, "llGetInventoryNumber(7)")) - sendForth(game, SID, "return 3"); + sendForth(ourGlobals, SID, "return 3"); else if (0 == strcmp(command, "llGetInventoryName(7, 2)")) - sendForth(game, SID, "return \".readme\""); + sendForth(ourGlobals, SID, "return \".readme\""); else if (0 == strcmp(command, "llGetInventoryName(7, 1)")) - sendForth(game, SID, "return \".POSITIONS\""); + sendForth(ourGlobals, SID, "return \".POSITIONS\""); else if (0 == strcmp(command, "llGetInventoryName(7, 0)")) - sendForth(game, SID, "return \".MENUITEMS\""); + sendForth(ourGlobals, SID, "return \".MENUITEMS\""); else PI("Script %s sent command %s", SID, command); } @@ -286,11 +286,11 @@ static Eina_Bool _data(void *data, int type __UNUSED__, Ecore_Con_Event_Server_D static Eina_Bool _del(void *data, int type __UNUSED__, Ecore_Con_Event_Server_Del *ev) { - gameGlobals *game = data; + gameGlobals *ourGlobals = data; if (ev->server) { - game->server = NULL; + ourGlobals->server = NULL; ecore_con_server_del(ev->server); ecore_main_loop_quit(); } @@ -301,27 +301,27 @@ static Eina_Bool _del(void *data, int type __UNUSED__, Ecore_Con_Event_Server_De int main(int argc, char **argv) { /* put here any init specific to this app like parsing args etc. */ - gameGlobals game; + gameGlobals ourGlobals; char *programName = argv[0]; boolean badArgs = FALSE; int result = EXIT_FAILURE; - memset(&game, 0, sizeof(gameGlobals)); - game.address = "127.0.0.1"; - game.port = 8211; + memset(&ourGlobals, 0, sizeof(gameGlobals)); + ourGlobals.address = "127.0.0.1"; + ourGlobals.port = 8211; if (eina_init()) { - loggingStartup(&game); - game.scripts = eina_hash_string_superfast_new(NULL); + ourGlobals.logDom = loggingStartup("LuaSL_test", ourGlobals.logDom); + ourGlobals.scripts = eina_hash_string_superfast_new(NULL); if (ecore_con_init()) { - if ((game.server = ecore_con_server_connect(ECORE_CON_REMOTE_TCP, game.address, game.port, &game))) + if ((ourGlobals.server = ecore_con_server_connect(ECORE_CON_REMOTE_TCP, ourGlobals.address, ourGlobals.port, &ourGlobals))) { - ecore_event_handler_add(ECORE_CON_EVENT_SERVER_ADD, (Ecore_Event_Handler_Cb) _add, &game); - ecore_event_handler_add(ECORE_CON_EVENT_SERVER_DATA, (Ecore_Event_Handler_Cb) _data, &game); - ecore_event_handler_add(ECORE_CON_EVENT_SERVER_DEL, (Ecore_Event_Handler_Cb) _del, &game); + ecore_event_handler_add(ECORE_CON_EVENT_SERVER_ADD, (Ecore_Event_Handler_Cb) _add, &ourGlobals); + ecore_event_handler_add(ECORE_CON_EVENT_SERVER_DATA, (Ecore_Event_Handler_Cb) _data, &ourGlobals); + ecore_event_handler_add(ECORE_CON_EVENT_SERVER_DEL, (Ecore_Event_Handler_Cb) _del, &ourGlobals); clientStream = eina_strbuf_new(); if (ecore_evas_init()) @@ -340,7 +340,7 @@ int main(int argc, char **argv) { case 'u': { - game.ui = TRUE; + ourGlobals.ui = TRUE; break; } default: @@ -358,7 +358,7 @@ int main(int argc, char **argv) printf(" -u: Show the test UI.\n"); } else - // else if ((game.config) && (game.data)) + // else if ((ourGlobals.config) && (ourGlobals.data)) { unsigned int i; Evas_Object *bub, *sh; @@ -366,80 +366,80 @@ int main(int argc, char **argv) char *group = "main"; char buf[PATH_MAX]; - if (game.ui) + if (ourGlobals.ui) { /* this will give you a window with an Evas canvas under the first engine available */ - game.ee = ecore_evas_new(NULL, 0, 0, WIDTH, HEIGHT, NULL); - if (!game.ee) + ourGlobals.ee = ecore_evas_new(NULL, 0, 0, WIDTH, HEIGHT, NULL); + if (!ourGlobals.ee) { PEm("You got to have at least one evas engine built and linked up to ecore-evas for this example to run properly."); edje_shutdown(); ecore_evas_shutdown(); return -1; } - game.canvas = ecore_evas_get(game.ee); - ecore_evas_title_set(game.ee, "LuaSL test harness"); - ecore_evas_show(game.ee); - - game.bg = evas_object_rectangle_add(game.canvas); - evas_object_color_set(game.bg, 255, 255, 255, 255); /* white bg */ - evas_object_move(game.bg, 0, 0); /* at canvas' origin */ - evas_object_size_hint_weight_set(game.bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_resize(game.bg, WIDTH, HEIGHT); /* covers full canvas */ - evas_object_show(game.bg); - ecore_evas_object_associate(game.ee, game.bg, ECORE_EVAS_OBJECT_ASSOCIATE_BASE); - evas_object_focus_set(game.bg, EINA_TRUE); - - game.edje = edje_object_add(game.canvas); + ourGlobals.canvas = ecore_evas_get(ourGlobals.ee); + ecore_evas_title_set(ourGlobals.ee, "LuaSL test harness"); + ecore_evas_show(ourGlobals.ee); + + ourGlobals.bg = evas_object_rectangle_add(ourGlobals.canvas); + evas_object_color_set(ourGlobals.bg, 255, 255, 255, 255); /* white bg */ + evas_object_move(ourGlobals.bg, 0, 0); /* at canvas' origin */ + evas_object_size_hint_weight_set(ourGlobals.bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_resize(ourGlobals.bg, WIDTH, HEIGHT); /* covers full canvas */ + evas_object_show(ourGlobals.bg); + ecore_evas_object_associate(ourGlobals.ee, ourGlobals.bg, ECORE_EVAS_OBJECT_ASSOCIATE_BASE); + evas_object_focus_set(ourGlobals.bg, EINA_TRUE); + + ourGlobals.edje = edje_object_add(ourGlobals.canvas); snprintf(buf, sizeof(buf), "%s/%s.edj", PACKAGE_DATA_DIR, "LuaSL"); - if (!edje_object_file_set(game.edje, buf, group)) + if (!edje_object_file_set(ourGlobals.edje, buf, group)) { - int err = edje_object_load_error_get(game.edje); + int err = edje_object_load_error_get(ourGlobals.edje); const char *errmsg = edje_load_error_str(err); PEm("Could not load '%s' from %s: %s\n", group, buf, errmsg); - evas_object_del(game.edje); - ecore_evas_free(game.ee); + evas_object_del(ourGlobals.edje); + ecore_evas_free(ourGlobals.ee); edje_shutdown(); ecore_evas_shutdown(); return -2; } - evas_object_move(game.edje, 0, 0); - evas_object_resize(game.edje, WIDTH, HEIGHT); - evas_object_show(game.edje); + evas_object_move(ourGlobals.edje, 0, 0); + evas_object_resize(ourGlobals.edje, WIDTH, HEIGHT); + evas_object_show(ourGlobals.edje); snprintf(buf, sizeof(buf), "%s/images/bubble_sh.png", PACKAGE_DATA_DIR); for (i = 0; i < (sizeof(names) / sizeof(char *) / 2); i++) { - sh = evas_object_image_filled_add(game.canvas); + sh = evas_object_image_filled_add(ourGlobals.canvas); evas_object_image_file_set(sh, buf, NULL); evas_object_resize(sh, 64, 64); evas_object_show(sh); - evas_object_data_set(game.bg, names[(i * 2) + 1], sh); + evas_object_data_set(ourGlobals.bg, names[(i * 2) + 1], sh); } snprintf(buf, sizeof(buf), "%s/images/bubble.png", PACKAGE_DATA_DIR); for (i = 0; i < (sizeof(names) / sizeof(char *) / 2); i++) { - bub = evas_object_image_filled_add(game.canvas); + bub = evas_object_image_filled_add(ourGlobals.canvas); evas_object_image_file_set(bub, buf, NULL); evas_object_resize(bub, 64, 64); evas_object_show(bub); - evas_object_data_set(game.bg, names[(i * 2)], bub); + evas_object_data_set(ourGlobals.bg, names[(i * 2)], bub); } - ani = ecore_animator_add(anim, &game); - evas_object_data_set(game.bg, "animator", ani); + ani = ecore_animator_add(anim, &ourGlobals); + evas_object_data_set(ourGlobals.bg, "animator", ani); // Setup our callbacks. - ecore_evas_callback_delete_request_set(game.ee, _on_delete); - edje_object_signal_callback_add(game.edje, "*", "game_*", _edje_signal_cb, &game); + ecore_evas_callback_delete_request_set(ourGlobals.ee, _on_delete); + edje_object_signal_callback_add(ourGlobals.edje, "*", "game_*", _edje_signal_cb, &ourGlobals); } ecore_main_loop_begin(); - if (game.ui) + if (ourGlobals.ui) { ecore_animator_del(ani); - ecore_evas_free(game.ee); + ecore_evas_free(ourGlobals.ee); } } -- cgit v1.1