aboutsummaryrefslogtreecommitdiff
path: root/ltm.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2001-01-24 13:45:33 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2001-01-24 13:45:33 -0200
commit71ae4801d66d9592b0fb08e4e78138b7a6e993d5 (patch)
treea683b5b3757efb979329bf513f1bd9fde3fb9d1f /ltm.c
parent6fda6a530265268c01a83c31f8fc30e34753bbf1 (diff)
downloadlua-71ae4801d66d9592b0fb08e4e78138b7a6e993d5.tar.gz
lua-71ae4801d66d9592b0fb08e4e78138b7a6e993d5.tar.bz2
lua-71ae4801d66d9592b0fb08e4e78138b7a6e993d5.zip
macros LUA_ENTRY/LUA_EXIT to control exclusive access to Lua core
Diffstat (limited to 'ltm.c')
-rw-r--r--ltm.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/ltm.c b/ltm.c
index 21fd7662..3f10a7b1 100644
--- a/ltm.c
+++ b/ltm.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ltm.c,v 1.60 2001/01/18 15:59:09 roberto Exp roberto $ 2** $Id: ltm.c,v 1.61 2001/01/19 13:20:30 roberto Exp roberto $
3** Tag methods 3** Tag methods
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -84,10 +84,14 @@ void luaT_init (lua_State *L) {
84 84
85 85
86LUA_API int lua_newtag (lua_State *L) { 86LUA_API int lua_newtag (lua_State *L) {
87 int tag;
88 LUA_ENTRY;
87 luaM_growvector(L, G(L)->TMtable, G(L)->ntag, G(L)->sizeTM, struct TM, 89 luaM_growvector(L, G(L)->TMtable, G(L)->ntag, G(L)->sizeTM, struct TM,
88 MAX_INT, "tag table overflow"); 90 MAX_INT, "tag table overflow");
89 init_entry(L, G(L)->ntag); 91 init_entry(L, G(L)->ntag);
90 return G(L)->ntag++; 92 tag = G(L)->ntag++;
93 LUA_EXIT;
94 return tag;
91} 95}
92 96
93 97
@@ -104,12 +108,14 @@ void luaT_realtag (lua_State *L, int tag) {
104 108
105LUA_API int lua_copytagmethods (lua_State *L, int tagto, int tagfrom) { 109LUA_API int lua_copytagmethods (lua_State *L, int tagto, int tagfrom) {
106 int e; 110 int e;
111 LUA_ENTRY;
107 checktag(L, tagto); 112 checktag(L, tagto);
108 checktag(L, tagfrom); 113 checktag(L, tagfrom);
109 for (e=0; e<TM_N; e++) { 114 for (e=0; e<TM_N; e++) {
110 if (luaT_validevent(tagto, e)) 115 if (luaT_validevent(tagto, e))
111 luaT_gettm(G(L), tagto, e) = luaT_gettm(G(L), tagfrom, e); 116 luaT_gettm(G(L), tagto, e) = luaT_gettm(G(L), tagfrom, e);
112 } 117 }
118 LUA_EXIT;
113 return tagto; 119 return tagto;
114} 120}
115 121
@@ -126,6 +132,7 @@ int luaT_tag (const TObject *o) {
126 132
127LUA_API void lua_gettagmethod (lua_State *L, int t, const char *event) { 133LUA_API void lua_gettagmethod (lua_State *L, int t, const char *event) {
128 int e; 134 int e;
135 LUA_ENTRY;
129 e = luaI_checkevent(L, event, t); 136 e = luaI_checkevent(L, event, t);
130 checktag(L, t); 137 checktag(L, t);
131 if (luaT_validevent(t, e) && luaT_gettm(G(L), t, e)) { 138 if (luaT_validevent(t, e) && luaT_gettm(G(L), t, e)) {
@@ -134,11 +141,14 @@ LUA_API void lua_gettagmethod (lua_State *L, int t, const char *event) {
134 else 141 else
135 setnilvalue(L->top); 142 setnilvalue(L->top);
136 incr_top; 143 incr_top;
144 LUA_EXIT;
137} 145}
138 146
139 147
140LUA_API void lua_settagmethod (lua_State *L, int t, const char *event) { 148LUA_API void lua_settagmethod (lua_State *L, int t, const char *event) {
141 int e = luaI_checkevent(L, event, t); 149 int e;
150 LUA_ENTRY;
151 e = luaI_checkevent(L, event, t);
142 checktag(L, t); 152 checktag(L, t);
143 if (!luaT_validevent(t, e)) 153 if (!luaT_validevent(t, e))
144 luaO_verror(L, "cannot change `%.20s' tag method for type `%.20s'%.20s", 154 luaO_verror(L, "cannot change `%.20s' tag method for type `%.20s'%.20s",
@@ -153,8 +163,9 @@ LUA_API void lua_settagmethod (lua_State *L, int t, const char *event) {
153 luaT_gettm(G(L), t, e) = clvalue(L->top - 1); 163 luaT_gettm(G(L), t, e) = clvalue(L->top - 1);
154 break; 164 break;
155 default: 165 default:
156 lua_error(L, "tag method must be a function (or nil)"); 166 luaD_error(L, "tag method must be a function (or nil)");
157 } 167 }
158 L->top--; 168 L->top--;
169 LUA_EXIT;
159} 170}
160 171