From 87805f895c7eeccc43dd5d0adb85d18e529c597d Mon Sep 17 00:00:00 2001 From: lixianjing Date: Sat, 31 Mar 2018 19:48:56 +0800 Subject: [PATCH] format code --- demos/demo1_app.c | 4 +- demos/res/raw/theme/theme.xml | 38 +- demos/res/src/images/green_btn_p.data | 2 +- demos/res/src/images/info.data | 2 +- demos/res/src/theme/default.data | 14 +- demos/res/src/ui/dialog1.data | 4 +- lua/custom.c | 2 +- lua/lftk_lua.c | 1139 ++++++++++--------------- src/base/dialog.c | 4 +- src/base/dialog.h | 1 - src/base/enums.c | 41 +- src/lcd/lcd_reg.inc | 28 +- tests/theme_gen_test.cc | 22 + 13 files changed, 555 insertions(+), 746 deletions(-) diff --git a/demos/demo1_app.c b/demos/demo1_app.c index 8b97ff6d8..187a2fecf 100644 --- a/demos/demo1_app.c +++ b/demos/demo1_app.c @@ -94,8 +94,8 @@ ret_t application_init() { image = image_create(win, 100, 230, 200, 200); image_set_image_name(image, "earth"); - image_set_draw_type(image, IMAGE_DRAW_SCALE); - + image_set_draw_type(image, IMAGE_DRAW_SCALE); + label = label_create(win, 10, 40, 80, 30); widget_set_text(label, L"Left"); widget_use_style(label, "2:left"); diff --git a/demos/res/raw/theme/theme.xml b/demos/res/raw/theme/theme.xml index 1d3559666..a558e7b8c 100644 --- a/demos/res/raw/theme/theme.xml +++ b/demos/res/raw/theme/theme.xml @@ -9,23 +9,23 @@ @@ -58,16 +58,16 @@ - - diff --git a/demos/res/src/images/green_btn_p.data b/demos/res/src/images/green_btn_p.data index b59781b21..aa3f27526 100644 --- a/demos/res/src/images/green_btn_p.data +++ b/demos/res/src/images/green_btn_p.data @@ -180,4 +180,4 @@ const unsigned char image_green_btn_p[] = { 0x4e,0xab,0x82,0xff,0x4e,0xab,0x82,0xff,0x4e,0xab,0x82,0xff,0x4e,0xab,0x82,0xff,0x4e,0xab,0x82,0xff, 0x4e,0xab,0x82,0xff,0x4e,0xab,0x82,0xff,0x4e,0xab,0x82,0xff,0x4e,0xab,0x82,0xff,0x4e,0xab,0x82,0xff, 0x5d,0xb1,0x8c,0xff,0x7d,0xbf,0xa1,0xd7,0x9a,0xcd,0xb6,0x97,0xdb,0xed,0xe5,0x37,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,}; +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xad,0xa6,0x83,0xad,}; diff --git a/demos/res/src/images/info.data b/demos/res/src/images/info.data index ea1d0d170..953306bc4 100644 --- a/demos/res/src/images/info.data +++ b/demos/res/src/images/info.data @@ -116,4 +116,4 @@ const unsigned char image_info[] = { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x15,0x80,0xea,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,}; +0xff,0xff,0xff,0xff,}; diff --git a/demos/res/src/theme/default.data b/demos/res/src/theme/default.data index ad707089c..6d8cb259e 100644 --- a/demos/res/src/theme/default.data +++ b/demos/res/src/theme/default.data @@ -13,13 +13,13 @@ const unsigned char theme_default[] = { 0x01,0x00,0x11,0x00,0xd9,0x03,0x00,0x00,0x01,0x00,0x12,0x00,0x03,0x04,0x00,0x00,0x01,0x00,0x00,0x00, 0x01,0x00,0x00,0x00,0xf0,0xf0,0xf0,0xff,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x0b,0x00,0x00,0x00, 0x05,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x0a,0x00,0x00,0x00,0x62,0x72,0x69,0x63,0x6b,0x73,0x00,0x03, -0x00,0x00,0x00,0x01,0x00,0x00,0x00,0xf0,0xf0,0xf0,0xff,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x09, -0x00,0x00,0x00,0xa0,0xa0,0xa0,0xff,0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0xc0, -0xc0,0xc0,0xff,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x09,0x00,0x00,0x00,0xa0,0xa0,0xa0,0xff,0x00, -0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0xe0,0xe0,0xe0,0xff,0x06,0x00,0x00,0x00,0x00, -0x00,0x00,0xff,0x09,0x00,0x00,0x00,0xa0,0xa0,0xa0,0xff,0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x01, -0x00,0x00,0x00,0xbe,0xbe,0xbe,0xff,0x06,0x00,0x00,0x00,0xd0,0xd0,0xd0,0xff,0x09,0x00,0x00,0x00,0xa0, -0xa0,0xa0,0xff,0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x0b,0x00,0x00,0x00,0x09,0x00,0x00,0x00,0x06, +0x00,0x00,0x00,0x09,0x00,0x00,0x00,0xa0,0xa0,0xa0,0xff,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x01, +0x00,0x00,0x00,0xf0,0xf0,0xf0,0xff,0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x09,0x00,0x00,0x00,0xa0, +0xa0,0xa0,0xff,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x01,0x00,0x00,0x00,0xc0,0xc0,0xc0,0xff,0x00, +0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x09,0x00,0x00,0x00,0xa0,0xa0,0xa0,0xff,0x06,0x00,0x00,0x00,0x00, +0x00,0x00,0xff,0x01,0x00,0x00,0x00,0xe0,0xe0,0xe0,0xff,0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x09, +0x00,0x00,0x00,0xa0,0xa0,0xa0,0xff,0x06,0x00,0x00,0x00,0xd0,0xd0,0xd0,0xff,0x01,0x00,0x00,0x00,0xbe, +0xbe,0xbe,0xff,0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x0b,0x00,0x00,0x00,0x09,0x00,0x00,0x00,0x06, 0x00,0x00,0x00,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0x0a,0x00,0x00,0x00,0x67,0x72,0x65,0x65,0x6e, 0x5f,0x62,0x74,0x6e,0x5f,0x6e,0x00,0x02,0x00,0x00,0x00,0x0b,0x00,0x00,0x00,0x09,0x00,0x00,0x00,0x06, 0x00,0x00,0x00,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0x0a,0x00,0x00,0x00,0x67,0x72,0x65,0x65,0x6e, diff --git a/demos/res/src/ui/dialog1.data b/demos/res/src/ui/dialog1.data index 8009bf6d3..7cafab28d 100644 --- a/demos/res/src/ui/dialog1.data +++ b/demos/res/src/ui/dialog1.data @@ -11,5 +11,5 @@ const unsigned char ui_dialog1[] = { 0x74,0x6e,0x00,0x74,0x65,0x78,0x74,0x00,0x59,0x65,0x73,0x00,0x00,0x00,0x01,0x00,0x0a,0x00,0x03,0x03, 0x01,0x00,0x0a,0x00,0x00,0x00,0x0a,0x00,0x00,0x00,0x28,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x6e,0x61, 0x6d,0x65,0x00,0x63,0x61,0x6e,0x63,0x65,0x6c,0x00,0x73,0x74,0x79,0x6c,0x65,0x00,0x32,0x3a,0x72,0x65, -0x64,0x5f,0x62,0x74,0x6e,0x00,0x74,0x65,0x78,0x74,0x00,0x4e,0x6f,0x00,0x00,0x00,0x00,0x5d,0xc3,0x77, -0xff,}; +0x64,0x5f,0x62,0x74,0x6e,0x00,0x74,0x65,0x78,0x74,0x00,0x4e,0x6f,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,}; diff --git a/lua/custom.c b/lua/custom.c index de50ea654..ebfa0dda0 100644 --- a/lua/custom.c +++ b/lua/custom.c @@ -31,7 +31,7 @@ static int lftk_newuserdata(lua_State* L, void* data, const char* info, const ch if (metatable != NULL) { int ret = luaL_getmetatable(L, metatable); - if(ret == 0 && strstr(info, "/widget_t") != NULL) { + if (ret == 0 && strstr(info, "/widget_t") != NULL) { lua_pop(L, 1); ret = luaL_getmetatable(L, "lftk.widget_t"); } diff --git a/lua/lftk_lua.c b/lua/lftk_lua.c index d04a28a66..b1874c53a 100644 --- a/lua/lftk_lua.c +++ b/lua/lftk_lua.c @@ -66,7 +66,7 @@ static int wrap_lftk_quit(lua_State* L) { ret_t ret = 0; ret = (ret_t)lftk_quit(); - lua_pushnumber(L,(lua_Number)(ret)); + lua_pushnumber(L, (lua_Number)(ret)); return 1; } @@ -98,16 +98,13 @@ static int wrap_button_set_text(lua_State* L) { wchar_t* text = (wchar_t*)lua_touserdata(L, 2); ret = (ret_t)button_set_text(widget, text); - lua_pushnumber(L,(lua_Number)(ret)); + lua_pushnumber(L, (lua_Number)(ret)); return 1; } - -static const struct luaL_Reg button_t_member_funcs[] = { - {"set_text", wrap_button_set_text}, - {NULL, NULL} -}; +static const struct luaL_Reg button_t_member_funcs[] = {{"set_text", wrap_button_set_text}, + {NULL, NULL}}; static int wrap_button_t_set_prop(lua_State* L) { button_t* obj = (button_t*)lftk_checkudata(L, 1, "button_t"); @@ -115,8 +112,8 @@ static int wrap_button_t_set_prop(lua_State* L) { (void)obj; (void)name; return wrap_widget_t_set_prop(L); - printf("%s: not supported %s\n", __func__, name); - return 0; + printf("%s: not supported %s\n", __func__, name); + return 0; } static int wrap_button_t_get_prop(lua_State* L) { @@ -126,26 +123,19 @@ static int wrap_button_t_get_prop(lua_State* L) { (void)obj; (void)name; - if(ret) { + if (ret) { lua_pushcfunction(L, ret->func); return 1; - } - else { + } else { return wrap_widget_t_get_prop(L); } } static void button_t_init(lua_State* L) { - static const struct luaL_Reg static_funcs[] = { - {"create", wrap_button_create}, - {NULL, NULL} - }; + static const struct luaL_Reg static_funcs[] = {{"create", wrap_button_create}, {NULL, NULL}}; static const struct luaL_Reg index_funcs[] = { - {"__index", wrap_button_t_get_prop}, - {"__newindex", wrap_button_t_set_prop}, - {NULL, NULL} - }; + {"__index", wrap_button_t_get_prop}, {"__newindex", wrap_button_t_set_prop}, {NULL, NULL}}; luaL_newmetatable(L, "lftk.button_t"); lua_pushstring(L, "__index"); @@ -156,17 +146,15 @@ static void button_t_init(lua_State* L) { lua_settop(L, 0); } -static const struct luaL_Reg canvas_t_member_funcs[] = { - {NULL, NULL} -}; +static const struct luaL_Reg canvas_t_member_funcs[] = {{NULL, NULL}}; static int wrap_canvas_t_set_prop(lua_State* L) { canvas_t* obj = (canvas_t*)lftk_checkudata(L, 1, "canvas_t"); const char* name = (const char*)luaL_checkstring(L, 2); (void)obj; (void)name; - printf("%s: not supported %s\n", __func__, name); - return 0; + printf("%s: not supported %s\n", __func__, name); + return 0; } static int wrap_canvas_t_get_prop(lua_State* L) { @@ -176,26 +164,20 @@ static int wrap_canvas_t_get_prop(lua_State* L) { (void)obj; (void)name; - if(ret) { + if (ret) { lua_pushcfunction(L, ret->func); return 1; - } - else { + } else { printf("%s: not supported %s\n", __func__, name); return 0; } } static void canvas_t_init(lua_State* L) { - static const struct luaL_Reg static_funcs[] = { - {NULL, NULL} - }; + static const struct luaL_Reg static_funcs[] = {{NULL, NULL}}; static const struct luaL_Reg index_funcs[] = { - {"__index", wrap_canvas_t_get_prop}, - {"__newindex", wrap_canvas_t_set_prop}, - {NULL, NULL} - }; + {"__index", wrap_canvas_t_get_prop}, {"__newindex", wrap_canvas_t_set_prop}, {NULL, NULL}}; luaL_newmetatable(L, "lftk.canvas_t"); lua_pushstring(L, "__index"); @@ -235,7 +217,7 @@ static int wrap_check_button_set_text(lua_State* L) { wchar_t* text = (wchar_t*)lua_touserdata(L, 2); ret = (ret_t)check_button_set_text(widget, text); - lua_pushnumber(L,(lua_Number)(ret)); + lua_pushnumber(L, (lua_Number)(ret)); return 1; } @@ -246,29 +228,26 @@ static int wrap_check_button_set_value(lua_State* L) { uint32_t value = (uint32_t)luaL_checkinteger(L, 2); ret = (ret_t)check_button_set_value(widget, value); - lua_pushnumber(L,(lua_Number)(ret)); + lua_pushnumber(L, (lua_Number)(ret)); return 1; } - static const struct luaL_Reg check_button_t_member_funcs[] = { - {"set_text", wrap_check_button_set_text}, - {"set_value", wrap_check_button_set_value}, - {NULL, NULL} -}; + {"set_text", wrap_check_button_set_text}, + {"set_value", wrap_check_button_set_value}, + {NULL, NULL}}; static int wrap_check_button_t_set_prop(lua_State* L) { check_button_t* obj = (check_button_t*)lftk_checkudata(L, 1, "check_button_t"); const char* name = (const char*)luaL_checkstring(L, 2); (void)obj; (void)name; - if(strcmp(name, "value") == 0) { + if (strcmp(name, "value") == 0) { printf("value is readonly\n"); return 0; - } - else { - return wrap_widget_t_set_prop(L); + } else { + return wrap_widget_t_set_prop(L); } } @@ -279,32 +258,27 @@ static int wrap_check_button_t_get_prop(lua_State* L) { (void)obj; (void)name; - if(ret) { + if (ret) { lua_pushcfunction(L, ret->func); return 1; } - if(strcmp(name, "value") == 0) { - lua_pushboolean(L,(lua_Integer)(obj->value)); + if (strcmp(name, "value") == 0) { + lua_pushboolean(L, (lua_Integer)(obj->value)); - return 1; - } - else { + return 1; + } else { return wrap_widget_t_get_prop(L); } } static void check_button_t_init(lua_State* L) { - static const struct luaL_Reg static_funcs[] = { - {"create", wrap_check_button_create}, - {"create_radio", wrap_check_button_create_radio}, - {NULL, NULL} - }; + static const struct luaL_Reg static_funcs[] = {{"create", wrap_check_button_create}, + {"create_radio", wrap_check_button_create_radio}, + {NULL, NULL}}; - static const struct luaL_Reg index_funcs[] = { - {"__index", wrap_check_button_t_get_prop}, - {"__newindex", wrap_check_button_t_set_prop}, - {NULL, NULL} - }; + static const struct luaL_Reg index_funcs[] = {{"__index", wrap_check_button_t_get_prop}, + {"__newindex", wrap_check_button_t_set_prop}, + {NULL, NULL}}; luaL_newmetatable(L, "lftk.check_button_t"); lua_pushstring(L, "__index"); @@ -340,7 +314,7 @@ static int wrap_dialog_set_title(lua_State* L) { wchar_t* title = (wchar_t*)lua_touserdata(L, 2); ret = (ret_t)dialog_set_title(widget, title); - lua_pushnumber(L,(lua_Number)(ret)); + lua_pushnumber(L, (lua_Number)(ret)); return 1; } @@ -350,7 +324,7 @@ static int wrap_dialog_modal(lua_State* L) { widget_t* widget = (widget_t*)lftk_checkudata(L, 1, "widget_t"); ret = (ret_t)dialog_modal(widget); - lua_pushnumber(L,(lua_Number)(ret)); + lua_pushnumber(L, (lua_Number)(ret)); return 1; } @@ -361,18 +335,15 @@ static int wrap_dialog_quit(lua_State* L) { uint32_t code = (uint32_t)luaL_checkinteger(L, 2); ret = (ret_t)dialog_quit(widget, code); - lua_pushnumber(L,(lua_Number)(ret)); + lua_pushnumber(L, (lua_Number)(ret)); return 1; } - -static const struct luaL_Reg dialog_t_member_funcs[] = { - {"set_title", wrap_dialog_set_title}, - {"modal", wrap_dialog_modal}, - {"quit", wrap_dialog_quit}, - {NULL, NULL} -}; +static const struct luaL_Reg dialog_t_member_funcs[] = {{"set_title", wrap_dialog_set_title}, + {"modal", wrap_dialog_modal}, + {"quit", wrap_dialog_quit}, + {NULL, NULL}}; static int wrap_dialog_t_set_prop(lua_State* L) { dialog_t* obj = (dialog_t*)lftk_checkudata(L, 1, "dialog_t"); @@ -380,8 +351,8 @@ static int wrap_dialog_t_set_prop(lua_State* L) { (void)obj; (void)name; return wrap_widget_t_set_prop(L); - printf("%s: not supported %s\n", __func__, name); - return 0; + printf("%s: not supported %s\n", __func__, name); + return 0; } static int wrap_dialog_t_get_prop(lua_State* L) { @@ -391,27 +362,20 @@ static int wrap_dialog_t_get_prop(lua_State* L) { (void)obj; (void)name; - if(ret) { + if (ret) { lua_pushcfunction(L, ret->func); return 1; - } - else { + } else { return wrap_widget_t_get_prop(L); } } static void dialog_t_init(lua_State* L) { static const struct luaL_Reg static_funcs[] = { - {"create", wrap_dialog_create}, - {"open", wrap_dialog_open}, - {NULL, NULL} - }; + {"create", wrap_dialog_create}, {"open", wrap_dialog_open}, {NULL, NULL}}; static const struct luaL_Reg index_funcs[] = { - {"__index", wrap_dialog_t_get_prop}, - {"__newindex", wrap_dialog_t_set_prop}, - {NULL, NULL} - }; + {"__index", wrap_dialog_t_get_prop}, {"__newindex", wrap_dialog_t_set_prop}, {NULL, NULL}}; luaL_newmetatable(L, "lftk.dialog_t"); lua_pushstring(L, "__index"); @@ -428,93 +392,88 @@ static void event_type_t_init(lua_State* L) { lua_pushstring(L, "NONE"); lua_pushinteger(L, EVT_NONE); - lua_settable(L, -3); + lua_settable(L, -3); lua_pushstring(L, "POINTER_DOWN"); lua_pushinteger(L, EVT_POINTER_DOWN); - lua_settable(L, -3); + lua_settable(L, -3); lua_pushstring(L, "POINTER_MOVE"); lua_pushinteger(L, EVT_POINTER_MOVE); - lua_settable(L, -3); + lua_settable(L, -3); lua_pushstring(L, "POINTER_UP"); lua_pushinteger(L, EVT_POINTER_UP); - lua_settable(L, -3); + lua_settable(L, -3); lua_pushstring(L, "POINTER_ENTER"); lua_pushinteger(L, EVT_POINTER_ENTER); - lua_settable(L, -3); + lua_settable(L, -3); lua_pushstring(L, "POINTER_LEAVE"); lua_pushinteger(L, EVT_POINTER_LEAVE); - lua_settable(L, -3); + lua_settable(L, -3); lua_pushstring(L, "CLICK"); lua_pushinteger(L, EVT_CLICK); - lua_settable(L, -3); + lua_settable(L, -3); lua_pushstring(L, "KEY_DOWN"); lua_pushinteger(L, EVT_KEY_DOWN); - lua_settable(L, -3); + lua_settable(L, -3); lua_pushstring(L, "KEY_UP"); lua_pushinteger(L, EVT_KEY_UP); - lua_settable(L, -3); + lua_settable(L, -3); lua_pushstring(L, "MOVE"); lua_pushinteger(L, EVT_MOVE); - lua_settable(L, -3); + lua_settable(L, -3); lua_pushstring(L, "RESIZE"); lua_pushinteger(L, EVT_RESIZE); - lua_settable(L, -3); + lua_settable(L, -3); lua_pushstring(L, "DESTROY"); lua_pushinteger(L, EVT_DESTROY); - lua_settable(L, -3); + lua_settable(L, -3); lua_pushstring(L, "MOVE_RESIZE"); lua_pushinteger(L, EVT_MOVE_RESIZE); - lua_settable(L, -3); + lua_settable(L, -3); lua_pushstring(L, "PROP_CHANGED"); lua_pushinteger(L, EVT_PROP_CHANGED); - lua_settable(L, -3); + lua_settable(L, -3); lua_pushstring(L, "VALUE_CHANGED"); lua_pushinteger(L, EVT_VALUE_CHANGED); - lua_settable(L, -3); + lua_settable(L, -3); lua_pushstring(L, "PAINT"); lua_pushinteger(L, EVT_PAINT); - lua_settable(L, -3); + lua_settable(L, -3); lua_pushstring(L, "BEFORE_PAINT"); lua_pushinteger(L, EVT_BEFORE_PAINT); - lua_settable(L, -3); + lua_settable(L, -3); lua_pushstring(L, "AFTER_PAINT"); lua_pushinteger(L, EVT_AFTER_PAINT); - lua_settable(L, -3); - + lua_settable(L, -3); } - -static const struct luaL_Reg event_t_member_funcs[] = { - {NULL, NULL} -}; +static const struct luaL_Reg event_t_member_funcs[] = {{NULL, NULL}}; static int wrap_event_t_set_prop(lua_State* L) { event_t* obj = (event_t*)lftk_checkudata(L, 1, "event_t"); const char* name = (const char*)luaL_checkstring(L, 2); (void)obj; (void)name; - if(strcmp(name, "type") == 0) { + if (strcmp(name, "type") == 0) { printf("type is readonly\n"); return 0; - } - else { + } else { printf("%s: not supported %s\n", __func__, name); return 0; } @@ -527,31 +486,25 @@ static int wrap_event_t_get_prop(lua_State* L) { (void)obj; (void)name; - if(ret) { + if (ret) { lua_pushcfunction(L, ret->func); return 1; } - if(strcmp(name, "type") == 0) { - lua_pushinteger(L,(lua_Integer)(obj->type)); + if (strcmp(name, "type") == 0) { + lua_pushinteger(L, (lua_Integer)(obj->type)); - return 1; - } - else { + return 1; + } else { printf("%s: not supported %s\n", __func__, name); return 0; } } static void event_t_init(lua_State* L) { - static const struct luaL_Reg static_funcs[] = { - {NULL, NULL} - }; + static const struct luaL_Reg static_funcs[] = {{NULL, NULL}}; static const struct luaL_Reg index_funcs[] = { - {"__index", wrap_event_t_get_prop}, - {"__newindex", wrap_event_t_set_prop}, - {NULL, NULL} - }; + {"__index", wrap_event_t_get_prop}, {"__newindex", wrap_event_t_set_prop}, {NULL, NULL}}; luaL_newmetatable(L, "lftk.event_t"); lua_pushstring(L, "__index"); @@ -569,34 +522,27 @@ static int wrap_pointer_event_cast(lua_State* L) { return lftk_newuserdata(L, ret, "/pointer_event_t/event_t", "lftk.pointer_event_t"); } - -static const struct luaL_Reg pointer_event_t_member_funcs[] = { - {NULL, NULL} -}; +static const struct luaL_Reg pointer_event_t_member_funcs[] = {{NULL, NULL}}; static int wrap_pointer_event_t_set_prop(lua_State* L) { pointer_event_t* obj = (pointer_event_t*)lftk_checkudata(L, 1, "pointer_event_t"); const char* name = (const char*)luaL_checkstring(L, 2); (void)obj; (void)name; - if(strcmp(name, "x") == 0) { + if (strcmp(name, "x") == 0) { printf("x is readonly\n"); return 0; - } - else if(strcmp(name, "y") == 0) { + } else if (strcmp(name, "y") == 0) { printf("y is readonly\n"); return 0; - } - else if(strcmp(name, "button") == 0) { + } else if (strcmp(name, "button") == 0) { printf("button is readonly\n"); return 0; - } - else if(strcmp(name, "pressed") == 0) { + } else if (strcmp(name, "pressed") == 0) { printf("pressed is readonly\n"); return 0; - } - else { - return wrap_event_t_set_prop(L); + } else { + return wrap_event_t_set_prop(L); } } @@ -607,46 +553,37 @@ static int wrap_pointer_event_t_get_prop(lua_State* L) { (void)obj; (void)name; - if(ret) { + if (ret) { lua_pushcfunction(L, ret->func); return 1; } - if(strcmp(name, "x") == 0) { - lua_pushnumber(L,(lua_Number)(obj->x)); + if (strcmp(name, "x") == 0) { + lua_pushnumber(L, (lua_Number)(obj->x)); - return 1; - } - else if(strcmp(name, "y") == 0) { - lua_pushnumber(L,(lua_Number)(obj->y)); + return 1; + } else if (strcmp(name, "y") == 0) { + lua_pushnumber(L, (lua_Number)(obj->y)); - return 1; - } - else if(strcmp(name, "button") == 0) { - lua_pushinteger(L,(lua_Integer)(obj->button)); + return 1; + } else if (strcmp(name, "button") == 0) { + lua_pushinteger(L, (lua_Integer)(obj->button)); - return 1; - } - else if(strcmp(name, "pressed") == 0) { - lua_pushboolean(L,(lua_Integer)(obj->pressed)); + return 1; + } else if (strcmp(name, "pressed") == 0) { + lua_pushboolean(L, (lua_Integer)(obj->pressed)); - return 1; - } - else { + return 1; + } else { return wrap_event_t_get_prop(L); } } static void pointer_event_t_init(lua_State* L) { - static const struct luaL_Reg static_funcs[] = { - {"cast", wrap_pointer_event_cast}, - {NULL, NULL} - }; + static const struct luaL_Reg static_funcs[] = {{"cast", wrap_pointer_event_cast}, {NULL, NULL}}; - static const struct luaL_Reg index_funcs[] = { - {"__index", wrap_pointer_event_t_get_prop}, - {"__newindex", wrap_pointer_event_t_set_prop}, - {NULL, NULL} - }; + static const struct luaL_Reg index_funcs[] = {{"__index", wrap_pointer_event_t_get_prop}, + {"__newindex", wrap_pointer_event_t_set_prop}, + {NULL, NULL}}; luaL_newmetatable(L, "lftk.pointer_event_t"); lua_pushstring(L, "__index"); @@ -664,34 +601,27 @@ static int wrap_key_event_cast(lua_State* L) { return lftk_newuserdata(L, ret, "/key_event_t/event_t", "lftk.key_event_t"); } - -static const struct luaL_Reg key_event_t_member_funcs[] = { - {NULL, NULL} -}; +static const struct luaL_Reg key_event_t_member_funcs[] = {{NULL, NULL}}; static int wrap_key_event_t_set_prop(lua_State* L) { key_event_t* obj = (key_event_t*)lftk_checkudata(L, 1, "key_event_t"); const char* name = (const char*)luaL_checkstring(L, 2); (void)obj; (void)name; - if(strcmp(name, "key") == 0) { + if (strcmp(name, "key") == 0) { printf("key is readonly\n"); return 0; - } - else if(strcmp(name, "alt") == 0) { + } else if (strcmp(name, "alt") == 0) { printf("alt is readonly\n"); return 0; - } - else if(strcmp(name, "ctrl") == 0) { + } else if (strcmp(name, "ctrl") == 0) { printf("ctrl is readonly\n"); return 0; - } - else if(strcmp(name, "shift") == 0) { + } else if (strcmp(name, "shift") == 0) { printf("shift is readonly\n"); return 0; - } - else { - return wrap_event_t_set_prop(L); + } else { + return wrap_event_t_set_prop(L); } } @@ -702,46 +632,37 @@ static int wrap_key_event_t_get_prop(lua_State* L) { (void)obj; (void)name; - if(ret) { + if (ret) { lua_pushcfunction(L, ret->func); return 1; } - if(strcmp(name, "key") == 0) { - lua_pushinteger(L,(lua_Integer)(obj->key)); + if (strcmp(name, "key") == 0) { + lua_pushinteger(L, (lua_Integer)(obj->key)); - return 1; - } - else if(strcmp(name, "alt") == 0) { - lua_pushboolean(L,(lua_Integer)(obj->alt)); + return 1; + } else if (strcmp(name, "alt") == 0) { + lua_pushboolean(L, (lua_Integer)(obj->alt)); - return 1; - } - else if(strcmp(name, "ctrl") == 0) { - lua_pushboolean(L,(lua_Integer)(obj->ctrl)); + return 1; + } else if (strcmp(name, "ctrl") == 0) { + lua_pushboolean(L, (lua_Integer)(obj->ctrl)); - return 1; - } - else if(strcmp(name, "shift") == 0) { - lua_pushboolean(L,(lua_Integer)(obj->shift)); + return 1; + } else if (strcmp(name, "shift") == 0) { + lua_pushboolean(L, (lua_Integer)(obj->shift)); - return 1; - } - else { + return 1; + } else { return wrap_event_t_get_prop(L); } } static void key_event_t_init(lua_State* L) { - static const struct luaL_Reg static_funcs[] = { - {"cast", wrap_key_event_cast}, - {NULL, NULL} - }; + static const struct luaL_Reg static_funcs[] = {{"cast", wrap_key_event_cast}, {NULL, NULL}}; - static const struct luaL_Reg index_funcs[] = { - {"__index", wrap_key_event_t_get_prop}, - {"__newindex", wrap_key_event_t_set_prop}, - {NULL, NULL} - }; + static const struct luaL_Reg index_funcs[] = {{"__index", wrap_key_event_t_get_prop}, + {"__newindex", wrap_key_event_t_set_prop}, + {NULL, NULL}}; luaL_newmetatable(L, "lftk.key_event_t"); lua_pushstring(L, "__index"); @@ -759,22 +680,18 @@ static int wrap_paint_event_cast(lua_State* L) { return lftk_newuserdata(L, ret, "/paint_event_t/event_t", "lftk.paint_event_t"); } - -static const struct luaL_Reg paint_event_t_member_funcs[] = { - {NULL, NULL} -}; +static const struct luaL_Reg paint_event_t_member_funcs[] = {{NULL, NULL}}; static int wrap_paint_event_t_set_prop(lua_State* L) { paint_event_t* obj = (paint_event_t*)lftk_checkudata(L, 1, "paint_event_t"); const char* name = (const char*)luaL_checkstring(L, 2); (void)obj; (void)name; - if(strcmp(name, "c") == 0) { + if (strcmp(name, "c") == 0) { printf("c is readonly\n"); return 0; - } - else { - return wrap_event_t_set_prop(L); + } else { + return wrap_event_t_set_prop(L); } } @@ -785,29 +702,23 @@ static int wrap_paint_event_t_get_prop(lua_State* L) { (void)obj; (void)name; - if(ret) { + if (ret) { lua_pushcfunction(L, ret->func); return 1; } - if(strcmp(name, "c") == 0) { + if (strcmp(name, "c") == 0) { return lftk_newuserdata(L, obj->c, "/canvas_t", "lftk.canvas_t"); - } - else { + } else { return wrap_event_t_get_prop(L); } } static void paint_event_t_init(lua_State* L) { - static const struct luaL_Reg static_funcs[] = { - {"cast", wrap_paint_event_cast}, - {NULL, NULL} - }; + static const struct luaL_Reg static_funcs[] = {{"cast", wrap_paint_event_cast}, {NULL, NULL}}; - static const struct luaL_Reg index_funcs[] = { - {"__index", wrap_paint_event_t_get_prop}, - {"__newindex", wrap_paint_event_t_set_prop}, - {NULL, NULL} - }; + static const struct luaL_Reg index_funcs[] = {{"__index", wrap_paint_event_t_get_prop}, + {"__newindex", wrap_paint_event_t_set_prop}, + {NULL, NULL}}; luaL_newmetatable(L, "lftk.paint_event_t"); lua_pushstring(L, "__index"); @@ -829,10 +740,7 @@ static int wrap_group_box_create(lua_State* L) { return lftk_newuserdata(L, ret, "/group_box_t/widget_t", "lftk.group_box_t"); } - -static const struct luaL_Reg group_box_t_member_funcs[] = { - {NULL, NULL} -}; +static const struct luaL_Reg group_box_t_member_funcs[] = {{NULL, NULL}}; static int wrap_group_box_t_set_prop(lua_State* L) { group_box_t* obj = (group_box_t*)lftk_checkudata(L, 1, "group_box_t"); @@ -840,8 +748,8 @@ static int wrap_group_box_t_set_prop(lua_State* L) { (void)obj; (void)name; return wrap_widget_t_set_prop(L); - printf("%s: not supported %s\n", __func__, name); - return 0; + printf("%s: not supported %s\n", __func__, name); + return 0; } static int wrap_group_box_t_get_prop(lua_State* L) { @@ -851,26 +759,20 @@ static int wrap_group_box_t_get_prop(lua_State* L) { (void)obj; (void)name; - if(ret) { + if (ret) { lua_pushcfunction(L, ret->func); return 1; - } - else { + } else { return wrap_widget_t_get_prop(L); } } static void group_box_t_init(lua_State* L) { - static const struct luaL_Reg static_funcs[] = { - {"create", wrap_group_box_create}, - {NULL, NULL} - }; + static const struct luaL_Reg static_funcs[] = {{"create", wrap_group_box_create}, {NULL, NULL}}; - static const struct luaL_Reg index_funcs[] = { - {"__index", wrap_group_box_t_get_prop}, - {"__newindex", wrap_group_box_t_set_prop}, - {NULL, NULL} - }; + static const struct luaL_Reg index_funcs[] = {{"__index", wrap_group_box_t_get_prop}, + {"__newindex", wrap_group_box_t_set_prop}, + {NULL, NULL}}; luaL_newmetatable(L, "lftk.group_box_t"); lua_pushstring(L, "__index"); @@ -898,7 +800,7 @@ static int wrap_image_set_image_name(lua_State* L) { char* name = (char*)luaL_checkstring(L, 2); ret = (ret_t)image_set_image_name(widget, name); - lua_pushnumber(L,(lua_Number)(ret)); + lua_pushnumber(L, (lua_Number)(ret)); return 1; } @@ -909,17 +811,15 @@ static int wrap_image_set_draw_type(lua_State* L) { image_draw_type_t draw_type = (image_draw_type_t)luaL_checkinteger(L, 2); ret = (ret_t)image_set_draw_type(widget, draw_type); - lua_pushnumber(L,(lua_Number)(ret)); + lua_pushnumber(L, (lua_Number)(ret)); return 1; } - static const struct luaL_Reg image_t_member_funcs[] = { - {"set_image_name", wrap_image_set_image_name}, - {"set_draw_type", wrap_image_set_draw_type}, - {NULL, NULL} -}; + {"set_image_name", wrap_image_set_image_name}, + {"set_draw_type", wrap_image_set_draw_type}, + {NULL, NULL}}; static int wrap_image_t_set_prop(lua_State* L) { image_t* obj = (image_t*)lftk_checkudata(L, 1, "image_t"); @@ -927,8 +827,8 @@ static int wrap_image_t_set_prop(lua_State* L) { (void)obj; (void)name; return wrap_widget_t_set_prop(L); - printf("%s: not supported %s\n", __func__, name); - return 0; + printf("%s: not supported %s\n", __func__, name); + return 0; } static int wrap_image_t_get_prop(lua_State* L) { @@ -938,26 +838,19 @@ static int wrap_image_t_get_prop(lua_State* L) { (void)obj; (void)name; - if(ret) { + if (ret) { lua_pushcfunction(L, ret->func); return 1; - } - else { + } else { return wrap_widget_t_get_prop(L); } } static void image_t_init(lua_State* L) { - static const struct luaL_Reg static_funcs[] = { - {"create", wrap_image_create}, - {NULL, NULL} - }; + static const struct luaL_Reg static_funcs[] = {{"create", wrap_image_create}, {NULL, NULL}}; static const struct luaL_Reg index_funcs[] = { - {"__index", wrap_image_t_get_prop}, - {"__newindex", wrap_image_t_set_prop}, - {NULL, NULL} - }; + {"__index", wrap_image_t_get_prop}, {"__newindex", wrap_image_t_set_prop}, {NULL, NULL}}; luaL_newmetatable(L, "lftk.image_t"); lua_pushstring(L, "__index"); @@ -985,16 +878,13 @@ static int wrap_label_set_text(lua_State* L) { wchar_t* text = (wchar_t*)lua_touserdata(L, 2); ret = (ret_t)label_set_text(widget, text); - lua_pushnumber(L,(lua_Number)(ret)); + lua_pushnumber(L, (lua_Number)(ret)); return 1; } - -static const struct luaL_Reg label_t_member_funcs[] = { - {"set_text", wrap_label_set_text}, - {NULL, NULL} -}; +static const struct luaL_Reg label_t_member_funcs[] = {{"set_text", wrap_label_set_text}, + {NULL, NULL}}; static int wrap_label_t_set_prop(lua_State* L) { label_t* obj = (label_t*)lftk_checkudata(L, 1, "label_t"); @@ -1002,8 +892,8 @@ static int wrap_label_t_set_prop(lua_State* L) { (void)obj; (void)name; return wrap_widget_t_set_prop(L); - printf("%s: not supported %s\n", __func__, name); - return 0; + printf("%s: not supported %s\n", __func__, name); + return 0; } static int wrap_label_t_get_prop(lua_State* L) { @@ -1013,26 +903,19 @@ static int wrap_label_t_get_prop(lua_State* L) { (void)obj; (void)name; - if(ret) { + if (ret) { lua_pushcfunction(L, ret->func); return 1; - } - else { + } else { return wrap_widget_t_get_prop(L); } } static void label_t_init(lua_State* L) { - static const struct luaL_Reg static_funcs[] = { - {"create", wrap_label_create}, - {NULL, NULL} - }; + static const struct luaL_Reg static_funcs[] = {{"create", wrap_label_create}, {NULL, NULL}}; static const struct luaL_Reg index_funcs[] = { - {"__index", wrap_label_t_get_prop}, - {"__newindex", wrap_label_t_set_prop}, - {NULL, NULL} - }; + {"__index", wrap_label_t_get_prop}, {"__newindex", wrap_label_t_set_prop}, {NULL, NULL}}; luaL_newmetatable(L, "lftk.label_t"); lua_pushstring(L, "__index"); @@ -1060,7 +943,7 @@ static int wrap_progress_bar_set_value(lua_State* L) { uint8_t value = (uint8_t)luaL_checkinteger(L, 2); ret = (ret_t)progress_bar_set_value(widget, value); - lua_pushnumber(L,(lua_Number)(ret)); + lua_pushnumber(L, (lua_Number)(ret)); return 1; } @@ -1071,7 +954,7 @@ static int wrap_progress_bar_set_vertical(lua_State* L) { bool_t vertical = (bool_t)lua_toboolean(L, 2); ret = (ret_t)progress_bar_set_vertical(widget, vertical); - lua_pushnumber(L,(lua_Number)(ret)); + lua_pushnumber(L, (lua_Number)(ret)); return 1; } @@ -1082,38 +965,33 @@ static int wrap_progress_bar_set_show_text(lua_State* L) { bool_t show_text = (bool_t)lua_toboolean(L, 2); ret = (ret_t)progress_bar_set_show_text(widget, show_text); - lua_pushnumber(L,(lua_Number)(ret)); + lua_pushnumber(L, (lua_Number)(ret)); return 1; } - static const struct luaL_Reg progress_bar_t_member_funcs[] = { - {"set_value", wrap_progress_bar_set_value}, - {"set_vertical", wrap_progress_bar_set_vertical}, - {"set_show_text", wrap_progress_bar_set_show_text}, - {NULL, NULL} -}; + {"set_value", wrap_progress_bar_set_value}, + {"set_vertical", wrap_progress_bar_set_vertical}, + {"set_show_text", wrap_progress_bar_set_show_text}, + {NULL, NULL}}; static int wrap_progress_bar_t_set_prop(lua_State* L) { progress_bar_t* obj = (progress_bar_t*)lftk_checkudata(L, 1, "progress_bar_t"); const char* name = (const char*)luaL_checkstring(L, 2); (void)obj; (void)name; - if(strcmp(name, "value") == 0) { + if (strcmp(name, "value") == 0) { printf("value is readonly\n"); return 0; - } - else if(strcmp(name, "vertical") == 0) { + } else if (strcmp(name, "vertical") == 0) { printf("vertical is readonly\n"); return 0; - } - else if(strcmp(name, "show_text") == 0) { + } else if (strcmp(name, "show_text") == 0) { printf("show_text is readonly\n"); return 0; - } - else { - return wrap_widget_t_set_prop(L); + } else { + return wrap_widget_t_set_prop(L); } } @@ -1124,41 +1002,34 @@ static int wrap_progress_bar_t_get_prop(lua_State* L) { (void)obj; (void)name; - if(ret) { + if (ret) { lua_pushcfunction(L, ret->func); return 1; } - if(strcmp(name, "value") == 0) { - lua_pushinteger(L,(lua_Integer)(obj->value)); + if (strcmp(name, "value") == 0) { + lua_pushinteger(L, (lua_Integer)(obj->value)); - return 1; - } - else if(strcmp(name, "vertical") == 0) { - lua_pushboolean(L,(lua_Integer)(obj->vertical)); + return 1; + } else if (strcmp(name, "vertical") == 0) { + lua_pushboolean(L, (lua_Integer)(obj->vertical)); - return 1; - } - else if(strcmp(name, "show_text") == 0) { - lua_pushboolean(L,(lua_Integer)(obj->show_text)); + return 1; + } else if (strcmp(name, "show_text") == 0) { + lua_pushboolean(L, (lua_Integer)(obj->show_text)); - return 1; - } - else { + return 1; + } else { return wrap_widget_t_get_prop(L); } } static void progress_bar_t_init(lua_State* L) { - static const struct luaL_Reg static_funcs[] = { - {"create", wrap_progress_bar_create}, - {NULL, NULL} - }; + static const struct luaL_Reg static_funcs[] = {{"create", wrap_progress_bar_create}, + {NULL, NULL}}; - static const struct luaL_Reg index_funcs[] = { - {"__index", wrap_progress_bar_t_get_prop}, - {"__newindex", wrap_progress_bar_t_set_prop}, - {NULL, NULL} - }; + static const struct luaL_Reg index_funcs[] = {{"__index", wrap_progress_bar_t_get_prop}, + {"__newindex", wrap_progress_bar_t_set_prop}, + {NULL, NULL}}; luaL_newmetatable(L, "lftk.progress_bar_t"); lua_pushstring(L, "__index"); @@ -1169,24 +1040,20 @@ static void progress_bar_t_init(lua_State* L) { lua_settop(L, 0); } -static const struct luaL_Reg point_t_member_funcs[] = { - {NULL, NULL} -}; +static const struct luaL_Reg point_t_member_funcs[] = {{NULL, NULL}}; static int wrap_point_t_set_prop(lua_State* L) { point_t* obj = (point_t*)lftk_checkudata(L, 1, "point_t"); const char* name = (const char*)luaL_checkstring(L, 2); (void)obj; (void)name; - if(strcmp(name, "x") == 0) { + if (strcmp(name, "x") == 0) { printf("x is readonly\n"); return 0; - } - else if(strcmp(name, "y") == 0) { + } else if (strcmp(name, "y") == 0) { printf("y is readonly\n"); return 0; - } - else { + } else { printf("%s: not supported %s\n", __func__, name); return 0; } @@ -1199,36 +1066,29 @@ static int wrap_point_t_get_prop(lua_State* L) { (void)obj; (void)name; - if(ret) { + if (ret) { lua_pushcfunction(L, ret->func); return 1; } - if(strcmp(name, "x") == 0) { - lua_pushnumber(L,(lua_Number)(obj->x)); + if (strcmp(name, "x") == 0) { + lua_pushnumber(L, (lua_Number)(obj->x)); - return 1; - } - else if(strcmp(name, "y") == 0) { - lua_pushnumber(L,(lua_Number)(obj->y)); + return 1; + } else if (strcmp(name, "y") == 0) { + lua_pushnumber(L, (lua_Number)(obj->y)); - return 1; - } - else { + return 1; + } else { printf("%s: not supported %s\n", __func__, name); return 0; } } static void point_t_init(lua_State* L) { - static const struct luaL_Reg static_funcs[] = { - {NULL, NULL} - }; + static const struct luaL_Reg static_funcs[] = {{NULL, NULL}}; static const struct luaL_Reg index_funcs[] = { - {"__index", wrap_point_t_get_prop}, - {"__newindex", wrap_point_t_set_prop}, - {NULL, NULL} - }; + {"__index", wrap_point_t_get_prop}, {"__newindex", wrap_point_t_set_prop}, {NULL, NULL}}; luaL_newmetatable(L, "lftk.point_t"); lua_pushstring(L, "__index"); @@ -1239,32 +1099,26 @@ static void point_t_init(lua_State* L) { lua_settop(L, 0); } -static const struct luaL_Reg rect_t_member_funcs[] = { - {NULL, NULL} -}; +static const struct luaL_Reg rect_t_member_funcs[] = {{NULL, NULL}}; static int wrap_rect_t_set_prop(lua_State* L) { rect_t* obj = (rect_t*)lftk_checkudata(L, 1, "rect_t"); const char* name = (const char*)luaL_checkstring(L, 2); (void)obj; (void)name; - if(strcmp(name, "x") == 0) { + if (strcmp(name, "x") == 0) { printf("x is readonly\n"); return 0; - } - else if(strcmp(name, "y") == 0) { + } else if (strcmp(name, "y") == 0) { printf("y is readonly\n"); return 0; - } - else if(strcmp(name, "w") == 0) { + } else if (strcmp(name, "w") == 0) { printf("w is readonly\n"); return 0; - } - else if(strcmp(name, "h") == 0) { + } else if (strcmp(name, "h") == 0) { printf("h is readonly\n"); return 0; - } - else { + } else { printf("%s: not supported %s\n", __func__, name); return 0; } @@ -1277,46 +1131,37 @@ static int wrap_rect_t_get_prop(lua_State* L) { (void)obj; (void)name; - if(ret) { + if (ret) { lua_pushcfunction(L, ret->func); return 1; } - if(strcmp(name, "x") == 0) { - lua_pushnumber(L,(lua_Number)(obj->x)); + if (strcmp(name, "x") == 0) { + lua_pushnumber(L, (lua_Number)(obj->x)); - return 1; - } - else if(strcmp(name, "y") == 0) { - lua_pushnumber(L,(lua_Number)(obj->y)); + return 1; + } else if (strcmp(name, "y") == 0) { + lua_pushnumber(L, (lua_Number)(obj->y)); - return 1; - } - else if(strcmp(name, "w") == 0) { - lua_pushnumber(L,(lua_Number)(obj->w)); + return 1; + } else if (strcmp(name, "w") == 0) { + lua_pushnumber(L, (lua_Number)(obj->w)); - return 1; - } - else if(strcmp(name, "h") == 0) { - lua_pushnumber(L,(lua_Number)(obj->h)); + return 1; + } else if (strcmp(name, "h") == 0) { + lua_pushnumber(L, (lua_Number)(obj->h)); - return 1; - } - else { + return 1; + } else { printf("%s: not supported %s\n", __func__, name); return 0; } } static void rect_t_init(lua_State* L) { - static const struct luaL_Reg static_funcs[] = { - {NULL, NULL} - }; + static const struct luaL_Reg static_funcs[] = {{NULL, NULL}}; static const struct luaL_Reg index_funcs[] = { - {"__index", wrap_rect_t_get_prop}, - {"__newindex", wrap_rect_t_set_prop}, - {NULL, NULL} - }; + {"__index", wrap_rect_t_get_prop}, {"__newindex", wrap_rect_t_set_prop}, {NULL, NULL}}; luaL_newmetatable(L, "lftk.rect_t"); lua_pushstring(L, "__index"); @@ -1333,20 +1178,19 @@ static void align_v_t_init(lua_State* L) { lua_pushstring(L, "NONE"); lua_pushinteger(L, ALIGN_V_NONE); - lua_settable(L, -3); + lua_settable(L, -3); lua_pushstring(L, "MIDDLE"); lua_pushinteger(L, ALIGN_V_MIDDLE); - lua_settable(L, -3); + lua_settable(L, -3); lua_pushstring(L, "TOP"); lua_pushinteger(L, ALIGN_V_TOP); - lua_settable(L, -3); + lua_settable(L, -3); lua_pushstring(L, "BOTTOM"); lua_pushinteger(L, ALIGN_V_BOTTOM); - lua_settable(L, -3); - + lua_settable(L, -3); } static void align_h_t_init(lua_State* L) { @@ -1356,38 +1200,35 @@ static void align_h_t_init(lua_State* L) { lua_pushstring(L, "NONE"); lua_pushinteger(L, ALIGN_H_NONE); - lua_settable(L, -3); + lua_settable(L, -3); lua_pushstring(L, "CENTER"); lua_pushinteger(L, ALIGN_H_CENTER); - lua_settable(L, -3); + lua_settable(L, -3); lua_pushstring(L, "LEFT"); lua_pushinteger(L, ALIGN_H_LEFT); - lua_settable(L, -3); + lua_settable(L, -3); lua_pushstring(L, "RIGHT"); lua_pushinteger(L, ALIGN_H_RIGHT); - lua_settable(L, -3); - + lua_settable(L, -3); } static int wrap_timer_count(lua_State* L) { uint32_t ret = 0; ret = (uint32_t)timer_count(); - lua_pushinteger(L,(lua_Integer)(ret)); + lua_pushinteger(L, (lua_Integer)(ret)); return 1; } static void timer_t_init(lua_State* L) { - static const struct luaL_Reg static_funcs[] = { - {"add", wrap_timer_add}, - {"remove", wrap_timer_remove}, - {"count", wrap_timer_count}, - {NULL, NULL} - }; + static const struct luaL_Reg static_funcs[] = {{"add", wrap_timer_add}, + {"remove", wrap_timer_remove}, + {"count", wrap_timer_count}, + {NULL, NULL}}; luaL_openlib(L, "Timer", static_funcs, 0); lua_settop(L, 0); @@ -1399,40 +1240,39 @@ static void ret_t_init(lua_State* L) { lua_pushstring(L, "OK"); lua_pushinteger(L, RET_OK); - lua_settable(L, -3); + lua_settable(L, -3); lua_pushstring(L, "OOM"); lua_pushinteger(L, RET_OOM); - lua_settable(L, -3); + lua_settable(L, -3); lua_pushstring(L, "FAIL"); lua_pushinteger(L, RET_FAIL); - lua_settable(L, -3); + lua_settable(L, -3); lua_pushstring(L, "QUIT"); lua_pushinteger(L, RET_QUIT); - lua_settable(L, -3); + lua_settable(L, -3); lua_pushstring(L, "FOUND"); lua_pushinteger(L, RET_FOUND); - lua_settable(L, -3); + lua_settable(L, -3); lua_pushstring(L, "REMOVE"); lua_pushinteger(L, RET_REMOVE); - lua_settable(L, -3); + lua_settable(L, -3); lua_pushstring(L, "REPEAT"); lua_pushinteger(L, RET_REPEAT); - lua_settable(L, -3); + lua_settable(L, -3); lua_pushstring(L, "NOT_FOUND"); lua_pushinteger(L, RET_NOT_FOUND); - lua_settable(L, -3); + lua_settable(L, -3); lua_pushstring(L, "BAD_PARAMS"); lua_pushinteger(L, RET_BAD_PARAMS); - lua_settable(L, -3); - + lua_settable(L, -3); } static void value_type_t_init(lua_State* L) { @@ -1442,64 +1282,63 @@ static void value_type_t_init(lua_State* L) { lua_pushstring(L, "INVALID"); lua_pushinteger(L, VALUE_TYPE_INVALID); - lua_settable(L, -3); + lua_settable(L, -3); lua_pushstring(L, "BOOL"); lua_pushinteger(L, VALUE_TYPE_BOOL); - lua_settable(L, -3); + lua_settable(L, -3); lua_pushstring(L, "INT8"); lua_pushinteger(L, VALUE_TYPE_INT8); - lua_settable(L, -3); + lua_settable(L, -3); lua_pushstring(L, "UINT8"); lua_pushinteger(L, VALUE_TYPE_UINT8); - lua_settable(L, -3); + lua_settable(L, -3); lua_pushstring(L, "INT16"); lua_pushinteger(L, VALUE_TYPE_INT16); - lua_settable(L, -3); + lua_settable(L, -3); lua_pushstring(L, "UINT16"); lua_pushinteger(L, VALUE_TYPE_UINT16); - lua_settable(L, -3); + lua_settable(L, -3); lua_pushstring(L, "INT32"); lua_pushinteger(L, VALUE_TYPE_INT32); - lua_settable(L, -3); + lua_settable(L, -3); lua_pushstring(L, "UINT32"); lua_pushinteger(L, VALUE_TYPE_UINT32); - lua_settable(L, -3); + lua_settable(L, -3); lua_pushstring(L, "INT64"); lua_pushinteger(L, VALUE_TYPE_INT64); - lua_settable(L, -3); + lua_settable(L, -3); lua_pushstring(L, "UINT64"); lua_pushinteger(L, VALUE_TYPE_UINT64); - lua_settable(L, -3); + lua_settable(L, -3); lua_pushstring(L, "POINTER"); lua_pushinteger(L, VALUE_TYPE_POINTER); - lua_settable(L, -3); + lua_settable(L, -3); lua_pushstring(L, "FLOAT"); lua_pushinteger(L, VALUE_TYPE_FLOAT); - lua_settable(L, -3); + lua_settable(L, -3); lua_pushstring(L, "DOUBLE"); lua_pushinteger(L, VALUE_TYPE_DOUBLE); - lua_settable(L, -3); + lua_settable(L, -3); lua_pushstring(L, "STRING"); lua_pushinteger(L, VALUE_TYPE_STRING); - lua_settable(L, -3); + lua_settable(L, -3); lua_pushstring(L, "WSTRING"); lua_pushinteger(L, VALUE_TYPE_WSTRING); - lua_settable(L, -3); - + lua_settable(L, -3); } static int wrap_value_set_bool(lua_State* L) { @@ -1516,7 +1355,7 @@ static int wrap_value_bool(lua_State* L) { value_t* v = (value_t*)lftk_checkudata(L, 1, "value_t"); ret = (bool_t)value_bool(v); - lua_pushboolean(L,(lua_Integer)(ret)); + lua_pushboolean(L, (lua_Integer)(ret)); return 1; } @@ -1535,7 +1374,7 @@ static int wrap_value_int8(lua_State* L) { value_t* v = (value_t*)lftk_checkudata(L, 1, "value_t"); ret = (int8_t)value_int8(v); - lua_pushinteger(L,(lua_Integer)(ret)); + lua_pushinteger(L, (lua_Integer)(ret)); return 1; } @@ -1554,7 +1393,7 @@ static int wrap_value_uint8(lua_State* L) { value_t* v = (value_t*)lftk_checkudata(L, 1, "value_t"); ret = (int8_t)value_uint8(v); - lua_pushinteger(L,(lua_Integer)(ret)); + lua_pushinteger(L, (lua_Integer)(ret)); return 1; } @@ -1573,7 +1412,7 @@ static int wrap_value_int16(lua_State* L) { value_t* v = (value_t*)lftk_checkudata(L, 1, "value_t"); ret = (int16_t)value_int16(v); - lua_pushinteger(L,(lua_Integer)(ret)); + lua_pushinteger(L, (lua_Integer)(ret)); return 1; } @@ -1592,7 +1431,7 @@ static int wrap_value_uint16(lua_State* L) { value_t* v = (value_t*)lftk_checkudata(L, 1, "value_t"); ret = (uint16_t)value_uint16(v); - lua_pushinteger(L,(lua_Integer)(ret)); + lua_pushinteger(L, (lua_Integer)(ret)); return 1; } @@ -1611,7 +1450,7 @@ static int wrap_value_int32(lua_State* L) { value_t* v = (value_t*)lftk_checkudata(L, 1, "value_t"); ret = (int32_t)value_int32(v); - lua_pushinteger(L,(lua_Integer)(ret)); + lua_pushinteger(L, (lua_Integer)(ret)); return 1; } @@ -1630,7 +1469,7 @@ static int wrap_value_uint32(lua_State* L) { value_t* v = (value_t*)lftk_checkudata(L, 1, "value_t"); ret = (uint32_t)value_uint32(v); - lua_pushinteger(L,(lua_Integer)(ret)); + lua_pushinteger(L, (lua_Integer)(ret)); return 1; } @@ -1649,7 +1488,7 @@ static int wrap_value_int64(lua_State* L) { value_t* v = (value_t*)lftk_checkudata(L, 1, "value_t"); ret = (int64_t)value_int64(v); - lua_pushinteger(L,(lua_Integer)(ret)); + lua_pushinteger(L, (lua_Integer)(ret)); return 1; } @@ -1668,7 +1507,7 @@ static int wrap_value_uint64(lua_State* L) { value_t* v = (value_t*)lftk_checkudata(L, 1, "value_t"); ret = (uint64_t)value_uint64(v); - lua_pushinteger(L,(lua_Integer)(ret)); + lua_pushinteger(L, (lua_Integer)(ret)); return 1; } @@ -1687,7 +1526,7 @@ static int wrap_value_float(lua_State* L) { value_t* v = (value_t*)lftk_checkudata(L, 1, "value_t"); ret = (float)value_float(v); - lua_pushnumber(L,(lua_Number)(ret)); + lua_pushnumber(L, (lua_Number)(ret)); return 1; } @@ -1706,7 +1545,7 @@ static int wrap_value_double(lua_State* L) { value_t* v = (value_t*)lftk_checkudata(L, 1, "value_t"); ret = (double)value_double(v); - lua_pushnumber(L,(lua_Number)(ret)); + lua_pushnumber(L, (lua_Number)(ret)); return 1; } @@ -1725,7 +1564,7 @@ static int wrap_value_str(lua_State* L) { value_t* v = (value_t*)lftk_checkudata(L, 1, "value_t"); ret = (const char*)value_str(v); - lua_pushstring(L,(char*)(ret)); + lua_pushstring(L, (char*)(ret)); return 1; } @@ -1735,7 +1574,7 @@ static int wrap_value_is_null(lua_State* L) { value_t* value = (value_t*)lftk_checkudata(L, 1, "value_t"); ret = (bool_t)value_is_null(value); - lua_pushboolean(L,(lua_Integer)(ret)); + lua_pushboolean(L, (lua_Integer)(ret)); return 1; } @@ -1745,7 +1584,7 @@ static int wrap_value_int(lua_State* L) { value_t* v = (value_t*)lftk_checkudata(L, 1, "value_t"); ret = (int)value_int(v); - lua_pushinteger(L,(lua_Integer)(ret)); + lua_pushinteger(L, (lua_Integer)(ret)); return 1; } @@ -1772,49 +1611,45 @@ static int wrap_value_destroy(lua_State* L) { return 0; } - -static const struct luaL_Reg value_t_member_funcs[] = { - {"set_bool", wrap_value_set_bool}, - {"bool", wrap_value_bool}, - {"set_int8", wrap_value_set_int8}, - {"int8", wrap_value_int8}, - {"set_uint8", wrap_value_set_uint8}, - {"uint8", wrap_value_uint8}, - {"set_int16", wrap_value_set_int16}, - {"int16", wrap_value_int16}, - {"set_uint16", wrap_value_set_uint16}, - {"uint16", wrap_value_uint16}, - {"set_int32", wrap_value_set_int32}, - {"int32", wrap_value_int32}, - {"set_uint32", wrap_value_set_uint32}, - {"uint32", wrap_value_uint32}, - {"set_int64", wrap_value_set_int64}, - {"int64", wrap_value_int64}, - {"set_uint64", wrap_value_set_uint64}, - {"uint64", wrap_value_uint64}, - {"set_float", wrap_value_set_float}, - {"float", wrap_value_float}, - {"set_double", wrap_value_set_double}, - {"double", wrap_value_double}, - {"set_str", wrap_value_set_str}, - {"str", wrap_value_str}, - {"is_null", wrap_value_is_null}, - {"int", wrap_value_int}, - {"copy", wrap_value_copy}, - {"destroy", wrap_value_destroy}, - {NULL, NULL} -}; +static const struct luaL_Reg value_t_member_funcs[] = {{"set_bool", wrap_value_set_bool}, + {"bool", wrap_value_bool}, + {"set_int8", wrap_value_set_int8}, + {"int8", wrap_value_int8}, + {"set_uint8", wrap_value_set_uint8}, + {"uint8", wrap_value_uint8}, + {"set_int16", wrap_value_set_int16}, + {"int16", wrap_value_int16}, + {"set_uint16", wrap_value_set_uint16}, + {"uint16", wrap_value_uint16}, + {"set_int32", wrap_value_set_int32}, + {"int32", wrap_value_int32}, + {"set_uint32", wrap_value_set_uint32}, + {"uint32", wrap_value_uint32}, + {"set_int64", wrap_value_set_int64}, + {"int64", wrap_value_int64}, + {"set_uint64", wrap_value_set_uint64}, + {"uint64", wrap_value_uint64}, + {"set_float", wrap_value_set_float}, + {"float", wrap_value_float}, + {"set_double", wrap_value_set_double}, + {"double", wrap_value_double}, + {"set_str", wrap_value_set_str}, + {"str", wrap_value_str}, + {"is_null", wrap_value_is_null}, + {"int", wrap_value_int}, + {"copy", wrap_value_copy}, + {"destroy", wrap_value_destroy}, + {NULL, NULL}}; static int wrap_value_t_set_prop(lua_State* L) { value_t* obj = (value_t*)lftk_checkudata(L, 1, "value_t"); const char* name = (const char*)luaL_checkstring(L, 2); (void)obj; (void)name; - if(strcmp(name, "type") == 0) { + if (strcmp(name, "type") == 0) { printf("type is readonly\n"); return 0; - } - else { + } else { printf("%s: not supported %s\n", __func__, name); return 0; } @@ -1827,32 +1662,25 @@ static int wrap_value_t_get_prop(lua_State* L) { (void)obj; (void)name; - if(ret) { + if (ret) { lua_pushcfunction(L, ret->func); return 1; } - if(strcmp(name, "type") == 0) { - lua_pushinteger(L,(lua_Integer)(obj->type)); + if (strcmp(name, "type") == 0) { + lua_pushinteger(L, (lua_Integer)(obj->type)); - return 1; - } - else { + return 1; + } else { printf("%s: not supported %s\n", __func__, name); return 0; } } static void value_t_init(lua_State* L) { - static const struct luaL_Reg static_funcs[] = { - {"create", wrap_value_create}, - {NULL, NULL} - }; + static const struct luaL_Reg static_funcs[] = {{"create", wrap_value_create}, {NULL, NULL}}; static const struct luaL_Reg index_funcs[] = { - {"__index", wrap_value_t_get_prop}, - {"__newindex", wrap_value_t_set_prop}, - {NULL, NULL} - }; + {"__index", wrap_value_t_get_prop}, {"__newindex", wrap_value_t_set_prop}, {NULL, NULL}}; luaL_newmetatable(L, "lftk.value_t"); lua_pushstring(L, "__index"); @@ -1869,36 +1697,35 @@ static void widget_state_t_init(lua_State* L) { lua_pushstring(L, "STATE_NONE"); lua_pushinteger(L, WIDGET_STATE_NONE); - lua_settable(L, -3); + lua_settable(L, -3); lua_pushstring(L, "STATE_NORMAL"); lua_pushinteger(L, WIDGET_STATE_NORMAL); - lua_settable(L, -3); + lua_settable(L, -3); lua_pushstring(L, "STATE_PRESSED"); lua_pushinteger(L, WIDGET_STATE_PRESSED); - lua_settable(L, -3); + lua_settable(L, -3); lua_pushstring(L, "STATE_OVER"); lua_pushinteger(L, WIDGET_STATE_OVER); - lua_settable(L, -3); + lua_settable(L, -3); lua_pushstring(L, "STATE_DISABLE"); lua_pushinteger(L, WIDGET_STATE_DISABLE); - lua_settable(L, -3); + lua_settable(L, -3); lua_pushstring(L, "STATE_FOCUSED"); lua_pushinteger(L, WIDGET_STATE_FOCUSED); - lua_settable(L, -3); + lua_settable(L, -3); lua_pushstring(L, "STATE_CHECKED"); lua_pushinteger(L, WIDGET_STATE_CHECKED); - lua_settable(L, -3); + lua_settable(L, -3); lua_pushstring(L, "STATE_UNCHECKED"); lua_pushinteger(L, WIDGET_STATE_UNCHECKED); - lua_settable(L, -3); - + lua_settable(L, -3); } static void widget_type_t_init(lua_State* L) { @@ -1908,80 +1735,79 @@ static void widget_type_t_init(lua_State* L) { lua_pushstring(L, "WIDGET_NONE"); lua_pushinteger(L, WIDGET_NONE); - lua_settable(L, -3); + lua_settable(L, -3); lua_pushstring(L, "WIDGET_WINDOW_MANAGER"); lua_pushinteger(L, WIDGET_WINDOW_MANAGER); - lua_settable(L, -3); + lua_settable(L, -3); lua_pushstring(L, "WIDGET_NORMAL_WINDOW"); lua_pushinteger(L, WIDGET_NORMAL_WINDOW); - lua_settable(L, -3); + lua_settable(L, -3); lua_pushstring(L, "WIDGET_TOOL_BAR"); lua_pushinteger(L, WIDGET_TOOL_BAR); - lua_settable(L, -3); + lua_settable(L, -3); lua_pushstring(L, "WIDGET_DIALOG"); lua_pushinteger(L, WIDGET_DIALOG); - lua_settable(L, -3); + lua_settable(L, -3); lua_pushstring(L, "WIDGET_POPUP"); lua_pushinteger(L, WIDGET_POPUP); - lua_settable(L, -3); + lua_settable(L, -3); lua_pushstring(L, "WIDGET_SPRITE"); lua_pushinteger(L, WIDGET_SPRITE); - lua_settable(L, -3); + lua_settable(L, -3); lua_pushstring(L, "WIDGET_KEYBOARD"); lua_pushinteger(L, WIDGET_KEYBOARD); - lua_settable(L, -3); + lua_settable(L, -3); lua_pushstring(L, "WIDGET_DRAGGER"); lua_pushinteger(L, WIDGET_DRAGGER); - lua_settable(L, -3); + lua_settable(L, -3); lua_pushstring(L, "WIDGET_LABEL"); lua_pushinteger(L, WIDGET_LABEL); - lua_settable(L, -3); + lua_settable(L, -3); lua_pushstring(L, "WIDGET_BUTTON"); lua_pushinteger(L, WIDGET_BUTTON); - lua_settable(L, -3); + lua_settable(L, -3); lua_pushstring(L, "WIDGET_IMAGE"); lua_pushinteger(L, WIDGET_IMAGE); - lua_settable(L, -3); + lua_settable(L, -3); lua_pushstring(L, "WIDGET_EDIT"); lua_pushinteger(L, WIDGET_EDIT); - lua_settable(L, -3); + lua_settable(L, -3); lua_pushstring(L, "WIDGET_PROGRESS_BAR"); lua_pushinteger(L, WIDGET_PROGRESS_BAR); - lua_settable(L, -3); + lua_settable(L, -3); lua_pushstring(L, "WIDGET_GROUP_BOX"); lua_pushinteger(L, WIDGET_GROUP_BOX); - lua_settable(L, -3); + lua_settable(L, -3); lua_pushstring(L, "WIDGET_CHECK_BUTTON"); lua_pushinteger(L, WIDGET_CHECK_BUTTON); - lua_settable(L, -3); + lua_settable(L, -3); lua_pushstring(L, "WIDGET_RADIO_BUTTON"); lua_pushinteger(L, WIDGET_RADIO_BUTTON); - lua_settable(L, -3); + lua_settable(L, -3); lua_pushstring(L, "WIDGET_DIALOG_TITLE"); lua_pushinteger(L, WIDGET_DIALOG_TITLE); - lua_settable(L, -3); + lua_settable(L, -3); lua_pushstring(L, "WIDGET_DIALOG_CLIENT"); lua_pushinteger(L, WIDGET_DIALOG_CLIENT); - lua_settable(L, -3); - + lua_settable(L, -3); } static int wrap_widget_count_children(lua_State* L) { @@ -1989,7 +1815,7 @@ static int wrap_widget_count_children(lua_State* L) { widget_t* widget = (widget_t*)lftk_checkudata(L, 1, "widget_t"); ret = (uint32_t)widget_count_children(widget); - lua_pushinteger(L,(lua_Integer)(ret)); + lua_pushinteger(L, (lua_Integer)(ret)); return 1; } @@ -2010,7 +1836,7 @@ static int wrap_widget_move(lua_State* L) { xy_t y = (xy_t)luaL_checkinteger(L, 3); ret = (ret_t)widget_move(widget, x, y); - lua_pushnumber(L,(lua_Number)(ret)); + lua_pushnumber(L, (lua_Number)(ret)); return 1; } @@ -2022,7 +1848,7 @@ static int wrap_widget_resize(lua_State* L) { wh_t h = (wh_t)luaL_checkinteger(L, 3); ret = (ret_t)widget_resize(widget, w, h); - lua_pushnumber(L,(lua_Number)(ret)); + lua_pushnumber(L, (lua_Number)(ret)); return 1; } @@ -2036,7 +1862,7 @@ static int wrap_widget_move_resize(lua_State* L) { wh_t h = (wh_t)luaL_checkinteger(L, 5); ret = (ret_t)widget_move_resize(widget, x, y, w, h); - lua_pushnumber(L,(lua_Number)(ret)); + lua_pushnumber(L, (lua_Number)(ret)); return 1; } @@ -2047,7 +1873,7 @@ static int wrap_widget_set_value(lua_State* L) { uint32_t value = (uint32_t)luaL_checkinteger(L, 2); ret = (ret_t)widget_set_value(widget, value); - lua_pushnumber(L,(lua_Number)(ret)); + lua_pushnumber(L, (lua_Number)(ret)); return 1; } @@ -2058,7 +1884,7 @@ static int wrap_widget_use_style(lua_State* L) { char* value = (char*)luaL_checkstring(L, 2); ret = (ret_t)widget_use_style(widget, value); - lua_pushnumber(L,(lua_Number)(ret)); + lua_pushnumber(L, (lua_Number)(ret)); return 1; } @@ -2069,7 +1895,7 @@ static int wrap_widget_set_text(lua_State* L) { wchar_t* text = (wchar_t*)lua_touserdata(L, 2); ret = (ret_t)widget_set_text(widget, text); - lua_pushnumber(L,(lua_Number)(ret)); + lua_pushnumber(L, (lua_Number)(ret)); return 1; } @@ -2079,7 +1905,7 @@ static int wrap_widget_get_value(lua_State* L) { widget_t* widget = (widget_t*)lftk_checkudata(L, 1, "widget_t"); ret = (uint32_t)widget_get_value(widget); - lua_pushinteger(L,(lua_Integer)(ret)); + lua_pushinteger(L, (lua_Integer)(ret)); return 1; } @@ -2089,7 +1915,7 @@ static int wrap_widget_get_text(lua_State* L) { widget_t* widget = (widget_t*)lftk_checkudata(L, 1, "widget_t"); ret = (wchar_t*)widget_get_text(widget); - lua_pushlightuserdata(L,(void*)(ret)); + lua_pushlightuserdata(L, (void*)(ret)); return 1; } @@ -2100,7 +1926,7 @@ static int wrap_widget_to_local(lua_State* L) { point_t* p = (point_t*)lftk_checkudata(L, 2, "point_t"); ret = (ret_t)widget_to_local(widget, p); - lua_pushnumber(L,(lua_Number)(ret)); + lua_pushnumber(L, (lua_Number)(ret)); return 1; } @@ -2111,7 +1937,7 @@ static int wrap_widget_to_global(lua_State* L) { point_t* p = (point_t*)lftk_checkudata(L, 2, "point_t"); ret = (ret_t)widget_to_global(widget, p); - lua_pushnumber(L,(lua_Number)(ret)); + lua_pushnumber(L, (lua_Number)(ret)); return 1; } @@ -2122,7 +1948,7 @@ static int wrap_widget_set_name(lua_State* L) { char* name = (char*)luaL_checkstring(L, 2); ret = (ret_t)widget_set_name(widget, name); - lua_pushnumber(L,(lua_Number)(ret)); + lua_pushnumber(L, (lua_Number)(ret)); return 1; } @@ -2133,7 +1959,7 @@ static int wrap_widget_set_enable(lua_State* L) { bool_t enable = (bool_t)lua_toboolean(L, 2); ret = (ret_t)widget_set_enable(widget, enable); - lua_pushnumber(L,(lua_Number)(ret)); + lua_pushnumber(L, (lua_Number)(ret)); return 1; } @@ -2144,7 +1970,7 @@ static int wrap_widget_set_focused(lua_State* L) { bool_t focused = (bool_t)lua_toboolean(L, 2); ret = (ret_t)widget_set_focused(widget, focused); - lua_pushnumber(L,(lua_Number)(ret)); + lua_pushnumber(L, (lua_Number)(ret)); return 1; } @@ -2155,7 +1981,7 @@ static int wrap_widget_set_state(lua_State* L) { widget_state_t state = (widget_state_t)luaL_checkinteger(L, 2); ret = (ret_t)widget_set_state(widget, state); - lua_pushnumber(L,(lua_Number)(ret)); + lua_pushnumber(L, (lua_Number)(ret)); return 1; } @@ -2165,7 +1991,7 @@ static int wrap_widget_destroy_children(lua_State* L) { widget_t* widget = (widget_t*)lftk_checkudata(L, 1, "widget_t"); ret = (ret_t)widget_destroy_children(widget); - lua_pushnumber(L,(lua_Number)(ret)); + lua_pushnumber(L, (lua_Number)(ret)); return 1; } @@ -2176,7 +2002,7 @@ static int wrap_widget_add_child(lua_State* L) { widget_t* child = (widget_t*)lftk_checkudata(L, 2, "widget_t"); ret = (ret_t)widget_add_child(widget, child); - lua_pushnumber(L,(lua_Number)(ret)); + lua_pushnumber(L, (lua_Number)(ret)); return 1; } @@ -2187,7 +2013,7 @@ static int wrap_widget_remove_child(lua_State* L) { widget_t* child = (widget_t*)lftk_checkudata(L, 2, "widget_t"); ret = (ret_t)widget_remove_child(widget, child); - lua_pushnumber(L,(lua_Number)(ret)); + lua_pushnumber(L, (lua_Number)(ret)); return 1; } @@ -2209,7 +2035,7 @@ static int wrap_widget_set_visible(lua_State* L) { bool_t recursive = (bool_t)lua_toboolean(L, 3); ret = (ret_t)widget_set_visible(widget, visible, recursive); - lua_pushnumber(L,(lua_Number)(ret)); + lua_pushnumber(L, (lua_Number)(ret)); return 1; } @@ -2220,7 +2046,7 @@ static int wrap_widget_invalidate(lua_State* L) { rect_t* r = (rect_t*)lftk_checkudata(L, 2, "rect_t"); ret = (ret_t)widget_invalidate(widget, r); - lua_pushnumber(L,(lua_Number)(ret)); + lua_pushnumber(L, (lua_Number)(ret)); return 1; } @@ -2232,7 +2058,7 @@ static int wrap_widget_get_prop(lua_State* L) { value_t* v = (value_t*)lftk_checkudata(L, 3, "value_t"); ret = (ret_t)widget_get_prop(widget, name, v); - lua_pushnumber(L,(lua_Number)(ret)); + lua_pushnumber(L, (lua_Number)(ret)); return 1; } @@ -2244,7 +2070,7 @@ static int wrap_widget_set_prop(lua_State* L) { value_t* v = (value_t*)lftk_checkudata(L, 3, "value_t"); ret = (ret_t)widget_set_prop(widget, name, v); - lua_pushnumber(L,(lua_Number)(ret)); + lua_pushnumber(L, (lua_Number)(ret)); return 1; } @@ -2255,7 +2081,7 @@ static int wrap_widget_grab(lua_State* L) { widget_t* child = (widget_t*)lftk_checkudata(L, 2, "widget_t"); ret = (ret_t)widget_grab(widget, child); - lua_pushnumber(L,(lua_Number)(ret)); + lua_pushnumber(L, (lua_Number)(ret)); return 1; } @@ -2266,7 +2092,7 @@ static int wrap_widget_ungrab(lua_State* L) { widget_t* child = (widget_t*)lftk_checkudata(L, 2, "widget_t"); ret = (ret_t)widget_ungrab(widget, child); - lua_pushnumber(L,(lua_Number)(ret)); + lua_pushnumber(L, (lua_Number)(ret)); return 1; } @@ -2276,100 +2102,86 @@ static int wrap_widget_destroy(lua_State* L) { widget_t* widget = (widget_t*)lftk_checkudata(L, 1, "widget_t"); ret = (ret_t)widget_destroy(widget); - lua_pushnumber(L,(lua_Number)(ret)); + lua_pushnumber(L, (lua_Number)(ret)); return 1; } - static const struct luaL_Reg widget_t_member_funcs[] = { - {"count_children", wrap_widget_count_children}, - {"get_child", wrap_widget_get_child}, - {"move", wrap_widget_move}, - {"resize", wrap_widget_resize}, - {"move_resize", wrap_widget_move_resize}, - {"set_value", wrap_widget_set_value}, - {"use_style", wrap_widget_use_style}, - {"set_text", wrap_widget_set_text}, - {"get_value", wrap_widget_get_value}, - {"get_text", wrap_widget_get_text}, - {"to_local", wrap_widget_to_local}, - {"to_global", wrap_widget_to_global}, - {"set_name", wrap_widget_set_name}, - {"set_enable", wrap_widget_set_enable}, - {"set_focused", wrap_widget_set_focused}, - {"set_state", wrap_widget_set_state}, - {"destroy_children", wrap_widget_destroy_children}, - {"add_child", wrap_widget_add_child}, - {"remove_child", wrap_widget_remove_child}, - {"lookup", wrap_widget_lookup}, - {"set_visible", wrap_widget_set_visible}, - {"on", wrap_widget_on}, - {"off", wrap_widget_off}, - {"on", wrap_widget_on}, - {"invalidate", wrap_widget_invalidate}, - {"get_prop", wrap_widget_get_prop}, - {"set_prop", wrap_widget_set_prop}, - {"grab", wrap_widget_grab}, - {"ungrab", wrap_widget_ungrab}, - {"destroy", wrap_widget_destroy}, - {NULL, NULL} -}; + {"count_children", wrap_widget_count_children}, + {"get_child", wrap_widget_get_child}, + {"move", wrap_widget_move}, + {"resize", wrap_widget_resize}, + {"move_resize", wrap_widget_move_resize}, + {"set_value", wrap_widget_set_value}, + {"use_style", wrap_widget_use_style}, + {"set_text", wrap_widget_set_text}, + {"get_value", wrap_widget_get_value}, + {"get_text", wrap_widget_get_text}, + {"to_local", wrap_widget_to_local}, + {"to_global", wrap_widget_to_global}, + {"set_name", wrap_widget_set_name}, + {"set_enable", wrap_widget_set_enable}, + {"set_focused", wrap_widget_set_focused}, + {"set_state", wrap_widget_set_state}, + {"destroy_children", wrap_widget_destroy_children}, + {"add_child", wrap_widget_add_child}, + {"remove_child", wrap_widget_remove_child}, + {"lookup", wrap_widget_lookup}, + {"set_visible", wrap_widget_set_visible}, + {"on", wrap_widget_on}, + {"off", wrap_widget_off}, + {"on", wrap_widget_on}, + {"invalidate", wrap_widget_invalidate}, + {"get_prop", wrap_widget_get_prop}, + {"set_prop", wrap_widget_set_prop}, + {"grab", wrap_widget_grab}, + {"ungrab", wrap_widget_ungrab}, + {"destroy", wrap_widget_destroy}, + {NULL, NULL}}; static int wrap_widget_t_set_prop(lua_State* L) { widget_t* obj = (widget_t*)lftk_checkudata(L, 1, "widget_t"); const char* name = (const char*)luaL_checkstring(L, 2); (void)obj; (void)name; - if(strcmp(name, "x") == 0) { + if (strcmp(name, "x") == 0) { printf("x is readonly\n"); return 0; - } - else if(strcmp(name, "y") == 0) { + } else if (strcmp(name, "y") == 0) { printf("y is readonly\n"); return 0; - } - else if(strcmp(name, "w") == 0) { + } else if (strcmp(name, "w") == 0) { printf("w is readonly\n"); return 0; - } - else if(strcmp(name, "h") == 0) { + } else if (strcmp(name, "h") == 0) { printf("h is readonly\n"); return 0; - } - else if(strcmp(name, "type") == 0) { + } else if (strcmp(name, "type") == 0) { printf("type is readonly\n"); return 0; - } - else if(strcmp(name, "style_type") == 0) { + } else if (strcmp(name, "style_type") == 0) { printf("style_type is readonly\n"); return 0; - } - else if(strcmp(name, "state") == 0) { + } else if (strcmp(name, "state") == 0) { printf("state is readonly\n"); return 0; - } - else if(strcmp(name, "enable") == 0) { + } else if (strcmp(name, "enable") == 0) { printf("enable is readonly\n"); return 0; - } - else if(strcmp(name, "visible") == 0) { + } else if (strcmp(name, "visible") == 0) { printf("visible is readonly\n"); return 0; - } - else if(strcmp(name, "focused") == 0) { + } else if (strcmp(name, "focused") == 0) { printf("focused is readonly\n"); return 0; - } - else if(strcmp(name, "name") == 0) { + } else if (strcmp(name, "name") == 0) { printf("name is readonly\n"); return 0; - } - else if(strcmp(name, "parent") == 0) { + } else if (strcmp(name, "parent") == 0) { printf("parent is readonly\n"); return 0; - } - else { + } else { printf("%s: not supported %s\n", __func__, name); return 0; } @@ -2382,71 +2194,59 @@ static int wrap_widget_t_get_prop(lua_State* L) { (void)obj; (void)name; - if(ret) { + if (ret) { lua_pushcfunction(L, ret->func); return 1; } - if(strcmp(name, "x") == 0) { - lua_pushnumber(L,(lua_Number)(obj->x)); + if (strcmp(name, "x") == 0) { + lua_pushnumber(L, (lua_Number)(obj->x)); - return 1; - } - else if(strcmp(name, "y") == 0) { - lua_pushnumber(L,(lua_Number)(obj->y)); + return 1; + } else if (strcmp(name, "y") == 0) { + lua_pushnumber(L, (lua_Number)(obj->y)); - return 1; - } - else if(strcmp(name, "w") == 0) { - lua_pushnumber(L,(lua_Number)(obj->w)); + return 1; + } else if (strcmp(name, "w") == 0) { + lua_pushnumber(L, (lua_Number)(obj->w)); - return 1; - } - else if(strcmp(name, "h") == 0) { - lua_pushnumber(L,(lua_Number)(obj->h)); + return 1; + } else if (strcmp(name, "h") == 0) { + lua_pushnumber(L, (lua_Number)(obj->h)); - return 1; - } - else if(strcmp(name, "type") == 0) { - lua_pushinteger(L,(lua_Integer)(obj->type)); + return 1; + } else if (strcmp(name, "type") == 0) { + lua_pushinteger(L, (lua_Integer)(obj->type)); - return 1; - } - else if(strcmp(name, "style_type") == 0) { - lua_pushinteger(L,(lua_Integer)(obj->style_type)); + return 1; + } else if (strcmp(name, "style_type") == 0) { + lua_pushinteger(L, (lua_Integer)(obj->style_type)); - return 1; - } - else if(strcmp(name, "state") == 0) { - lua_pushinteger(L,(lua_Integer)(obj->state)); + return 1; + } else if (strcmp(name, "state") == 0) { + lua_pushinteger(L, (lua_Integer)(obj->state)); - return 1; - } - else if(strcmp(name, "enable") == 0) { - lua_pushboolean(L,(lua_Integer)(obj->enable)); + return 1; + } else if (strcmp(name, "enable") == 0) { + lua_pushboolean(L, (lua_Integer)(obj->enable)); - return 1; - } - else if(strcmp(name, "visible") == 0) { - lua_pushboolean(L,(lua_Integer)(obj->visible)); + return 1; + } else if (strcmp(name, "visible") == 0) { + lua_pushboolean(L, (lua_Integer)(obj->visible)); - return 1; - } - else if(strcmp(name, "focused") == 0) { - lua_pushboolean(L,(lua_Integer)(obj->focused)); + return 1; + } else if (strcmp(name, "focused") == 0) { + lua_pushboolean(L, (lua_Integer)(obj->focused)); - return 1; - } - else if(strcmp(name, "name") == 0) { - lua_pushstring(L,(char*)(obj->name)); + return 1; + } else if (strcmp(name, "name") == 0) { + lua_pushstring(L, (char*)(obj->name)); - return 1; - } - else if(strcmp(name, "parent") == 0) { + return 1; + } else if (strcmp(name, "parent") == 0) { return lftk_newuserdata(L, obj->parent, "/widget_t", "lftk.widget_t"); - } - else { + } else { widget_t* child = widget_lookup(obj, name, FALSE); - if(child != NULL) { + if (child != NULL) { return lftk_newuserdata(L, child, "/widget_t", "lftk.widget_t"); } printf("%s: not supported %s\n", __func__, name); @@ -2455,15 +2255,10 @@ static int wrap_widget_t_get_prop(lua_State* L) { } static void widget_t_init(lua_State* L) { - static const struct luaL_Reg static_funcs[] = { - {NULL, NULL} - }; + static const struct luaL_Reg static_funcs[] = {{NULL, NULL}}; static const struct luaL_Reg index_funcs[] = { - {"__index", wrap_widget_t_get_prop}, - {"__newindex", wrap_widget_t_set_prop}, - {NULL, NULL} - }; + {"__index", wrap_widget_t_get_prop}, {"__newindex", wrap_widget_t_set_prop}, {NULL, NULL}}; luaL_newmetatable(L, "lftk.widget_t"); lua_pushstring(L, "__index"); @@ -2493,10 +2288,7 @@ static int wrap_window_open(lua_State* L) { return lftk_newuserdata(L, ret, "/window_t/widget_t", "lftk.window_t"); } - -static const struct luaL_Reg window_t_member_funcs[] = { - {NULL, NULL} -}; +static const struct luaL_Reg window_t_member_funcs[] = {{NULL, NULL}}; static int wrap_window_t_set_prop(lua_State* L) { window_t* obj = (window_t*)lftk_checkudata(L, 1, "window_t"); @@ -2504,8 +2296,8 @@ static int wrap_window_t_set_prop(lua_State* L) { (void)obj; (void)name; return wrap_widget_t_set_prop(L); - printf("%s: not supported %s\n", __func__, name); - return 0; + printf("%s: not supported %s\n", __func__, name); + return 0; } static int wrap_window_t_get_prop(lua_State* L) { @@ -2515,27 +2307,20 @@ static int wrap_window_t_get_prop(lua_State* L) { (void)obj; (void)name; - if(ret) { + if (ret) { lua_pushcfunction(L, ret->func); return 1; - } - else { + } else { return wrap_widget_t_get_prop(L); } } static void window_t_init(lua_State* L) { static const struct luaL_Reg static_funcs[] = { - {"create", wrap_window_create}, - {"open", wrap_window_open}, - {NULL, NULL} - }; + {"create", wrap_window_create}, {"open", wrap_window_open}, {NULL, NULL}}; static const struct luaL_Reg index_funcs[] = { - {"__index", wrap_window_t_get_prop}, - {"__newindex", wrap_window_t_set_prop}, - {NULL, NULL} - }; + {"__index", wrap_window_t_get_prop}, {"__newindex", wrap_window_t_set_prop}, {NULL, NULL}}; luaL_newmetatable(L, "lftk.window_t"); lua_pushstring(L, "__index"); diff --git a/src/base/dialog.c b/src/base/dialog.c index 544a853d8..e384583fc 100644 --- a/src/base/dialog.c +++ b/src/base/dialog.c @@ -51,8 +51,7 @@ static ret_t dialog_set_prop(widget_t* widget, const char* name, const value_t* return RET_NOT_FOUND; } -static const widget_vtable_t s_dialog_vtable = { - .get_prop = dialog_get_prop, +static const widget_vtable_t s_dialog_vtable = {.get_prop = dialog_get_prop, .set_prop = dialog_set_prop}; widget_t* dialog_title_create(widget_t* parent, xy_t x, xy_t y, wh_t w, wh_t h) { @@ -129,4 +128,3 @@ ret_t dialog_quit(widget_t* widget, uint32_t code) { return RET_OK; } - diff --git a/src/base/dialog.h b/src/base/dialog.h index 7145c4ee1..3ab33e784 100644 --- a/src/base/dialog.h +++ b/src/base/dialog.h @@ -97,4 +97,3 @@ ret_t dialog_quit(widget_t* widget, uint32_t code); END_C_DECLS #endif /*LFTK_DIALOG_H*/ - diff --git a/src/base/enums.c b/src/base/enums.c index 114cdecd1..8b30b5ca1 100644 --- a/src/base/enums.c +++ b/src/base/enums.c @@ -23,26 +23,27 @@ #include "base/widget.h" #include "base/resource_manager.h" -static const key_type_value_t widget_type_value[] = {{"widget", 0, WIDGET_NONE}, - {"window_manager", 0, WIDGET_WINDOW_MANAGER}, - {"window", 0, WIDGET_NORMAL_WINDOW}, - {"tool_bar", 0, WIDGET_TOOL_BAR}, - {"dialog", 0, WIDGET_DIALOG}, - {"popup", 0, WIDGET_POPUP}, - {"sprite", 0, WIDGET_SPRITE}, - {"keyboard", 0, WIDGET_KEYBOARD}, - {"dragger", 0, WIDGET_DRAGGER}, - {"label", 0, WIDGET_LABEL}, - {"button", 0, WIDGET_BUTTON}, - {"image", 0, WIDGET_IMAGE}, - {"edit", 0, WIDGET_EDIT}, - {"progress_bar", 0, WIDGET_PROGRESS_BAR}, - {"group_box", 0, WIDGET_GROUP_BOX}, - {"check_button", 0, WIDGET_CHECK_BUTTON}, - {"radio_button", 0, WIDGET_RADIO_BUTTON}, - {"dialog_title", 0, WIDGET_DIALOG_TITLE}, - {"dialog_client", 0, WIDGET_DIALOG_CLIENT}, - }; +static const key_type_value_t widget_type_value[] = { + {"widget", 0, WIDGET_NONE}, + {"window_manager", 0, WIDGET_WINDOW_MANAGER}, + {"window", 0, WIDGET_NORMAL_WINDOW}, + {"tool_bar", 0, WIDGET_TOOL_BAR}, + {"dialog", 0, WIDGET_DIALOG}, + {"popup", 0, WIDGET_POPUP}, + {"sprite", 0, WIDGET_SPRITE}, + {"keyboard", 0, WIDGET_KEYBOARD}, + {"dragger", 0, WIDGET_DRAGGER}, + {"label", 0, WIDGET_LABEL}, + {"button", 0, WIDGET_BUTTON}, + {"image", 0, WIDGET_IMAGE}, + {"edit", 0, WIDGET_EDIT}, + {"progress_bar", 0, WIDGET_PROGRESS_BAR}, + {"group_box", 0, WIDGET_GROUP_BOX}, + {"check_button", 0, WIDGET_CHECK_BUTTON}, + {"radio_button", 0, WIDGET_RADIO_BUTTON}, + {"dialog_title", 0, WIDGET_DIALOG_TITLE}, + {"dialog_client", 0, WIDGET_DIALOG_CLIENT}, +}; static const key_type_value_t style_id_name_value[] = { {"bg-color", TYPE_COLOR, STYLE_ID_BG_COLOR}, diff --git a/src/lcd/lcd_reg.inc b/src/lcd/lcd_reg.inc index a30b0b1c2..7bffe161e 100644 --- a/src/lcd/lcd_reg.inc +++ b/src/lcd/lcd_reg.inc @@ -124,11 +124,13 @@ static ret_t lcd_reg_draw_image(lcd_t* lcd, bitmap_t* img, rect_t* src, rect_t* for (j = 0; j < dh; j++) { for (i = 0; i < dw; i++) { color_t src_color = src_p[i]; - if(src_color.rgba.a > 7) { - pixel_t color = src_color.rgba.a < 0xfe ? blend_color(fill_color, src_color, src_color.rgba.a) : to_pixel(src_color); - write_data_func(color); + if (src_color.rgba.a > 7) { + pixel_t color = src_color.rgba.a < 0xfe + ? blend_color(fill_color, src_color, src_color.rgba.a) + : to_pixel(src_color); + write_data_func(color); } else { - write_data_func(fill_pixel); + write_data_func(fill_pixel); } } src_p += img->w; @@ -138,21 +140,23 @@ static ret_t lcd_reg_draw_image(lcd_t* lcd, bitmap_t* img, rect_t* src, rect_t* xy_t sy = src->y; wh_t sw = src->w; wh_t sh = src->h; - wh_t iw = img->w; - xy_t r = dst->x + dst->w; - xy_t b = dst->y + dst->h; - + wh_t iw = img->w; + xy_t r = dst->x + dst->w; + xy_t b = dst->y + dst->h; + for (j = 0, y = dst->y; y < b; j++, y++) { - const color_t* src_p = data + iw * (sy + (j * sh / dh)) + sx; + const color_t* src_p = data + iw * (sy + (j * sh / dh)) + sx; for (i = 0, x = dst->x; x < r; i++, x++) { uint32_t s = (i * sw) / dw; color_t src_color = src_p[s]; - if(src_color.rgba.a > 7) { - pixel_t color = src_color.rgba.a < 0xfe ? blend_color(fill_color, src_color, src_color.rgba.a) : to_pixel(src_color); + if (src_color.rgba.a > 7) { + pixel_t color = src_color.rgba.a < 0xfe + ? blend_color(fill_color, src_color, src_color.rgba.a) + : to_pixel(src_color); set_window_func(x, y, x, y); write_data_func(color); - } + } } } } diff --git a/tests/theme_gen_test.cc b/tests/theme_gen_test.cc index a4bf4b944..1b8cd392d 100644 --- a/tests/theme_gen_test.cc +++ b/tests/theme_gen_test.cc @@ -74,3 +74,25 @@ TEST(ThemeGen, style_type) { style.data = theme_find_style(&theme, WIDGET_BUTTON, 1, WIDGET_STATE_PRESSED); ASSERT_EQ(style.data != NULL, true); } + +TEST(ThemeGen, inher) { + uint8_t buff[1024]; + theme_t theme; + style_t style; + const char* str = + ""; + + xml_gen_buff(str, buff, sizeof(buff)); + theme.data = buff; + + style.data = theme_find_style(&theme, WIDGET_BUTTON, 1, WIDGET_STATE_OVER); + ASSERT_EQ(style.data != NULL, true); + ASSERT_EQ(style_get_int(&style, STYLE_ID_FONT_SIZE, 0), 12); + ASSERT_EQ(style_get_str(&style, STYLE_ID_FONT_NAME, ""), string("sans")); + + style.data = theme_find_style(&theme, WIDGET_BUTTON, 1, WIDGET_STATE_PRESSED); + ASSERT_EQ(style.data != NULL, true); + ASSERT_EQ(style_get_int(&style, STYLE_ID_FONT_SIZE, 0), 14); + ASSERT_EQ(style_get_str(&style, STYLE_ID_FONT_NAME, ""), string("serif")); +}