comparison src/if_lua.c @ 3459:5240610f2778 v7.3.494

updated for version 7.3.494 Problem: Can't compile with Lua 9.1 or dynamic Lua. Solution: Fix dll_ methods. Fix luado(). (Muraoka Taro, Luis Carvalho)
author Bram Moolenaar <bram@vim.org>
date Fri, 06 Apr 2012 14:31:00 +0200
parents b067b8b81be9
children c052f3b79b99
comparison
equal deleted inserted replaced
3458:68817c96c2ac 3459:5240610f2778
93 #define luaL_setfuncs dll_luaL_setfuncs 93 #define luaL_setfuncs dll_luaL_setfuncs
94 #define luaL_loadfilex dll_luaL_loadfilex 94 #define luaL_loadfilex dll_luaL_loadfilex
95 #define luaL_loadbufferx dll_luaL_loadbufferx 95 #define luaL_loadbufferx dll_luaL_loadbufferx
96 #define luaL_argerror dll_luaL_argerror 96 #define luaL_argerror dll_luaL_argerror
97 #endif 97 #endif
98 #define luaL_checkany dll_luaL_checkany
98 #define luaL_checklstring dll_luaL_checklstring 99 #define luaL_checklstring dll_luaL_checklstring
99 #define luaL_checkinteger dll_luaL_checkinteger 100 #define luaL_checkinteger dll_luaL_checkinteger
100 #define luaL_optinteger dll_luaL_optinteger 101 #define luaL_optinteger dll_luaL_optinteger
101 #define luaL_checktype dll_luaL_checktype 102 #define luaL_checktype dll_luaL_checktype
102 #define luaL_error dll_luaL_error 103 #define luaL_error dll_luaL_error
115 #define lua_tointegerx dll_lua_tointegerx 116 #define lua_tointegerx dll_lua_tointegerx
116 #define lua_callk dll_lua_callk 117 #define lua_callk dll_lua_callk
117 #define lua_pcallk dll_lua_pcallk 118 #define lua_pcallk dll_lua_pcallk
118 #define lua_getglobal dll_lua_getglobal 119 #define lua_getglobal dll_lua_getglobal
119 #define lua_setglobal dll_lua_setglobal 120 #define lua_setglobal dll_lua_setglobal
121 #endif
120 #define lua_typename dll_lua_typename 122 #define lua_typename dll_lua_typename
121 #endif
122 #define lua_close dll_lua_close 123 #define lua_close dll_lua_close
123 #define lua_gettop dll_lua_gettop 124 #define lua_gettop dll_lua_gettop
124 #define lua_settop dll_lua_settop 125 #define lua_settop dll_lua_settop
125 #define lua_pushvalue dll_lua_pushvalue 126 #define lua_pushvalue dll_lua_pushvalue
126 #define lua_replace dll_lua_replace 127 #define lua_replace dll_lua_replace
149 #define lua_getmetatable dll_lua_getmetatable 150 #define lua_getmetatable dll_lua_getmetatable
150 #define lua_setfield dll_lua_setfield 151 #define lua_setfield dll_lua_setfield
151 #define lua_rawset dll_lua_rawset 152 #define lua_rawset dll_lua_rawset
152 #define lua_rawseti dll_lua_rawseti 153 #define lua_rawseti dll_lua_rawseti
153 #define lua_setmetatable dll_lua_setmetatable 154 #define lua_setmetatable dll_lua_setmetatable
155 #define lua_next dll_lua_next
154 /* libs */ 156 /* libs */
155 #define luaopen_base dll_luaopen_base 157 #define luaopen_base dll_luaopen_base
156 #define luaopen_table dll_luaopen_table 158 #define luaopen_table dll_luaopen_table
157 #define luaopen_string dll_luaopen_string 159 #define luaopen_string dll_luaopen_string
158 #define luaopen_math dll_luaopen_math 160 #define luaopen_math dll_luaopen_math
175 void (*dll_luaL_setfuncs) (lua_State *L, const luaL_Reg *l, int nup); 177 void (*dll_luaL_setfuncs) (lua_State *L, const luaL_Reg *l, int nup);
176 int (*dll_luaL_loadfilex) (lua_State *L, const char *filename, const char *mode); 178 int (*dll_luaL_loadfilex) (lua_State *L, const char *filename, const char *mode);
177 int (*dll_luaL_loadbufferx) (lua_State *L, const char *buff, size_t sz, const char *name, const char *mode); 179 int (*dll_luaL_loadbufferx) (lua_State *L, const char *buff, size_t sz, const char *name, const char *mode);
178 int (*dll_luaL_argerror) (lua_State *L, int numarg, const char *extramsg); 180 int (*dll_luaL_argerror) (lua_State *L, int numarg, const char *extramsg);
179 #endif 181 #endif
182 void (*dll_luaL_checkany) (lua_State *L, int narg);
180 const char *(*dll_luaL_checklstring) (lua_State *L, int numArg, size_t *l); 183 const char *(*dll_luaL_checklstring) (lua_State *L, int numArg, size_t *l);
181 lua_Integer (*dll_luaL_checkinteger) (lua_State *L, int numArg); 184 lua_Integer (*dll_luaL_checkinteger) (lua_State *L, int numArg);
182 lua_Integer (*dll_luaL_optinteger) (lua_State *L, int nArg, lua_Integer def); 185 lua_Integer (*dll_luaL_optinteger) (lua_State *L, int nArg, lua_Integer def);
183 void (*dll_luaL_checktype) (lua_State *L, int narg, int t); 186 void (*dll_luaL_checktype) (lua_State *L, int narg, int t);
184 int (*dll_luaL_error) (lua_State *L, const char *fmt, ...); 187 int (*dll_luaL_error) (lua_State *L, const char *fmt, ...);
199 lua_CFunction k); 202 lua_CFunction k);
200 int (*dll_lua_pcallk) (lua_State *L, int nargs, int nresults, int errfunc, 203 int (*dll_lua_pcallk) (lua_State *L, int nargs, int nresults, int errfunc,
201 int ctx, lua_CFunction k); 204 int ctx, lua_CFunction k);
202 void (*dll_lua_getglobal) (lua_State *L, const char *var); 205 void (*dll_lua_getglobal) (lua_State *L, const char *var);
203 void (*dll_lua_setglobal) (lua_State *L, const char *var); 206 void (*dll_lua_setglobal) (lua_State *L, const char *var);
207 #endif
204 const char *(*dll_lua_typename) (lua_State *L, int tp); 208 const char *(*dll_lua_typename) (lua_State *L, int tp);
205 #endif
206 void (*dll_lua_close) (lua_State *L); 209 void (*dll_lua_close) (lua_State *L);
207 int (*dll_lua_gettop) (lua_State *L); 210 int (*dll_lua_gettop) (lua_State *L);
208 void (*dll_lua_settop) (lua_State *L, int idx); 211 void (*dll_lua_settop) (lua_State *L, int idx);
209 void (*dll_lua_pushvalue) (lua_State *L, int idx); 212 void (*dll_lua_pushvalue) (lua_State *L, int idx);
210 void (*dll_lua_replace) (lua_State *L, int idx); 213 void (*dll_lua_replace) (lua_State *L, int idx);
233 int (*dll_lua_getmetatable) (lua_State *L, int objindex); 236 int (*dll_lua_getmetatable) (lua_State *L, int objindex);
234 void (*dll_lua_setfield) (lua_State *L, int idx, const char *k); 237 void (*dll_lua_setfield) (lua_State *L, int idx, const char *k);
235 void (*dll_lua_rawset) (lua_State *L, int idx); 238 void (*dll_lua_rawset) (lua_State *L, int idx);
236 void (*dll_lua_rawseti) (lua_State *L, int idx, int n); 239 void (*dll_lua_rawseti) (lua_State *L, int idx, int n);
237 int (*dll_lua_setmetatable) (lua_State *L, int objindex); 240 int (*dll_lua_setmetatable) (lua_State *L, int objindex);
241 int (*dll_lua_next) (lua_State *L, int idx);
238 /* libs */ 242 /* libs */
239 int (*dll_luaopen_base) (lua_State *L); 243 int (*dll_luaopen_base) (lua_State *L);
240 int (*dll_luaopen_table) (lua_State *L); 244 int (*dll_luaopen_table) (lua_State *L);
241 int (*dll_luaopen_string) (lua_State *L); 245 int (*dll_luaopen_string) (lua_State *L);
242 int (*dll_luaopen_math) (lua_State *L); 246 int (*dll_luaopen_math) (lua_State *L);
266 {"luaL_setfuncs", (luaV_function) &dll_luaL_setfuncs}, 270 {"luaL_setfuncs", (luaV_function) &dll_luaL_setfuncs},
267 {"luaL_loadfilex", (luaV_function) &dll_luaL_loadfilex}, 271 {"luaL_loadfilex", (luaV_function) &dll_luaL_loadfilex},
268 {"luaL_loadbufferx", (luaV_function) &dll_luaL_loadbufferx}, 272 {"luaL_loadbufferx", (luaV_function) &dll_luaL_loadbufferx},
269 {"luaL_argerror", (luaV_function) &dll_luaL_argerror}, 273 {"luaL_argerror", (luaV_function) &dll_luaL_argerror},
270 #endif 274 #endif
275 {"luaL_checkany", (luaV_function) &dll_luaL_checkany},
271 {"luaL_checklstring", (luaV_function) &dll_luaL_checklstring}, 276 {"luaL_checklstring", (luaV_function) &dll_luaL_checklstring},
272 {"luaL_checkinteger", (luaV_function) &dll_luaL_checkinteger}, 277 {"luaL_checkinteger", (luaV_function) &dll_luaL_checkinteger},
273 {"luaL_optinteger", (luaV_function) &dll_luaL_optinteger}, 278 {"luaL_optinteger", (luaV_function) &dll_luaL_optinteger},
274 {"luaL_checktype", (luaV_function) &dll_luaL_checktype}, 279 {"luaL_checktype", (luaV_function) &dll_luaL_checktype},
275 {"luaL_error", (luaV_function) &dll_luaL_error}, 280 {"luaL_error", (luaV_function) &dll_luaL_error},
288 {"lua_tointegerx", (luaV_function) &dll_lua_tointegerx}, 293 {"lua_tointegerx", (luaV_function) &dll_lua_tointegerx},
289 {"lua_callk", (luaV_function) &dll_lua_callk}, 294 {"lua_callk", (luaV_function) &dll_lua_callk},
290 {"lua_pcallk", (luaV_function) &dll_lua_pcallk}, 295 {"lua_pcallk", (luaV_function) &dll_lua_pcallk},
291 {"lua_getglobal", (luaV_function) &dll_lua_getglobal}, 296 {"lua_getglobal", (luaV_function) &dll_lua_getglobal},
292 {"lua_setglobal", (luaV_function) &dll_lua_setglobal}, 297 {"lua_setglobal", (luaV_function) &dll_lua_setglobal},
298 #endif
293 {"lua_typename", (luaV_function) &dll_lua_typename}, 299 {"lua_typename", (luaV_function) &dll_lua_typename},
294 #endif
295 {"lua_close", (luaV_function) &dll_lua_close}, 300 {"lua_close", (luaV_function) &dll_lua_close},
296 {"lua_gettop", (luaV_function) &dll_lua_gettop}, 301 {"lua_gettop", (luaV_function) &dll_lua_gettop},
297 {"lua_settop", (luaV_function) &dll_lua_settop}, 302 {"lua_settop", (luaV_function) &dll_lua_settop},
298 {"lua_pushvalue", (luaV_function) &dll_lua_pushvalue}, 303 {"lua_pushvalue", (luaV_function) &dll_lua_pushvalue},
299 {"lua_replace", (luaV_function) &dll_lua_replace}, 304 {"lua_replace", (luaV_function) &dll_lua_replace},
322 {"lua_getmetatable", (luaV_function) &dll_lua_getmetatable}, 327 {"lua_getmetatable", (luaV_function) &dll_lua_getmetatable},
323 {"lua_setfield", (luaV_function) &dll_lua_setfield}, 328 {"lua_setfield", (luaV_function) &dll_lua_setfield},
324 {"lua_rawset", (luaV_function) &dll_lua_rawset}, 329 {"lua_rawset", (luaV_function) &dll_lua_rawset},
325 {"lua_rawseti", (luaV_function) &dll_lua_rawseti}, 330 {"lua_rawseti", (luaV_function) &dll_lua_rawseti},
326 {"lua_setmetatable", (luaV_function) &dll_lua_setmetatable}, 331 {"lua_setmetatable", (luaV_function) &dll_lua_setmetatable},
332 {"lua_next", (luaV_function) &dll_lua_next},
327 /* libs */ 333 /* libs */
328 {"luaopen_base", (luaV_function) &dll_luaopen_base}, 334 {"luaopen_base", (luaV_function) &dll_luaopen_base},
329 {"luaopen_table", (luaV_function) &dll_luaopen_table}, 335 {"luaopen_table", (luaV_function) &dll_luaopen_table},
330 {"luaopen_string", (luaV_function) &dll_luaopen_string}, 336 {"luaopen_string", (luaV_function) &dll_luaopen_string},
331 {"luaopen_math", (luaV_function) &dll_luaopen_math}, 337 {"luaopen_math", (luaV_function) &dll_luaopen_math},
1826 EMSG(_("cannot save undo information")); 1832 EMSG(_("cannot save undo information"));
1827 return; 1833 return;
1828 } 1834 }
1829 luaV_setrange(L, eap->line1, eap->line2); 1835 luaV_setrange(L, eap->line1, eap->line2);
1830 luaL_buffinit(L, &b); 1836 luaL_buffinit(L, &b);
1831 luaL_addlstring(&b, "return function(line) ", 22); /* header */ 1837 luaL_addlstring(&b, "return function(line, linenr) ", 30); /* header */
1832 luaL_addlstring(&b, s, strlen(s)); 1838 luaL_addlstring(&b, s, strlen(s));
1833 luaL_addlstring(&b, " end", 4); /* footer */ 1839 luaL_addlstring(&b, " end", 4); /* footer */
1834 luaL_pushresult(&b); 1840 luaL_pushresult(&b);
1835 s = lua_tolstring(L, -1, &len); 1841 s = lua_tolstring(L, -1, &len);
1836 if (luaL_loadbuffer(L, s, len, LUAVIM_CHUNKNAME)) 1842 if (luaL_loadbuffer(L, s, len, LUAVIM_CHUNKNAME))
1843 lua_replace(L, -2); /* function -> body */ 1849 lua_replace(L, -2); /* function -> body */
1844 for (l = eap->line1; l <= eap->line2; l++) 1850 for (l = eap->line1; l <= eap->line2; l++)
1845 { 1851 {
1846 lua_pushvalue(L, -1); /* function */ 1852 lua_pushvalue(L, -1); /* function */
1847 luaV_pushline(L, curbuf, l); /* current line as arg */ 1853 luaV_pushline(L, curbuf, l); /* current line as arg */
1848 if (lua_pcall(L, 1, 1, 0)) 1854 lua_pushinteger(L, l); /* current line number as arg */
1855 if (lua_pcall(L, 2, 1, 0))
1849 { 1856 {
1850 luaV_emsg(L); 1857 luaV_emsg(L);
1851 break; 1858 break;
1852 } 1859 }
1853 if (lua_isstring(L, -1)) /* update line? */ 1860 if (lua_isstring(L, -1)) /* update line? */