[FarGroup/FarManager] master: LuaFAR: refactoring (58a9eee69)

0 views
Skip to first unread message

farg...@farmanager.com

unread,
Jun 20, 2024, 10:45:48 AMJun 20
to farco...@googlegroups.com
Repository : https://github.com/FarGroup/FarManager
On branch : master
Link : https://github.com/FarGroup/FarManager/commit/58a9eee69a31948f3a396dbabe7913e16ba99ff6

>---------------------------------------------------------------

commit 58a9eee69a31948f3a396dbabe7913e16ba99ff6
Author: Shmuel Zeigerman <solo...@gmail.com>
Date: Thu Jun 20 17:44:17 2024 +0300

LuaFAR: refactoring


>---------------------------------------------------------------

58a9eee69a31948f3a396dbabe7913e16ba99ff6
plugins/luamacro/_globalinfo.lua | 2 +-
plugins/luamacro/changelog | 4 ++++
plugins/luamacro/luafar/exported.c | 21 +++++++++++----------
plugins/luamacro/luafar/version.h | 2 +-
4 files changed, 17 insertions(+), 12 deletions(-)

diff --git a/plugins/luamacro/_globalinfo.lua b/plugins/luamacro/_globalinfo.lua
index 47d3b9f5c..6ff53dcbc 100644
--- a/plugins/luamacro/_globalinfo.lua
+++ b/plugins/luamacro/_globalinfo.lua
@@ -1,6 +1,6 @@
function export.GetGlobalInfo()
return {
- Version = { 3, 0, 0, 843 },
+ Version = { 3, 0, 0, 844 },
MinFarVersion = { 3, 0, 0, 6327 },
Guid = win.Uuid("4EBBEFC8-2084-4B7F-94C0-692CE136894D"),
Title = "LuaMacro",
diff --git a/plugins/luamacro/changelog b/plugins/luamacro/changelog
index 89dbc3337..4cb42655a 100644
--- a/plugins/luamacro/changelog
+++ b/plugins/luamacro/changelog
@@ -1,3 +1,7 @@
+shmuel 2024-06-20 17:41:53+03:00 - build 844
+
+1. LuaFAR: refactoring
+
shmuel 2024-06-17 09:32:42+03:00 - build 843

1. LuaFAR: refactoring
diff --git a/plugins/luamacro/luafar/exported.c b/plugins/luamacro/luafar/exported.c
index 392552be2..2e2363865 100644
--- a/plugins/luamacro/luafar/exported.c
+++ b/plugins/luamacro/luafar/exported.c
@@ -302,13 +302,13 @@ void FillFindData(lua_State* L, struct GetFindDataInfo *Info)
size_t i, num;
size_t numLines = lua_objlen(L,-1);

- // allocate array with an additional element at its beginning to keep the reference to collector
- ppi = (struct PluginPanelItem *)malloc(sizeof(struct PluginPanelItem) * (1 + numLines));
+ ppi = (struct PluginPanelItem *)malloc(sizeof(struct PluginPanelItem) * numLines);
lua_newtable(L); //+3 Tbl,FindData,Coll
- lua_pushvalue(L,-1); //+4: Tbl,FindData,Coll,Coll
- ppi[0].CustomColumnNumber = (size_t)luaL_ref(L,-4); //+3: Tbl,FindData,Coll
+ lua_pushlightuserdata(L, ppi); //+4 Tbl,FindData,Coll,ppi
+ lua_pushvalue(L,-2); //+5: Tbl,FindData,Coll,ppi,Coll
+ lua_rawset(L, -5); //+3: Tbl,FindData,Coll

- for(i=1,num=1; i<=numLines; i++)
+ for(i=1,num=0; i<=numLines; i++)
{
lua_pushinteger(L, i); //+4
lua_gettable(L, -3); //+4: Tbl,FindData,Coll,FindData[i]
@@ -323,8 +323,8 @@ void FillFindData(lua_State* L, struct GetFindDataInfo *Info)
}

lua_pop(L,3); //+0
- Info->ItemsNumber = num-1;
- Info->PanelItem = ppi+1;
+ Info->ItemsNumber = num;
+ Info->PanelItem = ppi;
}

intptr_t LF_GetFindData(lua_State* L, struct GetFindDataInfo *Info)
@@ -364,12 +364,13 @@ void LF_FreeFindData(lua_State* L, const struct FreeFindDataInfo *Info)
{
if (Info->ItemsNumber > 0)
{
- struct PluginPanelItem *auxItem = Info->PanelItem - 1;
PushPluginTable(L, Info->hPanel);
- luaL_unref(L, -1, (int)auxItem->CustomColumnNumber); //free the collector
+ lua_pushlightuserdata(L, Info->PanelItem);
+ lua_pushnil(L);
+ lua_rawset(L, -3); //free the collector
lua_pop(L, 1);
lua_gc(L, LUA_GCCOLLECT, 0); //free memory taken by Collector
- free(auxItem);
+ free(Info->PanelItem);
}
}
//---------------------------------------------------------------------------
diff --git a/plugins/luamacro/luafar/version.h b/plugins/luamacro/luafar/version.h
index b725b45eb..74b96bb4b 100644
--- a/plugins/luamacro/luafar/version.h
+++ b/plugins/luamacro/luafar/version.h
@@ -1,3 +1,3 @@
#include <farversion.hpp>

-#define PLUGIN_BUILD 843
+#define PLUGIN_BUILD 844


Reply all
Reply to author
Forward
0 new messages