diff options
Diffstat (limited to 'lapi.c')
| -rw-r--r-- | lapi.c | 27 |
1 files changed, 2 insertions, 25 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lapi.c,v 1.47 1999/06/22 20:37:23 roberto Exp roberto $ | 2 | ** $Id: lapi.c,v 1.48 1999/08/16 20:52:00 roberto Exp roberto $ |
| 3 | ** Lua API | 3 | ** Lua API |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -85,7 +85,7 @@ static lua_Object put_luaObject (const TObject *o) { | |||
| 85 | } | 85 | } |
| 86 | 86 | ||
| 87 | 87 | ||
| 88 | static lua_Object put_luaObjectonTop (void) { | 88 | lua_Object put_luaObjectonTop (void) { |
| 89 | luaD_openstack((L->stack.top-L->stack.stack)-L->Cstack.base); | 89 | luaD_openstack((L->stack.top-L->stack.stack)-L->Cstack.base); |
| 90 | L->stack.stack[L->Cstack.base++] = *(--L->stack.top); | 90 | L->stack.stack[L->Cstack.base++] = *(--L->stack.top); |
| 91 | return L->Cstack.base; /* this is +1 real position (see Ref) */ | 91 | return L->Cstack.base; /* this is +1 real position (see Ref) */ |
| @@ -629,26 +629,3 @@ lua_Object lua_getref (int ref) { | |||
| 629 | 629 | ||
| 630 | /* }====================================================== */ | 630 | /* }====================================================== */ |
| 631 | 631 | ||
| 632 | |||
| 633 | |||
| 634 | #ifdef LUA_COMPAT2_5 | ||
| 635 | /* | ||
| 636 | ** API: set a function as a fallback | ||
| 637 | */ | ||
| 638 | |||
| 639 | static void do_unprotectedrun (lua_CFunction f, int nParams, int nResults) { | ||
| 640 | luaD_openstack(nParams); | ||
| 641 | (L->stack.top-nParams)->ttype = LUA_T_CPROTO; | ||
| 642 | (L->stack.top-nParams)->value.f = f; | ||
| 643 | luaD_calln(nParams, nResults); | ||
| 644 | } | ||
| 645 | |||
| 646 | |||
| 647 | lua_Object lua_setfallback (char *name, lua_CFunction fallback) { | ||
| 648 | lua_pushstring(name); | ||
| 649 | lua_pushcfunction(fallback); | ||
| 650 | do_unprotectedrun(luaT_setfallback, 2, 1); | ||
| 651 | return put_luaObjectonTop(); | ||
| 652 | } | ||
| 653 | #endif | ||
| 654 | |||
