diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2002-02-07 15:25:36 -0200 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2002-02-07 15:25:36 -0200 |
| commit | 86a4de256e88844e34535901d25923aa851d963e (patch) | |
| tree | 99f8cd31a5199f4c0a20dfb5c290f361887f90c5 /ldblib.c | |
| parent | 53aaee6ee65bee24e3ce05c35fcdd002b4ef0658 (diff) | |
| download | lua-86a4de256e88844e34535901d25923aa851d963e.tar.gz lua-86a4de256e88844e34535901d25923aa851d963e.tar.bz2 lua-86a4de256e88844e34535901d25923aa851d963e.zip | |
no more lua_[gs]etstr
Diffstat (limited to 'ldblib.c')
| -rw-r--r-- | ldblib.c | 20 |
1 files changed, 13 insertions, 7 deletions
| @@ -18,14 +18,16 @@ | |||
| 18 | 18 | ||
| 19 | 19 | ||
| 20 | static void settabss (lua_State *L, const char *i, const char *v) { | 20 | static void settabss (lua_State *L, const char *i, const char *v) { |
| 21 | lua_pushstring(L, i); | ||
| 21 | lua_pushstring(L, v); | 22 | lua_pushstring(L, v); |
| 22 | lua_setstr(L, -2, i); | 23 | lua_rawset(L, -3); |
| 23 | } | 24 | } |
| 24 | 25 | ||
| 25 | 26 | ||
| 26 | static void settabsi (lua_State *L, const char *i, int v) { | 27 | static void settabsi (lua_State *L, const char *i, int v) { |
| 28 | lua_pushstring(L, i); | ||
| 27 | lua_pushnumber(L, v); | 29 | lua_pushnumber(L, v); |
| 28 | lua_setstr(L, -2, i); | 30 | lua_rawset(L, -3); |
| 29 | } | 31 | } |
| 30 | 32 | ||
| 31 | 33 | ||
| @@ -69,8 +71,9 @@ static int getinfo (lua_State *L) { | |||
| 69 | settabss(L, "namewhat", ar.namewhat); | 71 | settabss(L, "namewhat", ar.namewhat); |
| 70 | break; | 72 | break; |
| 71 | case 'f': | 73 | case 'f': |
| 72 | lua_pushvalue(L, -2); | 74 | lua_pushliteral(L, "func"); |
| 73 | lua_setstr(L, -2, "func"); | 75 | lua_pushvalue(L, -3); |
| 76 | lua_rawset(L, -3); | ||
| 74 | break; | 77 | break; |
| 75 | } | 78 | } |
| 76 | } | 79 | } |
| @@ -112,7 +115,8 @@ static int setlocal (lua_State *L) { | |||
| 112 | 115 | ||
| 113 | 116 | ||
| 114 | static void hookf (lua_State *L, const char *key) { | 117 | static void hookf (lua_State *L, const char *key) { |
| 115 | lua_getstr(L, LUA_REGISTRYINDEX, key); | 118 | lua_pushstring(L, key); |
| 119 | lua_rawget(L, LUA_REGISTRYINDEX); | ||
| 116 | if (lua_isfunction(L, -1)) { | 120 | if (lua_isfunction(L, -1)) { |
| 117 | lua_pushvalue(L, -2); /* original argument (below function) */ | 121 | lua_pushvalue(L, -2); /* original argument (below function) */ |
| 118 | lua_rawcall(L, 1, 0); | 122 | lua_rawcall(L, 1, 0); |
| @@ -143,9 +147,11 @@ static void sethook (lua_State *L, const char *key, lua_Hook hook, | |||
| 143 | (*sethookf)(L, hook); | 147 | (*sethookf)(L, hook); |
| 144 | else | 148 | else |
| 145 | luaL_argerror(L, 1, "function expected"); | 149 | luaL_argerror(L, 1, "function expected"); |
| 146 | lua_getstr(L, LUA_REGISTRYINDEX, key); /* get old value */ | 150 | lua_pushstring(L, key); |
| 151 | lua_rawget(L, LUA_REGISTRYINDEX); /* get old value */ | ||
| 152 | lua_pushstring(L, key); | ||
| 147 | lua_pushvalue(L, 1); | 153 | lua_pushvalue(L, 1); |
| 148 | lua_setstr(L, LUA_REGISTRYINDEX, key); /* set new value */ | 154 | lua_rawset(L, LUA_REGISTRYINDEX); /* set new value */ |
| 149 | } | 155 | } |
| 150 | 156 | ||
| 151 | 157 | ||
