From dc27e9f7cfdcd45c67dbfe99bece466b80c7d0a1 Mon Sep 17 00:00:00 2001 From: Johny Mattsson Date: Tue, 24 Aug 2021 09:56:20 +1000 Subject: [PATCH] Updated modules to comply with __ ordering in rom tables. --- components/modules/file.c | 4 ++-- components/modules/http.c | 4 ++-- components/modules/mqtt.c | 4 ++-- components/modules/net.c | 14 +++++++------- components/modules/pulsecnt.c | 7 +++---- components/modules/sdmmc.c | 2 +- components/modules/spi_master.c | 8 ++++---- components/modules/tmr.c | 4 ++-- components/modules/touch.c | 7 +++---- components/modules/u8g2.c | 4 ++-- 10 files changed, 28 insertions(+), 30 deletions(-) diff --git a/components/modules/file.c b/components/modules/file.c index 5e94e072..658bada9 100644 --- a/components/modules/file.c +++ b/components/modules/file.c @@ -550,6 +550,8 @@ static int file_chdir( lua_State *L ) #endif LROT_BEGIN(file_obj, NULL, 0) + LROT_FUNCENTRY( __gc, file_obj_free ) + LROT_TABENTRY ( __index, file_obj ) LROT_FUNCENTRY( close, file_close ) LROT_FUNCENTRY( read, file_read ) LROT_FUNCENTRY( readline, file_readline ) @@ -557,8 +559,6 @@ LROT_BEGIN(file_obj, NULL, 0) LROT_FUNCENTRY( writeline, file_writeline ) LROT_FUNCENTRY( seek, file_seek ) LROT_FUNCENTRY( flush, file_flush ) - LROT_FUNCENTRY( __gc, file_obj_free ) - LROT_TABENTRY ( __index, file_obj ) LROT_END(file_obj, NULL, 0) // Module function map diff --git a/components/modules/http.c b/components/modules/http.c index ed78455e..e6f80753 100644 --- a/components/modules/http.c +++ b/components/modules/http.c @@ -791,6 +791,8 @@ LROT_BEGIN(http, NULL, 0) LROT_END(http, NULL, 0) LROT_BEGIN(http_context, NULL, 0) + LROT_FUNCENTRY(__gc, context_gc) + LROT_TABENTRY (__index, http_context) LROT_FUNCENTRY(on, http_lapi_on) LROT_FUNCENTRY(request, http_lapi_request) LROT_FUNCENTRY(setmethod, http_lapi_setmethod) @@ -799,8 +801,6 @@ LROT_BEGIN(http_context, NULL, 0) LROT_FUNCENTRY(setpostdata, http_lapi_setpostdata) LROT_FUNCENTRY(close, context_close) LROT_FUNCENTRY(ack, http_lapi_ack) - LROT_FUNCENTRY(__gc, context_gc) - LROT_TABENTRY (__index, http_context) LROT_END(http_context, NULL, 0) static int luaopen_http(lua_State *L) diff --git a/components/modules/mqtt.c b/components/modules/mqtt.c index d3b6e21c..9b92f22f 100644 --- a/components/modules/mqtt.c +++ b/components/modules/mqtt.c @@ -636,6 +636,8 @@ static int mqtt_new(lua_State* L) { // map client methods to functions: LROT_BEGIN(mqtt_metatable, NULL, 0) + LROT_FUNCENTRY(__gc, mqtt_delete) + LROT_TABENTRY(__index, mqtt_metatable) LROT_FUNCENTRY(connect, mqtt_connect) LROT_FUNCENTRY(close, mqtt_close) LROT_FUNCENTRY(lwt, mqtt_lwt) @@ -643,8 +645,6 @@ LROT_BEGIN(mqtt_metatable, NULL, 0) LROT_FUNCENTRY(subscribe, mqtt_subscribe) LROT_FUNCENTRY(unsubscribe, mqtt_unsubscribe) LROT_FUNCENTRY(on, mqtt_on) - LROT_FUNCENTRY(__gc, mqtt_delete) - LROT_TABENTRY(__index, mqtt_metatable) LROT_END(mqtt_metatable, NULL, 0) // Module function map diff --git a/components/modules/net.c b/components/modules/net.c index 46f073c7..bb7074e7 100644 --- a/components/modules/net.c +++ b/components/modules/net.c @@ -1109,14 +1109,16 @@ static void lerr_cb (lua_State *L, lnet_userdata *ud, err_t err) // Module function map LROT_BEGIN(net_tcpserver, NULL, 0) + LROT_FUNCENTRY( __gc, net_delete ) + LROT_TABENTRY ( __index, net_tcpserver ) LROT_FUNCENTRY( listen, net_listen ) LROT_FUNCENTRY( getaddr, net_getaddr ) LROT_FUNCENTRY( close, net_close ) - LROT_FUNCENTRY( __gc, net_delete ) - LROT_TABENTRY ( __index, net_tcpserver ) LROT_END(net_tcpserver, NULL, 0) LROT_BEGIN(net_tcpsocket, NULL, 0) + LROT_FUNCENTRY( __gc, net_delete ) + LROT_TABENTRY ( __index, net_tcpsocket ) LROT_FUNCENTRY( connect, net_connect ) LROT_FUNCENTRY( close, net_close ) LROT_FUNCENTRY( on, net_on ) @@ -1124,19 +1126,17 @@ LROT_BEGIN(net_tcpsocket, NULL, 0) LROT_FUNCENTRY( dns, net_dns ) LROT_FUNCENTRY( getpeer, net_getpeer ) LROT_FUNCENTRY( getaddr, net_getaddr ) - LROT_FUNCENTRY( __gc, net_delete ) - LROT_TABENTRY ( __index, net_tcpsocket ) LROT_END(net_tcpsocket, NULL, 0) LROT_BEGIN(net_udpsocket, NULL, 0) + LROT_FUNCENTRY( __gc, net_delete ) + LROT_TABENTRY ( __index, net_udpsocket ) LROT_FUNCENTRY( listen, net_listen ) LROT_FUNCENTRY( close, net_close ) LROT_FUNCENTRY( on, net_on ) LROT_FUNCENTRY( send, net_send ) LROT_FUNCENTRY( dns, net_dns ) LROT_FUNCENTRY( getaddr, net_getaddr ) - LROT_FUNCENTRY( __gc, net_delete ) - LROT_TABENTRY ( __index, net_udpsocket ) LROT_END(net_udpsocket, NULL, 0) LROT_BEGIN(net_dns, NULL, 0) @@ -1146,6 +1146,7 @@ LROT_BEGIN(net_dns, NULL, 0) LROT_END(net_dns, NULL, 0) LROT_BEGIN(net, NULL, 0) + LROT_TABENTRY ( __metatable, net ) LROT_FUNCENTRY( createServer, net_createServer ) LROT_FUNCENTRY( createConnection, net_createConnection ) LROT_FUNCENTRY( createUDPSocket, net_createUDPSocket ) @@ -1154,7 +1155,6 @@ LROT_BEGIN(net, NULL, 0) LROT_TABENTRY ( dns, net_dns ) LROT_NUMENTRY ( TCP, TYPE_TCP ) LROT_NUMENTRY ( UDP, TYPE_UDP ) - LROT_TABENTRY ( __metatable, net ) LROT_END(net, NULL, 0) int luaopen_net( lua_State *L ) { diff --git a/components/modules/pulsecnt.c b/components/modules/pulsecnt.c index b994161b..83e11d5c 100644 --- a/components/modules/pulsecnt.c +++ b/components/modules/pulsecnt.c @@ -679,6 +679,9 @@ static int pulsecnt_unregister(lua_State* L){ } LROT_BEGIN(pulsecnt_dyn, NULL, 0) + LROT_FUNCENTRY( __gc, pulsecnt_unregister ) + LROT_TABENTRY ( __index, pulsecnt_dyn ) + // LROT_FUNCENTRY( __tostring, pulsecnt_tostring ) LROT_FUNCENTRY( getCnt, pulsecnt_getCnt ) LROT_FUNCENTRY( clear, pulsecnt_clear ) LROT_FUNCENTRY( testCb, pulsecnt_testCb ) @@ -690,10 +693,6 @@ LROT_BEGIN(pulsecnt_dyn, NULL, 0) LROT_FUNCENTRY( setFilter, pulsecnt_set_filter ) LROT_FUNCENTRY( rawSetEventVal, pulsecnt_set_event_value ) LROT_FUNCENTRY( rawGetEventVal, pulsecnt_get_event_value ) - - // LROT_FUNCENTRY( __tostring, pulsecnt_tostring ) - LROT_FUNCENTRY( __gc, pulsecnt_unregister ) - LROT_TABENTRY ( __index, pulsecnt_dyn ) LROT_END(pulsecnt_dyn, NULL, 0) LROT_BEGIN(pulsecnt, NULL, 0) diff --git a/components/modules/sdmmc.c b/components/modules/sdmmc.c index f083407c..ad94f76d 100644 --- a/components/modules/sdmmc.c +++ b/components/modules/sdmmc.c @@ -328,12 +328,12 @@ static int lsdmmc_umount( lua_State *L ) } LROT_BEGIN(sdmmc_card, NULL, 0) + LROT_TABENTRY( __index, sdmmc_card ) LROT_FUNCENTRY( read, lsdmmc_read ) LROT_FUNCENTRY( write, lsdmmc_write ) LROT_FUNCENTRY( get_info, lsdmmc_get_info ) LROT_FUNCENTRY( mount, lsdmmc_mount ) LROT_FUNCENTRY( umount, lsdmmc_umount ) - LROT_TABENTRY( __index, sdmmc_card ) LROT_END(sdmmc_card, NULL, 0) LROT_BEGIN(sdmmc, NULL, 0) diff --git a/components/modules/spi_master.c b/components/modules/spi_master.c index ffa796d1..0642a8c6 100644 --- a/components/modules/spi_master.c +++ b/components/modules/spi_master.c @@ -178,10 +178,10 @@ free_mem: LROT_BEGIN(lspi_device, NULL, 0) - LROT_FUNCENTRY( transfer, lspi_device_transfer ) - LROT_FUNCENTRY( remove, lspi_device_free ) LROT_FUNCENTRY( __gc, lspi_device_free ) LROT_TABENTRY( __index, lspi_device ) + LROT_FUNCENTRY( transfer, lspi_device_transfer ) + LROT_FUNCENTRY( remove, lspi_device_free ) LROT_END(lspi_device, NULL, 0) @@ -321,10 +321,10 @@ static int lspi_host_device( lua_State *L ) LROT_BEGIN(lspi_master, NULL, 0) - LROT_FUNCENTRY( device, lspi_host_device ) - LROT_FUNCENTRY( close, lspi_host_free ) LROT_FUNCENTRY( __gc, lspi_host_free ) LROT_TABENTRY( __index, lspi_master ) + LROT_FUNCENTRY( device, lspi_host_device ) + LROT_FUNCENTRY( close, lspi_host_free ) LROT_END(lspi_master, NULL, 0) diff --git a/components/modules/tmr.c b/components/modules/tmr.c index a386dc26..85a3cea0 100755 --- a/components/modules/tmr.c +++ b/components/modules/tmr.c @@ -236,6 +236,8 @@ static int tmr_create( lua_State *L ) { // Module function map LROT_BEGIN(tmr_dyn, NULL, 0) + LROT_FUNCENTRY( __gc, tmr_unregister ) + LROT_TABENTRY ( __index, tmr_dyn ) LROT_FUNCENTRY( register, tmr_register ) LROT_FUNCENTRY( alarm, tmr_alarm ) LROT_FUNCENTRY( start, tmr_start ) @@ -243,8 +245,6 @@ LROT_BEGIN(tmr_dyn, NULL, 0) LROT_FUNCENTRY( unregister, tmr_unregister ) LROT_FUNCENTRY( interval, tmr_interval) LROT_FUNCENTRY( state, tmr_state ) - LROT_FUNCENTRY( __gc, tmr_unregister ) - LROT_TABENTRY ( __index, tmr_dyn ) LROT_END(tmr_dyn, NULL, 0) LROT_BEGIN(tmr, NULL, 0) diff --git a/components/modules/touch.c b/components/modules/touch.c index 3f25f04a..367fcb8a 100644 --- a/components/modules/touch.c +++ b/components/modules/touch.c @@ -590,15 +590,14 @@ static int touch_unregister(lua_State* L) { } LROT_BEGIN(touch_dyn, NULL, 0) + LROT_FUNCENTRY( __gc, touch_unregister ) + LROT_TABENTRY ( __index, touch_dyn ) + // LROT_FUNCENTRY( __tostring, touch_tostring ) LROT_FUNCENTRY( read, touch_read ) LROT_FUNCENTRY( intrEnable, touch_intrEnable ) LROT_FUNCENTRY( intrDisable, touch_intrDisable ) LROT_FUNCENTRY( setThres, touch_setThres ) LROT_FUNCENTRY( setTriggerMode, touch_setTriggerMode ) - - // LROT_FUNCENTRY( __tostring, touch_tostring ) - LROT_FUNCENTRY( __gc, touch_unregister ) - LROT_TABENTRY ( __index, touch_dyn ) LROT_END(touch_dyn, NULL, 0) LROT_BEGIN(touch, NULL, 0) diff --git a/components/modules/u8g2.c b/components/modules/u8g2.c index b7abed5c..0ec828a2 100644 --- a/components/modules/u8g2.c +++ b/components/modules/u8g2.c @@ -559,6 +559,8 @@ static int lu8g2_updateDisplayArea( lua_State *L ) LROT_BEGIN(lu8g2_display, NULL, 0) + //LROT_FUNCENTRY( __gc, lu8g2_display_free ) + LROT_TABENTRY( __index, lu8g2_display ) LROT_FUNCENTRY( clearBuffer, lu8g2_clearBuffer ) LROT_FUNCENTRY( drawBox, lu8g2_drawBox ) LROT_FUNCENTRY( drawCircle, lu8g2_drawCircle ) @@ -600,8 +602,6 @@ LROT_BEGIN(lu8g2_display, NULL, 0) LROT_FUNCENTRY( setPowerSave, lu8g2_setPowerSave ) LROT_FUNCENTRY( updateDispla, lu8g2_updateDisplay ) LROT_FUNCENTRY( updateDisplayArea, lu8g2_updateDisplayArea ) - //LROT_FUNCENTRY( __gc, lu8g2_display_free ) - LROT_TABENTRY( __index, lu8g2_display ) LROT_END(lu8g2_display, NULL, 0)