From 8bf47ec172e315c7da851ae5b1413ac519a9bddb Mon Sep 17 00:00:00 2001 From: Adam Date: Thu, 9 Feb 2023 11:55:47 -0500 Subject: [PATCH] Fixed up some post 5.1/jit Symbols (#1385) * Updated k functions to have appropriate method signatures for 5.3 and up. * Fixed up some inconsistent signatures that I forgot. --- resources/lite_xl_plugin_api.h | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/resources/lite_xl_plugin_api.h b/resources/lite_xl_plugin_api.h index 6d68e454..8bf74054 100644 --- a/resources/lite_xl_plugin_api.h +++ b/resources/lite_xl_plugin_api.h @@ -205,6 +205,7 @@ Go figure. #define luai_numisnan(L,a) (!luai_numeq((a), (a))) #endif #define LUA_INTEGER ptrdiff_t +#define LUA_KCONTEXT ptrdiff_t #define LUA_UNSIGNED unsigned LUA_INT32 #if defined(LUA_NUMBER_DOUBLE) && !defined(LUA_ANSI) #if defined(LUA_WIN) && defined(_MSC_VER) && defined(_M_IX86) @@ -235,10 +236,12 @@ typedef int (*lua_CFunction) (lua_State *L); typedef const char * (*lua_Reader) (lua_State *L, void *ud, size_t *sz); typedef int (*lua_Writer) (lua_State *L, const void* p, size_t sz, void* ud); typedef void * (*lua_Alloc) (void *ud, void *ptr, size_t osize, size_t nsize); +typedef LUA_KCONTEXT lua_KContext; typedef LUA_NUMBER lua_Number; typedef LUA_INTEGER lua_Integer; typedef LUA_UNSIGNED lua_Unsigned; typedef struct lua_Debug lua_Debug; +typedef int (*lua_KFunction) (lua_State *L, int status, lua_KContext ctx); typedef void (*lua_Hook) (lua_State *L, lua_Debug *ar); struct lua_Debug { int event; @@ -321,12 +324,12 @@ SYMBOL_DECLARE(void, lua_rawsetp, lua_State *L, int idx, SYMBOL_DECLARE(int, lua_setmetatable, lua_State *L, int objindex) SYMBOL_DECLARE(void, lua_setuservalue, lua_State *L, int idx) SYMBOL_DECLARE(void, lua_setiuservalue, lua_State *L, int idx, int n) -SYMBOL_DECLARE(void, lua_callk, lua_State *L, int nargs, int nresults, int ctx, lua_CFunction k) +SYMBOL_DECLARE(void, lua_callk, lua_State *L, int nargs, int nresults, lua_KContext ctx, lua_KFunction k) SYMBOL_DECLARE(int, lua_getctx, lua_State *L, int *ctx) -SYMBOL_DECLARE(int, lua_pcallk, lua_State *L, int nargs, int nresults, int errfunc, int ctx, lua_CFunction k) +SYMBOL_DECLARE(int, lua_pcallk, lua_State *L, int nargs, int nresults, int errfunc, lua_KContext ctx, lua_KFunction k) SYMBOL_DECLARE(int, lua_load, lua_State *L, lua_Reader reader, void *dt, const char *chunkname, const char *mode) SYMBOL_DECLARE(int, lua_dump, lua_State *L, lua_Writer writer, void *data, int strip) -SYMBOL_DECLARE(int, lua_yieldk, lua_State *L, int nresults, int ctx, lua_CFunction k) +SYMBOL_DECLARE(int, lua_yieldk, lua_State *L, int nresults, lua_KContext ctx, lua_KFunction k) SYMBOL_DECLARE(int, lua_resume, lua_State *L, lua_State *from, int narg) SYMBOL_DECLARE(int, lua_status, lua_State *L) SYMBOL_DECLARE(int, lua_gc, lua_State *L, int what, int data) @@ -740,13 +743,13 @@ SYMBOL_WRAP_DECL(void, lua_setuservalue, lua_State *L, int idx){ SYMBOL_WRAP_DECL(void, lua_setiuservalue, lua_State *L, int idx, int n){ SYMBOL_WRAP_CALL(lua_setiuservalue, L, idx, n); } -SYMBOL_WRAP_DECL(void, lua_callk, lua_State *L, int nargs, int nresults, int ctx, lua_CFunction k){ +SYMBOL_WRAP_DECL(void, lua_callk, lua_State *L, int nargs, int nresults, lua_KContext ctx, lua_KFunction k){ SYMBOL_WRAP_CALL(lua_callk, L, nargs, nresults, ctx, k); } SYMBOL_WRAP_DECL(int, lua_getctx, lua_State *L, int *ctx){ SYMBOL_WRAP_CALL(lua_getctx, L, ctx); } -SYMBOL_WRAP_DECL(int, lua_pcallk, lua_State *L, int nargs, int nresults, int errfunc, int ctx, lua_CFunction k){ +SYMBOL_WRAP_DECL(int, lua_pcallk, lua_State *L, int nargs, int nresults, int errfunc, lua_KContext ctx, lua_KFunction k){ SYMBOL_WRAP_CALL(lua_pcallk, L, nargs, nresults, errfunc, ctx, k); } SYMBOL_WRAP_DECL(int, lua_load, lua_State *L, lua_Reader reader, void *dt, const char *chunkname, const char *mode){ @@ -755,7 +758,7 @@ SYMBOL_WRAP_DECL(int, lua_load, lua_State *L, lua_Reader reader, void *dt, const SYMBOL_WRAP_DECL(int, lua_dump, lua_State *L, lua_Writer writer, void *data, int strip){ SYMBOL_WRAP_CALL(lua_dump, L, writer, data, strip); } -SYMBOL_WRAP_DECL(int, lua_yieldk, lua_State *L, int nresults, int ctx, lua_CFunction k){ +SYMBOL_WRAP_DECL(int, lua_yieldk, lua_State *L, int nresults, lua_KContext ctx, lua_KFunction k){ SYMBOL_WRAP_CALL(lua_yieldk, L, nresults, ctx, k); } SYMBOL_WRAP_DECL(int, lua_resume, lua_State *L, lua_State *from, int narg){ @@ -1041,12 +1044,12 @@ static void lite_xl_plugin_init(void *XL) { IMPORT_SYMBOL(lua_setmetatable, int , lua_State *L, int objindex); IMPORT_SYMBOL_OPT(lua_setuservalue, void , lua_State *L, int idx); IMPORT_SYMBOL(lua_setiuservalue, void , lua_State *L, int idx, int n); - IMPORT_SYMBOL(lua_callk, void , lua_State *L, int nargs, int nresults, int ctx, lua_CFunction k); + IMPORT_SYMBOL(lua_callk, void , lua_State *L, int nargs, int nresults, lua_KContext ctx, lua_KFunction k); IMPORT_SYMBOL(lua_getctx, int , lua_State *L, int *ctx); - IMPORT_SYMBOL(lua_pcallk, int , lua_State *L, int nargs, int nresults, int errfunc, int ctx, lua_CFunction k); + IMPORT_SYMBOL(lua_pcallk, int , lua_State *L, int nargs, int nresults, int errfunc, lua_KContext ctx, lua_KFunction k); IMPORT_SYMBOL(lua_load, int , lua_State *L, lua_Reader reader, void *dt, const char *chunkname, const char *mode); IMPORT_SYMBOL(lua_dump, int , lua_State *L, lua_Writer writer, void *data, int strip); - IMPORT_SYMBOL(lua_yieldk, int , lua_State *L, int nresults, int ctx, lua_CFunction k); + IMPORT_SYMBOL(lua_yieldk, int , lua_State *L, int nresults, lua_KContext ctx, lua_KFunction k); IMPORT_SYMBOL(lua_resume, int , lua_State *L, lua_State *from, int narg); IMPORT_SYMBOL(lua_status, int , lua_State *L); IMPORT_SYMBOL(lua_gc, int , lua_State *L, int what, int data);