Procházet zdrojové kódy

update: 调整components里面的rotable为rotable2

Wendal Chen před 3 roky
rodič
revize
21cd24746d

+ 10 - 10
components/camera/luat_lib_camera.c

@@ -240,20 +240,20 @@ static int l_camera_capture(lua_State *L) {
     return 0;
 }
 
-#include "rotable.h"
-static const rotable_Reg reg_camera[] =
+#include "rotable2.h"
+static const rotable_Reg_t reg_camera[] =
 {
-    { "init" ,        l_camera_init , 0},
-    { "start" ,       l_camera_start , 0},
-    { "stop" ,        l_camera_stop, 0},
-    { "capture",      l_camera_capture, 0},
-	{ "close",		l_camera_close, 0},
-    { "on",     l_camera_on, 0},
-	{ NULL,          NULL ,       0}
+    { "init" ,       ROREG_FUNC(l_camera_init )},
+    { "start" ,      ROREG_FUNC(l_camera_start )},
+    { "stop" ,       ROREG_FUNC(l_camera_stop)},
+    { "capture",     ROREG_FUNC(l_camera_capture)},
+	{ "close",		 ROREG_FUNC(l_camera_close)},
+    { "on",          ROREG_FUNC(l_camera_on)},
+	{ NULL,          {}}
 };
 
 LUAMOD_API int luaopen_camera( lua_State *L ) {
-    luat_newlib(L, reg_camera);
+    luat_newlib2(L, reg_camera);
     return 1;
 }
 

+ 5 - 5
components/coremark/luat_lib_coremark.c

@@ -28,14 +28,14 @@ static int l_coremark_run(lua_State *L) {
     return 0;
 }
 
-#include "rotable.h"
-static const rotable_Reg reg_coremark[] =
+#include "rotable2.h"
+static const rotable_Reg_t reg_coremark[] =
 {
-    { "run" ,         l_coremark_run ,0},
-    { NULL,             NULL ,        0}
+    { "run" ,         ROREG_FUNC(l_coremark_run)},
+    { NULL,           {}}
 };
 
 LUAMOD_API int luaopen_coremark( lua_State *L ) {
-    luat_newlib(L, reg_coremark);
+    luat_newlib2(L, reg_coremark);
     return 1;
 }

+ 10 - 9
components/flashdb/src/luat_lib_fdb.c

@@ -246,18 +246,19 @@ static int l_fdb_kv_clr(lua_State *L) {
 }
 
 
-#include "rotable.h"
-static const rotable_Reg reg_fdb[] =
+#include "rotable2.h"
+static const rotable_Reg_t reg_fdb[] =
 {
-    { "kvdb_init" ,         l_fdb_kvdb_init ,     0},
-    { "kvdb_deinit" ,       l_fdb_kvdb_deinit,    0},
-    { "kv_set",             l_fdb_kv_set, 0},
-    { "kv_get",             l_fdb_kv_get, 0},
-    { "kv_del",             l_fdb_kv_del, 0},
-    { "kv_clr",             l_fdb_kv_clr, 0},
+    { "kvdb_init" ,         ROREG_FUNC(l_fdb_kvdb_init)},
+    { "kvdb_deinit" ,       ROREG_FUNC(l_fdb_kvdb_deinit)},
+    { "kv_set",             ROREG_FUNC(l_fdb_kv_set)},
+    { "kv_get",             ROREG_FUNC(l_fdb_kv_get)},
+    { "kv_del",             ROREG_FUNC(l_fdb_kv_del)},
+    { "kv_clr",             ROREG_FUNC(l_fdb_kv_clr)},
+    { NULL,                 {}}
 };
 
 LUAMOD_API int luaopen_fdb( lua_State *L ) {
-    luat_newlib(L, reg_fdb);
+    luat_newlib2(L, reg_fdb);
     return 1;
 }

+ 4 - 4
components/gtfont/luat_lib_gtfont.c

@@ -165,11 +165,11 @@ static int l_gtfont_init(lua_State* L) {
     return 0;
 }
 
-#include "rotable.h"
-static const rotable_Reg reg_gtfont[] =
+#include "rotable2.h"
+static const rotable_Reg_t reg_gtfont[] =
 {
-    { "init" ,          l_gtfont_init , 0},
-	{ NULL,             NULL ,        0}
+    { "init" ,          ROREG_FUNC(l_gtfont_init)},
+	{ NULL,             {}}
 };
 
 LUAMOD_API int luaopen_gtfont( lua_State *L ) {

+ 20 - 20
components/io_queue/luat_lib_io_queue.c

@@ -336,29 +336,29 @@ static int l_io_queue_exti(lua_State *L) {
 	return 0;
 }
 
-#include "rotable.h"
-static const rotable_Reg reg_io_queue[] =
+#include "rotable2.h"
+static const rotable_Reg_t reg_io_queue[] =
 {
-    { "init" ,       l_io_queue_init , 0},
-    { "setdelay" ,        l_io_queue_set_delay, 0},
-	{ "delay" ,        l_io_queue_delay, 0},
-	{ "setgpio",	l_io_queue_set_gpio, 0},
-	{ "input",		l_io_queue_gpio_input, 0},
-	{ "output",      l_io_queue_gpio_output,           0},
-	{ "set_cap",      l_io_queue_set_capture,           0},
-	{ "capture",      l_io_queue_capture_pin,           0},
-	{ "cap_done",      l_io_queue_capture_end,           0},
-	{ "clear",		l_io_queue_clear, 0},
-    { "start",     l_io_queue_start, 0},
-    { "stop",            l_io_queue_stop,           0},
-	{ "done",            l_io_queue_is_done,           0},
-	{ "get",      l_io_queue_get, 0},
-	{ "release",            l_io_queue_release,           0},
-	{ "exti",            l_io_queue_exti,           0},
-	{ NULL,          NULL ,       0}
+    { "init" ,       ROREG_FUNC(l_io_queue_init)},
+    { "setdelay" ,   ROREG_FUNC(l_io_queue_set_delay)},
+	{ "delay" ,      ROREG_FUNC(l_io_queue_delay)},
+	{ "setgpio",	 ROREG_FUNC(l_io_queue_set_gpio)},
+	{ "input",		 ROREG_FUNC(l_io_queue_gpio_input)},
+	{ "output",      ROREG_FUNC(l_io_queue_gpio_output)},
+	{ "set_cap",     ROREG_FUNC(l_io_queue_set_capture)},
+	{ "capture",     ROREG_FUNC(l_io_queue_capture_pin)},
+	{ "cap_done",    ROREG_FUNC(l_io_queue_capture_end)},
+	{ "clear",	     ROREG_FUNC(l_io_queue_clear)},
+    { "start",       ROREG_FUNC(l_io_queue_start)},
+    { "stop",        ROREG_FUNC(l_io_queue_stop)},
+	{ "done",        ROREG_FUNC(l_io_queue_is_done)},
+	{ "get",         ROREG_FUNC(l_io_queue_get)},
+	{ "release",     ROREG_FUNC(l_io_queue_release)},
+	{ "exti",        ROREG_FUNC(l_io_queue_exti)},
+	{ NULL,          {}}
 };
 
 LUAMOD_API int luaopen_io_queue( lua_State *L ) {
-    luat_newlib(L, reg_io_queue);
+    luat_newlib2(L, reg_io_queue);
     return 1;
 }

+ 46 - 46
components/lcd/luat_lib_lcd.c

@@ -1182,59 +1182,59 @@ static int l_lcd_drawxbm(lua_State *L){
     return 1;
 }
 
-#include "rotable.h"
-static const rotable_Reg reg_lcd[] =
+#include "rotable2.h"
+static const rotable_Reg_t reg_lcd[] =
 {
-    { "init",      l_lcd_init,   0},
-    { "close",      l_lcd_close,       0},
-    { "on",      l_lcd_display_on,       0},
-    { "off",      l_lcd_display_off,       0},
-    { "sleep",      l_lcd_sleep,       0},
-    { "wakeup",      l_lcd_wakeup,       0},
-    { "invon",      l_lcd_inv_on,       0},
-    { "invoff",      l_lcd_inv_off,       0},
-    { "cmd",      l_lcd_write_cmd,       0},
-    { "data",      l_lcd_write_data,       0},
-    { "setColor",      l_lcd_set_color,       0},
-    { "draw",      l_lcd_draw,       0},
-    { "clear",      l_lcd_clear,       0},
-    { "fill",      l_lcd_draw_fill,       0},
-    { "drawPoint",      l_lcd_draw_point,       0},
-    { "drawLine",      l_lcd_draw_line,       0},
-    { "drawRectangle",      l_lcd_draw_rectangle,       0},
-    { "drawCircle",      l_lcd_draw_circle,       0},
-    { "drawQrcode",    l_lcd_drawQrcode, 0},
-    { "drawStr",      l_lcd_draw_str,       0},
-    { "setFont", l_lcd_set_font, 0},
-    { "setDefault", l_lcd_set_default, 0},
-    { "getDefault", l_lcd_get_default, 0},
-    { "getSize",    l_lcd_get_size, 0},
-    { "drawXbm",    l_lcd_drawxbm, 0},
+    { "init",       ROREG_FUNC(l_lcd_init)},
+    { "close",      ROREG_FUNC(l_lcd_close)},
+    { "on",         ROREG_FUNC(l_lcd_display_on)},
+    { "off",        ROREG_FUNC(l_lcd_display_off)},
+    { "sleep",      ROREG_FUNC(l_lcd_sleep)},
+    { "wakeup",     ROREG_FUNC(l_lcd_wakeup)},
+    { "invon",      ROREG_FUNC(l_lcd_inv_on)},
+    { "invoff",     ROREG_FUNC(l_lcd_inv_off)},
+    { "cmd",        ROREG_FUNC(l_lcd_write_cmd)},
+    { "data",       ROREG_FUNC(l_lcd_write_data)},
+    { "setColor",   ROREG_FUNC(l_lcd_set_color)},
+    { "draw",       ROREG_FUNC(l_lcd_draw)},
+    { "clear",      ROREG_FUNC(l_lcd_clear)},
+    { "fill",       ROREG_FUNC(l_lcd_draw_fill)},
+    { "drawPoint",  ROREG_FUNC(l_lcd_draw_point)},
+    { "drawLine",   ROREG_FUNC(l_lcd_draw_line)},
+    { "drawRectangle",   ROREG_FUNC(l_lcd_draw_rectangle)},
+    { "drawCircle", ROREG_FUNC(l_lcd_draw_circle)},
+    { "drawQrcode", ROREG_FUNC(l_lcd_drawQrcode)},
+    { "drawStr",    ROREG_FUNC(l_lcd_draw_str)},
+    { "setFont",    ROREG_FUNC(l_lcd_set_font)},
+    { "setDefault", ROREG_FUNC(l_lcd_set_default)},
+    { "getDefault", ROREG_FUNC(l_lcd_get_default)},
+    { "getSize",    ROREG_FUNC(l_lcd_get_size)},
+    { "drawXbm",    ROREG_FUNC(l_lcd_drawxbm)},
 #ifdef LUAT_USE_GTFONT
-    { "drawGtfontGb2312", l_lcd_draw_gtfont_gb2312, 0},
-    { "drawGtfontGb2312Gray", l_lcd_draw_gtfont_gb2312_gray, 0},
+    { "drawGtfontGb2312", ROREG_FUNC(l_lcd_draw_gtfont_gb2312)},
+    { "drawGtfontGb2312Gray", ROREG_FUNC(l_lcd_draw_gtfont_gb2312_gray)},
 #ifdef LUAT_USE_GTFONT_UTF8
-    { "drawGtfontUtf8", l_lcd_draw_gtfont_utf8, 0},
-    { "drawGtfontUtf8Gray", l_lcd_draw_gtfont_utf8_gray, 0},
+    { "drawGtfontUtf8", ROREG_FUNC(l_lcd_draw_gtfont_utf8)},
+    { "drawGtfontUtf8Gray", ROREG_FUNC(l_lcd_draw_gtfont_utf8_gray)},
 #endif // LUAT_USE_GTFONT_UTF8
 #endif // LUAT_USE_GTFONT
-    { "font_opposansm8", NULL,       font_opposansm8},
-    { "font_opposansm10", NULL,       font_opposansm10},
-    { "font_opposansm12", NULL,       font_opposansm12},
-    { "font_opposansm16", NULL,       font_opposansm16},
-    { "font_opposansm18", NULL,       font_opposansm18},
-    { "font_opposansm20", NULL,       font_opposansm20},
-    { "font_opposansm22", NULL,       font_opposansm22},
-    { "font_opposansm24", NULL,       font_opposansm24},
-    { "font_opposansm32", NULL,       font_opposansm32},
-    { "font_opposansm12_chinese", NULL,       font_opposansm12_chinese},
-    { "font_opposansm16_chinese", NULL,       font_opposansm16_chinese},
-    { "font_opposansm24_chinese", NULL,       font_opposansm24_chinese},
-    { "font_opposansm32_chinese", NULL,       font_opposansm32_chinese},
-	{ NULL,        NULL,   0}
+    { "font_opposansm8", ROREG_INT(font_opposansm8)},
+    { "font_opposansm10", ROREG_INT(font_opposansm10)},
+    { "font_opposansm12", ROREG_INT(font_opposansm12)},
+    { "font_opposansm16", ROREG_INT(font_opposansm16)},
+    { "font_opposansm18", ROREG_INT(font_opposansm18)},
+    { "font_opposansm20", ROREG_INT(font_opposansm20)},
+    { "font_opposansm22", ROREG_INT(font_opposansm22)},
+    { "font_opposansm24", ROREG_INT(font_opposansm24)},
+    { "font_opposansm32", ROREG_INT(font_opposansm32)},
+    { "font_opposansm12_chinese", ROREG_INT(font_opposansm12_chinese)},
+    { "font_opposansm16_chinese", ROREG_INT(font_opposansm16_chinese)},
+    { "font_opposansm24_chinese", ROREG_INT(font_opposansm24_chinese)},
+    { "font_opposansm32_chinese", ROREG_INT(font_opposansm32_chinese)},
+	  {NULL, {}}
 };
 
 LUAMOD_API int luaopen_lcd( lua_State *L ) {
-    luat_newlib(L, reg_lcd);
+    luat_newlib2(L, reg_lcd);
     return 1;
 }

+ 7 - 7
components/luatfonts/luat_lib_fonts.c

@@ -29,16 +29,16 @@ static int l_fonts_load_font(lua_State *L) {
     
 // }
 
-#include "rotable.h"
-static const rotable_Reg reg_fonts[] =
+#include "rotable2.h"
+static const rotable_Reg_t reg_fonts[] =
 {
-    { "get_data" ,       l_fonts_get_data , 0},
-    { "load_font" ,      l_fonts_load_font , 0},
-    //{ "close_font" ,     l_fonts_close_font, 0},
-	{ NULL,          NULL ,       0}
+    { "get_data" ,       ROREG_FUNC(l_fonts_get_data)},
+    { "load_font" ,      ROREG_FUNC(l_fonts_load_font)},
+    //{ "close_font" ,   ROREG_FUNC(l_fonts_close_font)},
+	{ NULL,              {}}
 };
 
 LUAMOD_API int luaopen_fonts( lua_State *L ) {
-    luat_newlib(L, reg_fonts);
+    luat_newlib2(L, reg_fonts);
     return 1;
 }

+ 7 - 7
components/luf/luat_lib_luf.c

@@ -83,16 +83,16 @@ static int l_luf_cmp(lua_State* L) {
   return 0;
 }
 
-#include "rotable.h"
-static const rotable_Reg reg_luf[] =
+#include "rotable2.h"
+static const rotable_Reg_t reg_luf[] =
 {
-    { "dump" ,        l_luf_dump , 0},
-    { "undump" ,      l_luf_undump , 0},
-    { "cmp",          l_luf_cmp,   0},
-	{ NULL,          NULL ,       0}
+    { "dump" ,        ROREG_FUNC(l_luf_dump)},
+    { "undump" ,      ROREG_FUNC(l_luf_undump)},
+    { "cmp",          ROREG_FUNC(l_luf_cmp)},
+	  { NULL,           {}}
 };
 
 LUAMOD_API int luaopen_luf( lua_State *L ) {
-    luat_newlib(L, reg_luf);
+    luat_newlib2(L, reg_luf);
     return 1;
 }

+ 11 - 10
components/sfd/luat_lib_sfd.c

@@ -169,19 +169,20 @@ static int l_sfd_id(lua_State *L) {
     return 1;
 }
 
-#include "rotable.h"
-static const rotable_Reg reg_sfd[] =
+#include "rotable2.h"
+static const rotable_Reg_t reg_sfd[] =
 {
-    { "init" ,             l_sfd_init,           0},
-    { "status",            l_sfd_status,         0},
-    { "read",              l_sfd_read,           0},
-    { "write",             l_sfd_write,          0},
-    { "erase",             l_sfd_erase,          0},
-    { "ioctl",             l_sfd_ioctl,          0},
-    { "id",                l_sfd_id,             0},
+    { "init" ,             ROREG_FUNC(l_sfd_init)},
+    { "status",            ROREG_FUNC(l_sfd_status)},
+    { "read",              ROREG_FUNC(l_sfd_read)},
+    { "write",             ROREG_FUNC(l_sfd_write)},
+    { "erase",             ROREG_FUNC(l_sfd_erase)},
+    { "ioctl",             ROREG_FUNC(l_sfd_ioctl)},
+    { "id",                ROREG_FUNC(l_sfd_id)},
+    { NULL,                {}}
 };
 
 LUAMOD_API int luaopen_sfd( lua_State *L ) {
-    luat_newlib(L, reg_sfd);
+    luat_newlib2(L, reg_sfd);
     return 1;
 }

+ 14 - 14
components/sfud/luat_lib_sfud.c

@@ -230,25 +230,25 @@ static int luat_sfud_mount(lua_State *L) {
 }
 #endif
 
-#include "rotable.h"
-static const rotable_Reg reg_sfud[] =
+#include "rotable2.h"
+static const rotable_Reg_t reg_sfud[] =
 {
-    { "init",           luat_sfud_init,             0},
-    { "getDeviceNum",   luat_sfud_get_device_num,   0},
-    { "getDevice",      luat_sfud_get_device,       0},
-    { "getDeviceTable", luat_sfud_get_device_table, 0},
-    { "erase",          luat_sfud_erase,            0},
-    { "chipErase",      luat_sfud_chip_erase,       0},
-    { "read",           luat_sfud_read,             0},
-    { "write",          luat_sfud_write,            0},
-    { "eraseWrite",     luat_sfud_erase_write,      0},
+    { "init",           ROREG_FUNC(luat_sfud_init)},
+    { "getDeviceNum",   ROREG_FUNC(luat_sfud_get_device_num)},
+    { "getDevice",      ROREG_FUNC(luat_sfud_get_device)},
+    { "getDeviceTable", ROREG_FUNC(luat_sfud_get_device_table)},
+    { "erase",          ROREG_FUNC(luat_sfud_erase)},
+    { "chipErase",      ROREG_FUNC(luat_sfud_chip_erase)},
+    { "read",           ROREG_FUNC(luat_sfud_read)},
+    { "write",          ROREG_FUNC(luat_sfud_write)},
+    { "eraseWrite",     ROREG_FUNC(luat_sfud_erase_write)},
 #ifdef LUAT_USE_FS_VFS
-    { "mount",          luat_sfud_mount,            0},
+    { "mount",          ROREG_FUNC(luat_sfud_mount)},
 #endif
-	{ NULL, NULL, 0}
+	{ NULL,             {}}
 };
 
 LUAMOD_API int luaopen_sfud( lua_State *L ) {
-    luat_newlib(L, reg_sfud);
+    luat_newlib2(L, reg_sfud);
     return 1;
 }

+ 6 - 7
components/soft_keyboard/luat_lib_softkeyboard.c

@@ -101,16 +101,15 @@ int l_softkb_deinit(lua_State* L) {
 }
 
 
-#include "rotable.h"
-static const rotable_Reg reg_softkb[] =
+#include "rotable2.h"
+static const rotable_Reg_t reg_softkb[] =
 {
-    { "init",        l_softkb_init,          0},
-    { "deinit",        l_softkb_deinit,          0},
-
-	{ NULL,        NULL,   0}
+    { "init",          ROREG_FUNC(l_softkb_init)},
+    { "deinit",        ROREG_FUNC(l_softkb_deinit)},
+	{ NULL,            {}}
 };
 
 LUAMOD_API int luaopen_softkb( lua_State *L ) {
-    luat_newlib(L, reg_softkb);
+    luat_newlib2(L, reg_softkb);
     return 1;
 }

+ 5 - 5
components/statem/luat_lib_statem.c

@@ -148,11 +148,11 @@ static int _statem_struct_newindex(lua_State *L) {
 }
 
 
-#include "rotable.h"
-static const rotable_Reg reg_statem[] =
+#include "rotable2.h"
+static const rotable_Reg_t reg_statem[] =
 {
-    { "create",      l_statem_create,   0},
-	{ NULL,                 NULL,   0}
+    { "create",      ROREG_FUNC(l_statem_create)},
+	{ NULL,          {}}
 };
 
 static void luat_statem_struct_init(lua_State *L) {
@@ -163,7 +163,7 @@ static void luat_statem_struct_init(lua_State *L) {
 }
 
 LUAMOD_API int luaopen_statem( lua_State *L ) {
-    luat_newlib(L, reg_statem);
+    luat_newlib2(L, reg_statem);
     luat_statem_struct_init(L);
     return 1;
 }

+ 6 - 6
components/zlib/luat_lib_zlib.c

@@ -255,15 +255,15 @@ _exit:
     return 1;
 }
 
-#include "rotable.h"
-static const rotable_Reg reg_zlib[] =
+#include "rotable2.h"
+static const rotable_Reg_t reg_zlib[] =
 {
-    { "c",      luat_zlib_compress,    0},
-    { "d",      luat_zlib_decompress,   0},
-	{ NULL, NULL, 0}
+    { "c",      ROREG_FUNC(luat_zlib_compress)},
+    { "d",      ROREG_FUNC(luat_zlib_decompress)},
+	{ NULL,     {}}
 };
 
 LUAMOD_API int luaopen_zlib( lua_State *L ) {
-    luat_newlib(L, reg_zlib);
+    luat_newlib2(L, reg_zlib);
     return 1;
 }