aboutsummaryrefslogtreecommitdiff
path: root/lapi.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2000-03-10 15:37:44 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2000-03-10 15:37:44 -0300
commit73aa465a8ed8dee6c6a27a6f8b2f51227b70789d (patch)
tree496a63ffffe0312f1d0b9882d97944fa38ed7801 /lapi.c
parent3d0577f4b98908be3f2d697ab75c5fbbd3f6999b (diff)
downloadlua-73aa465a8ed8dee6c6a27a6f8b2f51227b70789d.tar.gz
lua-73aa465a8ed8dee6c6a27a6f8b2f51227b70789d.tar.bz2
lua-73aa465a8ed8dee6c6a27a6f8b2f51227b70789d.zip
some name changes
Diffstat (limited to 'lapi.c')
-rw-r--r--lapi.c54
1 files changed, 27 insertions, 27 deletions
diff --git a/lapi.c b/lapi.c
index d915696b..1391511f 100644
--- a/lapi.c
+++ b/lapi.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lapi.c,v 1.72 2000/02/22 17:54:16 roberto Exp roberto $ 2** $Id: lapi.c,v 1.73 2000/03/03 14:58:26 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*/
@@ -33,7 +33,7 @@ const char lua_ident[] = "$Lua: " LUA_VERSION " " LUA_COPYRIGHT " $\n"
33 33
34const TObject *luaA_protovalue (const TObject *o) { 34const TObject *luaA_protovalue (const TObject *o) {
35 switch (ttype(o)) { 35 switch (ttype(o)) {
36 case LUA_T_CCLOSURE: case LUA_T_LCLOSURE: 36 case TAG_CCLOSURE: case TAG_LCLOSURE:
37 return protovalue(o); 37 return protovalue(o);
38 default: 38 default:
39 return o; 39 return o;
@@ -106,7 +106,7 @@ lua_Object lua_settagmethod (lua_State *L, int tag, const char *event) {
106 TObject *method; 106 TObject *method;
107 luaA_checkCargs(L, 1); 107 luaA_checkCargs(L, 1);
108 method = L->top-1; 108 method = L->top-1;
109 if ((ttype(method) != LUA_T_NIL) && (*lua_type(L, method) != 'f')) 109 if ((ttype(method) != TAG_NIL) && (*lua_type(L, method) != 'f'))
110 lua_error(L, "Lua API error - tag method must be a function or nil"); 110 lua_error(L, "Lua API error - tag method must be a function or nil");
111 luaT_settagmethod(L, tag, event, method); 111 luaT_settagmethod(L, tag, event, method);
112 return luaA_putObjectOnTop(L); 112 return luaA_putObjectOnTop(L);
@@ -132,7 +132,7 @@ lua_Object lua_gettable (lua_State *L) {
132lua_Object lua_rawgettable (lua_State *L) { 132lua_Object lua_rawgettable (lua_State *L) {
133 lua_Object res; 133 lua_Object res;
134 luaA_checkCargs(L, 2); 134 luaA_checkCargs(L, 2);
135 if (ttype(L->top-2) != LUA_T_ARRAY) 135 if (ttype(L->top-2) != TAG_ARRAY)
136 lua_error(L, "indexed expression not a table in rawgettable"); 136 lua_error(L, "indexed expression not a table in rawgettable");
137 res = luaA_putluaObject(L, luaH_get(L, avalue(L->top-2), L->top-1)); 137 res = luaA_putluaObject(L, luaH_get(L, avalue(L->top-2), L->top-1));
138 L->top -= 2; 138 L->top -= 2;
@@ -159,7 +159,7 @@ lua_Object lua_createtable (lua_State *L) {
159 TObject o; 159 TObject o;
160 luaC_checkGC(L); 160 luaC_checkGC(L);
161 avalue(&o) = luaH_new(L, 0); 161 avalue(&o) = luaH_new(L, 0);
162 ttype(&o) = LUA_T_ARRAY; 162 ttype(&o) = TAG_ARRAY;
163 return luaA_putluaObject(L, &o); 163 return luaA_putluaObject(L, &o);
164} 164}
165 165
@@ -196,21 +196,21 @@ const char *lua_type (lua_State *L, lua_Object o) {
196 196
197int lua_isnil (lua_State *L, lua_Object o) { 197int lua_isnil (lua_State *L, lua_Object o) {
198 UNUSED(L); 198 UNUSED(L);
199 return (o != LUA_NOOBJECT) && (ttype(o) == LUA_T_NIL); 199 return (o != LUA_NOOBJECT) && (ttype(o) == TAG_NIL);
200} 200}
201 201
202int lua_istable (lua_State *L, lua_Object o) { 202int lua_istable (lua_State *L, lua_Object o) {
203 UNUSED(L); 203 UNUSED(L);
204 return (o != LUA_NOOBJECT) && (ttype(o) == LUA_T_ARRAY); 204 return (o != LUA_NOOBJECT) && (ttype(o) == TAG_ARRAY);
205} 205}
206 206
207int lua_isuserdata (lua_State *L, lua_Object o) { 207int lua_isuserdata (lua_State *L, lua_Object o) {
208 UNUSED(L); 208 UNUSED(L);
209 return (o != LUA_NOOBJECT) && (ttype(o) == LUA_T_USERDATA); 209 return (o != LUA_NOOBJECT) && (ttype(o) == TAG_USERDATA);
210} 210}
211 211
212int lua_iscfunction (lua_State *L, lua_Object o) { 212int lua_iscfunction (lua_State *L, lua_Object o) {
213 return (lua_tag(L, o) == LUA_T_CPROTO); 213 return (lua_tag(L, o) == TAG_CPROTO);
214} 214}
215 215
216int lua_isnumber (lua_State *L, lua_Object o) { 216int lua_isnumber (lua_State *L, lua_Object o) {
@@ -220,8 +220,8 @@ int lua_isnumber (lua_State *L, lua_Object o) {
220 220
221int lua_isstring (lua_State *L, lua_Object o) { 221int lua_isstring (lua_State *L, lua_Object o) {
222 UNUSED(L); 222 UNUSED(L);
223 return (o != LUA_NOOBJECT && (ttype(o) == LUA_T_STRING || 223 return (o != LUA_NOOBJECT && (ttype(o) == TAG_STRING ||
224 ttype(o) == LUA_T_NUMBER)); 224 ttype(o) == TAG_NUMBER));
225} 225}
226 226
227int lua_isfunction (lua_State *L, lua_Object o) { 227int lua_isfunction (lua_State *L, lua_Object o) {
@@ -258,7 +258,7 @@ long lua_strlen (lua_State *L, lua_Object obj) {
258 258
259void *lua_getuserdata (lua_State *L, lua_Object obj) { 259void *lua_getuserdata (lua_State *L, lua_Object obj) {
260 UNUSED(L); 260 UNUSED(L);
261 if (obj == LUA_NOOBJECT || ttype(obj) != LUA_T_USERDATA) 261 if (obj == LUA_NOOBJECT || ttype(obj) != TAG_USERDATA)
262 return NULL; 262 return NULL;
263 else return tsvalue(obj)->u.d.value; 263 else return tsvalue(obj)->u.d.value;
264} 264}
@@ -271,19 +271,19 @@ lua_CFunction lua_getcfunction (lua_State *L, lua_Object obj) {
271 271
272 272
273void lua_pushnil (lua_State *L) { 273void lua_pushnil (lua_State *L) {
274 ttype(L->top) = LUA_T_NIL; 274 ttype(L->top) = TAG_NIL;
275 incr_top; 275 incr_top;
276} 276}
277 277
278void lua_pushnumber (lua_State *L, double n) { 278void lua_pushnumber (lua_State *L, double n) {
279 ttype(L->top) = LUA_T_NUMBER; 279 ttype(L->top) = TAG_NUMBER;
280 nvalue(L->top) = n; 280 nvalue(L->top) = n;
281 incr_top; 281 incr_top;
282} 282}
283 283
284void lua_pushlstring (lua_State *L, const char *s, long len) { 284void lua_pushlstring (lua_State *L, const char *s, long len) {
285 tsvalue(L->top) = luaS_newlstr(L, s, len); 285 tsvalue(L->top) = luaS_newlstr(L, s, len);
286 ttype(L->top) = LUA_T_STRING; 286 ttype(L->top) = TAG_STRING;
287 incr_top; 287 incr_top;
288 luaC_checkGC(L); 288 luaC_checkGC(L);
289} 289}
@@ -299,7 +299,7 @@ void lua_pushcclosure (lua_State *L, lua_CFunction fn, int n) {
299 if (fn == NULL) 299 if (fn == NULL)
300 lua_error(L, "Lua API error - attempt to push a NULL Cfunction"); 300 lua_error(L, "Lua API error - attempt to push a NULL Cfunction");
301 luaA_checkCargs(L, n); 301 luaA_checkCargs(L, n);
302 ttype(L->top) = LUA_T_CPROTO; 302 ttype(L->top) = TAG_CPROTO;
303 fvalue(L->top) = fn; 303 fvalue(L->top) = fn;
304 incr_top; 304 incr_top;
305 luaV_closure(L, n); 305 luaV_closure(L, n);
@@ -310,7 +310,7 @@ void lua_pushusertag (lua_State *L, void *u, int tag) {
310 if (tag < 0 && tag != LUA_ANYTAG) 310 if (tag < 0 && tag != LUA_ANYTAG)
311 luaT_realtag(L, tag); /* error if tag is not valid */ 311 luaT_realtag(L, tag); /* error if tag is not valid */
312 tsvalue(L->top) = luaS_createudata(L, u, tag); 312 tsvalue(L->top) = luaS_createudata(L, u, tag);
313 ttype(L->top) = LUA_T_USERDATA; 313 ttype(L->top) = TAG_USERDATA;
314 incr_top; 314 incr_top;
315 luaC_checkGC(L); 315 luaC_checkGC(L);
316} 316}
@@ -331,8 +331,8 @@ void lua_pushobject (lua_State *L, lua_Object o) {
331int lua_tag (lua_State *L, lua_Object o) { 331int lua_tag (lua_State *L, lua_Object o) {
332 UNUSED(L); 332 UNUSED(L);
333 if (o == LUA_NOOBJECT) 333 if (o == LUA_NOOBJECT)
334 return LUA_T_NIL; 334 return TAG_NIL;
335 else if (ttype(o) == LUA_T_USERDATA) /* to allow `old' tags (deprecated) */ 335 else if (ttype(o) == TAG_USERDATA) /* to allow `old' tags (deprecated) */
336 return o->value.ts->u.d.tag; 336 return o->value.ts->u.d.tag;
337 else 337 else
338 return luaT_effectivetag(o); 338 return luaT_effectivetag(o);
@@ -343,10 +343,10 @@ void lua_settag (lua_State *L, int tag) {
343 luaA_checkCargs(L, 1); 343 luaA_checkCargs(L, 1);
344 luaT_realtag(L, tag); 344 luaT_realtag(L, tag);
345 switch (ttype(L->top-1)) { 345 switch (ttype(L->top-1)) {
346 case LUA_T_ARRAY: 346 case TAG_ARRAY:
347 (L->top-1)->value.a->htag = tag; 347 (L->top-1)->value.a->htag = tag;
348 break; 348 break;
349 case LUA_T_USERDATA: 349 case TAG_USERDATA:
350 (L->top-1)->value.ts->u.d.tag = tag; 350 (L->top-1)->value.ts->u.d.tag = tag;
351 break; 351 break;
352 default: 352 default:
@@ -357,7 +357,7 @@ void lua_settag (lua_State *L, int tag) {
357} 357}
358 358
359 359
360GlobalVar *luaA_nextvar (lua_State *L, TaggedString *ts) { 360GlobalVar *luaA_nextvar (lua_State *L, TString *ts) {
361 GlobalVar *gv; 361 GlobalVar *gv;
362 if (ts == NULL) 362 if (ts == NULL)
363 gv = L->rootglobal; /* first variable */ 363 gv = L->rootglobal; /* first variable */
@@ -366,10 +366,10 @@ GlobalVar *luaA_nextvar (lua_State *L, TaggedString *ts) {
366 luaL_arg_check(L, ts->u.s.gv, 1, "variable name expected"); 366 luaL_arg_check(L, ts->u.s.gv, 1, "variable name expected");
367 gv = ts->u.s.gv->next; /* get next */ 367 gv = ts->u.s.gv->next; /* get next */
368 } 368 }
369 while (gv && gv->value.ttype == LUA_T_NIL) /* skip globals with nil */ 369 while (gv && gv->value.ttype == TAG_NIL) /* skip globals with nil */
370 gv = gv->next; 370 gv = gv->next;
371 if (gv) { 371 if (gv) {
372 ttype(L->top) = LUA_T_STRING; tsvalue(L->top) = gv->name; 372 ttype(L->top) = TAG_STRING; tsvalue(L->top) = gv->name;
373 incr_top; 373 incr_top;
374 luaA_pushobject(L, &gv->value); 374 luaA_pushobject(L, &gv->value);
375 } 375 }
@@ -378,7 +378,7 @@ GlobalVar *luaA_nextvar (lua_State *L, TaggedString *ts) {
378 378
379 379
380const char *lua_nextvar (lua_State *L, const char *varname) { 380const char *lua_nextvar (lua_State *L, const char *varname) {
381 TaggedString *ts = (varname == NULL) ? NULL : luaS_new(L, varname); 381 TString *ts = (varname == NULL) ? NULL : luaS_new(L, varname);
382 GlobalVar *gv = luaA_nextvar(L, ts); 382 GlobalVar *gv = luaA_nextvar(L, ts);
383 if (gv) { 383 if (gv) {
384 top2LC(L, 2); 384 top2LC(L, 2);
@@ -395,7 +395,7 @@ int luaA_next (lua_State *L, const Hash *t, int i) {
395 int tsize = t->size; 395 int tsize = t->size;
396 for (; i<tsize; i++) { 396 for (; i<tsize; i++) {
397 Node *n = node(t, i); 397 Node *n = node(t, i);
398 if (ttype(val(n)) != LUA_T_NIL) { 398 if (ttype(val(n)) != TAG_NIL) {
399 luaA_pushobject(L, key(n)); 399 luaA_pushobject(L, key(n));
400 luaA_pushobject(L, val(n)); 400 luaA_pushobject(L, val(n));
401 return i+1; /* index to be used next time */ 401 return i+1; /* index to be used next time */
@@ -406,7 +406,7 @@ int luaA_next (lua_State *L, const Hash *t, int i) {
406 406
407 407
408int lua_next (lua_State *L, lua_Object t, int i) { 408int lua_next (lua_State *L, lua_Object t, int i) {
409 if (ttype(t) != LUA_T_ARRAY) 409 if (ttype(t) != TAG_ARRAY)
410 lua_error(L, "Lua API error - object is not a table in `lua_next'"); 410 lua_error(L, "Lua API error - object is not a table in `lua_next'");
411 i = luaA_next(L, avalue(t), i); 411 i = luaA_next(L, avalue(t), i);
412 top2LC(L, (i==0) ? 0 : 2); 412 top2LC(L, (i==0) ? 0 : 2);