Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
Nodemcu Firmware
Commits
307323d1
Commit
307323d1
authored
Sep 01, 2015
by
TerryE
Browse files
Add luac.cross capability to nodeMCU
parent
a08626d8
Changes
43
Hide whitespace changes
Inline
Side-by-side
app/include/user_modules.h
View file @
307323d1
...
@@ -11,6 +11,7 @@
...
@@ -11,6 +11,7 @@
// #define LUA_USE_BUILTIN_DEBUG
// #define LUA_USE_BUILTIN_DEBUG
#define LUA_USE_BUILTIN_DEBUG_MINIMAL // for debug.getregistry() and debug.traceback()
#define LUA_USE_BUILTIN_DEBUG_MINIMAL // for debug.getregistry() and debug.traceback()
#ifndef LUA_CROSS_COMPILER
#define LUA_USE_MODULES
#define LUA_USE_MODULES
#ifdef LUA_USE_MODULES
#ifdef LUA_USE_MODULES
...
@@ -47,5 +48,6 @@
...
@@ -47,5 +48,6 @@
//#define LUA_USE_MODULES_HX711
//#define LUA_USE_MODULES_HX711
#endif
/* LUA_USE_MODULES */
#endif
/* LUA_USE_MODULES */
#endif
#endif
/* __USER_MODULES_H__ */
#endif
/* __USER_MODULES_H__ */
app/lua/lapi.c
View file @
307323d1
...
@@ -4,17 +4,15 @@
...
@@ -4,17 +4,15 @@
** See Copyright Notice in lua.h
** See Copyright Notice in lua.h
*/
*/
//#include "c_assert.h"
#include "c_math.h"
#include "c_stdarg.h"
#include "c_string.h"
#define lapi_c
#define lapi_c
#define LUA_CORE
#define LUA_CORE
#define LUAC_CROSS_FILE
#include "lua.h"
#include "lua.h"
//#include C_HEADER_ASSERT
#include C_HEADER_MATH
#include C_HEADER_STRING
#include "lapi.h"
#include "lapi.h"
#include "ldebug.h"
#include "ldebug.h"
#include "ldo.h"
#include "ldo.h"
...
...
app/lua/lauxlib.c
View file @
307323d1
...
@@ -4,14 +4,18 @@
...
@@ -4,14 +4,18 @@
** See Copyright Notice in lua.h
** See Copyright Notice in lua.h
*/
*/
#define LUAC_CROSS_FILE
#include "c_ctype.h"
#include "lua.h"
// #include "c_errno.h"
#include C_HEADER_CTYPE
#include "c_stdarg.h"
#include C_HEADER_ERRNO
#include "c_stdio.h"
#include C_HEADER_STDIO
#include "c_stdlib.h"
#include C_HEADER_STDLIB
#include "c_string.h"
#include C_HEADER_STRING
#ifndef LUA_CROSS_COMPILER
#include "flash_fs.h"
#include "flash_fs.h"
#else
#endif
/* This file uses only the official API of Lua.
/* This file uses only the official API of Lua.
** Any function declared here could be written as an application function.
** Any function declared here could be written as an application function.
...
@@ -20,8 +24,6 @@
...
@@ -20,8 +24,6 @@
#define lauxlib_c
#define lauxlib_c
#define LUA_LIB
#define LUA_LIB
#include "lua.h"
#include "lrotable.h"
#include "lrotable.h"
#include "lauxlib.h"
#include "lauxlib.h"
...
@@ -573,7 +575,7 @@ LUALIB_API void luaL_unref (lua_State *L, int t, int ref) {
...
@@ -573,7 +575,7 @@ LUALIB_API void luaL_unref (lua_State *L, int t, int ref) {
** =======================================================
** =======================================================
*/
*/
#if
0
#if
def LUA_CROSS_COMPILER
typedef
struct
LoadF
{
typedef
struct
LoadF
{
int
extraline
;
int
extraline
;
...
@@ -647,7 +649,7 @@ LUALIB_API int luaL_loadfile (lua_State *L, const char *filename) {
...
@@ -647,7 +649,7 @@ LUALIB_API int luaL_loadfile (lua_State *L, const char *filename) {
#else
#else
#include
"c_fcntl.h"
#include
C_HEADER_FCNTL
typedef
struct
LoadFSF
{
typedef
struct
LoadFSF
{
int
extraline
;
int
extraline
;
...
...
app/lua/lauxlib.h
View file @
307323d1
...
@@ -9,11 +9,14 @@
...
@@ -9,11 +9,14 @@
#define lauxlib_h
#define lauxlib_h
//#include "c_stddef.h"
#include "c_stdio.h"
#include "lua.h"
#include "lua.h"
#ifdef LUA_CROSS_COMPILER
#include <stdio.h>
#else
#include "c_stdio.h"
#endif
#if defined(LUA_COMPAT_GETN)
#if defined(LUA_COMPAT_GETN)
LUALIB_API
int
(
luaL_getn
)
(
lua_State
*
L
,
int
t
);
LUALIB_API
int
(
luaL_getn
)
(
lua_State
*
L
,
int
t
);
...
@@ -79,7 +82,7 @@ LUALIB_API int (luaL_checkoption) (lua_State *L, int narg, const char *def,
...
@@ -79,7 +82,7 @@ LUALIB_API int (luaL_checkoption) (lua_State *L, int narg, const char *def,
LUALIB_API
int
(
luaL_ref
)
(
lua_State
*
L
,
int
t
);
LUALIB_API
int
(
luaL_ref
)
(
lua_State
*
L
,
int
t
);
LUALIB_API
void
(
luaL_unref
)
(
lua_State
*
L
,
int
t
,
int
ref
);
LUALIB_API
void
(
luaL_unref
)
(
lua_State
*
L
,
int
t
,
int
ref
);
#if
0
#if
def LUA_CROSS_COMPILER
LUALIB_API
int
(
luaL_loadfile
)
(
lua_State
*
L
,
const
char
*
filename
);
LUALIB_API
int
(
luaL_loadfile
)
(
lua_State
*
L
,
const
char
*
filename
);
#else
#else
LUALIB_API
int
(
luaL_loadfsfile
)
(
lua_State
*
L
,
const
char
*
filename
);
LUALIB_API
int
(
luaL_loadfsfile
)
(
lua_State
*
L
,
const
char
*
filename
);
...
...
app/lua/lbaselib.c
View file @
307323d1
...
@@ -6,16 +6,14 @@
...
@@ -6,16 +6,14 @@
#include "c_ctype.h"
#include "c_stdio.h"
#include "c_stdlib.h"
#include "c_string.h"
#define lbaselib_c
#define lbaselib_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 C_HEADER_STDLIB
#include "lauxlib.h"
#include "lauxlib.h"
#include "lualib.h"
#include "lualib.h"
#include "lrotable.h"
#include "lrotable.h"
...
@@ -295,7 +293,7 @@ static int luaB_loadstring (lua_State *L) {
...
@@ -295,7 +293,7 @@ static int luaB_loadstring (lua_State *L) {
static
int
luaB_loadfile
(
lua_State
*
L
)
{
static
int
luaB_loadfile
(
lua_State
*
L
)
{
const
char
*
fname
=
luaL_optstring
(
L
,
1
,
NULL
);
const
char
*
fname
=
luaL_optstring
(
L
,
1
,
NULL
);
#if
0
#if
def LUA_CROSS_COMPILER
return
load_aux
(
L
,
luaL_loadfile
(
L
,
fname
));
return
load_aux
(
L
,
luaL_loadfile
(
L
,
fname
));
#else
#else
return
load_aux
(
L
,
luaL_loadfsfile
(
L
,
fname
));
return
load_aux
(
L
,
luaL_loadfsfile
(
L
,
fname
));
...
@@ -342,7 +340,7 @@ static int luaB_load (lua_State *L) {
...
@@ -342,7 +340,7 @@ static int luaB_load (lua_State *L) {
static
int
luaB_dofile
(
lua_State
*
L
)
{
static
int
luaB_dofile
(
lua_State
*
L
)
{
const
char
*
fname
=
luaL_optstring
(
L
,
1
,
NULL
);
const
char
*
fname
=
luaL_optstring
(
L
,
1
,
NULL
);
int
n
=
lua_gettop
(
L
);
int
n
=
lua_gettop
(
L
);
#if
0
#if
def LUA_CROSS_COMPILER
if
(
luaL_loadfile
(
L
,
fname
)
!=
0
)
lua_error
(
L
);
if
(
luaL_loadfile
(
L
,
fname
)
!=
0
)
lua_error
(
L
);
#else
#else
if
(
luaL_loadfsfile
(
L
,
fname
)
!=
0
)
lua_error
(
L
);
if
(
luaL_loadfsfile
(
L
,
fname
)
!=
0
)
lua_error
(
L
);
...
...
app/lua/lcode.c
View file @
307323d1
...
@@ -5,12 +5,12 @@
...
@@ -5,12 +5,12 @@
*/
*/
#include "c_stdlib.h"
#define lcode_c
#define lcode_c
#define LUA_CORE
#define LUA_CORE
#define LUAC_CROSS_FILE
#include "lua.h"
#include "lua.h"
#include C_HEADER_STDLIB
#include "lcode.h"
#include "lcode.h"
#include "ldebug.h"
#include "ldebug.h"
...
...
app/lua/ldblib.c
View file @
307323d1
...
@@ -5,14 +5,14 @@
...
@@ -5,14 +5,14 @@
*/
*/
#include "c_stdio.h"
#include "c_stdlib.h"
#include "c_string.h"
#define ldblib_c
#define ldblib_c
#define LUA_LIB
#define LUA_LIB
#define LUAC_CROSS_FILE
#include "lua.h"
#include "lua.h"
#include C_HEADER_STDIO
#include C_HEADER_STDLIB
#include C_HEADER_STRING
#include "lauxlib.h"
#include "lauxlib.h"
#include "lualib.h"
#include "lualib.h"
...
...
app/lua/ldebug.c
View file @
307323d1
...
@@ -5,15 +5,12 @@
...
@@ -5,15 +5,12 @@
*/
*/
#include "c_stdarg.h"
#include "c_stddef.h"
#include "c_string.h"
#define ldebug_c
#define ldebug_c
#define LUA_CORE
#define LUA_CORE
#define LUAC_CROSS_FILE
#include "lua.h"
#include "lua.h"
#include C_HEADER_STRING
#include "lapi.h"
#include "lapi.h"
#include "lcode.h"
#include "lcode.h"
...
...
app/lua/ldo.c
View file @
307323d1
...
@@ -4,15 +4,14 @@
...
@@ -4,15 +4,14 @@
** See Copyright Notice in lua.h
** See Copyright Notice in lua.h
*/
*/
#include <setjmp.h>
#include <setjmp.h>
#include "c_stdlib.h"
#include "c_string.h"
#define ldo_c
#define ldo_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"
...
...
app/lua/ldump.c
View file @
307323d1
...
@@ -4,13 +4,12 @@
...
@@ -4,13 +4,12 @@
** See Copyright Notice in lua.h
** See Copyright Notice in lua.h
*/
*/
#include "c_stddef.h"
#include "c_string.h"
#define ldump_c
#define ldump_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"
...
...
app/lua/lfunc.c
View file @
307323d1
...
@@ -4,11 +4,9 @@
...
@@ -4,11 +4,9 @@
** See Copyright Notice in lua.h
** See Copyright Notice in lua.h
*/
*/
#include "c_stddef.h"
#define lfunc_c
#define lfunc_c
#define LUA_CORE
#define LUA_CORE
#define LUAC_CROSS_FILE
#include "lua.h"
#include "lua.h"
...
...
app/lua/lgc.c
View file @
307323d1
...
@@ -4,12 +4,12 @@
...
@@ -4,12 +4,12 @@
** See Copyright Notice in lua.h
** See Copyright Notice in lua.h
*/
*/
#include "c_string.h"
#define lgc_c
#define lgc_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"
...
...
app/lua/llex.c
View file @
307323d1
...
@@ -5,14 +5,14 @@
...
@@ -5,14 +5,14 @@
*/
*/
#include "c_ctype.h"
#include "c_locale.h"
#include "c_string.h"
#define llex_c
#define llex_c
#define LUA_CORE
#define LUA_CORE
#define LUAC_CROSS_FILE
#include "lua.h"
#include "lua.h"
#include C_HEADER_CTYPE
#include C_HEADER_LOCALE
#include C_HEADER_STRING
#include "ldo.h"
#include "ldo.h"
#include "llex.h"
#include "llex.h"
...
...
app/lua/llimits.h
View file @
307323d1
...
@@ -9,12 +9,9 @@
...
@@ -9,12 +9,9 @@
//#include "c_limits.h"
//#include "c_limits.h"
//#include "c_stddef.h"
#include "lua.h"
#include "lua.h"
typedef
LUAI_UINT32
lu_int32
;
typedef
LUAI_UINT32
lu_int32
;
typedef
LUAI_UMEM
lu_mem
;
typedef
LUAI_UMEM
lu_mem
;
...
...
app/lua/lmathlib.c
View file @
307323d1
...
@@ -5,13 +5,13 @@
...
@@ -5,13 +5,13 @@
*/
*/
#include "c_stdlib.h"
#include "c_math.h"
#define lmathlib_c
#define lmathlib_c
#define LUA_LIB
#define LUA_LIB
#define LUAC_CROSS_FILE
#include "lua.h"
#include "lua.h"
#include C_HEADER_STDLIB
#include C_HEADER_MATH
#include "lauxlib.h"
#include "lauxlib.h"
#include "lualib.h"
#include "lualib.h"
...
@@ -35,7 +35,7 @@ static int math_abs (lua_State *L) {
...
@@ -35,7 +35,7 @@ static int math_abs (lua_State *L) {
}
}
#ifndef LUA_NUMBER_INTEGRAL
#ifndef LUA_NUMBER_INTEGRAL
#if 0
static int math_sin (lua_State *L) {
static int math_sin (lua_State *L) {
lua_pushnumber(L, sin(luaL_checknumber(L, 1)));
lua_pushnumber(L, sin(luaL_checknumber(L, 1)));
return 1;
return 1;
...
@@ -85,6 +85,7 @@ static int math_atan2 (lua_State *L) {
...
@@ -85,6 +85,7 @@ static int math_atan2 (lua_State *L) {
lua_pushnumber(L, atan2(luaL_checknumber(L, 1), luaL_checknumber(L, 2)));
lua_pushnumber(L, atan2(luaL_checknumber(L, 1), luaL_checknumber(L, 2)));
return 1;
return 1;
}
}
#endif
static
int
math_ceil
(
lua_State
*
L
)
{
static
int
math_ceil
(
lua_State
*
L
)
{
lua_pushnumber
(
L
,
ceil
(
luaL_checknumber
(
L
,
1
)));
lua_pushnumber
(
L
,
ceil
(
luaL_checknumber
(
L
,
1
)));
...
@@ -95,7 +96,7 @@ static int math_floor (lua_State *L) {
...
@@ -95,7 +96,7 @@ static int math_floor (lua_State *L) {
lua_pushnumber
(
L
,
floor
(
luaL_checknumber
(
L
,
1
)));
lua_pushnumber
(
L
,
floor
(
luaL_checknumber
(
L
,
1
)));
return
1
;
return
1
;
}
}
#if 0
static int math_fmod (lua_State *L) {
static int math_fmod (lua_State *L) {
lua_pushnumber(L, fmod(luaL_checknumber(L, 1), luaL_checknumber(L, 2)));
lua_pushnumber(L, fmod(luaL_checknumber(L, 1), luaL_checknumber(L, 2)));
return 1;
return 1;
...
@@ -108,6 +109,7 @@ static int math_modf (lua_State *L) {
...
@@ -108,6 +109,7 @@ static int math_modf (lua_State *L) {
lua_pushnumber(L, fp);
lua_pushnumber(L, fp);
return 2;
return 2;
}
}
#endif
#else // #ifndef LUA_NUMBER_INTEGRAL
#else // #ifndef LUA_NUMBER_INTEGRAL
...
@@ -173,7 +175,7 @@ static int math_pow (lua_State *L) {
...
@@ -173,7 +175,7 @@ static int math_pow (lua_State *L) {
#ifndef LUA_NUMBER_INTEGRAL
#ifndef LUA_NUMBER_INTEGRAL
#if 0
static int math_log (lua_State *L) {
static int math_log (lua_State *L) {
lua_pushnumber(L, log(luaL_checknumber(L, 1)));
lua_pushnumber(L, log(luaL_checknumber(L, 1)));
return 1;
return 1;
...
@@ -210,6 +212,7 @@ static int math_ldexp (lua_State *L) {
...
@@ -210,6 +212,7 @@ static int math_ldexp (lua_State *L) {
lua_pushnumber(L, ldexp(luaL_checknumber(L, 1), luaL_checkint(L, 2)));
lua_pushnumber(L, ldexp(luaL_checknumber(L, 1), luaL_checkint(L, 2)));
return 1;
return 1;
}
}
#endif
#endif // #ifdef LUA_NUMBER_INTEGRAL
#endif // #ifdef LUA_NUMBER_INTEGRAL
...
@@ -306,6 +309,8 @@ static int math_randomseed (lua_State *L) {
...
@@ -306,6 +309,8 @@ static int math_randomseed (lua_State *L) {
return
0
;
return
0
;
}
}
#define MIN_OPT_LEVEL 1
#define MIN_OPT_LEVEL 1
#include "lrodefs.h"
#include "lrodefs.h"
const
LUA_REG_TYPE
math_map
[]
=
{
const
LUA_REG_TYPE
math_map
[]
=
{
...
...
app/lua/lmem.c
View file @
307323d1
...
@@ -5,10 +5,9 @@
...
@@ -5,10 +5,9 @@
*/
*/
#include "c_stddef.h"
#define lmem_c
#define lmem_c
#define LUA_CORE
#define LUA_CORE
#define LUAC_CROSS_FILE
#include "lua.h"
#include "lua.h"
...
...
app/lua/lmem.h
View file @
307323d1
...
@@ -8,7 +8,11 @@
...
@@ -8,7 +8,11 @@
#define lmem_h
#define lmem_h
//#ifdef LUA_CROSS_COMPILER
//#include <stddef.h>
//#else
//#include "c_stddef.h"
//#include "c_stddef.h"
//#endif
#include "llimits.h"
#include "llimits.h"
#include "lua.h"
#include "lua.h"
...
...
app/lua/loadlib.c
View file @
307323d1
...
@@ -9,15 +9,18 @@
...
@@ -9,15 +9,18 @@
*/
*/
#include "c_stdlib.h"
#include "c_string.h"
#include "c_fcntl.h"
#include "flash_fs.h"
#define loadlib_c
#define loadlib_c
#define LUA_LIB
#define LUA_LIB
#define LUAC_CROSS_FILE
#include "lua.h"
#include "lua.h"
#include C_HEADER_STDLIB
#include C_HEADER_STRING
#include C_HEADER_FCNTL
#ifndef LUA_CROSS_COMPILER
#include "flash_fs.h"
#endif
#include "lauxlib.h"
#include "lauxlib.h"
#include "lualib.h"
#include "lualib.h"
...
@@ -328,7 +331,7 @@ static int ll_loadlib (lua_State *L) {
...
@@ -328,7 +331,7 @@ static int ll_loadlib (lua_State *L) {
** 'require' function
** 'require' function
** =======================================================
** =======================================================
*/
*/
#if
0
#if
def LUA_CROSS_COMPILER
static
int
readable
(
const
char
*
filename
)
{
static
int
readable
(
const
char
*
filename
)
{
FILE
*
f
=
c_fopen
(
filename
,
"r"
);
/* try to open file */
FILE
*
f
=
c_fopen
(
filename
,
"r"
);
/* try to open file */
if
(
f
==
NULL
)
return
0
;
/* open failed */
if
(
f
==
NULL
)
return
0
;
/* open failed */
...
@@ -389,7 +392,7 @@ static int loader_Lua (lua_State *L) {
...
@@ -389,7 +392,7 @@ static int loader_Lua (lua_State *L) {
const
char
*
name
=
luaL_checkstring
(
L
,
1
);
const
char
*
name
=
luaL_checkstring
(
L
,
1
);
filename
=
findfile
(
L
,
name
,
"path"
);
filename
=
findfile
(
L
,
name
,
"path"
);
if
(
filename
==
NULL
)
return
1
;
/* library not found in this path */
if
(
filename
==
NULL
)
return
1
;
/* library not found in this path */
#if
0
#if
def LUA_CROSS_COMPILER
if
(
luaL_loadfile
(
L
,
filename
)
!=
0
)
if
(
luaL_loadfile
(
L
,
filename
)
!=
0
)
#else
#else
if
(
luaL_loadfsfile
(
L
,
filename
)
!=
0
)
if
(
luaL_loadfsfile
(
L
,
filename
)
!=
0
)
...
...
app/lua/lobject.c
View file @
307323d1
...
@@ -4,16 +4,15 @@
...
@@ -4,16 +4,15 @@
** See Copyright Notice in lua.h
** See Copyright Notice in lua.h
*/
*/
#include "c_ctype.h"
#include "c_stdarg.h"
#include "c_stdio.h"
#include "c_stdlib.h"
#include "c_string.h"
#define lobject_c
#define lobject_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_STDLIB
#include "ldo.h"
#include "ldo.h"
#include "lmem.h"
#include "lmem.h"
...
@@ -21,9 +20,9 @@
...
@@ -21,9 +20,9 @@
#include "lstate.h"
#include "lstate.h"
#include "lstring.h"
#include "lstring.h"
#include "lvm.h"
#include "lvm.h"
#ifndef LUA_CROSS_COMPILER
#include "flash_api.h"
#include "flash_api.h"
#endif
const
TValue
luaO_nilobject_
=
{
LUA_TVALUE_NIL
};
const
TValue
luaO_nilobject_
=
{
LUA_TVALUE_NIL
};
...
@@ -64,9 +63,11 @@ int luaO_log2 (unsigned int x) {
...
@@ -64,9 +63,11 @@ int luaO_log2 (unsigned int x) {
};
};
int
l
=
-
1
;
int
l
=
-
1
;
while
(
x
>=
256
)
{
l
+=
8
;
x
>>=
8
;
}
while
(
x
>=
256
)
{
l
+=
8
;
x
>>=
8
;
}
// return l + log_2[x];
#ifdef LUA_CROSS_COMPILER
return
l
+
log_2
[
x
];
#else
return
l
+
byte_of_aligned_array
(
log_2
,
x
);
return
l
+
byte_of_aligned_array
(
log_2
,
x
);
#endif
}
}
...
...
app/lua/lobject.h
View file @
307323d1
...
@@ -8,9 +8,11 @@
...
@@ -8,9 +8,11 @@
#ifndef lobject_h
#ifndef lobject_h
#define lobject_h
#define lobject_h
#ifdef LUA_CROSS_COMPILER
#include <stdarg.h>
#else
#include "c_stdarg.h"
#include "c_stdarg.h"
#endif
#include "llimits.h"
#include "llimits.h"
#include "lua.h"
#include "lua.h"
...
...
Prev
1
2
3
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment