summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2014-01-05 12:04:46 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2014-01-05 12:04:46 -0200
commit438c534ff4c8ccad117354826d4ac133b84f2fdc (patch)
treecbb3b2c39cdb3b40587562a348ecb74bc819165b
parent1ea2d20f74cea9c61817d4a5ed67c4fc47cafb51 (diff)
downloadlua-438c534ff4c8ccad117354826d4ac133b84f2fdc.tar.gz
lua-438c534ff4c8ccad117354826d4ac133b84f2fdc.tar.bz2
lua-438c534ff4c8ccad117354826d4ac133b84f2fdc.zip
'arg' arguments (previously called 'narg', 'nArg', 'numArg', etc.)
renamed all to 'arg'
-rw-r--r--lauxlib.c92
-rw-r--r--lauxlib.h30
2 files changed, 61 insertions, 61 deletions
diff --git a/lauxlib.c b/lauxlib.c
index 6a6dd253..035cb06c 100644
--- a/lauxlib.c
+++ b/lauxlib.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lauxlib.c,v 1.254 2013/06/25 14:05:26 roberto Exp roberto $ 2** $Id: lauxlib.c,v 1.255 2013/06/27 18:32:33 roberto Exp roberto $
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*/
@@ -150,33 +150,33 @@ LUALIB_API void luaL_traceback (lua_State *L, lua_State *L1,
150** ======================================================= 150** =======================================================
151*/ 151*/
152 152
153LUALIB_API int luaL_argerror (lua_State *L, int narg, const char *extramsg) { 153LUALIB_API int luaL_argerror (lua_State *L, int arg, const char *extramsg) {
154 lua_Debug ar; 154 lua_Debug ar;
155 if (!lua_getstack(L, 0, &ar)) /* no stack frame? */ 155 if (!lua_getstack(L, 0, &ar)) /* no stack frame? */
156 return luaL_error(L, "bad argument #%d (%s)", narg, extramsg); 156 return luaL_error(L, "bad argument #%d (%s)", arg, extramsg);
157 lua_getinfo(L, "n", &ar); 157 lua_getinfo(L, "n", &ar);
158 if (strcmp(ar.namewhat, "method") == 0) { 158 if (strcmp(ar.namewhat, "method") == 0) {
159 narg--; /* do not count `self' */ 159 arg--; /* do not count `self' */
160 if (narg == 0) /* error is in the self argument itself? */ 160 if (arg == 0) /* error is in the self argument itself? */
161 return luaL_error(L, "calling " LUA_QS " on bad self (%s)", 161 return luaL_error(L, "calling " LUA_QS " on bad self (%s)",
162 ar.name, extramsg); 162 ar.name, extramsg);
163 } 163 }
164 if (ar.name == NULL) 164 if (ar.name == NULL)
165 ar.name = (pushglobalfuncname(L, &ar)) ? lua_tostring(L, -1) : "?"; 165 ar.name = (pushglobalfuncname(L, &ar)) ? lua_tostring(L, -1) : "?";
166 return luaL_error(L, "bad argument #%d to " LUA_QS " (%s)", 166 return luaL_error(L, "bad argument #%d to " LUA_QS " (%s)",
167 narg, ar.name, extramsg); 167 arg, ar.name, extramsg);
168} 168}
169 169
170 170
171static int typeerror (lua_State *L, int narg, const char *tname) { 171static int typeerror (lua_State *L, int arg, const char *tname) {
172 const char *msg = lua_pushfstring(L, "%s expected, got %s", 172 const char *msg = lua_pushfstring(L, "%s expected, got %s",
173 tname, luaL_typename(L, narg)); 173 tname, luaL_typename(L, arg));
174 return luaL_argerror(L, narg, msg); 174 return luaL_argerror(L, arg, msg);
175} 175}
176 176
177 177
178static void tag_error (lua_State *L, int narg, int tag) { 178static void tag_error (lua_State *L, int arg, int tag) {
179 typeerror(L, narg, lua_typename(L, tag)); 179 typeerror(L, arg, lua_typename(L, tag));
180} 180}
181 181
182 182
@@ -317,15 +317,15 @@ LUALIB_API void *luaL_checkudata (lua_State *L, int ud, const char *tname) {
317** ======================================================= 317** =======================================================
318*/ 318*/
319 319
320LUALIB_API int luaL_checkoption (lua_State *L, int narg, const char *def, 320LUALIB_API int luaL_checkoption (lua_State *L, int arg, const char *def,
321 const char *const lst[]) { 321 const char *const lst[]) {
322 const char *name = (def) ? luaL_optstring(L, narg, def) : 322 const char *name = (def) ? luaL_optstring(L, arg, def) :
323 luaL_checkstring(L, narg); 323 luaL_checkstring(L, arg);
324 int i; 324 int i;
325 for (i=0; lst[i]; i++) 325 for (i=0; lst[i]; i++)
326 if (strcmp(lst[i], name) == 0) 326 if (strcmp(lst[i], name) == 0)
327 return i; 327 return i;
328 return luaL_argerror(L, narg, 328 return luaL_argerror(L, arg,
329 lua_pushfstring(L, "invalid option " LUA_QS, name)); 329 lua_pushfstring(L, "invalid option " LUA_QS, name));
330} 330}
331 331
@@ -342,86 +342,86 @@ LUALIB_API void luaL_checkstack (lua_State *L, int space, const char *msg) {
342} 342}
343 343
344 344
345LUALIB_API void luaL_checktype (lua_State *L, int narg, int t) { 345LUALIB_API void luaL_checktype (lua_State *L, int arg, int t) {
346 if (lua_type(L, narg) != t) 346 if (lua_type(L, arg) != t)
347 tag_error(L, narg, t); 347 tag_error(L, arg, t);
348} 348}
349 349
350 350
351LUALIB_API void luaL_checkany (lua_State *L, int narg) { 351LUALIB_API void luaL_checkany (lua_State *L, int arg) {
352 if (lua_type(L, narg) == LUA_TNONE) 352 if (lua_type(L, arg) == LUA_TNONE)
353 luaL_argerror(L, narg, "value expected"); 353 luaL_argerror(L, arg, "value expected");
354} 354}
355 355
356 356
357LUALIB_API const char *luaL_checklstring (lua_State *L, int narg, size_t *len) { 357LUALIB_API const char *luaL_checklstring (lua_State *L, int arg, size_t *len) {
358 const char *s = lua_tolstring(L, narg, len); 358 const char *s = lua_tolstring(L, arg, len);
359 if (!s) tag_error(L, narg, LUA_TSTRING); 359 if (!s) tag_error(L, arg, LUA_TSTRING);
360 return s; 360 return s;
361} 361}
362 362
363 363
364LUALIB_API const char *luaL_optlstring (lua_State *L, int narg, 364LUALIB_API const char *luaL_optlstring (lua_State *L, int arg,
365 const char *def, size_t *len) { 365 const char *def, size_t *len) {
366 if (lua_isnoneornil(L, narg)) { 366 if (lua_isnoneornil(L, arg)) {
367 if (len) 367 if (len)
368 *len = (def ? strlen(def) : 0); 368 *len = (def ? strlen(def) : 0);
369 return def; 369 return def;
370 } 370 }
371 else return luaL_checklstring(L, narg, len); 371 else return luaL_checklstring(L, arg, len);
372} 372}
373 373
374 374
375LUALIB_API lua_Number luaL_checknumber (lua_State *L, int narg) { 375LUALIB_API lua_Number luaL_checknumber (lua_State *L, int arg) {
376 int isnum; 376 int isnum;
377 lua_Number d = lua_tonumberx(L, narg, &isnum); 377 lua_Number d = lua_tonumberx(L, arg, &isnum);
378 if (!isnum) 378 if (!isnum)
379 tag_error(L, narg, LUA_TNUMBER); 379 tag_error(L, arg, LUA_TNUMBER);
380 return d; 380 return d;
381} 381}
382 382
383 383
384LUALIB_API lua_Number luaL_optnumber (lua_State *L, int narg, lua_Number def) { 384LUALIB_API lua_Number luaL_optnumber (lua_State *L, int arg, lua_Number def) {
385 return luaL_opt(L, luaL_checknumber, narg, def); 385 return luaL_opt(L, luaL_checknumber, arg, def);
386} 386}
387 387
388 388
389static void interror (lua_State *L, int narg) { 389static void interror (lua_State *L, int arg) {
390 if (lua_type(L, narg) == LUA_TNUMBER) 390 if (lua_type(L, arg) == LUA_TNUMBER)
391 luaL_argerror(L, narg, "float value out of range"); 391 luaL_argerror(L, arg, "float value out of range");
392 else 392 else
393 tag_error(L, narg, LUA_TNUMBER); 393 tag_error(L, arg, LUA_TNUMBER);
394} 394}
395 395
396 396
397LUALIB_API lua_Integer luaL_checkinteger (lua_State *L, int narg) { 397LUALIB_API lua_Integer luaL_checkinteger (lua_State *L, int arg) {
398 int isnum; 398 int isnum;
399 lua_Integer d = lua_tointegerx(L, narg, &isnum); 399 lua_Integer d = lua_tointegerx(L, arg, &isnum);
400 if (!isnum) { 400 if (!isnum) {
401 interror(L, narg); 401 interror(L, arg);
402 } 402 }
403 return d; 403 return d;
404} 404}
405 405
406 406
407LUALIB_API lua_Unsigned luaL_checkunsigned (lua_State *L, int narg) { 407LUALIB_API lua_Unsigned luaL_checkunsigned (lua_State *L, int arg) {
408 int isnum; 408 int isnum;
409 lua_Unsigned d = lua_tounsignedx(L, narg, &isnum); 409 lua_Unsigned d = lua_tounsignedx(L, arg, &isnum);
410 if (!isnum) 410 if (!isnum)
411 interror(L, narg); 411 interror(L, arg);
412 return d; 412 return d;
413} 413}
414 414
415 415
416LUALIB_API lua_Integer luaL_optinteger (lua_State *L, int narg, 416LUALIB_API lua_Integer luaL_optinteger (lua_State *L, int arg,
417 lua_Integer def) { 417 lua_Integer def) {
418 return luaL_opt(L, luaL_checkinteger, narg, def); 418 return luaL_opt(L, luaL_checkinteger, arg, def);
419} 419}
420 420
421 421
422LUALIB_API lua_Unsigned luaL_optunsigned (lua_State *L, int narg, 422LUALIB_API lua_Unsigned luaL_optunsigned (lua_State *L, int arg,
423 lua_Unsigned def) { 423 lua_Unsigned def) {
424 return luaL_opt(L, luaL_checkunsigned, narg, def); 424 return luaL_opt(L, luaL_checkunsigned, arg, def);
425} 425}
426 426
427/* }====================================================== */ 427/* }====================================================== */
diff --git a/lauxlib.h b/lauxlib.h
index 24a6dbaf..9141aad5 100644
--- a/lauxlib.h
+++ b/lauxlib.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lauxlib.h,v 1.121 2013/06/25 14:05:26 roberto Exp roberto $ 2** $Id: lauxlib.h,v 1.122 2013/06/27 18:32:33 roberto Exp roberto $
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*/
@@ -35,24 +35,24 @@ LUALIB_API void (luaL_checkversion_) (lua_State *L, int ver, size_t sz);
35LUALIB_API int (luaL_getmetafield) (lua_State *L, int obj, const char *e); 35LUALIB_API int (luaL_getmetafield) (lua_State *L, int obj, const char *e);
36LUALIB_API int (luaL_callmeta) (lua_State *L, int obj, const char *e); 36LUALIB_API int (luaL_callmeta) (lua_State *L, int obj, const char *e);
37LUALIB_API const char *(luaL_tolstring) (lua_State *L, int idx, size_t *len); 37LUALIB_API const char *(luaL_tolstring) (lua_State *L, int idx, size_t *len);
38LUALIB_API int (luaL_argerror) (lua_State *L, int numarg, const char *extramsg); 38LUALIB_API int (luaL_argerror) (lua_State *L, int arg, const char *extramsg);
39LUALIB_API const char *(luaL_checklstring) (lua_State *L, int numArg, 39LUALIB_API const char *(luaL_checklstring) (lua_State *L, int arg,
40 size_t *l); 40 size_t *l);
41LUALIB_API const char *(luaL_optlstring) (lua_State *L, int numArg, 41LUALIB_API const char *(luaL_optlstring) (lua_State *L, int arg,
42 const char *def, size_t *l); 42 const char *def, size_t *l);
43LUALIB_API lua_Number (luaL_checknumber) (lua_State *L, int numArg); 43LUALIB_API lua_Number (luaL_checknumber) (lua_State *L, int arg);
44LUALIB_API lua_Number (luaL_optnumber) (lua_State *L, int nArg, lua_Number def); 44LUALIB_API lua_Number (luaL_optnumber) (lua_State *L, int arg, lua_Number def);
45 45
46LUALIB_API lua_Integer (luaL_checkinteger) (lua_State *L, int numArg); 46LUALIB_API lua_Integer (luaL_checkinteger) (lua_State *L, int arg);
47LUALIB_API lua_Integer (luaL_optinteger) (lua_State *L, int nArg, 47LUALIB_API lua_Integer (luaL_optinteger) (lua_State *L, int arg,
48 lua_Integer def); 48 lua_Integer def);
49LUALIB_API lua_Unsigned (luaL_checkunsigned) (lua_State *L, int numArg); 49LUALIB_API lua_Unsigned (luaL_checkunsigned) (lua_State *L, int arg);
50LUALIB_API lua_Unsigned (luaL_optunsigned) (lua_State *L, int numArg, 50LUALIB_API lua_Unsigned (luaL_optunsigned) (lua_State *L, int arg,
51 lua_Unsigned def); 51 lua_Unsigned def);
52 52
53LUALIB_API void (luaL_checkstack) (lua_State *L, int sz, const char *msg); 53LUALIB_API void (luaL_checkstack) (lua_State *L, int sz, const char *msg);
54LUALIB_API void (luaL_checktype) (lua_State *L, int narg, int t); 54LUALIB_API void (luaL_checktype) (lua_State *L, int arg, int t);
55LUALIB_API void (luaL_checkany) (lua_State *L, int narg); 55LUALIB_API void (luaL_checkany) (lua_State *L, int arg);
56 56
57LUALIB_API int (luaL_newmetatable) (lua_State *L, const char *tname); 57LUALIB_API int (luaL_newmetatable) (lua_State *L, const char *tname);
58LUALIB_API void (luaL_setmetatable) (lua_State *L, const char *tname); 58LUALIB_API void (luaL_setmetatable) (lua_State *L, const char *tname);
@@ -62,7 +62,7 @@ LUALIB_API void *(luaL_checkudata) (lua_State *L, int ud, const char *tname);
62LUALIB_API void (luaL_where) (lua_State *L, int lvl); 62LUALIB_API void (luaL_where) (lua_State *L, int lvl);
63LUALIB_API int (luaL_error) (lua_State *L, const char *fmt, ...); 63LUALIB_API int (luaL_error) (lua_State *L, const char *fmt, ...);
64 64
65LUALIB_API int (luaL_checkoption) (lua_State *L, int narg, const char *def, 65LUALIB_API int (luaL_checkoption) (lua_State *L, int arg, const char *def,
66 const char *const lst[]); 66 const char *const lst[]);
67 67
68LUALIB_API int (luaL_fileresult) (lua_State *L, int stat, const char *fname); 68LUALIB_API int (luaL_fileresult) (lua_State *L, int stat, const char *fname);
@@ -114,8 +114,8 @@ LUALIB_API void (luaL_requiref) (lua_State *L, const char *modname,
114#define luaL_newlib(L,l) \ 114#define luaL_newlib(L,l) \
115 (luaL_checkversion(L), luaL_newlibtable(L,l), luaL_setfuncs(L,l,0)) 115 (luaL_checkversion(L), luaL_newlibtable(L,l), luaL_setfuncs(L,l,0))
116 116
117#define luaL_argcheck(L, cond,numarg,extramsg) \ 117#define luaL_argcheck(L, cond,arg,extramsg) \
118 ((void)((cond) || luaL_argerror(L, (numarg), (extramsg)))) 118 ((void)((cond) || luaL_argerror(L, (arg), (extramsg))))
119#define luaL_checkstring(L,n) (luaL_checklstring(L, (n), NULL)) 119#define luaL_checkstring(L,n) (luaL_checklstring(L, (n), NULL))
120#define luaL_optstring(L,n,d) (luaL_optlstring(L, (n), (d), NULL)) 120#define luaL_optstring(L,n,d) (luaL_optlstring(L, (n), (d), NULL))
121#define luaL_checkint(L,n) ((int)luaL_checkinteger(L, (n))) 121#define luaL_checkint(L,n) ((int)luaL_checkinteger(L, (n)))