Bugfix #1542466 added code to allow mapping Lua nil's <-> C/C++ NULL's

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@9256 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Mark Gossage 2006-08-21 08:00:13 +00:00
commit 02f0a49bc5
4 changed files with 83 additions and 8 deletions

View file

@ -0,0 +1,37 @@
-- demo of lua swig
require("import") -- the import fn
import("voidtest") -- import lib
-- test calling functions
voidtest.globalfunc()
f = voidtest.Foo()
f:memberfunc() -- member fns must have : not a .
voidtest.Foo_staticmemberfunc() -- static member fns are still a little messy
v1 = voidtest.vfunc1(f)
v2 = voidtest.vfunc2(f)
assert(swig_equals(v1,v2)) -- a raw equals will not work, we look at the raw pointers
v3 = voidtest.vfunc3(v1)
assert(swig_equals(v3,f))
v4 = voidtest.vfunc1(f)
assert(swig_equals(v4,v1))
v3:memberfunc()
-- also testing nil's support
-- nil, are acceptable anywhere a pointer is
n1 = voidtest.vfunc1(nil)
n2 = voidtest.vfunc2(nil)
assert(n1==nil)
assert(n2==nil)
n3 = voidtest.vfunc3(n1)
n4 = voidtest.vfunc1(nil)
assert(n3==nil)
assert(n4==nil)