aboutsummaryrefslogtreecommitdiff
path: root/lapi.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2018-02-26 11:16:05 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2018-02-26 11:16:05 -0300
commitef8263f81fdde2310ebb15c9a3fe5e954d57cab5 (patch)
tree8532d24bcfc4c59212616bdae1b25f087f1eb179 /lapi.c
parent2952bc5fc9cdc05ed061539cb7be26899513f004 (diff)
downloadlua-ef8263f81fdde2310ebb15c9a3fe5e954d57cab5.tar.gz
lua-ef8263f81fdde2310ebb15c9a3fe5e954d57cab5.tar.bz2
lua-ef8263f81fdde2310ebb15c9a3fe5e954d57cab5.zip
better names for macros for tags and types.
rttype -> rawtt; ttyperaw -> withvariant; ttype -> ttypetag; tnov -> ttype
Diffstat (limited to 'lapi.c')
-rw-r--r--lapi.c32
1 files changed, 16 insertions, 16 deletions
diff --git a/lapi.c b/lapi.c
index b6c52721..92e98def 100644
--- a/lapi.c
+++ b/lapi.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lapi.c,v 2.286 2018/02/23 13:13:31 roberto Exp roberto $ 2** $Id: lapi.c,v 2.287 2018/02/25 12:48:16 roberto Exp roberto $
3** Lua API 3** Lua API
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -257,7 +257,7 @@ LUA_API void lua_pushvalue (lua_State *L, int idx) {
257 257
258LUA_API int lua_type (lua_State *L, int idx) { 258LUA_API int lua_type (lua_State *L, int idx) {
259 const TValue *o = index2value(L, idx); 259 const TValue *o = index2value(L, idx);
260 return (isvalid(o) ? ttnov(o) : LUA_TNONE); 260 return (isvalid(o) ? ttype(o) : LUA_TNONE);
261} 261}
262 262
263 263
@@ -399,7 +399,7 @@ LUA_API const char *lua_tolstring (lua_State *L, int idx, size_t *len) {
399 399
400LUA_API lua_Unsigned lua_rawlen (lua_State *L, int idx) { 400LUA_API lua_Unsigned lua_rawlen (lua_State *L, int idx) {
401 const TValue *o = index2value(L, idx); 401 const TValue *o = index2value(L, idx);
402 switch (ttype(o)) { 402 switch (ttypetag(o)) {
403 case LUA_TSHRSTR: return tsvalue(o)->shrlen; 403 case LUA_TSHRSTR: return tsvalue(o)->shrlen;
404 case LUA_TLNGSTR: return tsvalue(o)->u.lnglen; 404 case LUA_TLNGSTR: return tsvalue(o)->u.lnglen;
405 case LUA_TUSERDATA: return uvalue(o)->len; 405 case LUA_TUSERDATA: return uvalue(o)->len;
@@ -420,7 +420,7 @@ LUA_API lua_CFunction lua_tocfunction (lua_State *L, int idx) {
420 420
421LUA_API void *lua_touserdata (lua_State *L, int idx) { 421LUA_API void *lua_touserdata (lua_State *L, int idx) {
422 const TValue *o = index2value(L, idx); 422 const TValue *o = index2value(L, idx);
423 switch (ttnov(o)) { 423 switch (ttype(o)) {
424 case LUA_TUSERDATA: return getudatamem(uvalue(o)); 424 case LUA_TUSERDATA: return getudatamem(uvalue(o));
425 case LUA_TLIGHTUSERDATA: return pvalue(o); 425 case LUA_TLIGHTUSERDATA: return pvalue(o);
426 default: return NULL; 426 default: return NULL;
@@ -436,7 +436,7 @@ LUA_API lua_State *lua_tothread (lua_State *L, int idx) {
436 436
437LUA_API const void *lua_topointer (lua_State *L, int idx) { 437LUA_API const void *lua_topointer (lua_State *L, int idx) {
438 const TValue *o = index2value(L, idx); 438 const TValue *o = index2value(L, idx);
439 switch (ttype(o)) { 439 switch (ttypetag(o)) {
440 case LUA_TTABLE: return hvalue(o); 440 case LUA_TTABLE: return hvalue(o);
441 case LUA_TLCL: return clLvalue(o); 441 case LUA_TLCL: return clLvalue(o);
442 case LUA_TCCL: return clCvalue(o); 442 case LUA_TCCL: return clCvalue(o);
@@ -606,7 +606,7 @@ static int auxgetstr (lua_State *L, const TValue *t, const char *k) {
606 luaV_finishget(L, t, s2v(L->top - 1), L->top - 1, slot); 606 luaV_finishget(L, t, s2v(L->top - 1), L->top - 1, slot);
607 } 607 }
608 lua_unlock(L); 608 lua_unlock(L);
609 return ttnov(s2v(L->top - 1)); 609 return ttype(s2v(L->top - 1));
610} 610}
611 611
612 612
@@ -628,7 +628,7 @@ LUA_API int lua_gettable (lua_State *L, int idx) {
628 else 628 else
629 luaV_finishget(L, t, s2v(L->top - 1), L->top - 1, slot); 629 luaV_finishget(L, t, s2v(L->top - 1), L->top - 1, slot);
630 lua_unlock(L); 630 lua_unlock(L);
631 return ttnov(s2v(L->top - 1)); 631 return ttype(s2v(L->top - 1));
632} 632}
633 633
634 634
@@ -653,7 +653,7 @@ LUA_API int lua_geti (lua_State *L, int idx, lua_Integer n) {
653 } 653 }
654 api_incr_top(L); 654 api_incr_top(L);
655 lua_unlock(L); 655 lua_unlock(L);
656 return ttnov(s2v(L->top - 1)); 656 return ttype(s2v(L->top - 1));
657} 657}
658 658
659 659
@@ -664,7 +664,7 @@ static int finishrawget (lua_State *L, const TValue *val) {
664 setobj2s(L, L->top, val); 664 setobj2s(L, L->top, val);
665 api_incr_top(L); 665 api_incr_top(L);
666 lua_unlock(L); 666 lua_unlock(L);
667 return ttnov(s2v(L->top - 1)); 667 return ttype(s2v(L->top - 1));
668} 668}
669 669
670 670
@@ -749,7 +749,7 @@ LUA_API int lua_getmetatable (lua_State *L, int objindex) {
749 int res = 0; 749 int res = 0;
750 lua_lock(L); 750 lua_lock(L);
751 obj = index2value(L, objindex); 751 obj = index2value(L, objindex);
752 switch (ttnov(obj)) { 752 switch (ttype(obj)) {
753 case LUA_TTABLE: 753 case LUA_TTABLE:
754 mt = hvalue(obj)->metatable; 754 mt = hvalue(obj)->metatable;
755 break; 755 break;
@@ -757,7 +757,7 @@ LUA_API int lua_getmetatable (lua_State *L, int objindex) {
757 mt = uvalue(obj)->metatable; 757 mt = uvalue(obj)->metatable;
758 break; 758 break;
759 default: 759 default:
760 mt = G(L)->mt[ttnov(obj)]; 760 mt = G(L)->mt[ttype(obj)];
761 break; 761 break;
762 } 762 }
763 if (mt != NULL) { 763 if (mt != NULL) {
@@ -782,7 +782,7 @@ LUA_API int lua_getiuservalue (lua_State *L, int idx, int n) {
782 } 782 }
783 else { 783 else {
784 setobj2s(L, L->top, &uvalue(o)->uv[n - 1].uv); 784 setobj2s(L, L->top, &uvalue(o)->uv[n - 1].uv);
785 t = ttnov(s2v(L->top)); 785 t = ttype(s2v(L->top));
786 } 786 }
787 api_incr_top(L); 787 api_incr_top(L);
788 lua_unlock(L); 788 lua_unlock(L);
@@ -917,7 +917,7 @@ LUA_API int lua_setmetatable (lua_State *L, int objindex) {
917 api_check(L, ttistable(s2v(L->top - 1)), "table expected"); 917 api_check(L, ttistable(s2v(L->top - 1)), "table expected");
918 mt = hvalue(s2v(L->top - 1)); 918 mt = hvalue(s2v(L->top - 1));
919 } 919 }
920 switch (ttnov(obj)) { 920 switch (ttype(obj)) {
921 case LUA_TTABLE: { 921 case LUA_TTABLE: {
922 hvalue(obj)->metatable = mt; 922 hvalue(obj)->metatable = mt;
923 if (mt) { 923 if (mt) {
@@ -935,7 +935,7 @@ LUA_API int lua_setmetatable (lua_State *L, int objindex) {
935 break; 935 break;
936 } 936 }
937 default: { 937 default: {
938 G(L)->mt[ttnov(obj)] = mt; 938 G(L)->mt[ttype(obj)] = mt;
939 break; 939 break;
940 } 940 }
941 } 941 }
@@ -1295,7 +1295,7 @@ LUA_API void *lua_newuserdatauv (lua_State *L, size_t size, int nuvalue) {
1295 1295
1296static const char *aux_upvalue (TValue *fi, int n, TValue **val, 1296static const char *aux_upvalue (TValue *fi, int n, TValue **val,
1297 GCObject **owner) { 1297 GCObject **owner) {
1298 switch (ttype(fi)) { 1298 switch (ttypetag(fi)) {
1299 case LUA_TCCL: { /* C closure */ 1299 case LUA_TCCL: { /* C closure */
1300 CClosure *f = clCvalue(fi); 1300 CClosure *f = clCvalue(fi);
1301 if (!(1 <= n && n <= f->nupvalues)) return NULL; 1301 if (!(1 <= n && n <= f->nupvalues)) return NULL;
@@ -1364,7 +1364,7 @@ static UpVal **getupvalref (lua_State *L, int fidx, int n, LClosure **pf) {
1364 1364
1365LUA_API void *lua_upvalueid (lua_State *L, int fidx, int n) { 1365LUA_API void *lua_upvalueid (lua_State *L, int fidx, int n) {
1366 TValue *fi = index2value(L, fidx); 1366 TValue *fi = index2value(L, fidx);
1367 switch (ttype(fi)) { 1367 switch (ttypetag(fi)) {
1368 case LUA_TLCL: { /* lua closure */ 1368 case LUA_TLCL: { /* lua closure */
1369 return *getupvalref(L, fidx, n, NULL); 1369 return *getupvalref(L, fidx, n, NULL);
1370 } 1370 }