Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GeanyLua: Support for LuaJIT and Lua 5.1-5.4 #1238

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
GeanyLua: Add support for Lua 5.2+
xiota committed Oct 13, 2024
commit 599766dae8fce6e9e4604f5946497248c4343ebc
2 changes: 1 addition & 1 deletion geanylua/glspi_app.c
Original file line number Diff line number Diff line change
@@ -549,5 +549,5 @@ static const struct luaL_Reg glspi_app_funcs[] = {

void glspi_init_app_funcs(lua_State *L, const gchar*script_dir) {
glspi_script_dir = script_dir;
luaL_register(L, NULL,glspi_app_funcs);
luaL_setfuncs(L, glspi_app_funcs, 0);
}
4 changes: 2 additions & 2 deletions geanylua/glspi_dlg.c
Original file line number Diff line number Diff line change
@@ -128,7 +128,7 @@ static gint glspi_choose(lua_State* L)
arg1=lua_tostring(L, 1);
}

n=lua_objlen(L,2);
n=lua_rawlen(L,2);
for (i=1;i<=n; i++) {
lua_rawgeti(L,2,i);
if (!lua_isstring(L, -1)) {
@@ -556,5 +556,5 @@ static const struct luaL_Reg glspi_dlg_funcs[] = {

void glspi_init_dlg_funcs(lua_State *L, GsDlgRunHook hook) {
glspi_pause_timer = hook;
luaL_register(L, NULL,glspi_dlg_funcs);
luaL_setfuncs(L, glspi_dlg_funcs, 0);
}
2 changes: 1 addition & 1 deletion geanylua/glspi_doc.c
Original file line number Diff line number Diff line change
@@ -374,5 +374,5 @@ static const struct luaL_Reg glspi_doc_funcs[] = {
};

void glspi_init_doc_funcs(lua_State *L) {
luaL_register(L, NULL,glspi_doc_funcs);
luaL_setfuncs(L, glspi_doc_funcs, 0);
}
2 changes: 1 addition & 1 deletion geanylua/glspi_init.c
Original file line number Diff line number Diff line change
@@ -546,5 +546,5 @@ static const struct luaL_Reg glspi_mnu_funcs[] = {


void glspi_init_mnu_funcs(lua_State *L) {
luaL_register(L, NULL,glspi_mnu_funcs);
luaL_setfuncs(L, glspi_mnu_funcs, 0);
}
6 changes: 4 additions & 2 deletions geanylua/glspi_kfile.c
Original file line number Diff line number Diff line change
@@ -395,8 +395,10 @@ static gint luaopen_keyfile(lua_State *L)
lua_pushstring(L,"__gc");
lua_pushcfunction(L,kfile_done);
lua_rawset(L,-3);
luaL_register(L, NULL, &kfile_funcs[1]);
luaL_register(L, LUA_MODULE_NAME, kfile_funcs);
luaL_setfuncs(L, &kfile_funcs[1], 0);
lua_newtable(L);
luaL_setfuncs(L, kfile_funcs, 0);
lua_setglobal(L, LUA_MODULE_NAME);
return 0;
}

28 changes: 13 additions & 15 deletions geanylua/glspi_run.c
Original file line number Diff line number Diff line change
@@ -293,21 +293,17 @@ static const struct luaL_Reg glspi_timer_funcs[] = {
/* Catch and report script errors */
static gint glspi_traceback(lua_State *L)
{
lua_getfield(L, LUA_GLOBALSINDEX, "debug");
if (!lua_istable(L, -1)) {
lua_pop(L, 1);
return 1;
}
lua_getfield(L, -1, "traceback");
if (!lua_isfunction(L, -1)) {
lua_pop(L, 2);
return 1;
const char *msg = lua_tostring(L, 1);
if (msg == NULL) { /* is error object not a string? */
if (luaL_callmeta(L, 1, "__tostring") && /* does it have a metamethod */
lua_type(L, -1) == LUA_TSTRING) /* that produces a string? */
return 1; /* that is the message */
else
msg = lua_pushfstring(L, "(error object is a %s value)",
luaL_typename(L, 1));
}
lua_pushvalue(L, 1);
lua_pushinteger(L, 2);
lua_call(L, 2, 1);

return 1;
luaL_traceback(L, L, msg, 1); /* append a standard traceback */
return 1; /* return the traceback */
}

/*
@@ -393,12 +389,14 @@ static void show_error(lua_State *L, const gchar *script_file)

static gint glspi_init_module(lua_State *L, const gchar *script_file, gint caller, GKeyFile*proj, const gchar*script_dir)
{
luaL_register(L, LUA_MODULE_NAME, glspi_timer_funcs);
lua_newtable(L);
luaL_setfuncs(L, glspi_timer_funcs, 0);
glspi_init_sci_funcs(L);
glspi_init_doc_funcs(L);
glspi_init_mnu_funcs(L);
glspi_init_dlg_funcs(L, glspi_pause_timer);
glspi_init_app_funcs(L,script_dir);
lua_setglobal(L, LUA_MODULE_NAME);
set_string_token(L,tokenWordChars,GEANY_WORDCHARS);
set_string_token(L,tokenBanner,DEFAULT_BANNER);
set_string_token(L,tokenDirSep, G_DIR_SEPARATOR_S);
4 changes: 2 additions & 2 deletions geanylua/glspi_sci.c
Original file line number Diff line number Diff line change
@@ -905,7 +905,7 @@ static gint glspi_find(lua_State* L)
ttf.chrg.cpMin=lua_tonumber(L,2);
ttf.chrg.cpMax=lua_tonumber(L,3);

n=lua_objlen(L,4);
n=lua_rawlen(L,4);
for (i=1;i<=n; i++) {
lua_rawgeti(L,4,i);
if (lua_isstring(L, -1)) {
@@ -995,5 +995,5 @@ static const struct luaL_Reg glspi_sci_funcs[] = {
};

void glspi_init_sci_funcs(lua_State *L) {
luaL_register(L, NULL,glspi_sci_funcs);
luaL_setfuncs(L, glspi_sci_funcs, 0);
}
8 changes: 5 additions & 3 deletions geanylua/gsdlg_lua.c
Original file line number Diff line number Diff line change
@@ -323,7 +323,7 @@ static gint gsdl_new(lua_State *L) {
if (argc>=2) {
if (!lua_istable(L,2)) { return FAIL_TABLE_ARG(2); }
}
n=lua_objlen(L,2);
n=lua_rawlen(L,2);
for (i=1;i<=n; i++) {
lua_rawgeti(L,2,i);
if (!lua_isstring(L, -1)) {
@@ -425,8 +425,10 @@ gint luaopen_dialog(lua_State *L)
lua_pushcfunction(L,gsdl_done);
lua_rawset(L,-3);

luaL_register(L, NULL, &gsdl_funcs[1]);
luaL_register(L, LUA_MODULE_NAME, gsdl_funcs);
luaL_setfuncs(L, &gsdl_funcs[1], 0);
lua_newtable(L);
luaL_setfuncs(L, gsdl_funcs, 0);
lua_setglobal(L, LUA_MODULE_NAME);
return 0;
}