aboutsummaryrefslogtreecommitdiff
path: root/ltm.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2001-02-23 14:17:25 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2001-02-23 14:17:25 -0300
commit39b79783297bee79db9853b63d199e120a009a8f (patch)
treec738c621c4c28d8822c2f785400786301985273b /ltm.c
parentd164e2294f73d8e69f00d95a66014514b2dd0ec0 (diff)
downloadlua-39b79783297bee79db9853b63d199e120a009a8f.tar.gz
lua-39b79783297bee79db9853b63d199e120a009a8f.tar.bz2
lua-39b79783297bee79db9853b63d199e120a009a8f.zip
first (big) step to support wide chars
Diffstat (limited to 'ltm.c')
-rw-r--r--ltm.c42
1 files changed, 21 insertions, 21 deletions
diff --git a/ltm.c b/ltm.c
index 43bdc0f8..aff4a227 100644
--- a/ltm.c
+++ b/ltm.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ltm.c,v 1.67 2001/02/20 18:15:33 roberto Exp roberto $ 2** $Id: ltm.c,v 1.68 2001/02/22 18:59:59 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*/
@@ -19,15 +19,15 @@
19#include "ltm.h" 19#include "ltm.h"
20 20
21 21
22const char *const luaT_eventname[] = { /* ORDER TM */ 22const l_char *const luaT_eventname[] = { /* ORDER TM */
23 "gettable", "settable", "index", "getglobal", "setglobal", "add", "sub", 23 l_s("gettable"), l_s("settable"), l_s("index"), l_s("getglobal"), l_s("setglobal"), l_s("add"), l_s("sub"),
24 "mul", "div", "pow", "unm", "lt", "concat", "gc", "function", 24 l_s("mul"), l_s("div"), l_s("pow"), l_s("unm"), l_s("lt"), l_s("concat"), l_s("gc"), l_s("function"),
25 "le", "gt", "ge", /* deprecated options!! */ 25 l_s("le"), l_s("gt"), l_s("ge"), /* deprecated options!! */
26 NULL 26 NULL
27}; 27};
28 28
29 29
30static int findevent (const char *name) { 30static int findevent (const l_char *name) {
31 int i; 31 int i;
32 for (i=0; luaT_eventname[i]; i++) 32 for (i=0; luaT_eventname[i]; i++)
33 if (strcmp(luaT_eventname[i], name) == 0) 33 if (strcmp(luaT_eventname[i], name) == 0)
@@ -36,14 +36,14 @@ static int findevent (const char *name) {
36} 36}
37 37
38 38
39static int luaI_checkevent (lua_State *L, const char *name, int t) { 39static int luaI_checkevent (lua_State *L, const l_char *name, int t) {
40 int e = findevent(name); 40 int e = findevent(name);
41 if (e >= TM_N) 41 if (e >= TM_N)
42 luaO_verror(L, "event `%.50s' is deprecated", name); 42 luaO_verror(L, l_s("event `%.50s' is deprecated"), name);
43 if (e == TM_GC && t == LUA_TTABLE) 43 if (e == TM_GC && t == LUA_TTABLE)
44 luaO_verror(L, "event `gc' for tables is deprecated"); 44 luaO_verror(L, l_s("event `gc' for tables is deprecated"));
45 if (e < 0) 45 if (e < 0)
46 luaO_verror(L, "`%.50s' is not a valid event name", name); 46 luaO_verror(L, l_s("`%.50s' is not a valid event name"), name);
47 return e; 47 return e;
48} 48}
49 49
@@ -68,8 +68,8 @@ int luaT_validevent (int t, int e) { /* ORDER LUA_T */
68 68
69 69
70void luaT_init (lua_State *L) { 70void luaT_init (lua_State *L) {
71 static const char *const typenames[NUM_TAGS] = { 71 static const l_char *const typenames[NUM_TAGS] = {
72 "userdata", "nil", "number", "string", "table", "function" 72 l_s("userdata"), l_s("nil"), l_s("number"), l_s("string"), l_s("table"), l_s("function")
73 }; 73 };
74 int i; 74 int i;
75 for (i=0; i<NUM_TAGS; i++) 75 for (i=0; i<NUM_TAGS; i++)
@@ -77,12 +77,12 @@ void luaT_init (lua_State *L) {
77} 77}
78 78
79 79
80int luaT_newtag (lua_State *L, const char *name, int basictype) { 80int luaT_newtag (lua_State *L, const l_char *name, int basictype) {
81 int tag; 81 int tag;
82 int i; 82 int i;
83 TString *ts; 83 TString *ts;
84 luaM_growvector(L, G(L)->TMtable, G(L)->ntag, G(L)->sizeTM, struct TM, 84 luaM_growvector(L, G(L)->TMtable, G(L)->ntag, G(L)->sizeTM, struct TM,
85 MAX_INT, "tag table overflow"); 85 MAX_INT, l_s("tag table overflow"));
86 tag = G(L)->ntag; 86 tag = G(L)->ntag;
87 if (name == NULL) 87 if (name == NULL)
88 ts = NULL; 88 ts = NULL;
@@ -105,7 +105,7 @@ int luaT_newtag (lua_State *L, const char *name, int basictype) {
105 105
106static void checktag (lua_State *L, int tag) { 106static void checktag (lua_State *L, int tag) {
107 if (!(0 <= tag && tag < G(L)->ntag)) 107 if (!(0 <= tag && tag < G(L)->ntag))
108 luaO_verror(L, "%d is not a valid tag", tag); 108 luaO_verror(L, l_s("%d is not a valid tag"), tag);
109} 109}
110 110
111 111
@@ -133,7 +133,7 @@ int luaT_tag (const TObject *o) {
133} 133}
134 134
135 135
136const char *luaT_typename (global_State *G, const TObject *o) { 136const l_char *luaT_typename (global_State *G, const TObject *o) {
137 int t = ttype(o); 137 int t = ttype(o);
138 int tag; 138 int tag;
139 TString *ts; 139 TString *ts;
@@ -154,7 +154,7 @@ const char *luaT_typename (global_State *G, const TObject *o) {
154} 154}
155 155
156 156
157LUA_API void lua_gettagmethod (lua_State *L, int t, const char *event) { 157LUA_API void lua_gettagmethod (lua_State *L, int t, const l_char *event) {
158 int e; 158 int e;
159 LUA_LOCK(L); 159 LUA_LOCK(L);
160 e = luaI_checkevent(L, event, t); 160 e = luaI_checkevent(L, event, t);
@@ -169,16 +169,16 @@ LUA_API void lua_gettagmethod (lua_State *L, int t, const char *event) {
169} 169}
170 170
171 171
172LUA_API void lua_settagmethod (lua_State *L, int t, const char *event) { 172LUA_API void lua_settagmethod (lua_State *L, int t, const l_char *event) {
173 int e; 173 int e;
174 LUA_LOCK(L); 174 LUA_LOCK(L);
175 e = luaI_checkevent(L, event, t); 175 e = luaI_checkevent(L, event, t);
176 checktag(L, t); 176 checktag(L, t);
177 if (!luaT_validevent(t, e)) 177 if (!luaT_validevent(t, e))
178 luaO_verror(L, "cannot change `%.20s' tag method for type `%.20s'%.20s", 178 luaO_verror(L, l_s("cannot change `%.20s' tag method for type `%.20s'%.20s"),
179 luaT_eventname[e], basictypename(G(L), t), 179 luaT_eventname[e], basictypename(G(L), t),
180 (t == LUA_TTABLE || t == LUA_TUSERDATA) ? 180 (t == LUA_TTABLE || t == LUA_TUSERDATA) ?
181 " with default tag" : ""); 181 l_s(" with default tag") : l_s(""));
182 switch (ttype(L->top - 1)) { 182 switch (ttype(L->top - 1)) {
183 case LUA_TNIL: 183 case LUA_TNIL:
184 luaT_gettm(G(L), t, e) = NULL; 184 luaT_gettm(G(L), t, e) = NULL;
@@ -187,7 +187,7 @@ LUA_API void lua_settagmethod (lua_State *L, int t, const char *event) {
187 luaT_gettm(G(L), t, e) = clvalue(L->top - 1); 187 luaT_gettm(G(L), t, e) = clvalue(L->top - 1);
188 break; 188 break;
189 default: 189 default:
190 luaD_error(L, "tag method must be a function (or nil)"); 190 luaD_error(L, l_s("tag method must be a function (or nil)"));
191 } 191 }
192 L->top--; 192 L->top--;
193 LUA_UNLOCK(L); 193 LUA_UNLOCK(L);