diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2001-11-28 18:13:13 -0200 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2001-11-28 18:13:13 -0200 |
commit | 72659a06050632da1a9b4c492302be46ac283f6b (patch) | |
tree | bac06b4ea523ba5443564d0869e392180d4b7b77 /ltm.c | |
parent | dfaf8c5291fa8aef5bedbfa375853475364ac76e (diff) | |
download | lua-72659a06050632da1a9b4c492302be46ac283f6b.tar.gz lua-72659a06050632da1a9b4c492302be46ac283f6b.tar.bz2 lua-72659a06050632da1a9b4c492302be46ac283f6b.zip |
no more explicit support for wide-chars; too much troble...
Diffstat (limited to 'ltm.c')
-rw-r--r-- | ltm.c | 43 |
1 files changed, 21 insertions, 22 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ltm.c,v 1.78 2001/08/31 19:46:07 roberto Exp $ | 2 | ** $Id: ltm.c,v 1.80 2001/10/11 21:41:21 roberto Exp $ |
3 | ** Tag methods | 3 | ** Tag methods |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -8,7 +8,6 @@ | |||
8 | #include <stdio.h> | 8 | #include <stdio.h> |
9 | #include <string.h> | 9 | #include <string.h> |
10 | 10 | ||
11 | #define LUA_PRIVATE | ||
12 | #include "lua.h" | 11 | #include "lua.h" |
13 | 12 | ||
14 | #include "ldo.h" | 13 | #include "ldo.h" |
@@ -20,16 +19,16 @@ | |||
20 | #include "ltm.h" | 19 | #include "ltm.h" |
21 | 20 | ||
22 | 21 | ||
23 | const l_char *const luaT_eventname[] = { /* ORDER TM */ | 22 | const char *const luaT_eventname[] = { /* ORDER TM */ |
24 | l_s("gettable"), l_s("settable"), l_s("index"), l_s("getglobal"), | 23 | "gettable", "settable", "index", "getglobal", |
25 | l_s("setglobal"), l_s("add"), l_s("sub"), l_s("mul"), l_s("div"), | 24 | "setglobal", "add", "sub", "mul", "div", |
26 | l_s("pow"), l_s("unm"), l_s("lt"), l_s("concat"), l_s("gc"), | 25 | "pow", "unm", "lt", "concat", "gc", |
27 | l_s("function"), | 26 | "function", |
28 | NULL | 27 | NULL |
29 | }; | 28 | }; |
30 | 29 | ||
31 | 30 | ||
32 | static int findevent (const l_char *name) { | 31 | static int findevent (const char *name) { |
33 | int i; | 32 | int i; |
34 | for (i=0; luaT_eventname[i]; i++) | 33 | for (i=0; luaT_eventname[i]; i++) |
35 | if (strcmp(luaT_eventname[i], name) == 0) | 34 | if (strcmp(luaT_eventname[i], name) == 0) |
@@ -38,10 +37,10 @@ static int findevent (const l_char *name) { | |||
38 | } | 37 | } |
39 | 38 | ||
40 | 39 | ||
41 | static int luaI_checkevent (lua_State *L, const l_char *name) { | 40 | static int luaI_checkevent (lua_State *L, const char *name) { |
42 | int e = findevent(name); | 41 | int e = findevent(name); |
43 | if (e < 0) | 42 | if (e < 0) |
44 | luaO_verror(L, l_s("`%.50s' is not a valid event name"), name); | 43 | luaO_verror(L, "`%.50s' is not a valid event name", name); |
45 | return e; | 44 | return e; |
46 | } | 45 | } |
47 | 46 | ||
@@ -66,9 +65,9 @@ static int luaT_validevent (int t, int e) { /* ORDER LUA_T */ | |||
66 | 65 | ||
67 | 66 | ||
68 | void luaT_init (lua_State *L) { | 67 | void luaT_init (lua_State *L) { |
69 | static const l_char *const typenames[NUM_TAGS] = { | 68 | static const char *const typenames[NUM_TAGS] = { |
70 | l_s("userdata"), l_s("nil"), l_s("number"), l_s("string"), | 69 | "userdata", "nil", "number", "string", |
71 | l_s("table"), l_s("function") | 70 | "table", "function" |
72 | }; | 71 | }; |
73 | int i; | 72 | int i; |
74 | for (i=0; i<NUM_TAGS; i++) | 73 | for (i=0; i<NUM_TAGS; i++) |
@@ -76,12 +75,12 @@ void luaT_init (lua_State *L) { | |||
76 | } | 75 | } |
77 | 76 | ||
78 | 77 | ||
79 | int luaT_newtag (lua_State *L, const l_char *name, int basictype) { | 78 | int luaT_newtag (lua_State *L, const char *name, int basictype) { |
80 | int tag; | 79 | int tag; |
81 | int i; | 80 | int i; |
82 | TString *ts = NULL; | 81 | TString *ts = NULL; |
83 | luaM_growvector(L, G(L)->TMtable, G(L)->ntag, G(L)->sizeTM, struct TM, | 82 | luaM_growvector(L, G(L)->TMtable, G(L)->ntag, G(L)->sizeTM, struct TM, |
84 | MAX_INT, l_s("tag table overflow")); | 83 | MAX_INT, "tag table overflow"); |
85 | tag = G(L)->ntag; | 84 | tag = G(L)->ntag; |
86 | if (name) { | 85 | if (name) { |
87 | const TObject *v; | 86 | const TObject *v; |
@@ -104,7 +103,7 @@ int luaT_newtag (lua_State *L, const l_char *name, int basictype) { | |||
104 | 103 | ||
105 | static void checktag (lua_State *L, int tag) { | 104 | static void checktag (lua_State *L, int tag) { |
106 | if (!(0 <= tag && tag < G(L)->ntag)) | 105 | if (!(0 <= tag && tag < G(L)->ntag)) |
107 | luaO_verror(L, l_s("%d is not a valid tag"), tag); | 106 | luaO_verror(L, "%d is not a valid tag", tag); |
108 | } | 107 | } |
109 | 108 | ||
110 | 109 | ||
@@ -118,7 +117,7 @@ int luaT_tag (const TObject *o) { | |||
118 | } | 117 | } |
119 | 118 | ||
120 | 119 | ||
121 | const l_char *luaT_typename (global_State *G, const TObject *o) { | 120 | const char *luaT_typename (global_State *G, const TObject *o) { |
122 | int t = ttype(o); | 121 | int t = ttype(o); |
123 | int tag; | 122 | int tag; |
124 | TString *ts; | 123 | TString *ts; |
@@ -139,7 +138,7 @@ const l_char *luaT_typename (global_State *G, const TObject *o) { | |||
139 | } | 138 | } |
140 | 139 | ||
141 | 140 | ||
142 | LUA_API void lua_gettagmethod (lua_State *L, int t, const l_char *event) { | 141 | LUA_API void lua_gettagmethod (lua_State *L, int t, const char *event) { |
143 | int e; | 142 | int e; |
144 | lua_lock(L); | 143 | lua_lock(L); |
145 | e = luaI_checkevent(L, event); | 144 | e = luaI_checkevent(L, event); |
@@ -154,16 +153,16 @@ LUA_API void lua_gettagmethod (lua_State *L, int t, const l_char *event) { | |||
154 | } | 153 | } |
155 | 154 | ||
156 | 155 | ||
157 | LUA_API void lua_settagmethod (lua_State *L, int t, const l_char *event) { | 156 | LUA_API void lua_settagmethod (lua_State *L, int t, const char *event) { |
158 | int e; | 157 | int e; |
159 | lua_lock(L); | 158 | lua_lock(L); |
160 | e = luaI_checkevent(L, event); | 159 | e = luaI_checkevent(L, event); |
161 | checktag(L, t); | 160 | checktag(L, t); |
162 | if (!luaT_validevent(t, e)) | 161 | if (!luaT_validevent(t, e)) |
163 | luaO_verror(L, l_s("cannot change `%.20s' tag method for type `%.20s'%.20s"), | 162 | luaO_verror(L, "cannot change `%.20s' tag method for type `%.20s'%.20s", |
164 | luaT_eventname[e], typenamebytag(G(L), t), | 163 | luaT_eventname[e], typenamebytag(G(L), t), |
165 | (t == LUA_TTABLE || t == LUA_TUSERDATA) ? | 164 | (t == LUA_TTABLE || t == LUA_TUSERDATA) ? |
166 | l_s(" with default tag") : l_s("")); | 165 | " with default tag" : ""); |
167 | switch (ttype(L->top - 1)) { | 166 | switch (ttype(L->top - 1)) { |
168 | case LUA_TNIL: | 167 | case LUA_TNIL: |
169 | luaT_gettm(G(L), t, e) = NULL; | 168 | luaT_gettm(G(L), t, e) = NULL; |
@@ -172,7 +171,7 @@ LUA_API void lua_settagmethod (lua_State *L, int t, const l_char *event) { | |||
172 | luaT_gettm(G(L), t, e) = clvalue(L->top - 1); | 171 | luaT_gettm(G(L), t, e) = clvalue(L->top - 1); |
173 | break; | 172 | break; |
174 | default: | 173 | default: |
175 | luaD_error(L, l_s("tag method must be a function (or nil)")); | 174 | luaD_error(L, "tag method must be a function (or nil)"); |
176 | } | 175 | } |
177 | L->top--; | 176 | L->top--; |
178 | lua_unlock(L); | 177 | lua_unlock(L); |