diff options
| author | Lua Team <team@lua.org> | 1995-11-28 12:00:00 +0000 |
|---|---|---|
| committer | repogen <> | 1995-11-28 12:00:00 +0000 |
| commit | 71754d2f6423fb9b6e87658e58bafc5470d53f65 (patch) | |
| tree | c704e97b80e52a52d3152738941bb4c8ca676b97 /src/fallback.c | |
| parent | a8b6ba0954edb9e0e669e1f451b9a8f145ce5166 (diff) | |
| download | lua-github-2.2.tar.gz | |
Lua 2.22.2
Diffstat (limited to 'src/fallback.c')
| -rw-r--r-- | src/fallback.c | 50 |
1 files changed, 28 insertions, 22 deletions
diff --git a/src/fallback.c b/src/fallback.c index d5bbbba1..aa9fc99d 100644 --- a/src/fallback.c +++ b/src/fallback.c @@ -3,7 +3,7 @@ ** TecCGraf - PUC-Rio */ -char *rcs_fallback="$Id: fallback.c,v 1.11 1995/02/06 19:34:03 roberto Exp $"; +char *rcs_fallback="$Id: fallback.c,v 1.17 1995/10/17 14:30:05 roberto Exp $"; #include <stdio.h> #include <string.h> @@ -11,7 +11,6 @@ char *rcs_fallback="$Id: fallback.c,v 1.11 1995/02/06 19:34:03 roberto Exp $"; #include "mem.h" #include "fallback.h" #include "opcode.h" -#include "inout.h" #include "lua.h" @@ -29,15 +28,16 @@ static void funcFB (void); ** Warning: This list must be in the same order as the #define's */ struct FB luaI_fallBacks[] = { -{"error", {LUA_T_CFUNCTION, errorFB}}, -{"index", {LUA_T_CFUNCTION, indexFB}}, -{"gettable", {LUA_T_CFUNCTION, gettableFB}}, -{"arith", {LUA_T_CFUNCTION, arithFB}}, -{"order", {LUA_T_CFUNCTION, orderFB}}, -{"concat", {LUA_T_CFUNCTION, concatFB}}, -{"settable", {LUA_T_CFUNCTION, gettableFB}}, -{"gc", {LUA_T_CFUNCTION, GDFB}}, -{"function", {LUA_T_CFUNCTION, funcFB}} +{"error", {LUA_T_CFUNCTION, {errorFB}}, 1, 0}, +{"index", {LUA_T_CFUNCTION, {indexFB}}, 2, 1}, +{"gettable", {LUA_T_CFUNCTION, {gettableFB}}, 2, 1}, +{"arith", {LUA_T_CFUNCTION, {arithFB}}, 3, 1}, +{"order", {LUA_T_CFUNCTION, {orderFB}}, 3, 1}, +{"concat", {LUA_T_CFUNCTION, {concatFB}}, 2, 1}, +{"settable", {LUA_T_CFUNCTION, {gettableFB}}, 3, 0}, +{"gc", {LUA_T_CFUNCTION, {GDFB}}, 1, 0}, +{"function", {LUA_T_CFUNCTION, {funcFB}}, -1, -1} + /* no fixed number of params or results */ }; #define N_FB (sizeof(luaI_fallBacks)/sizeof(struct FB)) @@ -48,10 +48,7 @@ void luaI_setfallback (void) char *name = lua_getstring(lua_getparam(1)); lua_Object func = lua_getparam(2); if (name == NULL || !(lua_isfunction(func) || lua_iscfunction(func))) - { - lua_pushnil(); - return; - } + lua_error("incorrect argument to function `setfallback'"); for (i=0; i<N_FB; i++) { if (strcmp(luaI_fallBacks[i].kind, name) == 0) @@ -62,7 +59,7 @@ void luaI_setfallback (void) } } /* name not found */ - lua_pushnil(); + lua_error("incorrect argument to function `setfallback'"); } @@ -84,31 +81,31 @@ static void indexFB (void) static void gettableFB (void) { - lua_reportbug("indexed expression not a table"); + lua_error("indexed expression not a table"); } static void arithFB (void) { - lua_reportbug("unexpected type at conversion to number"); + lua_error("unexpected type at conversion to number"); } static void concatFB (void) { - lua_reportbug("unexpected type at conversion to string"); + lua_error("unexpected type at conversion to string"); } static void orderFB (void) { - lua_reportbug("unexpected type at comparison"); + lua_error("unexpected type at comparison"); } static void GDFB (void) { } static void funcFB (void) { - lua_reportbug("call expression not a function"); + lua_error("call expression not a function"); } @@ -162,10 +159,19 @@ Object *luaI_getlocked (int ref) } -void luaI_travlock (void (*fn)(Object *)) +void luaI_travlock (int (*fn)(Object *)) { Word i; for (i=0; i<lockSize; i++) fn(&lockArray[i]); } + +char *luaI_travfallbacks (int (*fn)(Object *)) +{ + Word i; + for (i=0; i<N_FB; i++) + if (fn(&luaI_fallBacks[i].function)) + return luaI_fallBacks[i].kind; + return NULL; +} |
