forked from len0rd/rockbox
lua disable bytecode dump & undump functions
Adds a flag to remove the ability to dump and load lua bytecode saves 6+kb Change-Id: I080323df7f03f752e0a10928e22a7ce3190a9633
This commit is contained in:
parent
d5908f520e
commit
8bd992c503
4 changed files with 33 additions and 5 deletions
|
@ -15,6 +15,8 @@
|
||||||
#include "lstate.h"
|
#include "lstate.h"
|
||||||
#include "lundump.h"
|
#include "lundump.h"
|
||||||
|
|
||||||
|
#ifndef LUA_DISABLE_BYTECODE
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
lua_State* L;
|
lua_State* L;
|
||||||
lua_Writer writer;
|
lua_Writer writer;
|
||||||
|
@ -162,3 +164,14 @@ int luaU_dump (lua_State* L, const Proto* f, lua_Writer w, void* data, int strip
|
||||||
DumpFunction(f,NULL,&D);
|
DumpFunction(f,NULL,&D);
|
||||||
return D.status;
|
return D.status;
|
||||||
}
|
}
|
||||||
|
#else /* LUA_DISABLE_BYTECODE */
|
||||||
|
#include "lauxlib.h"
|
||||||
|
int luaU_dump (lua_State* L, const Proto* f, lua_Writer w, void* data, int strip)
|
||||||
|
{
|
||||||
|
(void) f;
|
||||||
|
(void) w;
|
||||||
|
(void) data;
|
||||||
|
(void) strip;
|
||||||
|
return luaL_error(L, " bytecode not supported");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
|
@ -797,7 +797,7 @@ extern long rb_pow(long, long);
|
||||||
#undef LUA_COMPAT_GFIND
|
#undef LUA_COMPAT_GFIND
|
||||||
#undef LUA_COMPAT_OPENLIB
|
#undef LUA_COMPAT_OPENLIB
|
||||||
|
|
||||||
/* Resize heap allocated buffers */
|
/* Resize [STACK] allocated buffers */
|
||||||
#undef LUAI_MAXVARS /*200*/
|
#undef LUAI_MAXVARS /*200*/
|
||||||
#define LUAI_MAXVARS 100
|
#define LUAI_MAXVARS 100
|
||||||
|
|
||||||
|
@ -811,6 +811,6 @@ extern long rb_pow(long, long);
|
||||||
#include "rockconf.h"
|
#include "rockconf.h"
|
||||||
|
|
||||||
/*else*/
|
/*else*/
|
||||||
#define LUAC_TRUST_BINARIES
|
#define LUA_DISABLE_BYTECODE
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -20,6 +20,8 @@
|
||||||
#include "lundump.h"
|
#include "lundump.h"
|
||||||
#include "lzio.h"
|
#include "lzio.h"
|
||||||
|
|
||||||
|
#ifndef LUA_DISABLE_BYTECODE
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
lua_State* L;
|
lua_State* L;
|
||||||
ZIO* Z;
|
ZIO* Z;
|
||||||
|
@ -225,3 +227,14 @@ void luaU_header (char* h)
|
||||||
*h++=(char)sizeof(lua_Number);
|
*h++=(char)sizeof(lua_Number);
|
||||||
*h++=(char)(((lua_Number)0.5)==0); /* is lua_Number integral? */
|
*h++=(char)(((lua_Number)0.5)==0); /* is lua_Number integral? */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#else /* LUA_DISABLE_BYTECODE */
|
||||||
|
#include "lauxlib.h"
|
||||||
|
Proto* luaU_undump (lua_State* L, ZIO* Z, Mbuffer* buff, const char* name)
|
||||||
|
{
|
||||||
|
(void) Z;
|
||||||
|
(void) buff;
|
||||||
|
luaL_error(L, LUA_QL("%s") " bytecode not supported", name);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
|
@ -13,12 +13,13 @@
|
||||||
/* load one chunk; from lundump.c */
|
/* load one chunk; from lundump.c */
|
||||||
LUAI_FUNC Proto* luaU_undump (lua_State* L, ZIO* Z, Mbuffer* buff, const char* name);
|
LUAI_FUNC Proto* luaU_undump (lua_State* L, ZIO* Z, Mbuffer* buff, const char* name);
|
||||||
|
|
||||||
/* make header; from lundump.c */
|
|
||||||
LUAI_FUNC void luaU_header (char* h);
|
|
||||||
|
|
||||||
/* dump one chunk; from ldump.c */
|
/* dump one chunk; from ldump.c */
|
||||||
LUAI_FUNC int luaU_dump (lua_State* L, const Proto* f, lua_Writer w, void* data, int strip);
|
LUAI_FUNC int luaU_dump (lua_State* L, const Proto* f, lua_Writer w, void* data, int strip);
|
||||||
|
|
||||||
|
#ifndef LUA_DISABLE_BYTECODE
|
||||||
|
/* make header; from lundump.c */
|
||||||
|
LUAI_FUNC void luaU_header (char* h);
|
||||||
|
|
||||||
#ifdef luac_c
|
#ifdef luac_c
|
||||||
/* print one chunk; from print.c */
|
/* print one chunk; from print.c */
|
||||||
LUAI_FUNC void luaU_print (const Proto* f, int full);
|
LUAI_FUNC void luaU_print (const Proto* f, int full);
|
||||||
|
@ -33,4 +34,5 @@ LUAI_FUNC void luaU_print (const Proto* f, int full);
|
||||||
/* size of header of binary files */
|
/* size of header of binary files */
|
||||||
#define LUAC_HEADERSIZE 12
|
#define LUAC_HEADERSIZE 12
|
||||||
|
|
||||||
|
#endif /* LUA_DISABLE_BYTECODE */
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue