add more cases
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@7686 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
e5f50bd942
commit
ab790f802a
6 changed files with 136 additions and 56 deletions
|
|
@ -63,6 +63,16 @@ namespace hi {
|
||||||
|
|
||||||
typedef void VoidType;
|
typedef void VoidType;
|
||||||
|
|
||||||
|
struct Bar
|
||||||
|
{
|
||||||
|
int x;
|
||||||
|
Bar(int _x = 0) : x(_x)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class MyClass {
|
class MyClass {
|
||||||
public:
|
public:
|
||||||
MyClass(int a = 0)
|
MyClass(int a = 0)
|
||||||
|
|
@ -77,6 +87,22 @@ public:
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual Bar vmethod(Bar b)
|
||||||
|
{
|
||||||
|
b.x += 13;
|
||||||
|
return b;
|
||||||
|
}
|
||||||
|
|
||||||
|
Bar cmethod(const Bar &b)
|
||||||
|
{
|
||||||
|
return vmethod(b);
|
||||||
|
}
|
||||||
|
|
||||||
|
static MyClass *get_self(MyClass *c)
|
||||||
|
{
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
|
|
|
||||||
|
|
@ -452,3 +452,7 @@ template_typedef_import.py
|
||||||
li_cwstring.py
|
li_cwstring.py
|
||||||
compactdefaultargs.py
|
compactdefaultargs.py
|
||||||
refcount.py
|
refcount.py
|
||||||
|
li_implicit.py
|
||||||
|
director_wstring.py
|
||||||
|
immutable.py
|
||||||
|
inherit.py
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,16 @@
|
||||||
import director_basic
|
import director_basic
|
||||||
|
|
||||||
class MyFoo(director_basic.Foo):
|
class PyFoo(director_basic.Foo):
|
||||||
def ping(self):
|
def ping(self):
|
||||||
return "MyFoo::ping()"
|
return "PyFoo::ping()"
|
||||||
|
|
||||||
|
|
||||||
a = MyFoo()
|
a = PyFoo()
|
||||||
|
|
||||||
if a.ping() != "MyFoo::ping()":
|
if a.ping() != "PyFoo::ping()":
|
||||||
raise RuntimeError, a.ping()
|
raise RuntimeError, a.ping()
|
||||||
|
|
||||||
if a.pong() != "Foo::pong();MyFoo::ping()":
|
if a.pong() != "Foo::pong();PyFoo::ping()":
|
||||||
raise RuntimeError, a.pong()
|
raise RuntimeError, a.pong()
|
||||||
|
|
||||||
b = director_basic.Foo()
|
b = director_basic.Foo()
|
||||||
|
|
@ -26,3 +26,28 @@ a = director_basic.A1(1)
|
||||||
if a.rg(2) != 2:
|
if a.rg(2) != 2:
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class PyClass(director_basic.MyClass):
|
||||||
|
def vmethod(self, b):
|
||||||
|
b.x += 31
|
||||||
|
return b
|
||||||
|
|
||||||
|
|
||||||
|
b = director_basic.Bar(3)
|
||||||
|
d = director_basic.MyClass()
|
||||||
|
c = PyClass()
|
||||||
|
|
||||||
|
cc = PyClass.get_self(c)
|
||||||
|
dd = PyClass.get_self(d)
|
||||||
|
|
||||||
|
bc = cc.cmethod(b)
|
||||||
|
bd = dd.cmethod(b)
|
||||||
|
|
||||||
|
if bc.x != 34:
|
||||||
|
raise RuntimeError
|
||||||
|
|
||||||
|
|
||||||
|
if bd.x != 16:
|
||||||
|
raise RuntimeError
|
||||||
|
|
||||||
|
|
|
||||||
14
Examples/test-suite/python/li_cmalloc_runme.py
Normal file
14
Examples/test-suite/python/li_cmalloc_runme.py
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
from li_cmalloc import *
|
||||||
|
|
||||||
|
p = malloc_int()
|
||||||
|
free_int(p)
|
||||||
|
|
||||||
|
ok = 0
|
||||||
|
try:
|
||||||
|
p = calloc_int(-1)
|
||||||
|
free_int(p)
|
||||||
|
except:
|
||||||
|
ok = 1
|
||||||
|
|
||||||
|
if ok != 1:
|
||||||
|
raise RuntimeError
|
||||||
10
Examples/test-suite/python/li_cpointer_runme.py
Normal file
10
Examples/test-suite/python/li_cpointer_runme.py
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
from li_cpointer import *
|
||||||
|
|
||||||
|
|
||||||
|
p = new_intp()
|
||||||
|
intp_assign(p,3)
|
||||||
|
|
||||||
|
if intp_value(p) != 3:
|
||||||
|
raise RuntimeError
|
||||||
|
|
||||||
|
delete_intp(p)
|
||||||
|
|
@ -265,6 +265,7 @@ cvar.var_namet = pc
|
||||||
if cvar.var_namet != "hola":
|
if cvar.var_namet != "hola":
|
||||||
raise RuntimeError, "bad pointer case"
|
raise RuntimeError, "bad pointer case"
|
||||||
|
|
||||||
|
delete_pchar(pc)
|
||||||
|
|
||||||
#
|
#
|
||||||
# Now when things should fail
|
# Now when things should fail
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue