diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2001-02-23 14:17:25 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2001-02-23 14:17:25 -0300 |
commit | 39b79783297bee79db9853b63d199e120a009a8f (patch) | |
tree | c738c621c4c28d8822c2f785400786301985273b /lapi.c | |
parent | d164e2294f73d8e69f00d95a66014514b2dd0ec0 (diff) | |
download | lua-39b79783297bee79db9853b63d199e120a009a8f.tar.gz lua-39b79783297bee79db9853b63d199e120a009a8f.tar.bz2 lua-39b79783297bee79db9853b63d199e120a009a8f.zip |
first (big) step to support wide chars
Diffstat (limited to 'lapi.c')
-rw-r--r-- | lapi.c | 50 |
1 files changed, 25 insertions, 25 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lapi.c,v 1.131 2001/02/20 18:15:33 roberto Exp roberto $ | 2 | ** $Id: lapi.c,v 1.132 2001/02/22 18:59:59 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 | */ |
@@ -22,8 +22,8 @@ | |||
22 | #include "lvm.h" | 22 | #include "lvm.h" |
23 | 23 | ||
24 | 24 | ||
25 | const char lua_ident[] = "$Lua: " LUA_VERSION " " LUA_COPYRIGHT " $\n" | 25 | const l_char lua_ident[] = l_s("$Lua: ") l_s(LUA_VERSION) l_s(" ") |
26 | "$Authors: " LUA_AUTHORS " $"; | 26 | l_s(LUA_COPYRIGHT) l_s(" $\n") l_s("$Authors: ") l_s(LUA_AUTHORS) l_s(" $"); |
27 | 27 | ||
28 | 28 | ||
29 | 29 | ||
@@ -150,21 +150,21 @@ LUA_API int lua_type (lua_State *L, int index) { | |||
150 | } | 150 | } |
151 | 151 | ||
152 | 152 | ||
153 | LUA_API const char *lua_typename (lua_State *L, int t) { | 153 | LUA_API const l_char *lua_typename (lua_State *L, int t) { |
154 | const char *s; | 154 | const l_char *s; |
155 | LUA_LOCK(L); | 155 | LUA_LOCK(L); |
156 | s = (t == LUA_TNONE) ? "no value" : basictypename(G(L), t); | 156 | s = (t == LUA_TNONE) ? l_s("no value") : basictypename(G(L), t); |
157 | LUA_UNLOCK(L); | 157 | LUA_UNLOCK(L); |
158 | return s; | 158 | return s; |
159 | } | 159 | } |
160 | 160 | ||
161 | 161 | ||
162 | LUA_API const char *lua_xtype (lua_State *L, int index) { | 162 | LUA_API const l_char *lua_xtype (lua_State *L, int index) { |
163 | StkId o; | 163 | StkId o; |
164 | const char *type; | 164 | const l_char *type; |
165 | LUA_LOCK(L); | 165 | LUA_LOCK(L); |
166 | o = luaA_indexAcceptable(L, index); | 166 | o = luaA_indexAcceptable(L, index); |
167 | type = (o == NULL) ? "no value" : luaT_typename(G(L), o); | 167 | type = (o == NULL) ? l_s("no value") : luaT_typename(G(L), o); |
168 | LUA_UNLOCK(L); | 168 | LUA_UNLOCK(L); |
169 | return type; | 169 | return type; |
170 | } | 170 | } |
@@ -242,9 +242,9 @@ LUA_API lua_Number lua_tonumber (lua_State *L, int index) { | |||
242 | return n; | 242 | return n; |
243 | } | 243 | } |
244 | 244 | ||
245 | LUA_API const char *lua_tostring (lua_State *L, int index) { | 245 | LUA_API const l_char *lua_tostring (lua_State *L, int index) { |
246 | StkId o; | 246 | StkId o; |
247 | const char *s; | 247 | const l_char *s; |
248 | LUA_LOCK(L); | 248 | LUA_LOCK(L); |
249 | o = luaA_indexAcceptable(L, index); | 249 | o = luaA_indexAcceptable(L, index); |
250 | s = (o == NULL || tostring(L, o)) ? NULL : svalue(o); | 250 | s = (o == NULL || tostring(L, o)) ? NULL : svalue(o); |
@@ -329,7 +329,7 @@ LUA_API void lua_pushnumber (lua_State *L, lua_Number n) { | |||
329 | } | 329 | } |
330 | 330 | ||
331 | 331 | ||
332 | LUA_API void lua_pushlstring (lua_State *L, const char *s, size_t len) { | 332 | LUA_API void lua_pushlstring (lua_State *L, const l_char *s, size_t len) { |
333 | LUA_LOCK(L); | 333 | LUA_LOCK(L); |
334 | setsvalue(L->top, luaS_newlstr(L, s, len)); | 334 | setsvalue(L->top, luaS_newlstr(L, s, len)); |
335 | api_incr_top(L); | 335 | api_incr_top(L); |
@@ -337,7 +337,7 @@ LUA_API void lua_pushlstring (lua_State *L, const char *s, size_t len) { | |||
337 | } | 337 | } |
338 | 338 | ||
339 | 339 | ||
340 | LUA_API void lua_pushstring (lua_State *L, const char *s) { | 340 | LUA_API void lua_pushstring (lua_State *L, const l_char *s) { |
341 | if (s == NULL) | 341 | if (s == NULL) |
342 | lua_pushnil(L); | 342 | lua_pushnil(L); |
343 | else | 343 | else |
@@ -369,7 +369,7 @@ LUA_API int lua_pushuserdata (lua_State *L, void *u) { | |||
369 | */ | 369 | */ |
370 | 370 | ||
371 | 371 | ||
372 | LUA_API void lua_getglobal (lua_State *L, const char *name) { | 372 | LUA_API void lua_getglobal (lua_State *L, const l_char *name) { |
373 | LUA_LOCK(L); | 373 | LUA_LOCK(L); |
374 | luaV_getglobal(L, luaS_new(L, name), L->top); | 374 | luaV_getglobal(L, luaS_new(L, name), L->top); |
375 | api_incr_top(L); | 375 | api_incr_top(L); |
@@ -450,7 +450,7 @@ LUA_API void lua_newtable (lua_State *L) { | |||
450 | */ | 450 | */ |
451 | 451 | ||
452 | 452 | ||
453 | LUA_API void lua_setglobal (lua_State *L, const char *name) { | 453 | LUA_API void lua_setglobal (lua_State *L, const l_char *name) { |
454 | LUA_LOCK(L); | 454 | LUA_LOCK(L); |
455 | api_checknelems(L, 1); | 455 | api_checknelems(L, 1); |
456 | luaV_setglobal(L, luaS_new(L, name), L->top - 1); | 456 | luaV_setglobal(L, luaS_new(L, name), L->top - 1); |
@@ -518,7 +518,7 @@ LUA_API int lua_ref (lua_State *L, int lock) { | |||
518 | } | 518 | } |
519 | else { /* no more free places */ | 519 | else { /* no more free places */ |
520 | luaM_growvector(L, G(L)->refArray, G(L)->nref, G(L)->sizeref, struct Ref, | 520 | luaM_growvector(L, G(L)->refArray, G(L)->nref, G(L)->sizeref, struct Ref, |
521 | MAX_INT, "reference table overflow"); | 521 | MAX_INT, l_s("reference table overflow")); |
522 | ref = G(L)->nref++; | 522 | ref = G(L)->nref++; |
523 | } | 523 | } |
524 | setobj(&G(L)->refArray[ref].o, L->top-1); | 524 | setobj(&G(L)->refArray[ref].o, L->top-1); |
@@ -582,22 +582,22 @@ LUA_API void lua_setgcthreshold (lua_State *L, int newthreshold) { | |||
582 | ** miscellaneous functions | 582 | ** miscellaneous functions |
583 | */ | 583 | */ |
584 | 584 | ||
585 | LUA_API int lua_newtype (lua_State *L, const char *name, int basictype) { | 585 | LUA_API int lua_newtype (lua_State *L, const l_char *name, int basictype) { |
586 | int tag; | 586 | int tag; |
587 | LUA_LOCK(L); | 587 | LUA_LOCK(L); |
588 | if (basictype != LUA_TNONE && | 588 | if (basictype != LUA_TNONE && |
589 | basictype != LUA_TTABLE && | 589 | basictype != LUA_TTABLE && |
590 | basictype != LUA_TUSERDATA) | 590 | basictype != LUA_TUSERDATA) |
591 | luaO_verror(L, "invalid basic type (%d) for new type", basictype); | 591 | luaO_verror(L, l_s("invalid basic type (%d) for new type"), basictype); |
592 | tag = luaT_newtag(L, name, basictype); | 592 | tag = luaT_newtag(L, name, basictype); |
593 | if (tag == LUA_TNONE) | 593 | if (tag == LUA_TNONE) |
594 | luaO_verror(L, "type name '%.30s' already exists", name); | 594 | luaO_verror(L, l_s("type name '%.30s' already exists"), name); |
595 | LUA_UNLOCK(L); | 595 | LUA_UNLOCK(L); |
596 | return tag; | 596 | return tag; |
597 | } | 597 | } |
598 | 598 | ||
599 | 599 | ||
600 | LUA_API int lua_type2tag (lua_State *L, const char *name) { | 600 | LUA_API int lua_type2tag (lua_State *L, const l_char *name) { |
601 | int tag; | 601 | int tag; |
602 | const TObject *v; | 602 | const TObject *v; |
603 | LUA_LOCK(L); | 603 | LUA_LOCK(L); |
@@ -618,10 +618,10 @@ LUA_API void lua_settag (lua_State *L, int tag) { | |||
618 | LUA_LOCK(L); | 618 | LUA_LOCK(L); |
619 | api_checknelems(L, 1); | 619 | api_checknelems(L, 1); |
620 | if (tag < 0 || tag >= G(L)->ntag) | 620 | if (tag < 0 || tag >= G(L)->ntag) |
621 | luaO_verror(L, "%d is not a valid tag", tag); | 621 | luaO_verror(L, l_s("%d is not a valid tag"), tag); |
622 | basictype = G(L)->TMtable[tag].basictype; | 622 | basictype = G(L)->TMtable[tag].basictype; |
623 | if (basictype != LUA_TNONE && basictype != ttype(L->top-1)) | 623 | if (basictype != LUA_TNONE && basictype != ttype(L->top-1)) |
624 | luaO_verror(L, "tag %d can only be used for type '%.20s'", tag, | 624 | luaO_verror(L, l_s("tag %d can only be used for type '%.20s'"), tag, |
625 | basictypename(G(L), basictype)); | 625 | basictypename(G(L), basictype)); |
626 | switch (ttype(L->top-1)) { | 626 | switch (ttype(L->top-1)) { |
627 | case LUA_TTABLE: | 627 | case LUA_TTABLE: |
@@ -631,14 +631,14 @@ LUA_API void lua_settag (lua_State *L, int tag) { | |||
631 | tsvalue(L->top-1)->u.d.tag = tag; | 631 | tsvalue(L->top-1)->u.d.tag = tag; |
632 | break; | 632 | break; |
633 | default: | 633 | default: |
634 | luaO_verror(L, "cannot change the tag of a %.20s", | 634 | luaO_verror(L, l_s("cannot change the tag of a %.20s"), |
635 | luaT_typename(G(L), L->top-1)); | 635 | luaT_typename(G(L), L->top-1)); |
636 | } | 636 | } |
637 | LUA_UNLOCK(L); | 637 | LUA_UNLOCK(L); |
638 | } | 638 | } |
639 | 639 | ||
640 | 640 | ||
641 | LUA_API void lua_error (lua_State *L, const char *s) { | 641 | LUA_API void lua_error (lua_State *L, const l_char *s) { |
642 | LUA_LOCK(L); | 642 | LUA_LOCK(L); |
643 | luaD_error(L, s); | 643 | luaD_error(L, s); |
644 | LUA_UNLOCK(L); | 644 | LUA_UNLOCK(L); |
@@ -685,7 +685,7 @@ LUA_API int lua_getn (lua_State *L, int index) { | |||
685 | int n; | 685 | int n; |
686 | LUA_LOCK(L); | 686 | LUA_LOCK(L); |
687 | h = hvalue(luaA_index(L, index)); | 687 | h = hvalue(luaA_index(L, index)); |
688 | value = luaH_getstr(h, luaS_newliteral(L, "n")); /* = h.n */ | 688 | value = luaH_getstr(h, luaS_newliteral(L, l_s("n"))); /* = h.n */ |
689 | if (ttype(value) == LUA_TNUMBER) | 689 | if (ttype(value) == LUA_TNUMBER) |
690 | n = (int)nvalue(value); | 690 | n = (int)nvalue(value); |
691 | else { | 691 | else { |