mirror of https://github.com/rusefi/lua.git
lua_getuserdata must return NULL if object is not userdata;
small BUG: wrong error message for a=b[1] (b not a table)
This commit is contained in:
parent
4355e1afcd
commit
f29fbf2bf6
16
opcode.c
16
opcode.c
|
@ -3,7 +3,7 @@
|
||||||
** TecCGraf - PUC-Rio
|
** 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 <setjmp.h>
|
||||||
#include <stdio.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 */
|
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);
|
callIM(im, 2, 1);
|
||||||
else
|
else
|
||||||
lua_error("indexed expression not a table");
|
lua_error("indexed expression not a table");
|
||||||
|
@ -821,10 +821,18 @@ char *lua_getstring (lua_Object object)
|
||||||
void *lua_getbinarydata (lua_Object object)
|
void *lua_getbinarydata (lua_Object object)
|
||||||
{
|
{
|
||||||
if (object == LUA_NOOBJECT || ttype(Address(object)) != LUA_T_USERDATA)
|
if (object == LUA_NOOBJECT || ttype(Address(object)) != LUA_T_USERDATA)
|
||||||
lua_error("getbinarydata: object is not binary data");
|
return NULL;
|
||||||
return svalue(Address(object));
|
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)
|
int lua_getbindatasize (lua_Object object)
|
||||||
{
|
{
|
||||||
if (object == LUA_NOOBJECT || ttype(Address(object)) != LUA_T_USERDATA)
|
if (object == LUA_NOOBJECT || ttype(Address(object)) != LUA_T_USERDATA)
|
||||||
|
|
Loading…
Reference in New Issue