Fix unwrapping of LUA lightuserdata type. Add test case.
This commit is contained in:
parent
b465531141
commit
33c59614fc
4 changed files with 29 additions and 0 deletions
|
|
@ -15,6 +15,7 @@ top_builddir = @top_builddir@
|
||||||
CPP_TEST_CASES += \
|
CPP_TEST_CASES += \
|
||||||
lua_no_module_global \
|
lua_no_module_global \
|
||||||
lua_inherit_getitem \
|
lua_inherit_getitem \
|
||||||
|
lua_lightuserdata \
|
||||||
|
|
||||||
|
|
||||||
C_TEST_CASES += \
|
C_TEST_CASES += \
|
||||||
|
|
|
||||||
7
Examples/test-suite/lua/lua_lightuserdata_runme.lua
Normal file
7
Examples/test-suite/lua/lua_lightuserdata_runme.lua
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
require("import") -- the import fn
|
||||||
|
require("lua_lightuserdata") -- import lib
|
||||||
|
|
||||||
|
local t = lua_lightuserdata
|
||||||
|
local d = t.get_lightuserdata()
|
||||||
|
local r = t.check_lighuserdata(d)
|
||||||
|
assert(r)
|
||||||
16
Examples/test-suite/lua_lightuserdata.i
Normal file
16
Examples/test-suite/lua_lightuserdata.i
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
%module lua_lightuserdata
|
||||||
|
|
||||||
|
%native(get_lightuserdata) int get_lightuserdata(lua_State* L);
|
||||||
|
%{
|
||||||
|
int get_lightuserdata(lua_State* L)
|
||||||
|
{
|
||||||
|
lua_pushlightuserdata(L, reinterpret_cast<void*>(0x123456));
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
%}
|
||||||
|
|
||||||
|
%inline %{
|
||||||
|
bool check_lighuserdata(const void* d) {
|
||||||
|
return reinterpret_cast<void*>(0x123456) == d;
|
||||||
|
}
|
||||||
|
%}
|
||||||
|
|
@ -1765,6 +1765,11 @@ SWIGRUNTIME int SWIG_Lua_ConvertPtr(lua_State *L,int index,void **ptr,swig_type
|
||||||
*ptr=0;
|
*ptr=0;
|
||||||
return (flags & SWIG_POINTER_NO_NULL) ? SWIG_NullReferenceError : SWIG_OK;
|
return (flags & SWIG_POINTER_NO_NULL) ? SWIG_NullReferenceError : SWIG_OK;
|
||||||
}
|
}
|
||||||
|
if (lua_islightuserdata(L,index))
|
||||||
|
{
|
||||||
|
*ptr=lua_touserdata(L,index);
|
||||||
|
return (flags & SWIG_POINTER_NO_NULL) ? SWIG_NullReferenceError : SWIG_OK;
|
||||||
|
}
|
||||||
usr=(swig_lua_userdata*)lua_touserdata(L,index); /* get data */
|
usr=(swig_lua_userdata*)lua_touserdata(L,index); /* get data */
|
||||||
if (usr)
|
if (usr)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue