Commit 307323d1 authored by TerryE's avatar TerryE
Browse files

Add luac.cross capability to nodeMCU

parent a08626d8
...@@ -6,11 +6,11 @@ ...@@ -6,11 +6,11 @@
#define lopcodes_c #define lopcodes_c
#define LUA_CORE #define LUA_CORE
#define LUAC_CROSS_FILE
#include "luac_cross.h"
#include "lopcodes.h" #include "lopcodes.h"
/* ORDER OP */ /* ORDER OP */
const char *const luaP_opnames[NUM_OPCODES+1] = { const char *const luaP_opnames[NUM_OPCODES+1] = {
......
...@@ -5,12 +5,12 @@ ...@@ -5,12 +5,12 @@
*/ */
#include "c_string.h"
#define lparser_c #define lparser_c
#define LUA_CORE #define LUA_CORE
#define LUAC_CROSS_FILE
#include "lua.h" #include "lua.h"
#include C_HEADER_STRING
#include "lcode.h" #include "lcode.h"
#include "ldebug.h" #include "ldebug.h"
......
/* Read-only tables for Lua */ /* Read-only tables for Lua */
#define LUAC_CROSS_FILE
#include "c_string.h"
#include "lrotable.h"
#include "lua.h" #include "lua.h"
#include C_HEADER_STRING
#include "lrotable.h"
#include "lauxlib.h" #include "lauxlib.h"
#include "lstring.h" #include "lstring.h"
#include "lobject.h" #include "lobject.h"
......
...@@ -5,10 +5,9 @@ ...@@ -5,10 +5,9 @@
*/ */
#include "c_stddef.h"
#define lstate_c #define lstate_c
#define LUA_CORE #define LUA_CORE
#define LUAC_CROSS_FILE
#include "lua.h" #include "lua.h"
......
...@@ -5,12 +5,13 @@ ...@@ -5,12 +5,13 @@
*/ */
#include "c_string.h"
#define lstring_c #define lstring_c
#define LUA_CORE #define LUA_CORE
#define LUAC_CROSS_FILE
#include "lua.h" #include "lua.h"
#include C_HEADER_STRING
#include "lmem.h" #include "lmem.h"
#include "lobject.h" #include "lobject.h"
......
...@@ -5,16 +5,13 @@ ...@@ -5,16 +5,13 @@
*/ */
#include "c_ctype.h"
#include "c_stddef.h"
#include "c_stdio.h"
#include "c_stdlib.h"
#include "c_string.h"
#define lstrlib_c #define lstrlib_c
#define LUA_LIB #define LUA_LIB
#define LUAC_CROSS_FILE
#include "lua.h" #include "lua.h"
#include C_HEADER_STDIO
#include C_HEADER_STRING
#include "lauxlib.h" #include "lauxlib.h"
#include "lualib.h" #include "lualib.h"
......
...@@ -18,13 +18,13 @@ ...@@ -18,13 +18,13 @@
** Hence even when the load factor reaches 100%, performance remains good. ** Hence even when the load factor reaches 100%, performance remains good.
*/ */
#include "c_math.h"
#include "c_string.h"
#define ltable_c #define ltable_c
#define LUA_CORE #define LUA_CORE
#define LUAC_CROSS_FILE
#include "lua.h" #include "lua.h"
#include C_HEADER_MATH
#include C_HEADER_STRING
#include "ldebug.h" #include "ldebug.h"
#include "ldo.h" #include "ldo.h"
......
...@@ -5,10 +5,9 @@ ...@@ -5,10 +5,9 @@
*/ */
#include "c_stddef.h"
#define ltablib_c #define ltablib_c
#define LUA_LIB #define LUA_LIB
#define LUAC_CROSS_FILE
#include "lua.h" #include "lua.h"
......
...@@ -5,12 +5,12 @@ ...@@ -5,12 +5,12 @@
*/ */
#include "c_string.h"
#define ltm_c #define ltm_c
#define LUA_CORE #define LUA_CORE
#define LUAC_CROSS_FILE
#include "lua.h" #include "lua.h"
#include C_HEADER_STRING
#include "lobject.h" #include "lobject.h"
#include "lstate.h" #include "lstate.h"
......
...@@ -8,10 +8,18 @@ ...@@ -8,10 +8,18 @@
#ifndef lua_h #ifndef lua_h
#define lua_h #define lua_h
#ifdef LUAC_CROSS_FILE
#include "luac_cross.h"
#endif
#ifdef LUA_CROSS_COMPILER
#include <stdarg.h>
#include <stddef.h>
#include <ctype.h>
#else
#include "c_stdarg.h" #include "c_stdarg.h"
#include "c_stddef.h" #include "c_stddef.h"
#include "c_types.h" #include "c_types.h"
#endif
#include "luaconf.h" #include "luaconf.h"
......
/*
** Header to allow luac.cross compile within NodeMCU
** See Copyright Notice in lua.h
*/
#ifndef luac_cross_h
#define luac_cross_h
#ifdef LUA_CROSS_COMPILER
#define C_HEADER_ASSERT <assert.h>
#define C_HEADER_CTYPE <ctype.h>
#define C_HEADER_ERRNO <errno.h>
#define C_HEADER_FCNTL <fcntl.h>
#define C_HEADER_LOCALE <locale.h>
#define C_HEADER_MATH <math.h>
#define C_HEADER_STDIO <stdio.h>
#define C_HEADER_STDLIB <stdlib.h>
#define C_HEADER_STRING <string.h>
#define C_HEADER_TIME <time.h>
#define ICACHE_RODATA_ATTR
#define c_abs abs
#define c_exit exit
#define c_fclose fclose
#define c_feof feof
#define c_ferror ferror
#define c_fopen fopen
#define c_fread fread
#define c_free free
#define c_freopen freopen
#define c_getc getc
#define c_getenv getenv
#define c_memcmp memcmp
#define c_memcpy memcpy
#define c_printf printf
#define c_puts puts
#define c_reader reader
#define c_realloc realloc
#define c_sprintf sprintf
#define c_stderr stderr
#define c_stdin stdin
#define c_stdout stdout
#define c_strcat strcat
#define c_strchr strchr
#define c_strcmp strcmp
#define c_strcoll strcoll
#define c_strcpy strcpy
#define c_strcspn strcspn
#define c_strerror strerror
#define c_strlen strlen
#define c_strncat strncat
#define c_strncmp strncmp
#define c_strncpy strncpy
#define c_strpbrk strpbrk
#define c_strrchr strrchr
#define c_strstr strstr
#define c_strtod strtod
#define c_strtoul strtoul
#define c_ungetc ungetc
#else
#define C_HEADER_ASSERT "c_assert.h"
#define C_HEADER_CTYPE "c_ctype.h"
#define C_HEADER_ERRNO "c_errno.h"
#define C_HEADER_FCNTL "c_fcntl.h"
#define C_HEADER_LOCALE "c_locale.h"
#define C_HEADER_MATH "c_math.h"
#define C_HEADER_STDIO "c_stdio.h"
#define C_HEADER_STDLIB "c_stdlib.h"
#define C_HEADER_STRING "c_string.h"
#define C_HEADER_TIME "c_time.h"
#endif /* LUA_CROSS_COMPILER */
#endif /* luac_cross_h */
...@@ -4,12 +4,14 @@ ...@@ -4,12 +4,14 @@
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
#define LUAC_CROSS_FILE
#include <errno.h>
#include <locale.h> #include "luac_cross.h"
#include <stdlib.h> #include C_HEADER_ERRNO
#include <string.h> #include C_HEADER_LOCALE
#include <time.h> #include C_HEADER_STDLIB
#include C_HEADER_STRING
#include C_HEADER_TIME
#define loslib_c #define loslib_c
#define LUA_LIB #define LUA_LIB
......
...@@ -4,10 +4,13 @@ ...@@ -4,10 +4,13 @@
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
#include "c_errno.h" #define LUAC_CROSS_FILE
#include "c_stdio.h"
#include "c_stdlib.h" #include "luac_cross.h"
#include "c_string.h" #include C_HEADER_ERRNO
#include C_HEADER_STDIO
#include C_HEADER_STDLIB
#include C_HEADER_STRING
#define luac_c #define luac_c
#define LUA_CORE #define LUA_CORE
......
...@@ -4,8 +4,11 @@ ...@@ -4,8 +4,11 @@
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
#include "c_ctype.h" #define LUAC_CROSS_FILE
#include "c_stdio.h"
#include "luac_cross.h"
#include C_HEADER_CTYPE
#include C_HEADER_STDIO
#define luac_c #define luac_c
#define LUA_CORE #define LUA_CORE
......
...@@ -8,8 +8,13 @@ ...@@ -8,8 +8,13 @@
#ifndef lconfig_h #ifndef lconfig_h
#define lconfig_h #define lconfig_h
#ifdef LUA_CROSS_COMPILER
#include <limits.h>
#include <stddef.h>
#else
#include "c_limits.h" #include "c_limits.h"
#include "c_stddef.h" #include "c_stddef.h"
#endif
#include "user_config.h" #include "user_config.h"
/* /*
...@@ -252,7 +257,12 @@ ...@@ -252,7 +257,12 @@
#define lua_stdin_is_tty() isatty(0) #define lua_stdin_is_tty() isatty(0)
#elif defined(LUA_WIN) #elif defined(LUA_WIN)
#include <io.h> #include <io.h>
#ifdef LUA_CROSS_COMPILER
#include <stdio.h>
else
#include "c_stdio.h" #include "c_stdio.h"
#endif
#define lua_stdin_is_tty() _isatty(_fileno(stdin)) #define lua_stdin_is_tty() _isatty(_fileno(stdin))
#else #else
#define lua_stdin_is_tty() 1 /* assume stdin is a tty */ #define lua_stdin_is_tty() 1 /* assume stdin is a tty */
...@@ -294,8 +304,8 @@ ...@@ -294,8 +304,8 @@
** GNU readline and history facilities). ** GNU readline and history facilities).
*/ */
#if defined(LUA_USE_STDIO) #if defined(LUA_USE_STDIO)
#if defined(LUA_USE_READLINE) #if defined(LUA_CROSS_COMPILER) && defined(LUA_USE_READLINE)
#include "c_stdio.h" #include <stdio.h>
#include <readline/readline.h> #include <readline/readline.h>
#include <readline/history.h> #include <readline/history.h>
#define lua_readline(L,b,p) ((void)L, ((b)=readline(p)) != NULL) #define lua_readline(L,b,p) ((void)L, ((b)=readline(p)) != NULL)
...@@ -303,7 +313,7 @@ ...@@ -303,7 +313,7 @@
if (lua_strlen(L,idx) > 0) /* non-empty line? */ \ if (lua_strlen(L,idx) > 0) /* non-empty line? */ \
add_history(lua_tostring(L, idx)); /* add it to history */ add_history(lua_tostring(L, idx)); /* add it to history */
#define lua_freeline(L,b) ((void)L, c_free(b)) #define lua_freeline(L,b) ((void)L, c_free(b))
#else // #if defined(LUA_USE_READLINE) #else // #if defined(LUA_CROSS_COMPILER) && defined(LUA_USE_READLINE)
#define lua_readline(L,b,p) \ #define lua_readline(L,b,p) \
((void)L, c_fputs(p, c_stdout), c_fflush(c_stdout), /* show prompt */ \ ((void)L, c_fputs(p, c_stdout), c_fflush(c_stdout), /* show prompt */ \
c_fgets(b, LUA_MAXINPUT, c_stdin) != NULL) /* get line */ c_fgets(b, LUA_MAXINPUT, c_stdin) != NULL) /* get line */
...@@ -623,7 +633,11 @@ extern int readline4lua(const char *prompt, char *buffer, int length); ...@@ -623,7 +633,11 @@ extern int readline4lua(const char *prompt, char *buffer, int length);
@@ The luai_num* macros define the primitive operations over numbers. @@ The luai_num* macros define the primitive operations over numbers.
*/ */
#if defined(LUA_CORE) #if defined(LUA_CORE)
#ifdef LUA_CROSS_COMPILER
#include <math.h>
#else
#include "c_math.h" #include "c_math.h"
#endif
#define luai_numadd(a,b) ((a)+(b)) #define luai_numadd(a,b) ((a)+(b))
#define luai_numsub(a,b) ((a)-(b)) #define luai_numsub(a,b) ((a)-(b))
#define luai_nummul(a,b) ((a)*(b)) #define luai_nummul(a,b) ((a)*(b))
...@@ -866,7 +880,10 @@ union luai_Cast { double l_d; long l_l; }; ...@@ -866,7 +880,10 @@ union luai_Cast { double l_d; long l_l; };
#define LUA_INTFRMLEN "l" #define LUA_INTFRMLEN "l"
#define LUA_INTFRM_T long #define LUA_INTFRM_T long
#ifndef LUA_CROSS_COMPILER
typedef short int16_t;
typedef long int32_t;
#endif
#endif #endif
......
...@@ -4,13 +4,12 @@ ...@@ -4,13 +4,12 @@
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
#include "c_string.h"
#include "c_types.h"
#define lundump_c #define lundump_c
#define LUA_CORE #define LUA_CORE
#define LUAC_CROSS_FILE
#include "lua.h" #include "lua.h"
#include C_HEADER_STRING
#include "ldebug.h" #include "ldebug.h"
#include "ldo.h" #include "ldo.h"
......
...@@ -7,7 +7,11 @@ ...@@ -7,7 +7,11 @@
#ifndef lundump_h #ifndef lundump_h
#define lundump_h #define lundump_h
#ifdef LUA_CROSS_COMPILER
#include <stdint.h>
#else
#include "c_stdint.h" #include "c_stdint.h"
#endif
#include "lobject.h" #include "lobject.h"
#include "lzio.h" #include "lzio.h"
......
...@@ -5,15 +5,14 @@ ...@@ -5,15 +5,14 @@
*/ */
#include "c_stdio.h"
#include "c_stdlib.h"
#include "c_string.h"
#include "c_math.h"
#define lvm_c #define lvm_c
#define LUA_CORE #define LUA_CORE
#define LUAC_CROSS_FILE
#include "lua.h" #include "lua.h"
#include C_HEADER_STDIO
#include C_HEADER_STRING
#include C_HEADER_MATH
#include "ldebug.h" #include "ldebug.h"
#include "ldo.h" #include "ldo.h"
......
...@@ -5,12 +5,12 @@ ...@@ -5,12 +5,12 @@
*/ */
#include "c_string.h"
#define lzio_c #define lzio_c
#define LUA_CORE #define LUA_CORE
#define LUAC_CROSS_FILE
#include "lua.h" #include "lua.h"
#include C_HEADER_STRING
#include "llimits.h" #include "llimits.h"
#include "lmem.h" #include "lmem.h"
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#define linit_c #define linit_c
#define LUA_LIB #define LUA_LIB
#define LUAC_CROSS_FILE
#include "lua.h" #include "lua.h"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment