mirror of
https://github.com/lua/lua.git
synced 2025-02-04 06:13:04 +08:00
function "setfallback" now gives an error if called with wrong parameters.
This commit is contained in:
parent
d80659759b
commit
a66404aca6
@ -3,7 +3,7 @@
|
|||||||
** TecCGraf - PUC-Rio
|
** TecCGraf - PUC-Rio
|
||||||
*/
|
*/
|
||||||
|
|
||||||
char *rcs_fallback="$Id: fallback.c,v 1.15 1995/10/09 13:14:29 roberto Exp roberto $";
|
char *rcs_fallback="$Id: fallback.c,v 1.16 1995/10/17 11:52:38 roberto Exp roberto $";
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@ -48,10 +48,7 @@ void luaI_setfallback (void)
|
|||||||
char *name = lua_getstring(lua_getparam(1));
|
char *name = lua_getstring(lua_getparam(1));
|
||||||
lua_Object func = lua_getparam(2);
|
lua_Object func = lua_getparam(2);
|
||||||
if (name == NULL || !(lua_isfunction(func) || lua_iscfunction(func)))
|
if (name == NULL || !(lua_isfunction(func) || lua_iscfunction(func)))
|
||||||
{
|
lua_error("incorrect argument to function `setfallback'");
|
||||||
lua_pushnil();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
for (i=0; i<N_FB; i++)
|
for (i=0; i<N_FB; i++)
|
||||||
{
|
{
|
||||||
if (strcmp(luaI_fallBacks[i].kind, name) == 0)
|
if (strcmp(luaI_fallBacks[i].kind, name) == 0)
|
||||||
@ -62,7 +59,7 @@ void luaI_setfallback (void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* name not found */
|
/* name not found */
|
||||||
lua_pushnil();
|
lua_error("incorrect argument to function `setfallback'");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
8
opcode.c
8
opcode.c
@ -3,7 +3,7 @@
|
|||||||
** TecCGraf - PUC-Rio
|
** TecCGraf - PUC-Rio
|
||||||
*/
|
*/
|
||||||
|
|
||||||
char *rcs_opcode="$Id: opcode.c,v 3.44 1995/10/17 11:58:41 roberto Exp roberto $";
|
char *rcs_opcode="$Id: opcode.c,v 3.45 1995/10/17 14:12:45 roberto Exp $";
|
||||||
|
|
||||||
#include <setjmp.h>
|
#include <setjmp.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@ -500,8 +500,10 @@ lua_Object lua_setfallback (char *name, lua_CFunction fallback)
|
|||||||
stack[CBase].value.f = luaI_setfallback;
|
stack[CBase].value.f = luaI_setfallback;
|
||||||
lua_pushstring(name);
|
lua_pushstring(name);
|
||||||
lua_pushcfunction(fallback);
|
lua_pushcfunction(fallback);
|
||||||
do_protectedrun(1);
|
if (do_protectedrun(1) == 0)
|
||||||
return (Ref(top-1));
|
return (Ref(top-1));
|
||||||
|
else
|
||||||
|
return LUA_NOOBJECT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user