commit f29fbf2bf604aa425a5200f02a74f8311ece98f3
parent 4355e1afcdd5dd20d1ebf8aac27a7c109ea0c487
Author: Roberto Ierusalimschy <roberto@inf.puc-rio.br>
Date: Wed, 2 Apr 1997 14:43:58 -0300
lua_getuserdata must return NULL if object is not userdata;
small BUG: wrong error message for a=b[1] (b not a table)
Diffstat:
1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/opcode.c b/opcode.c
@@ -3,7 +3,7 @@
** TecCGraf - PUC-Rio
*/
-char *rcs_opcode="$Id: opcode.c,v 3.89 1997/03/31 20:59:09 roberto Exp roberto $";
+char *rcs_opcode="$Id: opcode.c,v 3.90 1997/04/01 19:02:43 roberto Exp roberto $";
#include <setjmp.h>
#include <stdio.h>
@@ -332,7 +332,7 @@ static void pushsubscript (void)
}
}
else { /* object is not a table, and/or has a specific "gettable" method */
- if (im)
+ if (ttype(im) != LUA_T_NIL)
callIM(im, 2, 1);
else
lua_error("indexed expression not a table");
@@ -821,10 +821,18 @@ char *lua_getstring (lua_Object object)
void *lua_getbinarydata (lua_Object object)
{
if (object == LUA_NOOBJECT || ttype(Address(object)) != LUA_T_USERDATA)
- lua_error("getbinarydata: object is not binary data");
- return svalue(Address(object));
+ return NULL;
+ else return svalue(Address(object));
}
+void *lua_getuserdata (lua_Object object)
+{
+ void *add = lua_getbinarydata(object);
+ if (add == NULL) return NULL;
+ else return *(void **)add;
+}
+
+
int lua_getbindatasize (lua_Object object)
{
if (object == LUA_NOOBJECT || ttype(Address(object)) != LUA_T_USERDATA)