diff options
author | Marcin Bukat <marcin.bukat@gmail.com> | 2014-04-02 20:46:06 +0200 |
---|---|---|
committer | Marcin Bukat <marcin.bukat@gmail.com> | 2014-04-02 20:46:06 +0200 |
commit | bfd0179042b0b02fb88748d54e56e7e208bb117f (patch) | |
tree | 42d5fd51574054caaf673420fca1ec962d62d2f2 /apps/plugins/lua/lauxlib.h | |
parent | 36378988ad4059982742f05f5eb50580b456840a (diff) | |
download | rockbox-bfd0179042b0b02fb88748d54e56e7e208bb117f.tar.gz rockbox-bfd0179042b0b02fb88748d54e56e7e208bb117f.zip |
Revert "Update lua plugin to 5.2.3"
FILE typedef to *void needs more work to not break sim and
application builds. I checked only a few random native builds
unfortunately. Sorry for inconvenience.
Diffstat (limited to 'apps/plugins/lua/lauxlib.h')
-rw-r--r-- | apps/plugins/lua/lauxlib.h | 130 |
1 files changed, 48 insertions, 82 deletions
diff --git a/apps/plugins/lua/lauxlib.h b/apps/plugins/lua/lauxlib.h index 0fb023b8e7..a36de351fe 100644 --- a/apps/plugins/lua/lauxlib.h +++ b/apps/plugins/lua/lauxlib.h | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lauxlib.h,v 1.120.1.1 2013/04/12 18:48:47 roberto Exp $ | 2 | ** $Id$ |
3 | ** Auxiliary functions for building Lua libraries | 3 | ** Auxiliary functions for building Lua libraries |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -15,6 +15,18 @@ | |||
15 | #include "lua.h" | 15 | #include "lua.h" |
16 | 16 | ||
17 | 17 | ||
18 | #if defined(LUA_COMPAT_GETN) | ||
19 | LUALIB_API int (luaL_getn) (lua_State *L, int t); | ||
20 | LUALIB_API void (luaL_setn) (lua_State *L, int t, int n); | ||
21 | #else | ||
22 | #define luaL_getn(L,i) ((int)lua_objlen(L, i)) | ||
23 | #define luaL_setn(L,i,j) ((void)0) /* no op! */ | ||
24 | #endif | ||
25 | |||
26 | #if defined(LUA_COMPAT_OPENLIB) | ||
27 | #define luaI_openlib luaL_openlib | ||
28 | #endif | ||
29 | |||
18 | 30 | ||
19 | /* extra error code for `luaL_load' */ | 31 | /* extra error code for `luaL_load' */ |
20 | #define LUA_ERRFILE (LUA_ERRERR+1) | 32 | #define LUA_ERRFILE (LUA_ERRERR+1) |
@@ -26,12 +38,14 @@ typedef struct luaL_Reg { | |||
26 | } luaL_Reg; | 38 | } luaL_Reg; |
27 | 39 | ||
28 | 40 | ||
29 | LUALIB_API void (luaL_checkversion_) (lua_State *L, lua_Number ver); | ||
30 | #define luaL_checkversion(L) luaL_checkversion_(L, LUA_VERSION_NUM) | ||
31 | 41 | ||
42 | LUALIB_API void (luaI_openlib) (lua_State *L, const char *libname, | ||
43 | const luaL_Reg *l, int nup); | ||
44 | LUALIB_API void (luaL_register) (lua_State *L, const char *libname, | ||
45 | const luaL_Reg *l); | ||
32 | LUALIB_API int (luaL_getmetafield) (lua_State *L, int obj, const char *e); | 46 | LUALIB_API int (luaL_getmetafield) (lua_State *L, int obj, const char *e); |
33 | LUALIB_API int (luaL_callmeta) (lua_State *L, int obj, const char *e); | 47 | LUALIB_API int (luaL_callmeta) (lua_State *L, int obj, const char *e); |
34 | LUALIB_API const char *(luaL_tolstring) (lua_State *L, int idx, size_t *len); | 48 | LUALIB_API int (luaL_typerror) (lua_State *L, int narg, const char *tname); |
35 | LUALIB_API int (luaL_argerror) (lua_State *L, int numarg, const char *extramsg); | 49 | LUALIB_API int (luaL_argerror) (lua_State *L, int numarg, const char *extramsg); |
36 | LUALIB_API const char *(luaL_checklstring) (lua_State *L, int numArg, | 50 | LUALIB_API const char *(luaL_checklstring) (lua_State *L, int numArg, |
37 | size_t *l); | 51 | size_t *l); |
@@ -43,17 +57,16 @@ LUALIB_API lua_Number (luaL_optnumber) (lua_State *L, int nArg, lua_Number def); | |||
43 | LUALIB_API lua_Integer (luaL_checkinteger) (lua_State *L, int numArg); | 57 | LUALIB_API lua_Integer (luaL_checkinteger) (lua_State *L, int numArg); |
44 | LUALIB_API lua_Integer (luaL_optinteger) (lua_State *L, int nArg, | 58 | LUALIB_API lua_Integer (luaL_optinteger) (lua_State *L, int nArg, |
45 | lua_Integer def); | 59 | lua_Integer def); |
46 | LUALIB_API lua_Unsigned (luaL_checkunsigned) (lua_State *L, int numArg); | 60 | |
47 | LUALIB_API lua_Unsigned (luaL_optunsigned) (lua_State *L, int numArg, | 61 | LUALIB_API int (luaL_checkboolean) (lua_State *L, int numArg); |
48 | lua_Unsigned def); | 62 | LUALIB_API int (luaL_optboolean) (lua_State *L, int nArg, |
63 | int def); | ||
49 | 64 | ||
50 | LUALIB_API void (luaL_checkstack) (lua_State *L, int sz, const char *msg); | 65 | LUALIB_API void (luaL_checkstack) (lua_State *L, int sz, const char *msg); |
51 | LUALIB_API void (luaL_checktype) (lua_State *L, int narg, int t); | 66 | LUALIB_API void (luaL_checktype) (lua_State *L, int narg, int t); |
52 | LUALIB_API void (luaL_checkany) (lua_State *L, int narg); | 67 | LUALIB_API void (luaL_checkany) (lua_State *L, int narg); |
53 | 68 | ||
54 | LUALIB_API int (luaL_newmetatable) (lua_State *L, const char *tname); | 69 | LUALIB_API int (luaL_newmetatable) (lua_State *L, const char *tname); |
55 | LUALIB_API void (luaL_setmetatable) (lua_State *L, const char *tname); | ||
56 | LUALIB_API void *(luaL_testudata) (lua_State *L, int ud, const char *tname); | ||
57 | LUALIB_API void *(luaL_checkudata) (lua_State *L, int ud, const char *tname); | 70 | LUALIB_API void *(luaL_checkudata) (lua_State *L, int ud, const char *tname); |
58 | 71 | ||
59 | LUALIB_API void (luaL_where) (lua_State *L, int lvl); | 72 | LUALIB_API void (luaL_where) (lua_State *L, int lvl); |
@@ -62,41 +75,25 @@ LUALIB_API int (luaL_error) (lua_State *L, const char *fmt, ...); | |||
62 | LUALIB_API int (luaL_checkoption) (lua_State *L, int narg, const char *def, | 75 | LUALIB_API int (luaL_checkoption) (lua_State *L, int narg, const char *def, |
63 | const char *const lst[]); | 76 | const char *const lst[]); |
64 | 77 | ||
65 | LUALIB_API int (luaL_fileresult) (lua_State *L, int stat, const char *fname); | ||
66 | LUALIB_API int (luaL_execresult) (lua_State *L, int stat); | ||
67 | |||
68 | /* pre-defined references */ | ||
69 | #define LUA_NOREF (-2) | ||
70 | #define LUA_REFNIL (-1) | ||
71 | |||
72 | LUALIB_API int (luaL_ref) (lua_State *L, int t); | 78 | LUALIB_API int (luaL_ref) (lua_State *L, int t); |
73 | LUALIB_API void (luaL_unref) (lua_State *L, int t, int ref); | 79 | LUALIB_API void (luaL_unref) (lua_State *L, int t, int ref); |
74 | 80 | ||
75 | LUALIB_API int (luaL_loadfilex) (lua_State *L, const char *filename, | 81 | LUALIB_API int (luaL_loadfile) (lua_State *L, const char *filename); |
76 | const char *mode); | 82 | LUALIB_API int (luaL_loadbuffer) (lua_State *L, const char *buff, size_t sz, |
77 | 83 | const char *name); | |
78 | #define luaL_loadfile(L,f) luaL_loadfilex(L,f,NULL) | ||
79 | |||
80 | LUALIB_API int (luaL_loadbufferx) (lua_State *L, const char *buff, size_t sz, | ||
81 | const char *name, const char *mode); | ||
82 | LUALIB_API int (luaL_loadstring) (lua_State *L, const char *s); | 84 | LUALIB_API int (luaL_loadstring) (lua_State *L, const char *s); |
83 | 85 | ||
84 | LUALIB_API lua_State *(luaL_newstate) (void); | 86 | LUALIB_API lua_State *(luaL_newstate) (void); |
85 | 87 | ||
86 | LUALIB_API int (luaL_len) (lua_State *L, int idx); | ||
87 | 88 | ||
88 | LUALIB_API const char *(luaL_gsub) (lua_State *L, const char *s, const char *p, | 89 | LUALIB_API const char *(luaL_gsub) (lua_State *L, const char *s, const char *p, |
89 | const char *r); | 90 | const char *r); |
90 | 91 | ||
91 | LUALIB_API void (luaL_setfuncs) (lua_State *L, const luaL_Reg *l, int nup); | 92 | LUALIB_API const char *(luaL_findtable) (lua_State *L, int idx, |
93 | const char *fname, int szhint); | ||
92 | 94 | ||
93 | LUALIB_API int (luaL_getsubtable) (lua_State *L, int idx, const char *fname); | ||
94 | 95 | ||
95 | LUALIB_API void (luaL_traceback) (lua_State *L, lua_State *L1, | ||
96 | const char *msg, int level); | ||
97 | 96 | ||
98 | LUALIB_API void (luaL_requiref) (lua_State *L, const char *modname, | ||
99 | lua_CFunction openf, int glb); | ||
100 | 97 | ||
101 | /* | 98 | /* |
102 | ** =============================================================== | 99 | ** =============================================================== |
@@ -104,12 +101,6 @@ LUALIB_API void (luaL_requiref) (lua_State *L, const char *modname, | |||
104 | ** =============================================================== | 101 | ** =============================================================== |
105 | */ | 102 | */ |
106 | 103 | ||
107 | |||
108 | #define luaL_newlibtable(L,l) \ | ||
109 | lua_createtable(L, 0, sizeof(l)/sizeof((l)[0]) - 1) | ||
110 | |||
111 | #define luaL_newlib(L,l) (luaL_newlibtable(L,l), luaL_setfuncs(L,l,0)) | ||
112 | |||
113 | #define luaL_argcheck(L, cond,numarg,extramsg) \ | 104 | #define luaL_argcheck(L, cond,numarg,extramsg) \ |
114 | ((void)((cond) || luaL_argerror(L, (numarg), (extramsg)))) | 105 | ((void)((cond) || luaL_argerror(L, (numarg), (extramsg)))) |
115 | #define luaL_checkstring(L,n) (luaL_checklstring(L, (n), NULL)) | 106 | #define luaL_checkstring(L,n) (luaL_checklstring(L, (n), NULL)) |
@@ -131,81 +122,56 @@ LUALIB_API void (luaL_requiref) (lua_State *L, const char *modname, | |||
131 | 122 | ||
132 | #define luaL_opt(L,f,n,d) (lua_isnoneornil(L,(n)) ? (d) : f(L,(n))) | 123 | #define luaL_opt(L,f,n,d) (lua_isnoneornil(L,(n)) ? (d) : f(L,(n))) |
133 | 124 | ||
134 | #define luaL_loadbuffer(L,s,sz,n) luaL_loadbufferx(L,s,sz,n,NULL) | ||
135 | |||
136 | |||
137 | /* | 125 | /* |
138 | ** {====================================================== | 126 | ** {====================================================== |
139 | ** Generic Buffer manipulation | 127 | ** Generic Buffer manipulation |
140 | ** ======================================================= | 128 | ** ======================================================= |
141 | */ | 129 | */ |
142 | 130 | ||
131 | |||
132 | |||
143 | typedef struct luaL_Buffer { | 133 | typedef struct luaL_Buffer { |
144 | char *b; /* buffer address */ | 134 | char *p; /* current position in buffer */ |
145 | size_t size; /* buffer size */ | 135 | int lvl; /* number of strings in the stack (level) */ |
146 | size_t n; /* number of characters in buffer */ | ||
147 | lua_State *L; | 136 | lua_State *L; |
148 | char initb[LUAL_BUFFERSIZE]; /* initial buffer */ | 137 | char buffer[LUAL_BUFFERSIZE]; |
149 | } luaL_Buffer; | 138 | } luaL_Buffer; |
150 | 139 | ||
151 | |||
152 | #define luaL_addchar(B,c) \ | 140 | #define luaL_addchar(B,c) \ |
153 | ((void)((B)->n < (B)->size || luaL_prepbuffsize((B), 1)), \ | 141 | ((void)((B)->p < ((B)->buffer+LUAL_BUFFERSIZE) || luaL_prepbuffer(B)), \ |
154 | ((B)->b[(B)->n++] = (c))) | 142 | (*(B)->p++ = (char)(c))) |
155 | 143 | ||
156 | #define luaL_addsize(B,s) ((B)->n += (s)) | 144 | /* compatibility only */ |
145 | #define luaL_putchar(B,c) luaL_addchar(B,c) | ||
146 | |||
147 | #define luaL_addsize(B,n) ((B)->p += (n)) | ||
157 | 148 | ||
158 | LUALIB_API void (luaL_buffinit) (lua_State *L, luaL_Buffer *B); | 149 | LUALIB_API void (luaL_buffinit) (lua_State *L, luaL_Buffer *B); |
159 | LUALIB_API char *(luaL_prepbuffsize) (luaL_Buffer *B, size_t sz); | 150 | LUALIB_API char *(luaL_prepbuffer) (luaL_Buffer *B); |
160 | LUALIB_API void (luaL_addlstring) (luaL_Buffer *B, const char *s, size_t l); | 151 | LUALIB_API void (luaL_addlstring) (luaL_Buffer *B, const char *s, size_t l); |
161 | LUALIB_API void (luaL_addstring) (luaL_Buffer *B, const char *s); | 152 | LUALIB_API void (luaL_addstring) (luaL_Buffer *B, const char *s); |
162 | LUALIB_API void (luaL_addvalue) (luaL_Buffer *B); | 153 | LUALIB_API void (luaL_addvalue) (luaL_Buffer *B); |
163 | LUALIB_API void (luaL_pushresult) (luaL_Buffer *B); | 154 | LUALIB_API void (luaL_pushresult) (luaL_Buffer *B); |
164 | LUALIB_API void (luaL_pushresultsize) (luaL_Buffer *B, size_t sz); | ||
165 | LUALIB_API char *(luaL_buffinitsize) (lua_State *L, luaL_Buffer *B, size_t sz); | ||
166 | 155 | ||
167 | #define luaL_prepbuffer(B) luaL_prepbuffsize(B, LUAL_BUFFERSIZE) | ||
168 | 156 | ||
169 | /* }====================================================== */ | 157 | /* }====================================================== */ |
170 | 158 | ||
171 | 159 | ||
160 | /* compatibility with ref system */ | ||
172 | 161 | ||
173 | /* | 162 | /* pre-defined references */ |
174 | ** {====================================================== | 163 | #define LUA_NOREF (-2) |
175 | ** File handles for IO library | 164 | #define LUA_REFNIL (-1) |
176 | ** ======================================================= | ||
177 | */ | ||
178 | |||
179 | /* | ||
180 | ** A file handle is a userdata with metatable 'LUA_FILEHANDLE' and | ||
181 | ** initial structure 'luaL_Stream' (it may contain other fields | ||
182 | ** after that initial structure). | ||
183 | */ | ||
184 | |||
185 | #define LUA_FILEHANDLE "FILE*" | ||
186 | |||
187 | |||
188 | typedef struct luaL_Stream { | ||
189 | FILE *f; /* stream (NULL for incompletely created streams) */ | ||
190 | lua_CFunction closef; /* to close stream (NULL for closed streams) */ | ||
191 | } luaL_Stream; | ||
192 | |||
193 | /* }====================================================== */ | ||
194 | |||
195 | |||
196 | 165 | ||
197 | /* compatibility with old module system */ | 166 | #define lua_ref(L,lock) ((lock) ? luaL_ref(L, LUA_REGISTRYINDEX) : \ |
198 | #if defined(LUA_COMPAT_MODULE) | 167 | (lua_pushstring(L, "unlocked references are obsolete"), lua_error(L), 0)) |
199 | 168 | ||
200 | LUALIB_API void (luaL_pushmodule) (lua_State *L, const char *modname, | 169 | #define lua_unref(L,ref) luaL_unref(L, LUA_REGISTRYINDEX, (ref)) |
201 | int sizehint); | ||
202 | LUALIB_API void (luaL_openlib) (lua_State *L, const char *libname, | ||
203 | const luaL_Reg *l, int nup); | ||
204 | 170 | ||
205 | #define luaL_register(L,n,l) (luaL_openlib(L,(n),(l),0)) | 171 | #define lua_getref(L,ref) lua_rawgeti(L, LUA_REGISTRYINDEX, (ref)) |
206 | 172 | ||
207 | #endif | ||
208 | 173 | ||
174 | #define luaL_reg luaL_Reg | ||
209 | 175 | ||
210 | #endif | 176 | #endif |
211 | 177 | ||