diff options
| -rw-r--r-- | lua.h | 9 | ||||
| -rw-r--r-- | opcode.c | 26 |
2 files changed, 18 insertions, 17 deletions
| @@ -2,7 +2,7 @@ | |||
| 2 | ** LUA - An Extensible Extension Language | 2 | ** LUA - An Extensible Extension Language |
| 3 | ** TeCGraf: Grupo de Tecnologia em Computacao Grafica, PUC-Rio, Brazil | 3 | ** TeCGraf: Grupo de Tecnologia em Computacao Grafica, PUC-Rio, Brazil |
| 4 | ** e-mail: lua@tecgraf.puc-rio.br | 4 | ** e-mail: lua@tecgraf.puc-rio.br |
| 5 | ** $Id: lua.h,v 4.5 1997/06/06 20:54:40 roberto Exp roberto $ | 5 | ** $Id: lua.h,v 4.6 1997/06/09 17:28:14 roberto Exp roberto $ |
| 6 | */ | 6 | */ |
| 7 | 7 | ||
| 8 | 8 | ||
| @@ -21,8 +21,8 @@ | |||
| 21 | typedef void (*lua_CFunction) (void); | 21 | typedef void (*lua_CFunction) (void); |
| 22 | typedef unsigned int lua_Object; | 22 | typedef unsigned int lua_Object; |
| 23 | 23 | ||
| 24 | void lua_settagmethod (int tag, char *event, lua_CFunction method); | 24 | lua_Object lua_settagmethod (int tag, char *event, lua_CFunction method); |
| 25 | void lua_gettagmethod (int tag, char *event); /* out: method */ | 25 | lua_Object lua_gettagmethod (int tag, char *event); |
| 26 | void lua_seterrormethod (lua_CFunction method); | 26 | void lua_seterrormethod (lua_CFunction method); |
| 27 | 27 | ||
| 28 | int lua_newtag (void); | 28 | int lua_newtag (void); |
| @@ -81,9 +81,6 @@ void lua_unref (int ref); | |||
| 81 | 81 | ||
| 82 | lua_Object lua_createtable (void); | 82 | lua_Object lua_createtable (void); |
| 83 | 83 | ||
| 84 | lua_Object lua_getudata (void *u, int tag); | ||
| 85 | |||
| 86 | |||
| 87 | long lua_collectgarbage (long limit); | 84 | long lua_collectgarbage (long limit); |
| 88 | 85 | ||
| 89 | 86 | ||
| @@ -3,7 +3,7 @@ | |||
| 3 | ** TecCGraf - PUC-Rio | 3 | ** TecCGraf - PUC-Rio |
| 4 | */ | 4 | */ |
| 5 | 5 | ||
| 6 | char *rcs_opcode="$Id: opcode.c,v 4.6 1997/06/06 20:54:40 roberto Exp roberto $"; | 6 | char *rcs_opcode="$Id: opcode.c,v 4.7 1997/06/09 17:28:14 roberto Exp roberto $"; |
| 7 | 7 | ||
| 8 | #include <setjmp.h> | 8 | #include <setjmp.h> |
| 9 | #include <stdio.h> | 9 | #include <stdio.h> |
| @@ -552,13 +552,14 @@ static void do_callinc (int nResults) | |||
| 552 | CLS_current.base = base + CLS_current.num; /* incorporate results on stack */ | 552 | CLS_current.base = base + CLS_current.num; /* incorporate results on stack */ |
| 553 | } | 553 | } |
| 554 | 554 | ||
| 555 | |||
| 555 | static void do_unprotectedrun (lua_CFunction f, int nParams, int nResults) | 556 | static void do_unprotectedrun (lua_CFunction f, int nParams, int nResults) |
| 556 | { | 557 | { |
| 557 | adjustC(nParams); | 558 | StkId base = (top-stack)-nParams; |
| 558 | open_stack((top-stack)-CLS_current.base); | 559 | open_stack(nParams); |
| 559 | stack[CLS_current.base].ttype = LUA_T_CFUNCTION; | 560 | stack[base].ttype = LUA_T_CFUNCTION; |
| 560 | stack[CLS_current.base].value.f = f; | 561 | stack[base].value.f = f; |
| 561 | do_callinc(nResults); | 562 | do_call(base+1, nResults); |
| 562 | } | 563 | } |
| 563 | 564 | ||
| 564 | 565 | ||
| @@ -687,17 +688,18 @@ lua_Object lua_setfallback (char *name, lua_CFunction fallback) | |||
| 687 | lua_pushstring(name); | 688 | lua_pushstring(name); |
| 688 | lua_pushcfunction(fallback); | 689 | lua_pushcfunction(fallback); |
| 689 | do_unprotectedrun(luaI_setfallback, 2, 1); | 690 | do_unprotectedrun(luaI_setfallback, 2, 1); |
| 690 | return (Ref(top-1)); | 691 | return put_luaObjectonTop(); |
| 691 | } | 692 | } |
| 692 | 693 | ||
| 693 | void lua_gettagmethod (int tag, char *event) | 694 | lua_Object lua_gettagmethod (int tag, char *event) |
| 694 | { | 695 | { |
| 695 | lua_pushnumber(tag); | 696 | lua_pushnumber(tag); |
| 696 | lua_pushstring(event); | 697 | lua_pushstring(event); |
| 697 | do_unprotectedrun(luaI_gettagmethod, 2, 1); | 698 | do_unprotectedrun(luaI_gettagmethod, 2, 1); |
| 699 | return put_luaObjectonTop(); | ||
| 698 | } | 700 | } |
| 699 | 701 | ||
| 700 | void lua_settagmethod (int tag, char *event, lua_CFunction method) | 702 | lua_Object lua_settagmethod (int tag, char *event, lua_CFunction method) |
| 701 | { | 703 | { |
| 702 | lua_pushnumber(tag); | 704 | lua_pushnumber(tag); |
| 703 | lua_pushstring(event); | 705 | lua_pushstring(event); |
| @@ -706,11 +708,12 @@ void lua_settagmethod (int tag, char *event, lua_CFunction method) | |||
| 706 | else | 708 | else |
| 707 | lua_pushnil(); | 709 | lua_pushnil(); |
| 708 | do_unprotectedrun(luaI_settagmethod, 3, 1); | 710 | do_unprotectedrun(luaI_settagmethod, 3, 1); |
| 711 | return put_luaObjectonTop(); | ||
| 709 | } | 712 | } |
| 710 | 713 | ||
| 711 | void lua_seterrormethod (lua_CFunction method) | 714 | void lua_seterrormethod (lua_CFunction method) |
| 712 | { | 715 | { |
| 713 | lua_pushcfunction (method); | 716 | lua_pushcfunction(method); |
| 714 | do_unprotectedrun(luaI_seterrormethod, 1, 0); | 717 | do_unprotectedrun(luaI_seterrormethod, 1, 0); |
| 715 | } | 718 | } |
| 716 | 719 | ||
| @@ -992,7 +995,8 @@ void lua_pushcfunction (lua_CFunction fn) | |||
| 992 | 995 | ||
| 993 | void lua_pushusertag (void *u, int tag) | 996 | void lua_pushusertag (void *u, int tag) |
| 994 | { | 997 | { |
| 995 | if (tag < 0) luaI_realtag(tag); /* error if tag is not valid */ | 998 | if (tag < 0 && tag != LUA_ANYTAG) |
| 999 | luaI_realtag(tag); /* error if tag is not valid */ | ||
| 996 | tsvalue(top) = luaI_createudata(u, tag); | 1000 | tsvalue(top) = luaI_createudata(u, tag); |
| 997 | ttype(top) = LUA_T_USERDATA; | 1001 | ttype(top) = LUA_T_USERDATA; |
| 998 | incr_top; | 1002 | incr_top; |
