diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1997-04-02 14:44:18 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1997-04-02 14:44:18 -0300 |
commit | f29fbf2bf604aa425a5200f02a74f8311ece98f3 (patch) | |
tree | 1f4ceb4f71598c25030b13ba7c595f47becfd5d0 | |
parent | 4355e1afcdd5dd20d1ebf8aac27a7c109ea0c487 (diff) | |
download | lua-f29fbf2bf604aa425a5200f02a74f8311ece98f3.tar.gz lua-f29fbf2bf604aa425a5200f02a74f8311ece98f3.tar.bz2 lua-f29fbf2bf604aa425a5200f02a74f8311ece98f3.zip |
lua_getuserdata must return NULL if object is not userdata;
small BUG: wrong error message for a=b[1] (b not a table)
-rw-r--r-- | opcode.c | 16 |
1 files changed, 12 insertions, 4 deletions
@@ -3,7 +3,7 @@ | |||
3 | ** TecCGraf - PUC-Rio | 3 | ** TecCGraf - PUC-Rio |
4 | */ | 4 | */ |
5 | 5 | ||
6 | char *rcs_opcode="$Id: opcode.c,v 3.89 1997/03/31 20:59:09 roberto Exp roberto $"; | 6 | char *rcs_opcode="$Id: opcode.c,v 3.90 1997/04/01 19:02:43 roberto Exp roberto $"; |
7 | 7 | ||
8 | #include <setjmp.h> | 8 | #include <setjmp.h> |
9 | #include <stdio.h> | 9 | #include <stdio.h> |
@@ -332,7 +332,7 @@ static void pushsubscript (void) | |||
332 | } | 332 | } |
333 | } | 333 | } |
334 | else { /* object is not a table, and/or has a specific "gettable" method */ | 334 | else { /* object is not a table, and/or has a specific "gettable" method */ |
335 | if (im) | 335 | if (ttype(im) != LUA_T_NIL) |
336 | callIM(im, 2, 1); | 336 | callIM(im, 2, 1); |
337 | else | 337 | else |
338 | lua_error("indexed expression not a table"); | 338 | lua_error("indexed expression not a table"); |
@@ -821,10 +821,18 @@ char *lua_getstring (lua_Object object) | |||
821 | void *lua_getbinarydata (lua_Object object) | 821 | void *lua_getbinarydata (lua_Object object) |
822 | { | 822 | { |
823 | if (object == LUA_NOOBJECT || ttype(Address(object)) != LUA_T_USERDATA) | 823 | if (object == LUA_NOOBJECT || ttype(Address(object)) != LUA_T_USERDATA) |
824 | lua_error("getbinarydata: object is not binary data"); | 824 | return NULL; |
825 | return svalue(Address(object)); | 825 | else return svalue(Address(object)); |
826 | } | 826 | } |
827 | 827 | ||
828 | void *lua_getuserdata (lua_Object object) | ||
829 | { | ||
830 | void *add = lua_getbinarydata(object); | ||
831 | if (add == NULL) return NULL; | ||
832 | else return *(void **)add; | ||
833 | } | ||
834 | |||
835 | |||
828 | int lua_getbindatasize (lua_Object object) | 836 | int lua_getbindatasize (lua_Object object) |
829 | { | 837 | { |
830 | if (object == LUA_NOOBJECT || ttype(Address(object)) != LUA_T_USERDATA) | 838 | if (object == LUA_NOOBJECT || ttype(Address(object)) != LUA_T_USERDATA) |