aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormitchell <70453897+667e-11@users.noreply.github.com>2011-12-12 08:08:18 -0500
committermitchell <70453897+667e-11@users.noreply.github.com>2011-12-12 08:08:18 -0500
commit51bfd53e48d5310eb786069b758e0430129daf54 (patch)
tree15eedf68fad753b1fad5184c4d018bfced1e4001 /src
parentdfacbd6a183f6b09498f589e20f146cbbf332e88 (diff)
downloadtextadept-51bfd53e48d5310eb786069b758e0430129daf54.tar.gz
textadept-51bfd53e48d5310eb786069b758e0430129daf54.zip
Updated to Lua 5.2.
Diffstat (limited to 'src')
-rw-r--r--src/Makefile21
-rw-r--r--src/lua.sym45
-rw-r--r--src/textadept.c62
3 files changed, 77 insertions, 51 deletions
diff --git a/src/Makefile b/src/Makefile
index b326db63..333fb838 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -13,9 +13,7 @@ else
PLAT_FLAGS = -DGTK -D__BSD__
endif
SCI_THREAD_FLAG =
-#LUA_CFLAGS = -DLUA_USE_LINUX
-#Lua Coco needs the following flags because GCC is stupid.
-LUA_CFLAGS = -DLUA_USE_LINUX -fomit-frame-pointer -maccumulate-outgoing-args
+LUA_CFLAGS = -DLUA_USE_LINUX
TEXTADEPT = textadept
TEXTADEPT_RC =
EXPORTLUASYMS = -rdynamic -Wl,--retain-symbols-file -Wl,lua.sym
@@ -30,8 +28,7 @@ PKG_CONFIG = pkg-config --define-variable=prefix=win32gtk
PKG_CONFIG_PATH = $(shell pwd)/win32gtk/lib/pkgconfig
PLAT_FLAGS = -DGTK -D__WIN32__
SCI_THREAD_FLAG = -DG_THREADS_IMPL_NONE
-#LUA_CFLAGS = -D_WIN32 -DWIN32
-LUA_CFLAGS = -D_WIN32 -DWIN32 -fomit-frame-pointer -maccumulate-outgoing-args
+LUA_CFLAGS = -D_WIN32 -DWIN32
TEXTADEPT = textadept.exe
TEXTADEPT_RC = textadept_rc.o
EXPORTLUASYMS = -Wl,--retain-symbols-file -Wl,lua.sym
@@ -62,7 +59,7 @@ DEBUG_FLAG = -DNDEBUG
else
DEBUG_FLAG = -DDEBUG -DTRACE -g
endif
-INCLUDEDIRS = -Iscintilla/include -Ilua/include -Igcocoadialog
+INCLUDEDIRS = -Iscintilla/include -Ilua/src -Igcocoadialog
ifdef GTK3
GTKVERSION = gtk+-3.0
@@ -86,12 +83,12 @@ GTKLIBS += -framework Carbon -framework Cocoa -ligemacintegration
endif
TEXTADEPT_OBJS = textadept.o
-LUA_OBJS = lapi.o lcode.o ldebug.o ldo.o ldump.o lfunc.o lgc.o llex.o lmem.o \
- lobject.o lopcodes.o lparser.o lstate.o lstring.o ltable.o ltm.o lundump.o \
- lvm.o lzio.o \
- lauxlib.o lbaselib.o ldblib.o liolib.o lmathlib.o ltablib.o lstrlib.o \
- loadlib.o loslib.o linit.o \
- lpeg.o lfs.o lcoco.o
+LUA_OBJS = lapi.o lcode.o lctype.o ldebug.o ldo.o ldump.o lfunc.o lgc.o \
+ linit.o llex.o lmem.o lobject.o lopcodes.o lparser.o lstate.o lstring.o \
+ ltable.o ltm.o lundump.o lvm.o lzio.o \
+ lauxlib.o lbaselib.o lbitlib.o lcorolib.o ldblib.o liolib.o lmathlib.o \
+ loadlib.o loslib.o ltablib.o lstrlib.o \
+ lpeg.o lfs.o
GCOCOADIALOG = gcocoadialog.o
# Scintilla
diff --git a/src/lua.sym b/src/lua.sym
index 18ab3d6c..a2ce7548 100644
--- a/src/lua.sym
+++ b/src/lua.sym
@@ -3,6 +3,7 @@ luaL_addstring
luaL_addvalue
luaL_argerror
luaL_buffinit
+luaL_buffinitsize
luaL_callmeta
luaL_checkany
luaL_checkinteger
@@ -12,39 +13,55 @@ luaL_checkoption
luaL_checkstack
luaL_checktype
luaL_checkudata
+luaL_checkunsigned
+luaL_checkversion
luaL_error
+luaL_execresult
+luaL_fileresult
luaL_findtable
luaL_getmetafield
+luaL_getsubtable
luaL_gsub
+luaL_len
luaL_loadbuffer
luaL_loadfile
luaL_loadstring
+luaL_newlibtable
luaL_newmetatable
luaL_newstate
luaL_openlibs
luaL_optinteger
luaL_optlstring
luaL_optnumber
+luaL_optunsigned
luaL_prepbuffer
+luaL_prepbuffersize
luaL_pushresult
+luaL_pushresultsize
luaL_ref
-luaL_register
-luaL_typerror
+luaL_requiref
+luaL_setfuncs
+luaL_setmetatable
+luaL_testudata
+luaL_tostring
+luaL_traceback
luaL_unref
luaL_where
+lua_absindex
+lua_arith
lua_atpanic
lua_call
+lua_callk
lua_checkstack
lua_close
lua_concat
-lua_cpcall
+lua_copy
lua_createtable
lua_dump
-lua_equal
lua_error
lua_gc
lua_getallocf
-lua_getfenv
+lua_getctx
lua_getfield
lua_gethook
lua_gethookcount
@@ -56,20 +73,21 @@ lua_getstack
lua_gettable
lua_gettop
lua_getupvalue
+lua_getuservalue
lua_ident
lua_insert
lua_iscfunction
lua_isnumber
lua_isstring
lua_isuserdata
-lua_lessthan
+lua_len
lua_load
lua_newstate
lua_newthread
lua_newuserdata
lua_next
-lua_objlen
lua_pcall
+lua_pcallk
lua_pushboolean
lua_pushcclosure
lua_pushfstring
@@ -85,13 +103,13 @@ lua_pushvfstring
lua_rawequal
lua_rawget
lua_rawgeti
+lua_rawlen
lua_rawset
lua_rawseti
lua_remove
lua_replace
lua_resume
lua_setallocf
-lua_setfenv
lua_setfield
lua_sethook
lua_setlevel
@@ -100,20 +118,31 @@ lua_setmetatable
lua_settable
lua_settop
lua_setupvalue
+lua_setuservalue
lua_status
lua_toboolean
lua_tocfunction
lua_tointeger
+lua_tointegerx
lua_tolstring
lua_tonumber
+lua_tonumberx
lua_topointer
lua_tothread
+lua_tounsigned
+lua_tounsignedx
lua_touserdata
+lua_upvalueid
+lua_upvaluejoin
lua_type
lua_typename
+lua_version
lua_xmove
lua_yield
+lua_yieldk
luaopen_base
+luaopen_bitlib
+luaopen_coroutine
luaopen_debug
luaopen_io
luaopen_math
diff --git a/src/textadept.c b/src/textadept.c
index 2f95339f..f828e8ae 100644
--- a/src/textadept.c
+++ b/src/textadept.c
@@ -164,7 +164,7 @@ int main(int argc, char **argv) {
char *last_slash = strrchr(textadept_home, G_DIR_SEPARATOR);
if (last_slash) *last_slash = '\0';
gtk_init(&argc, &argv);
- if (lua = lua_open(), !lL_init(lua, argc, argv, FALSE)) return 1;
+ if (lua = luaL_newstate(), !lL_init(lua, argc, argv, FALSE)) return 1;
new_window();
lL_dofile(lua, "init.lua");
gtk_main();
@@ -732,7 +732,7 @@ static gboolean c_keypress(GtkWidget*_, GdkEventKey *event, gpointer __) {
/******************************************************************************/
#define lL_openlib(l, n, f) \
- (lua_pushcfunction(l, f), lua_pushstring(l, n), lua_call(l, 1, 0))
+ (luaL_requiref(l, n, f, 1), lua_pop(l, 1))
#define l_setcfunction(l, n, k, f) \
(lua_pushcfunction(l, f), lua_setfield(l, (n > 0) ? n : n - 1, k))
#define l_setmetatable(l, n, k, i, ni) { \
@@ -765,7 +765,7 @@ static int lL_init(lua_State *L, int argc, char **argv, int reinit) {
lua_getglobal(L, "package"), lua_getfield(L, -1, "loaded");
lL_cleartable(L, lua_gettop(L));
lua_pop(L, 2); // package and package.loaded
- lL_cleartable(L, LUA_GLOBALSINDEX);
+ lL_cleartable(L, LUA_RIDX_GLOBALS);
}
luaL_openlibs(L);
lL_openlib(L, "lpeg", luaopen_lpeg);
@@ -840,7 +840,7 @@ static int lL_init(lua_State *L, int argc, char **argv, int reinit) {
*/
static int lL_dofile(lua_State *L, const char *filename) {
char *file = g_strconcat(textadept_home, "/", filename, NULL);
- int ok = (luaL_dofile(L, file) == 0);
+ int ok = (luaL_dofile(L, file) == LUA_OK);
if (!ok) {
GtkWidget *dialog = gtk_message_dialog_new(NULL, GTK_DIALOG_MODAL,
GTK_MESSAGE_ERROR,
@@ -883,8 +883,8 @@ static void lL_addview(lua_State *L, GtkWidget *view) {
l_setmetatable(L, -2, "ta_view", lview__index, lview__newindex);
// vs[userdata] = v, vs[#vs + 1] = v, vs[v] = #vs
lua_pushvalue(L, -2), lua_settable(L, -4);
- lua_pushvalue(L, -1), lua_rawseti(L, -3, lua_objlen(L, -3) + 1);
- lua_pushinteger(L, lua_objlen(L, -2)), lua_settable(L, -3);
+ lua_pushvalue(L, -1), lua_rawseti(L, -3, lua_rawlen(L, -3) + 1);
+ lua_pushinteger(L, lua_rawlen(L, -2)), lua_settable(L, -3);
lua_pop(L, 1); // views
}
@@ -903,9 +903,9 @@ static void lL_removeview(lua_State *L, GtkWidget *view) {
if (lua_isnumber(L, -2) && view != l_toview(L, -1)) {
lua_getfield(L, -1, "widget_pointer");
// vs[userdata] = v, vs[#vs + 1] = v, vs[v] = #vs
- lua_pushvalue(L, -2), lua_rawseti(L, -6, lua_objlen(L, -6) + 1);
+ lua_pushvalue(L, -2), lua_rawseti(L, -6, lua_rawlen(L, -6) + 1);
lua_pushvalue(L, -2), lua_settable(L, -6);
- lua_pushinteger(L, lua_objlen(L, -4)), lua_settable(L, -5);
+ lua_pushinteger(L, lua_rawlen(L, -4)), lua_settable(L, -5);
} else lua_pop(L, 1); // value
}
lua_pop(L, 1); // views
@@ -942,8 +942,8 @@ static void lL_adddoc(lua_State *L, sptr_t doc) {
l_setmetatable(L, -2, "ta_buffer", lbuf_property, lbuf_property);
// bs[userdata] = b, bs[#bs + 1] = b, bs[b] = #bs
lua_pushvalue(L, -2), lua_settable(L, -4);
- lua_pushvalue(L, -1), lua_rawseti(L, -3, lua_objlen(L, -3) + 1);
- lua_pushinteger(L, lua_objlen(L, -2)), lua_settable(L, -3);
+ lua_pushvalue(L, -1), lua_rawseti(L, -3, lua_rawlen(L, -3) + 1);
+ lua_pushinteger(L, lua_rawlen(L, -2)), lua_settable(L, -3);
lua_pop(L, 1); // buffers
}
@@ -975,9 +975,9 @@ static void lL_removedoc(lua_State *L, sptr_t doc) {
if (lua_isnumber(L, -2) && doc != l_todoc(L, -1)) {
lua_getfield(L, -1, "doc_pointer");
// bs[userdata] = b, bs[#bs + 1] = b, bs[b] = #bs
- lua_pushvalue(L, -2), lua_rawseti(L, -6, lua_objlen(L, -6) + 1);
+ lua_pushvalue(L, -2), lua_rawseti(L, -6, lua_rawlen(L, -6) + 1);
lua_pushvalue(L, -2), lua_settable(L, -6);
- lua_pushinteger(L, lua_objlen(L, -4)), lua_settable(L, -5);
+ lua_pushinteger(L, lua_rawlen(L, -4)), lua_settable(L, -5);
} else lua_pop(L, 1); // value
}
lua_pop(L, 1); // buffers
@@ -1000,15 +1000,15 @@ static void lL_gotodoc(lua_State *L, GtkWidget *view, int n, int relative) {
l_pushdoc(L, SS(view, SCI_GETDOCPOINTER, 0, 0)), lua_gettable(L, -2);
n = lua_tointeger(L, -1) + n;
lua_pop(L, 1); // index
- if (n > lua_objlen(L, -1))
+ if (n > lua_rawlen(L, -1))
n = 1;
else if (n < 1)
- n = lua_objlen(L, -1);
+ n = lua_rawlen(L, -1);
lua_rawgeti(L, -1, n);
} else {
- luaL_argcheck(L, (n > 0 && n <= lua_objlen(L, -1)) || n == -1, 2,
+ luaL_argcheck(L, (n > 0 && n <= lua_rawlen(L, -1)) || n == -1, 2,
"no Buffer exists at that index");
- lua_rawgeti(L, -1, (n > 0) ? n : lua_objlen(L, -1));
+ lua_rawgeti(L, -1, (n > 0) ? n : lua_rawlen(L, -1));
}
sptr_t doc = l_todoc(L, -1);
SS(view, SCI_SETDOCPOINTER, 0, doc);
@@ -1153,7 +1153,7 @@ static long lL_checkscintillaparam(lua_State *L, int *narg, int type) {
static GtkWidget *lL_checkview(lua_State *L, int narg) {
luaL_getmetatable(L, "ta_view");
lua_getmetatable(L, narg);
- luaL_argcheck(L, lua_equal(L, -1, -2), narg, "View expected");
+ luaL_argcheck(L, lua_compare(L, -1, -2, LUA_OPEQ), narg, "View expected");
lua_getfield(L, (narg > 0) ? narg : narg - 2, "widget_pointer");
GtkWidget *view = (GtkWidget *)lua_touserdata(L, -1);
lua_pop(L, 3); // widget_pointer, metatable, metatable
@@ -1170,7 +1170,7 @@ static GtkWidget *lL_checkview(lua_State *L, int narg) {
static void lL_globaldoccheck(lua_State *L, int narg) {
luaL_getmetatable(L, "ta_buffer");
lua_getmetatable(L, (narg > 0) ? narg : narg - 1);
- luaL_argcheck(L, lua_equal(L, -1, -2), narg, "Buffer expected");
+ luaL_argcheck(L, lua_compare(L, -1, -2, LUA_OPEQ), narg, "Buffer expected");
lua_getfield(L, (narg > 0) ? narg : narg - 2, "doc_pointer");
sptr_t doc = (sptr_t)lua_touserdata(L, -1);
luaL_argcheck(L, doc == SS(focused_view, SCI_GETDOCPOINTER, 0, 0), narg,
@@ -1210,7 +1210,7 @@ static void l_pushgtkmenu(lua_State *L, int index, GCallback callback,
gtk_menu_shell_append(GTK_MENU_SHELL(menu),
(GtkWidget *)lua_touserdata(L, -1));
lua_pop(L, 1); // gtkmenu
- } else if (lua_objlen(L, -1) == 2 || lua_objlen(L, -1) == 4) {
+ } else if (lua_rawlen(L, -1) == 2 || lua_rawlen(L, -1) == 4) {
lua_rawgeti(L, -1, 1);
label = lua_tostring(L, -1);
lua_pop(L, 1); // label
@@ -1286,7 +1286,7 @@ static int lL_event(lua_State *L, const char *name, ...) {
type = va_arg(ap, int);
}
va_end(ap);
- if (lua_pcall(L, n, 1, 0) == 0)
+ if (lua_pcall(L, n, 1, 0) == LUA_OK)
ret = lua_toboolean(L, -1);
else
lL_event(L, "error", LUA_TSTRING, lua_tostring(L, -1), -1);
@@ -1386,7 +1386,7 @@ static int l_callscintilla(lua_State *L, int msg, int wtype, int ltype,
// Set wParam and lParam appropriately for Scintilla based on wtype and ltype.
if (wtype == tLENGTH && ltype == tSTRING) {
- wparam = (uptr_t)lua_strlen(L, arg);
+ wparam = (uptr_t)lua_rawlen(L, arg);
lparam = (sptr_t)luaL_checkstring(L, arg);
params_needed = 0;
} else if (ltype == tSTRINGRESULT) {
@@ -1429,7 +1429,7 @@ static int lbuf_property(lua_State *L) {
int newindex = (lua_gettop(L) == 3);
luaL_getmetatable(L, "ta_buffer");
lua_getmetatable(L, 1); // metatable can be either ta_buffer or ta_bufferp
- int is_buffer = lua_equal(L, -1, -2);
+ int is_buffer = lua_compare(L, -1, -2, LUA_OPEQ);
lua_pop(L, 2); // metatable, metatable
// If the key is a Scintilla function, return a callable closure.
@@ -1567,7 +1567,7 @@ static int lgui__newindex(lua_State *L) {
gtk_widget_hide(menubar);
#endif
} else if (strcmp(key, "size") == 0) {
- luaL_argcheck(L, lua_istable(L, 3) && lua_objlen(L, 3) == 2, 3,
+ luaL_argcheck(L, lua_istable(L, 3) && lua_rawlen(L, 3) == 2, 3,
"{ width, height } table expected");
int w = l_rawgetiint(L, 3, 1), h = l_rawgetiint(L, 3, 2);
if (w > 0 && h > 0) gtk_window_resize(GTK_WINDOW(window), w, h);
@@ -1667,7 +1667,7 @@ static int lbuffer_delete(lua_State *L) {
lL_globaldoccheck(L, 1);
sptr_t doc = SS(focused_view, SCI_GETDOCPOINTER, 0, 0);
lua_getfield(L, LUA_REGISTRYINDEX, "ta_buffers");
- if (lua_objlen(L, -1) == 1) new_buffer(0);
+ if (lua_rawlen(L, -1) == 1) new_buffer(0);
lL_gotodoc(L, focused_view, -1, TRUE);
delete_buffer(doc);
lL_event(L, "buffer_deleted", -1),
@@ -1678,7 +1678,7 @@ static int lbuffer_delete(lua_State *L) {
static int lbuffer_new(lua_State *L) {
new_buffer(0);
lua_getfield(L, LUA_REGISTRYINDEX, "ta_buffers");
- lua_rawgeti(L, -1, lua_objlen(L, -1));
+ lua_rawgeti(L, -1, lua_rawlen(L, -1));
return 1;
}
@@ -1757,11 +1757,11 @@ static int lgui_dialog(lua_State *L) {
GCDialogType type = gcocoadialog_type(luaL_checkstring(L, 1));
int i, j, k, n = lua_gettop(L) - 1, argc = n;
for (i = 2; i < n + 2; i++)
- if (lua_istable(L, i)) argc += lua_objlen(L, i) - 1;
+ if (lua_istable(L, i)) argc += lua_rawlen(L, i) - 1;
const char **argv = malloc((argc + 1) * sizeof(const char *));
for (i = 0, j = 2; j < n + 2; j++)
if (lua_istable(L, j)) {
- int len = lua_objlen(L, j);
+ int len = lua_rawlen(L, j);
for (k = 1; k <= len; k++) {
lua_rawgeti(L, j, k);
argv[i++] = luaL_checkstring(L, -1);
@@ -1782,13 +1782,13 @@ static int lgui_goto_view(lua_State *L) {
if (relative) {
l_pushview(L, focused_view), lua_gettable(L, -2);
n = lua_tointeger(L, -1) + n;
- if (n > lua_objlen(L, -2))
+ if (n > lua_rawlen(L, -2))
n = 1;
else if (n < 1)
- n = lua_objlen(L, -2);
+ n = lua_rawlen(L, -2);
lua_rawgeti(L, -2, n);
} else {
- luaL_argcheck(L, n > 0 && n <= lua_objlen(L, -1), 1,
+ luaL_argcheck(L, n > 0 && n <= lua_rawlen(L, -1), 1,
"no View exists at that index");
lua_rawgeti(L, -1, n);
}
@@ -1848,7 +1848,7 @@ static gboolean emit_timeout(gpointer data) {
lua_rawgeti(lua, LUA_REGISTRYINDEX, refs[0]); // function
int nargs = 0, repeat = TRUE;
while (refs[++nargs]) lua_rawgeti(lua, LUA_REGISTRYINDEX, refs[nargs]);
- int ok = (lua_pcall(lua, nargs - 1, 1, 0) == 0);
+ int ok = (lua_pcall(lua, nargs - 1, 1, 0) == LUA_OK);
if (!ok || !lua_toboolean(lua, -1)) {
while (--nargs >= 0) luaL_unref(lua, LUA_REGISTRYINDEX, refs[nargs]);
repeat = FALSE;