From f73126c260b3d9793228a11ab54818f5fcf5bd0e Mon Sep 17 00:00:00 2001 From: Shmuel Zeigerman Date: Tue, 6 Feb 2024 09:36:53 +0200 Subject: [PATCH] LuaFAR: refactoring --- plugins/luamacro/_globalinfo.lua | 2 +- plugins/luamacro/changelog | 4 ++++ plugins/luamacro/luafar/bit64.c | 8 +++++--- plugins/luamacro/luafar/version.h | 2 +- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/plugins/luamacro/_globalinfo.lua b/plugins/luamacro/_globalinfo.lua index bbdb72255c..f854341be1 100644 --- a/plugins/luamacro/_globalinfo.lua +++ b/plugins/luamacro/_globalinfo.lua @@ -1,6 +1,6 @@ function export.GetGlobalInfo() return { - Version = { 3, 0, 0, 804 }, + Version = { 3, 0, 0, 805 }, MinFarVersion = { 3, 0, 0, 6214 }, Guid = win.Uuid("4EBBEFC8-2084-4B7F-94C0-692CE136894D"), Title = "LuaMacro", diff --git a/plugins/luamacro/changelog b/plugins/luamacro/changelog index d097dd6db9..28d509fa55 100644 --- a/plugins/luamacro/changelog +++ b/plugins/luamacro/changelog @@ -1,3 +1,7 @@ +shmuel 2024-02-06 09:34:58+02:00 - build 805 + +1. LuaFAR: refactoring. + rohitab 2024-02-03 13:39:53+11:00 - build 804 1. LuaFAR: add MOUSE_HWHEELED flag. diff --git a/plugins/luamacro/luafar/bit64.c b/plugins/luamacro/luafar/bit64.c index b7ada87406..bf7549051b 100644 --- a/plugins/luamacro/luafar/bit64.c +++ b/plugins/luamacro/luafar/bit64.c @@ -2,7 +2,9 @@ #include #include -#define MAX53 0x1FFFFFFFFFFFFFLL +#define MAX52 (1LL << 52) +#define FIT52(v) ((v >= 0 && v < MAX52) || (v < 0 && v >= -MAX52)) + typedef __int64 INT64; typedef unsigned __int64 UINT64; static int f_new(lua_State *L); /* forward declaration */ @@ -19,7 +21,7 @@ int bit64_pushuserdata(lua_State *L, INT64 v) int bit64_push(lua_State *L, INT64 v) { - if((v >= 0 && v <= MAX53) || (v < 0 && v >= -MAX53)) + if (FIT52(v)) lua_pushnumber(L, (double)v); else bit64_pushuserdata(L, v); @@ -59,7 +61,7 @@ INT64 check64(lua_State *L, int pos, int* success) if(tp == LUA_TNUMBER) { double dd = lua_tonumber(L, pos); - if ((dd>=0 && dd<=0x7fffffffffffffffULL) || (dd<0 && -dd<=0x8000000000000000ULL)) + if (FIT52(dd)) return (INT64)dd; } else diff --git a/plugins/luamacro/luafar/version.h b/plugins/luamacro/luafar/version.h index 0279d7660b..fa7a91914a 100644 --- a/plugins/luamacro/luafar/version.h +++ b/plugins/luamacro/luafar/version.h @@ -1,3 +1,3 @@ #include -#define PLUGIN_BUILD 804 +#define PLUGIN_BUILD 805