aboutsummaryrefslogtreecommitdiff
path: root/ltm.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>1999-08-16 17:52:00 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>1999-08-16 17:52:00 -0300
commitc787dccd9b5c3e55547a2c4bb598c0276de65034 (patch)
treec4cdf2f7319fee48e048472a2044119f541e8da2 /ltm.c
parentb44e35b773bcaa9891d80a117392911ab5f656e5 (diff)
downloadlua-c787dccd9b5c3e55547a2c4bb598c0276de65034.tar.gz
lua-c787dccd9b5c3e55547a2c4bb598c0276de65034.tar.bz2
lua-c787dccd9b5c3e55547a2c4bb598c0276de65034.zip
"const" !!!
Diffstat (limited to 'ltm.c')
-rw-r--r--ltm.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/ltm.c b/ltm.c
index a9b3b515..4c0a0876 100644
--- a/ltm.c
+++ b/ltm.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ltm.c,v 1.24 1999/02/26 15:48:55 roberto Exp roberto $ 2** $Id: ltm.c,v 1.25 1999/05/21 19:41:49 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*/
@@ -15,14 +15,14 @@
15#include "ltm.h" 15#include "ltm.h"
16 16
17 17
18char *luaT_eventname[] = { /* ORDER IM */ 18const char *const luaT_eventname[] = { /* ORDER IM */
19 "gettable", "settable", "index", "getglobal", "setglobal", "add", 19 "gettable", "settable", "index", "getglobal", "setglobal", "add",
20 "sub", "mul", "div", "pow", "unm", "lt", "le", "gt", "ge", 20 "sub", "mul", "div", "pow", "unm", "lt", "le", "gt", "ge",
21 "concat", "gc", "function", NULL 21 "concat", "gc", "function", NULL
22}; 22};
23 23
24 24
25static int luaI_checkevent (char *name, char *list[]) { 25static int luaI_checkevent (const char *name, const char *const list[]) {
26 int e = luaL_findstring(name, list); 26 int e = luaL_findstring(name, list);
27 if (e < 0) 27 if (e < 0)
28 luaL_verror("`%.50s' is not a valid event name", name); 28 luaL_verror("`%.50s' is not a valid event name", name);
@@ -34,7 +34,8 @@ static int luaI_checkevent (char *name, char *list[]) {
34/* events in LUA_T_NIL are all allowed, since this is used as a 34/* events in LUA_T_NIL are all allowed, since this is used as a
35* 'placeholder' for "default" fallbacks 35* 'placeholder' for "default" fallbacks
36*/ 36*/
37static char luaT_validevents[NUM_TAGS][IM_N] = { /* ORDER LUA_T, ORDER IM */ 37/* ORDER LUA_T, ORDER IM */
38static const char luaT_validevents[NUM_TAGS][IM_N] = {
38{1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1}, /* LUA_T_USERDATA */ 39{1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1}, /* LUA_T_USERDATA */
39{1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1}, /* LUA_T_NUMBER */ 40{1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1}, /* LUA_T_NUMBER */
40{1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}, /* LUA_T_STRING */ 41{1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}, /* LUA_T_STRING */
@@ -96,7 +97,7 @@ int lua_copytagmethods (int tagto, int tagfrom) {
96} 97}
97 98
98 99
99int luaT_effectivetag (TObject *o) { 100int luaT_effectivetag (const TObject *o) {
100 int t; 101 int t;
101 switch (t = ttype(o)) { 102 switch (t = ttype(o)) {
102 case LUA_T_ARRAY: 103 case LUA_T_ARRAY:
@@ -118,7 +119,7 @@ int luaT_effectivetag (TObject *o) {
118} 119}
119 120
120 121
121TObject *luaT_gettagmethod (int t, char *event) { 122const TObject *luaT_gettagmethod (int t, const char *event) {
122 int e = luaI_checkevent(event, luaT_eventname); 123 int e = luaI_checkevent(event, luaT_eventname);
123 checktag(t); 124 checktag(t);
124 if (luaT_validevent(t, e)) 125 if (luaT_validevent(t, e))
@@ -128,7 +129,7 @@ TObject *luaT_gettagmethod (int t, char *event) {
128} 129}
129 130
130 131
131void luaT_settagmethod (int t, char *event, TObject *func) { 132void luaT_settagmethod (int t, const char *event, TObject *func) {
132 TObject temp; 133 TObject temp;
133 int e = luaI_checkevent(event, luaT_eventname); 134 int e = luaI_checkevent(event, luaT_eventname);
134 checktag(t); 135 checktag(t);
@@ -143,7 +144,7 @@ void luaT_settagmethod (int t, char *event, TObject *func) {
143} 144}
144 145
145 146
146char *luaT_travtagmethods (int (*fn)(TObject *)) { /* ORDER IM */ 147const char *luaT_travtagmethods (int (*fn)(TObject *)) { /* ORDER IM */
147 int e; 148 int e;
148 for (e=IM_GETTABLE; e<=IM_FUNCTION; e++) { 149 for (e=IM_GETTABLE; e<=IM_FUNCTION; e++) {
149 int t; 150 int t;
@@ -191,10 +192,11 @@ static void fillvalids (IMS e, TObject *func) {
191 192
192 193
193void luaT_setfallback (void) { 194void luaT_setfallback (void) {
194 static char *oldnames [] = {"error", "getglobal", "arith", "order", NULL}; 195 static const char *const oldnames [] = {"error", "getglobal", "arith",
196 "order", NULL};
195 TObject oldfunc; 197 TObject oldfunc;
196 lua_CFunction replace; 198 lua_CFunction replace;
197 char *name = luaL_check_string(1); 199 const char *name = luaL_check_string(1);
198 lua_Object func = lua_getparam(2); 200 lua_Object func = lua_getparam(2);
199 luaL_arg_check(lua_isfunction(func), 2, "function expected"); 201 luaL_arg_check(lua_isfunction(func), 2, "function expected");
200 switch (luaL_findstring(name, oldnames)) { 202 switch (luaL_findstring(name, oldnames)) {