From 4e55213ae6b2795cd28d3a472b1f3765710cdb01 Mon Sep 17 00:00:00 2001 From: bsongis Date: Mon, 16 Mar 2015 20:10:16 +0100 Subject: [PATCH 1/4] #1471 - libio added to Lua. For tests, can be simplified and expanded --- radio/src/Makefile | 2 +- radio/src/lua/src/lauxlib.h | 11 ++- radio/src/lua/src/linit.c | 3 +- radio/src/lua/src/liolib.c | 145 ++++++++++++++++++++++++------------ radio/src/lua/src/lvm.c | 5 +- 5 files changed, 114 insertions(+), 52 deletions(-) diff --git a/radio/src/Makefile b/radio/src/Makefile index bcc830620..67372a5a8 100644 --- a/radio/src/Makefile +++ b/radio/src/Makefile @@ -937,7 +937,7 @@ ifeq ($(PCB), TARANIS) CPPSRC += lua_api.cpp LUASRC = lua/src/lapi.c lua/src/lcode.c lua/src/lctype.c lua/src/ldebug.c lua/src/ldo.c lua/src/ldump.c lua/src/lfunc.c lua/src/lgc.c lua/src/llex.c lua/src/lmem.c \ lua/src/lobject.c lua/src/lopcodes.c lua/src/lparser.c lua/src/lstate.c lua/src/lstring.c lua/src/ltable.c lua/src/lrotable.c lua/src/ltm.c lua/src/lundump.c lua/src/lvm.c lua/src/lzio.c \ - lua/src/lbaselib.c lua/src/linit.c lua/src/lmathlib.c lua/src/lbitlib.c lua/src/loadlib.c lua/src/lauxlib.c lua/src/ltablib.c lua/src/lcorolib.c + lua/src/lbaselib.c lua/src/linit.c lua/src/lmathlib.c lua/src/lbitlib.c lua/src/loadlib.c lua/src/lauxlib.c lua/src/ltablib.c lua/src/lcorolib.c lua/src/liolib.c SRC += $(LUASRC) LUADEP = lua_exports.inc ifeq ($(USE_BIN_ALLOCATOR), YES) diff --git a/radio/src/lua/src/lauxlib.h b/radio/src/lua/src/lauxlib.h index 6cc922e12..63fd22fc9 100644 --- a/radio/src/lua/src/lauxlib.h +++ b/radio/src/lua/src/lauxlib.h @@ -26,8 +26,10 @@ typedef struct luaL_Reg { extern const luaL_Reg baselib[]; extern const luaL_Reg mathlib[]; -extern const luaL_Reg opentxLib[]; extern const luaL_Reg bitlib[]; +extern const luaL_Reg iolib[]; + +extern const luaL_Reg opentxLib[]; extern const luaL_Reg lcdLib[]; extern const luaL_Reg modelLib[]; @@ -191,14 +193,17 @@ LUALIB_API char *(luaL_buffinitsize) (lua_State *L, luaL_Buffer *B, size_t sz); #define LUA_FILEHANDLE "FILE*" +#if defined(USE_FATFS) + #define FILE FIL +#endif typedef struct luaL_Stream { #if defined(USE_FATFS) - FIL *f; /* stream (NULL for incompletely created streams) */ + FIL f; #else FILE *f; /* stream (NULL for incompletely created streams) */ -#endif lua_CFunction closef; /* to close stream (NULL for closed streams) */ +#endif } luaL_Stream; /* }====================================================== */ diff --git a/radio/src/lua/src/linit.c b/radio/src/lua/src/linit.c index 23596a6dc..6e9113a6e 100644 --- a/radio/src/lua/src/linit.c +++ b/radio/src/lua/src/linit.c @@ -31,7 +31,7 @@ static const luaL_Reg loadedlibs[] = { // {LUA_LOADLIBNAME, luaopen_package}, // {LUA_COLIBNAME, luaopen_coroutine}, // {LUA_TABLIBNAME, luaopen_table}, - // {LUA_IOLIBNAME, luaopen_io}, + {LUA_IOLIBNAME, luaopen_io}, // {LUA_OSLIBNAME, luaopen_os}, // {LUA_STRLIBNAME, luaopen_string}, // {LUA_BITLIBNAME, luaopen_bit32}, @@ -45,6 +45,7 @@ const luaR_table lua_rotable[] = { {LUA_MATHLIBNAME, mathlib, mathlib_vals}, {LUA_BITLIBNAME, bitlib, NULL}, + {LUA_IOLIBNAME, iolib, NULL}, {"lcd", lcdLib, NULL}, {"model", modelLib, NULL}, {"__baselib", baselib, NULL}, diff --git a/radio/src/lua/src/liolib.c b/radio/src/lua/src/liolib.c index 8d61394da..12c056882 100644 --- a/radio/src/lua/src/liolib.c +++ b/radio/src/lua/src/liolib.c @@ -121,8 +121,9 @@ typedef luaL_Stream LStream; #define tolstream(L) ((LStream *)luaL_checkudata(L, 1, LUA_FILEHANDLE)) -#define isclosed(p) ((p)->closef == NULL) +#if !defined(USE_FATFS) +#define isclosed(p) ((p)->closef == NULL) static int io_type (lua_State *L) { LStream *p; @@ -147,13 +148,18 @@ static int f_tostring (lua_State *L) { return 1; } +#endif static FILE *tofile (lua_State *L) { LStream *p = tolstream(L); +#if defined(USE_FATFS) + return &p->f; +#else if (isclosed(p)) luaL_error(L, "attempt to use a closed file"); lua_assert(p->f); return p->f; +#endif } @@ -164,36 +170,48 @@ static FILE *tofile (lua_State *L) { */ static LStream *newprefile (lua_State *L) { LStream *p = (LStream *)lua_newuserdata(L, sizeof(LStream)); +#if !defined(USE_FATFS) p->closef = NULL; /* mark file handle as 'closed' */ +#endif luaL_setmetatable(L, LUA_FILEHANDLE); return p; } - +#if !defined(USE_FATFS) static int aux_close (lua_State *L) { +#if !defined(USE_FATFS) LStream *p = tolstream(L); lua_CFunction cf = p->closef; p->closef = NULL; /* mark stream as closed */ return (*cf)(L); /* close it */ +#else + return 0; +#endif } - +#endif static int io_close (lua_State *L) { +#if defined(USE_FATFS) + f_close(tofile(L)); + return 0; +#else if (lua_isnone(L, 1)) /* no argument? */ lua_getfield(L, LUA_REGISTRYINDEX, IO_OUTPUT); /* use standard output */ tofile(L); /* make sure argument is an open stream */ return aux_close(L); +#endif } - +#if !defined(USE_FATFS) static int f_gc (lua_State *L) { +#if !defined(USE_FATFS) LStream *p = tolstream(L); if (!isclosed(p) && p->f != NULL) aux_close(L); /* ignore closed and incompletely open files */ +#endif return 0; } - /* ** function to close regular files */ @@ -202,34 +220,49 @@ static int io_fclose (lua_State *L) { int res = fclose(p->f); return luaL_fileresult(L, (res == 0), NULL); } - +#endif static LStream *newfile (lua_State *L) { LStream *p = newprefile(L); +#if !defined(USE_FATFS) p->f = NULL; p->closef = &io_fclose; +#endif return p; } - +#if !defined(USE_FATFS) static void opencheck (lua_State *L, const char *fname, const char *mode) { LStream *p = newfile(L); p->f = fopen(fname, mode); if (p->f == NULL) luaL_error(L, "cannot open file " LUA_QS " (%s)", fname, strerror(errno)); } - +#endif static int io_open (lua_State *L) { const char *filename = luaL_checkstring(L, 1); - const char *mode = luaL_optstring(L, 2, "r"); + const char *md = luaL_optstring(L, 2, "r"); LStream *p = newfile(L); - const char *md = mode; /* to traverse/check mode */ - luaL_argcheck(L, lua_checkmode(md), 2, "invalid mode"); - p->f = fopen(filename, mode); +#if defined(USE_FATFS) + BYTE mode; + if (!md || *md == 'r') + mode = FA_READ; + else if (*md == 'w') + mode = FA_WRITE; + else + luaL_argerror(L, (2), ("invalid mode")); + FRESULT result = f_open(&p->f, filename, mode); + return result == FR_OK ? 1 : 0; +#else + const char *mode = md; /* to traverse/check mode */ + luaL_argcheck(L, lua_checkmode(mode), 2, "invalid mode"); + p->f = fopen(filename, md); return (p->f == NULL) ? luaL_fileresult(L, 0, filename) : 1; +#endif } +#if !defined(USE_FATFS) /* ** function to close 'popen' files @@ -239,7 +272,6 @@ static int io_pclose (lua_State *L) { return luaL_execresult(L, lua_pclose(L, p->f)); } - static int io_popen (lua_State *L) { const char *filename = luaL_checkstring(L, 1); const char *mode = luaL_optstring(L, 2, "r"); @@ -336,7 +368,6 @@ static int io_lines (lua_State *L) { return 1; } - /* ** {====================================================== ** READ @@ -356,7 +387,6 @@ static int read_number (lua_State *L, FILE *f) { } } - static int test_eof (lua_State *L, FILE *f) { int c = lua_getc(f); ungetc(c, f); @@ -386,7 +416,6 @@ static int read_line (lua_State *L, FILE *f, int chop) { } } - #define MAX_SIZE_T (~(size_t)0) static void read_all (lua_State *L, FILE *f) { @@ -403,21 +432,21 @@ static void read_all (lua_State *L, FILE *f) { } luaL_pushresult(&b); /* close buffer */ } - +#endif static int read_chars (lua_State *L, FILE *f, size_t n) { - size_t nr; /* number of chars actually read */ + unsigned int nr; /* number of chars actually read */ char *p; luaL_Buffer b; luaL_buffinit(L, &b); p = luaL_prepbuffsize(&b, n); /* prepare buffer to read whole block */ - nr = fread(p, sizeof(char), n, f); /* try to read 'n' chars */ + FRESULT result = f_read(f, p, n, &nr); /* try to read 'n' chars */ luaL_addsize(&b, nr); luaL_pushresult(&b); /* close buffer */ - return (nr > 0); /* true iff read something */ + return (result == FR_OK && nr > 0); /* true iff read something */ } - +#if !defined(USE_FATFS) static int g_read (lua_State *L, FILE *f, int first) { int nargs = lua_gettop(L) - 1; int success; @@ -477,7 +506,18 @@ static int f_read (lua_State *L) { return g_read(L, tofile(L), 2); } +#else +static int io_read (lua_State *L) { + LStream *p = tolstream(L); + size_t l = (size_t)lua_tointeger(L, 2); + read_chars(L, &p->f, l); + return 1; +} + +#endif + +#if !defined(USE_FATFS) static int io_readline (lua_State *L) { LStream *p = (LStream *)lua_touserdata(L, lua_upvalueindex(1)); int i; @@ -507,6 +547,7 @@ static int io_readline (lua_State *L) { /* }====================================================== */ +#endif static int g_write (lua_State *L, FILE *f, int arg) { int nargs = lua_gettop(L) - arg; @@ -515,31 +556,38 @@ static int g_write (lua_State *L, FILE *f, int arg) { if (lua_type(L, arg) == LUA_TNUMBER) { /* optimization: could be done exactly as for strings */ status = status && - fprintf(f, LUA_NUMBER_FMT, lua_tonumber(L, arg)) > 0; + f_printf(f, LUA_NUMBER_FMT, lua_tonumber(L, arg)) > 0; } else { size_t l; + UINT count; const char *s = luaL_checklstring(L, arg, &l); - status = status && (fwrite(s, sizeof(char), l, f) == l); + status = status && (f_write(f, s, l, &count) == FR_OK && count == l); } } if (status) return 1; /* file handle already on stack top */ else return luaL_fileresult(L, status, NULL); } - +#if !defined(USE_FATFS) static int io_write (lua_State *L) { return g_write(L, getiofile(L, IO_OUTPUT), 1); } - static int f_write (lua_State *L) { FILE *f = tofile(L); lua_pushvalue(L, 1); /* push file at the stack top (to be returned) */ return g_write(L, f, 2); } +#else +static int io_write (lua_State *L) { + FILE *f = tofile(L); + lua_pushvalue(L, 1); /* push file at the stack top (to be returned) */ + return g_write(L, f, 2); +} +#endif - +#if !defined(USE_FATFS) static int f_seek (lua_State *L) { static const int mode[] = {SEEK_SET, SEEK_CUR, SEEK_END}; static const char *const modenames[] = {"set", "cur", "end", NULL}; @@ -570,7 +618,7 @@ static int f_setvbuf (lua_State *L) { } - +#if !defined(USE_FATFS) static int io_flush (lua_State *L) { return luaL_fileresult(L, fflush(getiofile(L, IO_OUTPUT)) == 0, NULL); } @@ -579,26 +627,29 @@ static int io_flush (lua_State *L) { static int f_flush (lua_State *L) { return luaL_fileresult(L, fflush(tofile(L)) == 0, NULL); } +#endif +#endif /* ** functions for 'io' library */ -static const luaL_Reg iolib[] = { +const luaL_Reg iolib[] = { {"close", io_close}, - {"flush", io_flush}, - {"input", io_input}, - {"lines", io_lines}, + // {"flush", io_flush}, + // {"input", io_input}, + // {"lines", io_lines}, {"open", io_open}, - {"output", io_output}, - {"popen", io_popen}, + // {"output", io_output}, + // {"popen", io_popen}, {"read", io_read}, - {"tmpfile", io_tmpfile}, - {"type", io_type}, + // {"tmpfile", io_tmpfile}, + // {"type", io_type}, {"write", io_write}, {NULL, NULL} }; +#if !defined(USE_FATFS) /* ** methods for file handles @@ -607,7 +658,7 @@ static const luaL_Reg flib[] = { {"close", io_close}, {"flush", f_flush}, {"lines", f_lines}, - {"read", f_read}, + {"read", io_read}, {"seek", f_seek}, {"setvbuf", f_setvbuf}, {"write", f_write}, @@ -616,16 +667,17 @@ static const luaL_Reg flib[] = { {NULL, NULL} }; +#endif static void createmeta (lua_State *L) { luaL_newmetatable(L, LUA_FILEHANDLE); /* create metatable for file handles */ lua_pushvalue(L, -1); /* push metatable */ - lua_setfield(L, -2, "__index"); /* metatable.__index = metatable */ - luaL_setfuncs(L, flib, 0); /* add file methods to new metatable */ + // lua_setfield(L, -2, "__index"); /* metatable.__index = metatable */ + // luaL_setfuncs(L, flib, 0); /* add file methods to new metatable */ lua_pop(L, 1); /* pop new metatable */ } - +#if !defined(USE_FATFS) /* ** function to (not) close the standard files stdin, stdout, and stderr */ @@ -650,14 +702,15 @@ static void createstdfile (lua_State *L, FILE *f, const char *k, lua_setfield(L, -2, fname); /* add file to module */ } +#endif LUAMOD_API int luaopen_io (lua_State *L) { - luaL_newlib(L, iolib); /* new module */ - createmeta(L); + // luaL_newlib(L, iolib); /* new module */ + createmeta(L); /* create (and set) default files */ - createstdfile(L, stdin, IO_INPUT, "stdin"); - createstdfile(L, stdout, IO_OUTPUT, "stdout"); - createstdfile(L, stderr, NULL, "stderr"); - return 1; + // createstdfile(L, stdin, IO_INPUT, "stdin"); + // createstdfile(L, stdout, IO_OUTPUT, "stdout"); + // createstdfile(L, stderr, NULL, "stderr"); + // return 1; + return 0; } - diff --git a/radio/src/lua/src/lvm.c b/radio/src/lua/src/lvm.c index 6b049bcf1..47b0af6cf 100644 --- a/radio/src/lua/src/lvm.c +++ b/radio/src/lua/src/lvm.c @@ -119,6 +119,7 @@ void luaV_gettable (lua_State *L, const TValue *t, TValue *key, StkId val) { int loop; if (ttisrotable(t)) { setnilvalue(val); + TRACE("luaV_gettable(key=%s)", key); if (ttisstring(key)) { char keyname[LUA_MAX_ROTABLE_NAME + 1]; lu_byte keytype; @@ -143,8 +144,10 @@ void luaV_gettable (lua_State *L, const TValue *t, TValue *key, StkId val) { } /* else will try the tag method */ } - else if (ttisnil(tm = luaT_gettmbyobj(L, t, TM_INDEX))) + else if (ttisnil(tm = luaT_gettmbyobj(L, t, TM_INDEX))) { + TRACE("ERREUR ICI"); luaG_typeerror(L, t, "index"); + } if (ttisfunction(tm) || ttislightfunction(tm)) { callTM(L, tm, t, key, val, 1); return; From 0b7a85daa7c556d7df0a8fb03fc74419bb0da514 Mon Sep 17 00:00:00 2001 From: bsongis Date: Tue, 24 Mar 2015 18:58:58 +0100 Subject: [PATCH 2/4] #1471 - Lua moved to thirdparty directory - io.seek added --- .../firmwares/opentx/simulator/CMakeLists.txt | 1 + .../opentx/simulator/opentxsimulator.cpp | 58 +++++++++--------- radio/src/Makefile | 9 +-- radio/src/{lua => thirdparty/Lua}/Makefile | 0 radio/src/{lua => thirdparty/Lua}/README | 0 .../{lua => thirdparty/Lua}/doc/contents.html | 0 .../src/{lua => thirdparty/Lua}/doc/logo.gif | Bin radio/src/{lua => thirdparty/Lua}/doc/lua.1 | 0 radio/src/{lua => thirdparty/Lua}/doc/lua.css | 0 radio/src/{lua => thirdparty/Lua}/doc/luac.1 | 0 .../{lua => thirdparty/Lua}/doc/manual.css | 0 .../{lua => thirdparty/Lua}/doc/manual.html | 0 .../Lua}/doc/osi-certified-72x60.png | Bin .../{lua => thirdparty/Lua}/doc/readme.html | 0 .../src/{lua => thirdparty/Lua}/src/Makefile | 0 radio/src/{lua => thirdparty/Lua}/src/lapi.c | 0 radio/src/{lua => thirdparty/Lua}/src/lapi.h | 0 .../src/{lua => thirdparty/Lua}/src/lauxlib.c | 0 .../src/{lua => thirdparty/Lua}/src/lauxlib.h | 0 .../{lua => thirdparty/Lua}/src/lbaselib.c | 0 .../src/{lua => thirdparty/Lua}/src/lbitlib.c | 0 radio/src/{lua => thirdparty/Lua}/src/lcode.c | 0 radio/src/{lua => thirdparty/Lua}/src/lcode.h | 0 .../{lua => thirdparty/Lua}/src/lcorolib.c | 0 .../src/{lua => thirdparty/Lua}/src/lctype.c | 0 .../src/{lua => thirdparty/Lua}/src/lctype.h | 0 .../src/{lua => thirdparty/Lua}/src/ldblib.c | 0 .../src/{lua => thirdparty/Lua}/src/ldebug.c | 0 .../src/{lua => thirdparty/Lua}/src/ldebug.h | 0 radio/src/{lua => thirdparty/Lua}/src/ldo.c | 0 radio/src/{lua => thirdparty/Lua}/src/ldo.h | 0 radio/src/{lua => thirdparty/Lua}/src/ldump.c | 0 radio/src/{lua => thirdparty/Lua}/src/lfunc.c | 0 radio/src/{lua => thirdparty/Lua}/src/lfunc.h | 0 radio/src/{lua => thirdparty/Lua}/src/lgc.c | 0 radio/src/{lua => thirdparty/Lua}/src/lgc.h | 0 radio/src/{lua => thirdparty/Lua}/src/linit.c | 0 .../src/{lua => thirdparty/Lua}/src/liolib.c | 12 +++- radio/src/{lua => thirdparty/Lua}/src/llex.c | 0 radio/src/{lua => thirdparty/Lua}/src/llex.h | 0 .../src/{lua => thirdparty/Lua}/src/llimits.h | 0 .../{lua => thirdparty/Lua}/src/lmathlib.c | 0 radio/src/{lua => thirdparty/Lua}/src/lmem.c | 0 radio/src/{lua => thirdparty/Lua}/src/lmem.h | 0 .../src/{lua => thirdparty/Lua}/src/loadlib.c | 0 .../src/{lua => thirdparty/Lua}/src/lobject.c | 0 .../src/{lua => thirdparty/Lua}/src/lobject.h | 0 .../{lua => thirdparty/Lua}/src/lopcodes.c | 0 .../{lua => thirdparty/Lua}/src/lopcodes.h | 0 .../src/{lua => thirdparty/Lua}/src/loslib.c | 0 .../src/{lua => thirdparty/Lua}/src/lparser.c | 0 .../src/{lua => thirdparty/Lua}/src/lparser.h | 0 .../{lua => thirdparty/Lua}/src/lrotable.c | 0 .../{lua => thirdparty/Lua}/src/lrotable.h | 0 .../src/{lua => thirdparty/Lua}/src/lstate.c | 0 .../src/{lua => thirdparty/Lua}/src/lstate.h | 0 .../src/{lua => thirdparty/Lua}/src/lstring.c | 0 .../src/{lua => thirdparty/Lua}/src/lstring.h | 0 .../src/{lua => thirdparty/Lua}/src/lstrlib.c | 0 .../src/{lua => thirdparty/Lua}/src/ltable.c | 0 .../src/{lua => thirdparty/Lua}/src/ltable.h | 0 .../src/{lua => thirdparty/Lua}/src/ltablib.c | 0 radio/src/{lua => thirdparty/Lua}/src/ltm.c | 0 radio/src/{lua => thirdparty/Lua}/src/ltm.h | 0 radio/src/{lua => thirdparty/Lua}/src/lua.c | 0 radio/src/{lua => thirdparty/Lua}/src/lua.h | 0 radio/src/{lua => thirdparty/Lua}/src/lua.hpp | 0 radio/src/{lua => thirdparty/Lua}/src/luac.c | 0 .../src/{lua => thirdparty/Lua}/src/luaconf.h | 0 .../src/{lua => thirdparty/Lua}/src/lualib.h | 0 .../src/{lua => thirdparty/Lua}/src/lundump.c | 0 .../src/{lua => thirdparty/Lua}/src/lundump.h | 0 radio/src/{lua => thirdparty/Lua}/src/lvm.c | 0 radio/src/{lua => thirdparty/Lua}/src/lvm.h | 0 radio/src/{lua => thirdparty/Lua}/src/lzio.c | 0 radio/src/{lua => thirdparty/Lua}/src/lzio.h | 0 76 files changed, 45 insertions(+), 35 deletions(-) rename radio/src/{lua => thirdparty/Lua}/Makefile (100%) rename radio/src/{lua => thirdparty/Lua}/README (100%) rename radio/src/{lua => thirdparty/Lua}/doc/contents.html (100%) rename radio/src/{lua => thirdparty/Lua}/doc/logo.gif (100%) rename radio/src/{lua => thirdparty/Lua}/doc/lua.1 (100%) rename radio/src/{lua => thirdparty/Lua}/doc/lua.css (100%) rename radio/src/{lua => thirdparty/Lua}/doc/luac.1 (100%) rename radio/src/{lua => thirdparty/Lua}/doc/manual.css (100%) rename radio/src/{lua => thirdparty/Lua}/doc/manual.html (100%) rename radio/src/{lua => thirdparty/Lua}/doc/osi-certified-72x60.png (100%) rename radio/src/{lua => thirdparty/Lua}/doc/readme.html (100%) rename radio/src/{lua => thirdparty/Lua}/src/Makefile (100%) rename radio/src/{lua => thirdparty/Lua}/src/lapi.c (100%) rename radio/src/{lua => thirdparty/Lua}/src/lapi.h (100%) rename radio/src/{lua => thirdparty/Lua}/src/lauxlib.c (100%) rename radio/src/{lua => thirdparty/Lua}/src/lauxlib.h (100%) rename radio/src/{lua => thirdparty/Lua}/src/lbaselib.c (100%) rename radio/src/{lua => thirdparty/Lua}/src/lbitlib.c (100%) rename radio/src/{lua => thirdparty/Lua}/src/lcode.c (100%) rename radio/src/{lua => thirdparty/Lua}/src/lcode.h (100%) rename radio/src/{lua => thirdparty/Lua}/src/lcorolib.c (100%) rename radio/src/{lua => thirdparty/Lua}/src/lctype.c (100%) rename radio/src/{lua => thirdparty/Lua}/src/lctype.h (100%) rename radio/src/{lua => thirdparty/Lua}/src/ldblib.c (100%) rename radio/src/{lua => thirdparty/Lua}/src/ldebug.c (100%) rename radio/src/{lua => thirdparty/Lua}/src/ldebug.h (100%) rename radio/src/{lua => thirdparty/Lua}/src/ldo.c (100%) rename radio/src/{lua => thirdparty/Lua}/src/ldo.h (100%) rename radio/src/{lua => thirdparty/Lua}/src/ldump.c (100%) rename radio/src/{lua => thirdparty/Lua}/src/lfunc.c (100%) rename radio/src/{lua => thirdparty/Lua}/src/lfunc.h (100%) rename radio/src/{lua => thirdparty/Lua}/src/lgc.c (100%) rename radio/src/{lua => thirdparty/Lua}/src/lgc.h (100%) rename radio/src/{lua => thirdparty/Lua}/src/linit.c (100%) rename radio/src/{lua => thirdparty/Lua}/src/liolib.c (98%) rename radio/src/{lua => thirdparty/Lua}/src/llex.c (100%) rename radio/src/{lua => thirdparty/Lua}/src/llex.h (100%) rename radio/src/{lua => thirdparty/Lua}/src/llimits.h (100%) rename radio/src/{lua => thirdparty/Lua}/src/lmathlib.c (100%) rename radio/src/{lua => thirdparty/Lua}/src/lmem.c (100%) rename radio/src/{lua => thirdparty/Lua}/src/lmem.h (100%) rename radio/src/{lua => thirdparty/Lua}/src/loadlib.c (100%) rename radio/src/{lua => thirdparty/Lua}/src/lobject.c (100%) rename radio/src/{lua => thirdparty/Lua}/src/lobject.h (100%) rename radio/src/{lua => thirdparty/Lua}/src/lopcodes.c (100%) rename radio/src/{lua => thirdparty/Lua}/src/lopcodes.h (100%) rename radio/src/{lua => thirdparty/Lua}/src/loslib.c (100%) rename radio/src/{lua => thirdparty/Lua}/src/lparser.c (100%) rename radio/src/{lua => thirdparty/Lua}/src/lparser.h (100%) rename radio/src/{lua => thirdparty/Lua}/src/lrotable.c (100%) rename radio/src/{lua => thirdparty/Lua}/src/lrotable.h (100%) rename radio/src/{lua => thirdparty/Lua}/src/lstate.c (100%) rename radio/src/{lua => thirdparty/Lua}/src/lstate.h (100%) rename radio/src/{lua => thirdparty/Lua}/src/lstring.c (100%) rename radio/src/{lua => thirdparty/Lua}/src/lstring.h (100%) rename radio/src/{lua => thirdparty/Lua}/src/lstrlib.c (100%) rename radio/src/{lua => thirdparty/Lua}/src/ltable.c (100%) rename radio/src/{lua => thirdparty/Lua}/src/ltable.h (100%) rename radio/src/{lua => thirdparty/Lua}/src/ltablib.c (100%) rename radio/src/{lua => thirdparty/Lua}/src/ltm.c (100%) rename radio/src/{lua => thirdparty/Lua}/src/ltm.h (100%) rename radio/src/{lua => thirdparty/Lua}/src/lua.c (100%) rename radio/src/{lua => thirdparty/Lua}/src/lua.h (100%) rename radio/src/{lua => thirdparty/Lua}/src/lua.hpp (100%) rename radio/src/{lua => thirdparty/Lua}/src/luac.c (100%) rename radio/src/{lua => thirdparty/Lua}/src/luaconf.h (100%) rename radio/src/{lua => thirdparty/Lua}/src/lualib.h (100%) rename radio/src/{lua => thirdparty/Lua}/src/lundump.c (100%) rename radio/src/{lua => thirdparty/Lua}/src/lundump.h (100%) rename radio/src/{lua => thirdparty/Lua}/src/lvm.c (100%) rename radio/src/{lua => thirdparty/Lua}/src/lvm.h (100%) rename radio/src/{lua => thirdparty/Lua}/src/lzio.c (100%) rename radio/src/{lua => thirdparty/Lua}/src/lzio.h (100%) diff --git a/companion/src/firmwares/opentx/simulator/CMakeLists.txt b/companion/src/firmwares/opentx/simulator/CMakeLists.txt index a6992f5a7..2505f3bef 100644 --- a/companion/src/firmwares/opentx/simulator/CMakeLists.txt +++ b/companion/src/firmwares/opentx/simulator/CMakeLists.txt @@ -38,6 +38,7 @@ include_directories( ${RADIO_SRC_DIRECTORY}/thirdparty/FatFs ${RADIO_SRC_DIRECTORY}/thirdparty/FatFs/option ${RADIO_SRC_DIRECTORY}/thirdparty/CoOS + ${RADIO_SRC_DIRECTORY}/thirdparty/Lua/src ) if(DEFINED TRANSLATIONS) diff --git a/companion/src/firmwares/opentx/simulator/opentxsimulator.cpp b/companion/src/firmwares/opentx/simulator/opentxsimulator.cpp index cbe475ecc..46c977731 100644 --- a/companion/src/firmwares/opentx/simulator/opentxsimulator.cpp +++ b/companion/src/firmwares/opentx/simulator/opentxsimulator.cpp @@ -269,35 +269,35 @@ namespace NAMESPACE { #if defined(LUA) #include "radio/src/lua_api.cpp" -#include "radio/src/lua/src/lapi.c" -#include "radio/src/lua/src/lcode.c" -#include "radio/src/lua/src/lctype.c" -#include "radio/src/lua/src/ldebug.c" -#include "radio/src/lua/src/ldo.c" -#include "radio/src/lua/src/ldump.c" -#include "radio/src/lua/src/lfunc.c" -#include "radio/src/lua/src/lgc.c" -#include "radio/src/lua/src/llex.c" -#include "radio/src/lua/src/lmem.c" -#include "radio/src/lua/src/lobject.c" -#include "radio/src/lua/src/lopcodes.c" -#include "radio/src/lua/src/lparser.c" -#include "radio/src/lua/src/lstate.c" -#include "radio/src/lua/src/lstring.c" -#include "radio/src/lua/src/ltable.c" -#include "radio/src/lua/src/lrotable.c" -#include "radio/src/lua/src/ltm.c" -#include "radio/src/lua/src/lundump.c" -#include "radio/src/lua/src/lvm.c" -#include "radio/src/lua/src/lzio.c" -#include "radio/src/lua/src/lbaselib.c" -#include "radio/src/lua/src/linit.c" -#include "radio/src/lua/src/lmathlib.c" -#include "radio/src/lua/src/lbitlib.c" -#include "radio/src/lua/src/loadlib.c" -#include "radio/src/lua/src/lauxlib.c" -#include "radio/src/lua/src/ltablib.c" -#include "radio/src/lua/src/lcorolib.c" +#include "radio/src/thirdparty/Lua/src/lapi.c" +#include "radio/src/thirdparty/Lua/src/lcode.c" +#include "radio/src/thirdparty/Lua/src/lctype.c" +#include "radio/src/thirdparty/Lua/src/ldebug.c" +#include "radio/src/thirdparty/Lua/src/ldo.c" +#include "radio/src/thirdparty/Lua/src/ldump.c" +#include "radio/src/thirdparty/Lua/src/lfunc.c" +#include "radio/src/thirdparty/Lua/src/lgc.c" +#include "radio/src/thirdparty/Lua/src/llex.c" +#include "radio/src/thirdparty/Lua/src/lmem.c" +#include "radio/src/thirdparty/Lua/src/lobject.c" +#include "radio/src/thirdparty/Lua/src/lopcodes.c" +#include "radio/src/thirdparty/Lua/src/lparser.c" +#include "radio/src/thirdparty/Lua/src/lstate.c" +#include "radio/src/thirdparty/Lua/src/lstring.c" +#include "radio/src/thirdparty/Lua/src/ltable.c" +#include "radio/src/thirdparty/Lua/src/lrotable.c" +#include "radio/src/thirdparty/Lua/src/ltm.c" +#include "radio/src/thirdparty/Lua/src/lundump.c" +#include "radio/src/thirdparty/Lua/src/lvm.c" +#include "radio/src/thirdparty/Lua/src/lzio.c" +#include "radio/src/thirdparty/Lua/src/lbaselib.c" +#include "radio/src/thirdparty/Lua/src/linit.c" +#include "radio/src/thirdparty/Lua/src/lmathlib.c" +#include "radio/src/thirdparty/Lua/src/lbitlib.c" +#include "radio/src/thirdparty/Lua/src/loadlib.c" +#include "radio/src/thirdparty/Lua/src/lauxlib.c" +#include "radio/src/thirdparty/Lua/src/ltablib.c" +#include "radio/src/thirdparty/Lua/src/lcorolib.c" #endif int16_t g_anas[NUM_STICKS+NUM_POTS]; diff --git a/radio/src/Makefile b/radio/src/Makefile index 67372a5a8..57a6085c1 100644 --- a/radio/src/Makefile +++ b/radio/src/Makefile @@ -373,6 +373,7 @@ VERSION = 2.0.99 THIRDPARTY = thirdparty COOSDIR = $(THIRDPARTY)/CoOS FATFSDIR = $(THIRDPARTY)/FatFs +LUADIR = $(THIRDPARTY)/Lua/src SRC = CPPSRC = @@ -933,11 +934,11 @@ ifeq ($(PCB), TARANIS) GUIMODELSRC += gui/$(GUIDIRECTORY)/menu_model_custom_scripts.cpp endif CPPDEFS += -DLUA - INCDIRS += lua/src + INCDIRS += $(LUADIR) CPPSRC += lua_api.cpp - LUASRC = lua/src/lapi.c lua/src/lcode.c lua/src/lctype.c lua/src/ldebug.c lua/src/ldo.c lua/src/ldump.c lua/src/lfunc.c lua/src/lgc.c lua/src/llex.c lua/src/lmem.c \ - lua/src/lobject.c lua/src/lopcodes.c lua/src/lparser.c lua/src/lstate.c lua/src/lstring.c lua/src/ltable.c lua/src/lrotable.c lua/src/ltm.c lua/src/lundump.c lua/src/lvm.c lua/src/lzio.c \ - lua/src/lbaselib.c lua/src/linit.c lua/src/lmathlib.c lua/src/lbitlib.c lua/src/loadlib.c lua/src/lauxlib.c lua/src/ltablib.c lua/src/lcorolib.c lua/src/liolib.c + LUASRC = $(LUADIR)/lapi.c $(LUADIR)/lcode.c $(LUADIR)/lctype.c $(LUADIR)/ldebug.c $(LUADIR)/ldo.c $(LUADIR)/ldump.c $(LUADIR)/lfunc.c $(LUADIR)/lgc.c $(LUADIR)/llex.c $(LUADIR)/lmem.c \ + $(LUADIR)/lobject.c $(LUADIR)/lopcodes.c $(LUADIR)/lparser.c $(LUADIR)/lstate.c $(LUADIR)/lstring.c $(LUADIR)/ltable.c $(LUADIR)/lrotable.c $(LUADIR)/ltm.c $(LUADIR)/lundump.c $(LUADIR)/lvm.c $(LUADIR)/lzio.c \ + $(LUADIR)/lbaselib.c $(LUADIR)/linit.c $(LUADIR)/lmathlib.c $(LUADIR)/lbitlib.c $(LUADIR)/loadlib.c $(LUADIR)/lauxlib.c $(LUADIR)/ltablib.c $(LUADIR)/lcorolib.c $(LUADIR)/liolib.c SRC += $(LUASRC) LUADEP = lua_exports.inc ifeq ($(USE_BIN_ALLOCATOR), YES) diff --git a/radio/src/lua/Makefile b/radio/src/thirdparty/Lua/Makefile similarity index 100% rename from radio/src/lua/Makefile rename to radio/src/thirdparty/Lua/Makefile diff --git a/radio/src/lua/README b/radio/src/thirdparty/Lua/README similarity index 100% rename from radio/src/lua/README rename to radio/src/thirdparty/Lua/README diff --git a/radio/src/lua/doc/contents.html b/radio/src/thirdparty/Lua/doc/contents.html similarity index 100% rename from radio/src/lua/doc/contents.html rename to radio/src/thirdparty/Lua/doc/contents.html diff --git a/radio/src/lua/doc/logo.gif b/radio/src/thirdparty/Lua/doc/logo.gif similarity index 100% rename from radio/src/lua/doc/logo.gif rename to radio/src/thirdparty/Lua/doc/logo.gif diff --git a/radio/src/lua/doc/lua.1 b/radio/src/thirdparty/Lua/doc/lua.1 similarity index 100% rename from radio/src/lua/doc/lua.1 rename to radio/src/thirdparty/Lua/doc/lua.1 diff --git a/radio/src/lua/doc/lua.css b/radio/src/thirdparty/Lua/doc/lua.css similarity index 100% rename from radio/src/lua/doc/lua.css rename to radio/src/thirdparty/Lua/doc/lua.css diff --git a/radio/src/lua/doc/luac.1 b/radio/src/thirdparty/Lua/doc/luac.1 similarity index 100% rename from radio/src/lua/doc/luac.1 rename to radio/src/thirdparty/Lua/doc/luac.1 diff --git a/radio/src/lua/doc/manual.css b/radio/src/thirdparty/Lua/doc/manual.css similarity index 100% rename from radio/src/lua/doc/manual.css rename to radio/src/thirdparty/Lua/doc/manual.css diff --git a/radio/src/lua/doc/manual.html b/radio/src/thirdparty/Lua/doc/manual.html similarity index 100% rename from radio/src/lua/doc/manual.html rename to radio/src/thirdparty/Lua/doc/manual.html diff --git a/radio/src/lua/doc/osi-certified-72x60.png b/radio/src/thirdparty/Lua/doc/osi-certified-72x60.png similarity index 100% rename from radio/src/lua/doc/osi-certified-72x60.png rename to radio/src/thirdparty/Lua/doc/osi-certified-72x60.png diff --git a/radio/src/lua/doc/readme.html b/radio/src/thirdparty/Lua/doc/readme.html similarity index 100% rename from radio/src/lua/doc/readme.html rename to radio/src/thirdparty/Lua/doc/readme.html diff --git a/radio/src/lua/src/Makefile b/radio/src/thirdparty/Lua/src/Makefile similarity index 100% rename from radio/src/lua/src/Makefile rename to radio/src/thirdparty/Lua/src/Makefile diff --git a/radio/src/lua/src/lapi.c b/radio/src/thirdparty/Lua/src/lapi.c similarity index 100% rename from radio/src/lua/src/lapi.c rename to radio/src/thirdparty/Lua/src/lapi.c diff --git a/radio/src/lua/src/lapi.h b/radio/src/thirdparty/Lua/src/lapi.h similarity index 100% rename from radio/src/lua/src/lapi.h rename to radio/src/thirdparty/Lua/src/lapi.h diff --git a/radio/src/lua/src/lauxlib.c b/radio/src/thirdparty/Lua/src/lauxlib.c similarity index 100% rename from radio/src/lua/src/lauxlib.c rename to radio/src/thirdparty/Lua/src/lauxlib.c diff --git a/radio/src/lua/src/lauxlib.h b/radio/src/thirdparty/Lua/src/lauxlib.h similarity index 100% rename from radio/src/lua/src/lauxlib.h rename to radio/src/thirdparty/Lua/src/lauxlib.h diff --git a/radio/src/lua/src/lbaselib.c b/radio/src/thirdparty/Lua/src/lbaselib.c similarity index 100% rename from radio/src/lua/src/lbaselib.c rename to radio/src/thirdparty/Lua/src/lbaselib.c diff --git a/radio/src/lua/src/lbitlib.c b/radio/src/thirdparty/Lua/src/lbitlib.c similarity index 100% rename from radio/src/lua/src/lbitlib.c rename to radio/src/thirdparty/Lua/src/lbitlib.c diff --git a/radio/src/lua/src/lcode.c b/radio/src/thirdparty/Lua/src/lcode.c similarity index 100% rename from radio/src/lua/src/lcode.c rename to radio/src/thirdparty/Lua/src/lcode.c diff --git a/radio/src/lua/src/lcode.h b/radio/src/thirdparty/Lua/src/lcode.h similarity index 100% rename from radio/src/lua/src/lcode.h rename to radio/src/thirdparty/Lua/src/lcode.h diff --git a/radio/src/lua/src/lcorolib.c b/radio/src/thirdparty/Lua/src/lcorolib.c similarity index 100% rename from radio/src/lua/src/lcorolib.c rename to radio/src/thirdparty/Lua/src/lcorolib.c diff --git a/radio/src/lua/src/lctype.c b/radio/src/thirdparty/Lua/src/lctype.c similarity index 100% rename from radio/src/lua/src/lctype.c rename to radio/src/thirdparty/Lua/src/lctype.c diff --git a/radio/src/lua/src/lctype.h b/radio/src/thirdparty/Lua/src/lctype.h similarity index 100% rename from radio/src/lua/src/lctype.h rename to radio/src/thirdparty/Lua/src/lctype.h diff --git a/radio/src/lua/src/ldblib.c b/radio/src/thirdparty/Lua/src/ldblib.c similarity index 100% rename from radio/src/lua/src/ldblib.c rename to radio/src/thirdparty/Lua/src/ldblib.c diff --git a/radio/src/lua/src/ldebug.c b/radio/src/thirdparty/Lua/src/ldebug.c similarity index 100% rename from radio/src/lua/src/ldebug.c rename to radio/src/thirdparty/Lua/src/ldebug.c diff --git a/radio/src/lua/src/ldebug.h b/radio/src/thirdparty/Lua/src/ldebug.h similarity index 100% rename from radio/src/lua/src/ldebug.h rename to radio/src/thirdparty/Lua/src/ldebug.h diff --git a/radio/src/lua/src/ldo.c b/radio/src/thirdparty/Lua/src/ldo.c similarity index 100% rename from radio/src/lua/src/ldo.c rename to radio/src/thirdparty/Lua/src/ldo.c diff --git a/radio/src/lua/src/ldo.h b/radio/src/thirdparty/Lua/src/ldo.h similarity index 100% rename from radio/src/lua/src/ldo.h rename to radio/src/thirdparty/Lua/src/ldo.h diff --git a/radio/src/lua/src/ldump.c b/radio/src/thirdparty/Lua/src/ldump.c similarity index 100% rename from radio/src/lua/src/ldump.c rename to radio/src/thirdparty/Lua/src/ldump.c diff --git a/radio/src/lua/src/lfunc.c b/radio/src/thirdparty/Lua/src/lfunc.c similarity index 100% rename from radio/src/lua/src/lfunc.c rename to radio/src/thirdparty/Lua/src/lfunc.c diff --git a/radio/src/lua/src/lfunc.h b/radio/src/thirdparty/Lua/src/lfunc.h similarity index 100% rename from radio/src/lua/src/lfunc.h rename to radio/src/thirdparty/Lua/src/lfunc.h diff --git a/radio/src/lua/src/lgc.c b/radio/src/thirdparty/Lua/src/lgc.c similarity index 100% rename from radio/src/lua/src/lgc.c rename to radio/src/thirdparty/Lua/src/lgc.c diff --git a/radio/src/lua/src/lgc.h b/radio/src/thirdparty/Lua/src/lgc.h similarity index 100% rename from radio/src/lua/src/lgc.h rename to radio/src/thirdparty/Lua/src/lgc.h diff --git a/radio/src/lua/src/linit.c b/radio/src/thirdparty/Lua/src/linit.c similarity index 100% rename from radio/src/lua/src/linit.c rename to radio/src/thirdparty/Lua/src/linit.c diff --git a/radio/src/lua/src/liolib.c b/radio/src/thirdparty/Lua/src/liolib.c similarity index 98% rename from radio/src/lua/src/liolib.c rename to radio/src/thirdparty/Lua/src/liolib.c index 12c056882..4b57c5230 100644 --- a/radio/src/lua/src/liolib.c +++ b/radio/src/thirdparty/Lua/src/liolib.c @@ -618,7 +618,6 @@ static int f_setvbuf (lua_State *L) { } -#if !defined(USE_FATFS) static int io_flush (lua_State *L) { return luaL_fileresult(L, fflush(getiofile(L, IO_OUTPUT)) == 0, NULL); } @@ -627,7 +626,15 @@ static int io_flush (lua_State *L) { static int f_flush (lua_State *L) { return luaL_fileresult(L, fflush(tofile(L)) == 0, NULL); } -#endif + +#else + +static int io_seek (lua_State *L) { + FILE *f = tofile(L); + lua_Unsigned offset = luaL_checkunsigned(L, 2); + lua_pushinteger(L, f_lseek(f, offset)); + return 1; +} #endif @@ -639,6 +646,7 @@ const luaL_Reg iolib[] = { // {"flush", io_flush}, // {"input", io_input}, // {"lines", io_lines}, + {"seek", io_seek}, {"open", io_open}, // {"output", io_output}, // {"popen", io_popen}, diff --git a/radio/src/lua/src/llex.c b/radio/src/thirdparty/Lua/src/llex.c similarity index 100% rename from radio/src/lua/src/llex.c rename to radio/src/thirdparty/Lua/src/llex.c diff --git a/radio/src/lua/src/llex.h b/radio/src/thirdparty/Lua/src/llex.h similarity index 100% rename from radio/src/lua/src/llex.h rename to radio/src/thirdparty/Lua/src/llex.h diff --git a/radio/src/lua/src/llimits.h b/radio/src/thirdparty/Lua/src/llimits.h similarity index 100% rename from radio/src/lua/src/llimits.h rename to radio/src/thirdparty/Lua/src/llimits.h diff --git a/radio/src/lua/src/lmathlib.c b/radio/src/thirdparty/Lua/src/lmathlib.c similarity index 100% rename from radio/src/lua/src/lmathlib.c rename to radio/src/thirdparty/Lua/src/lmathlib.c diff --git a/radio/src/lua/src/lmem.c b/radio/src/thirdparty/Lua/src/lmem.c similarity index 100% rename from radio/src/lua/src/lmem.c rename to radio/src/thirdparty/Lua/src/lmem.c diff --git a/radio/src/lua/src/lmem.h b/radio/src/thirdparty/Lua/src/lmem.h similarity index 100% rename from radio/src/lua/src/lmem.h rename to radio/src/thirdparty/Lua/src/lmem.h diff --git a/radio/src/lua/src/loadlib.c b/radio/src/thirdparty/Lua/src/loadlib.c similarity index 100% rename from radio/src/lua/src/loadlib.c rename to radio/src/thirdparty/Lua/src/loadlib.c diff --git a/radio/src/lua/src/lobject.c b/radio/src/thirdparty/Lua/src/lobject.c similarity index 100% rename from radio/src/lua/src/lobject.c rename to radio/src/thirdparty/Lua/src/lobject.c diff --git a/radio/src/lua/src/lobject.h b/radio/src/thirdparty/Lua/src/lobject.h similarity index 100% rename from radio/src/lua/src/lobject.h rename to radio/src/thirdparty/Lua/src/lobject.h diff --git a/radio/src/lua/src/lopcodes.c b/radio/src/thirdparty/Lua/src/lopcodes.c similarity index 100% rename from radio/src/lua/src/lopcodes.c rename to radio/src/thirdparty/Lua/src/lopcodes.c diff --git a/radio/src/lua/src/lopcodes.h b/radio/src/thirdparty/Lua/src/lopcodes.h similarity index 100% rename from radio/src/lua/src/lopcodes.h rename to radio/src/thirdparty/Lua/src/lopcodes.h diff --git a/radio/src/lua/src/loslib.c b/radio/src/thirdparty/Lua/src/loslib.c similarity index 100% rename from radio/src/lua/src/loslib.c rename to radio/src/thirdparty/Lua/src/loslib.c diff --git a/radio/src/lua/src/lparser.c b/radio/src/thirdparty/Lua/src/lparser.c similarity index 100% rename from radio/src/lua/src/lparser.c rename to radio/src/thirdparty/Lua/src/lparser.c diff --git a/radio/src/lua/src/lparser.h b/radio/src/thirdparty/Lua/src/lparser.h similarity index 100% rename from radio/src/lua/src/lparser.h rename to radio/src/thirdparty/Lua/src/lparser.h diff --git a/radio/src/lua/src/lrotable.c b/radio/src/thirdparty/Lua/src/lrotable.c similarity index 100% rename from radio/src/lua/src/lrotable.c rename to radio/src/thirdparty/Lua/src/lrotable.c diff --git a/radio/src/lua/src/lrotable.h b/radio/src/thirdparty/Lua/src/lrotable.h similarity index 100% rename from radio/src/lua/src/lrotable.h rename to radio/src/thirdparty/Lua/src/lrotable.h diff --git a/radio/src/lua/src/lstate.c b/radio/src/thirdparty/Lua/src/lstate.c similarity index 100% rename from radio/src/lua/src/lstate.c rename to radio/src/thirdparty/Lua/src/lstate.c diff --git a/radio/src/lua/src/lstate.h b/radio/src/thirdparty/Lua/src/lstate.h similarity index 100% rename from radio/src/lua/src/lstate.h rename to radio/src/thirdparty/Lua/src/lstate.h diff --git a/radio/src/lua/src/lstring.c b/radio/src/thirdparty/Lua/src/lstring.c similarity index 100% rename from radio/src/lua/src/lstring.c rename to radio/src/thirdparty/Lua/src/lstring.c diff --git a/radio/src/lua/src/lstring.h b/radio/src/thirdparty/Lua/src/lstring.h similarity index 100% rename from radio/src/lua/src/lstring.h rename to radio/src/thirdparty/Lua/src/lstring.h diff --git a/radio/src/lua/src/lstrlib.c b/radio/src/thirdparty/Lua/src/lstrlib.c similarity index 100% rename from radio/src/lua/src/lstrlib.c rename to radio/src/thirdparty/Lua/src/lstrlib.c diff --git a/radio/src/lua/src/ltable.c b/radio/src/thirdparty/Lua/src/ltable.c similarity index 100% rename from radio/src/lua/src/ltable.c rename to radio/src/thirdparty/Lua/src/ltable.c diff --git a/radio/src/lua/src/ltable.h b/radio/src/thirdparty/Lua/src/ltable.h similarity index 100% rename from radio/src/lua/src/ltable.h rename to radio/src/thirdparty/Lua/src/ltable.h diff --git a/radio/src/lua/src/ltablib.c b/radio/src/thirdparty/Lua/src/ltablib.c similarity index 100% rename from radio/src/lua/src/ltablib.c rename to radio/src/thirdparty/Lua/src/ltablib.c diff --git a/radio/src/lua/src/ltm.c b/radio/src/thirdparty/Lua/src/ltm.c similarity index 100% rename from radio/src/lua/src/ltm.c rename to radio/src/thirdparty/Lua/src/ltm.c diff --git a/radio/src/lua/src/ltm.h b/radio/src/thirdparty/Lua/src/ltm.h similarity index 100% rename from radio/src/lua/src/ltm.h rename to radio/src/thirdparty/Lua/src/ltm.h diff --git a/radio/src/lua/src/lua.c b/radio/src/thirdparty/Lua/src/lua.c similarity index 100% rename from radio/src/lua/src/lua.c rename to radio/src/thirdparty/Lua/src/lua.c diff --git a/radio/src/lua/src/lua.h b/radio/src/thirdparty/Lua/src/lua.h similarity index 100% rename from radio/src/lua/src/lua.h rename to radio/src/thirdparty/Lua/src/lua.h diff --git a/radio/src/lua/src/lua.hpp b/radio/src/thirdparty/Lua/src/lua.hpp similarity index 100% rename from radio/src/lua/src/lua.hpp rename to radio/src/thirdparty/Lua/src/lua.hpp diff --git a/radio/src/lua/src/luac.c b/radio/src/thirdparty/Lua/src/luac.c similarity index 100% rename from radio/src/lua/src/luac.c rename to radio/src/thirdparty/Lua/src/luac.c diff --git a/radio/src/lua/src/luaconf.h b/radio/src/thirdparty/Lua/src/luaconf.h similarity index 100% rename from radio/src/lua/src/luaconf.h rename to radio/src/thirdparty/Lua/src/luaconf.h diff --git a/radio/src/lua/src/lualib.h b/radio/src/thirdparty/Lua/src/lualib.h similarity index 100% rename from radio/src/lua/src/lualib.h rename to radio/src/thirdparty/Lua/src/lualib.h diff --git a/radio/src/lua/src/lundump.c b/radio/src/thirdparty/Lua/src/lundump.c similarity index 100% rename from radio/src/lua/src/lundump.c rename to radio/src/thirdparty/Lua/src/lundump.c diff --git a/radio/src/lua/src/lundump.h b/radio/src/thirdparty/Lua/src/lundump.h similarity index 100% rename from radio/src/lua/src/lundump.h rename to radio/src/thirdparty/Lua/src/lundump.h diff --git a/radio/src/lua/src/lvm.c b/radio/src/thirdparty/Lua/src/lvm.c similarity index 100% rename from radio/src/lua/src/lvm.c rename to radio/src/thirdparty/Lua/src/lvm.c diff --git a/radio/src/lua/src/lvm.h b/radio/src/thirdparty/Lua/src/lvm.h similarity index 100% rename from radio/src/lua/src/lvm.h rename to radio/src/thirdparty/Lua/src/lvm.h diff --git a/radio/src/lua/src/lzio.c b/radio/src/thirdparty/Lua/src/lzio.c similarity index 100% rename from radio/src/lua/src/lzio.c rename to radio/src/thirdparty/Lua/src/lzio.c diff --git a/radio/src/lua/src/lzio.h b/radio/src/thirdparty/Lua/src/lzio.h similarity index 100% rename from radio/src/lua/src/lzio.h rename to radio/src/thirdparty/Lua/src/lzio.h From ad9c2e08181425f75616e988b2ac250ee74b86a4 Mon Sep 17 00:00:00 2001 From: Andre Bernet Date: Tue, 31 Mar 2015 20:34:02 +0400 Subject: [PATCH 3/4] Simu compilation --- companion/src/firmwares/opentx/simulator/opentxsimulator.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/companion/src/firmwares/opentx/simulator/opentxsimulator.cpp b/companion/src/firmwares/opentx/simulator/opentxsimulator.cpp index 46c977731..ffdb1755b 100644 --- a/companion/src/firmwares/opentx/simulator/opentxsimulator.cpp +++ b/companion/src/firmwares/opentx/simulator/opentxsimulator.cpp @@ -298,6 +298,7 @@ namespace NAMESPACE { #include "radio/src/thirdparty/Lua/src/lauxlib.c" #include "radio/src/thirdparty/Lua/src/ltablib.c" #include "radio/src/thirdparty/Lua/src/lcorolib.c" +#include "radio/src/thirdparty/Lua/src/liolib.c" #endif int16_t g_anas[NUM_STICKS+NUM_POTS]; From 84fc2007f56a2ce6279ec4c22ff84e209a556e4f Mon Sep 17 00:00:00 2001 From: bsongis Date: Tue, 31 Mar 2015 20:06:13 +0200 Subject: [PATCH 4/4] Lua f_open in "a" mode added --- radio/src/thirdparty/Lua/src/liolib.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/radio/src/thirdparty/Lua/src/liolib.c b/radio/src/thirdparty/Lua/src/liolib.c index 4b57c5230..8f29b8a99 100644 --- a/radio/src/thirdparty/Lua/src/liolib.c +++ b/radio/src/thirdparty/Lua/src/liolib.c @@ -246,13 +246,15 @@ static int io_open (lua_State *L) { LStream *p = newfile(L); #if defined(USE_FATFS) BYTE mode; - if (!md || *md == 'r') + if (!strcmp(md, "r")) mode = FA_READ; - else if (*md == 'w') + else if (!strcmp(md, "w") || !strcmp(md, "a")) mode = FA_WRITE; else luaL_argerror(L, (2), ("invalid mode")); FRESULT result = f_open(&p->f, filename, mode); + if (result == FR_OK && !strcmp(md, "a")) + result = f_lseek(&p->f, f_size(&p->f)); return result == FR_OK ? 1 : 0; #else const char *mode = md; /* to traverse/check mode */