Merge branch 'master' into gsoc2009-matevz

parser.y still to be fixed up

Conflicts:
	Doc/Devel/engineering.html
	Examples/Makefile.in
	Lib/allegrocl/allegrocl.swg
	Lib/csharp/csharp.swg
	Lib/csharp/enums.swg
	Lib/csharp/enumsimple.swg
	Lib/csharp/enumtypesafe.swg
	Lib/java/java.swg
	Lib/python/pydocs.swg
	Lib/r/rtype.swg
	Source/Include/swigwarn.h
	Source/Modules/octave.cxx
	Source/Modules/python.cxx
	Source/Modules/ruby.cxx
	Source/Swig/scanner.c
	Source/Swig/stype.c
	Source/Swig/swig.h
	configure.ac
This commit is contained in:
William S Fulton 2013-01-28 07:01:37 +00:00
commit e805d5f925
1074 changed files with 54339 additions and 20134 deletions

View file

@ -31,40 +31,43 @@ PY2TO3 = 2to3 -x import
CPP_TEST_CASES += \
argcargvtest \
python_autodoc \
python_append \
callback \
complextest \
director_stl \
director_wstring \
file_test \
iadd \
inout \
input \
inplaceadd \
implicittest \
inout \
inplaceadd \
input \
kwargs_feature \
li_cstring \
li_cwstring \
li_factory \
li_implicit \
li_std_vectora \
li_std_vector_extra \
li_std_containers_int \
li_std_map_member \
li_std_multimap \
li_std_pair_extra \
li_std_set \
li_std_stream \
li_std_string_extra \
li_std_vectora \
li_std_vector_extra \
li_std_wstream \
li_std_wstring \
primitive_types \
python_abstractbase \
python_kwargs \
python_append \
python_director \
python_nondynamic \
python_overload_simple_cast \
python_richcompare \
simutry \
std_containers \
swigobject \
template_matrix \
simutry
template_matrix
# li_std_carray
# director_profile
@ -74,7 +77,8 @@ C_TEST_CASES += \
file_test \
li_cstring \
li_cwstring \
python_nondynamic
python_nondynamic \
python_varargs_typemap
#
# This test only works with modern C compilers
@ -84,6 +88,19 @@ C_TEST_CASES += \
include $(srcdir)/../common.mk
BUILTIN_BROKEN = \
default_constructor.cpptest \
director_exception.cpptest \
exception_order.cpptest \
li_std_string_extra.cpptest \
li_std_wstring.cpptest \
python_abstractbase.cpptest \
threads_exception.cpptest
BUILTIN_NOT_BROKEN = $(filter-out $(BUILTIN_BROKEN),$(NOT_BROKEN_TEST_CASES))
builtin-check : $(BUILTIN_NOT_BROKEN)
# Overridden variables here
LIBS = -L.
VALGRIND_OPT += --suppressions=pythonswig.supp
@ -117,7 +134,7 @@ VALGRIND_OPT += --suppressions=pythonswig.supp
# Runs the testcase. A testcase is only run if
# a file is found which has _runme.py (or _runme3.py for Python 3) appended after the testcase name.
run_python = env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH PYTHONPATH=$(srcdir):$$PYTHONPATH $(RUNTOOL) $(PYTHON) $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX)
run_python = env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH PYTHONPATH=.:$(srcdir):$$PYTHONPATH $(RUNTOOL) $(PYTHON) $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX)
py2_runme = $(srcdir)/$(SCRIPTPREFIX)$*$(PY2SCRIPTSUFFIX)
py3_runme = $(srcdir)/$(SCRIPTPREFIX)$*$(PY3SCRIPTSUFFIX)

View file

@ -2,16 +2,16 @@ from argcargvtest import *
largs=['hi','hola','hello']
if mainc(largs) != 3:
raise RuntimeError, "bad main typemap"
raise RuntimeError("bad main typemap")
targs=('hi','hola')
if mainv(targs,1) != 'hola':
print mainv(targs,1)
raise RuntimeError, "bad main typemap"
print(mainv(targs,1))
raise RuntimeError("bad main typemap")
targs=('hi', 'hola')
if mainv(targs,1) != 'hola':
raise RuntimeError, "bad main typemap"
raise RuntimeError("bad main typemap")
try:
error = 0
@ -20,7 +20,7 @@ try:
except TypeError:
pass
if error:
raise RuntimeError, "bad main typemap"
raise RuntimeError("bad main typemap")

View file

@ -0,0 +1,176 @@
from autodoc import *
def check(got, expected):
if expected != got:
raise RuntimeError("\n" + "Expected: [" + str(expected) + "]\n" + "Got : [" + str(got) + "]")
check(A.__doc__, "Proxy of C++ A class")
check(A.funk.__doc__, "just a string")
check(A.func0.__doc__, "func0(self, arg2, hello) -> int")
check(A.func1.__doc__, "func1(A self, short arg2, Tuple hello) -> int")
check(A.func2.__doc__, "\n"
" func2(self, arg2, hello) -> int\n"
"\n"
" Parameters:\n"
" arg2: short\n"
" hello: int tuple[2]\n"
"\n"
" "
)
check(A.func3.__doc__, "\n"
" func3(A self, short arg2, Tuple hello) -> int\n"
"\n"
" Parameters:\n"
" arg2: short\n"
" hello: int tuple[2]\n"
"\n"
" "
)
check(A.func0default.__doc__, "\n"
" func0default(self, e, arg3, hello, f=2) -> int\n"
" func0default(self, e, arg3, hello) -> int\n"
" "
)
check(A.func1default.__doc__, "\n"
" func1default(A self, A e, short arg3, Tuple hello, double f=2) -> int\n"
" func1default(A self, A e, short arg3, Tuple hello) -> int\n"
" "
)
check(A.func2default.__doc__, "\n"
" func2default(self, e, arg3, hello, f=2) -> int\n"
"\n"
" Parameters:\n"
" e: A *\n"
" arg3: short\n"
" hello: int tuple[2]\n"
" f: double\n"
"\n"
" func2default(self, e, arg3, hello) -> int\n"
"\n"
" Parameters:\n"
" e: A *\n"
" arg3: short\n"
" hello: int tuple[2]\n"
"\n"
" "
)
check(A.func3default.__doc__, "\n"
" func3default(A self, A e, short arg3, Tuple hello, double f=2) -> int\n"
"\n"
" Parameters:\n"
" e: A *\n"
" arg3: short\n"
" hello: int tuple[2]\n"
" f: double\n"
"\n"
" func3default(A self, A e, short arg3, Tuple hello) -> int\n"
"\n"
" Parameters:\n"
" e: A *\n"
" arg3: short\n"
" hello: int tuple[2]\n"
"\n"
" "
)
check(A.func0static.__doc__, "\n"
" func0static(e, arg2, hello, f=2) -> int\n"
" func0static(e, arg2, hello) -> int\n"
" "
)
check(A.func1static.__doc__, "\n"
" func1static(A e, short arg2, Tuple hello, double f=2) -> int\n"
" func1static(A e, short arg2, Tuple hello) -> int\n"
" "
)
check(A.func2static.__doc__, "\n"
" func2static(e, arg2, hello, f=2) -> int\n"
"\n"
" Parameters:\n"
" e: A *\n"
" arg2: short\n"
" hello: int tuple[2]\n"
" f: double\n"
"\n"
" func2static(e, arg2, hello) -> int\n"
"\n"
" Parameters:\n"
" e: A *\n"
" arg2: short\n"
" hello: int tuple[2]\n"
"\n"
" "
)
check(A.func3static.__doc__, "\n"
" func3static(A e, short arg2, Tuple hello, double f=2) -> int\n"
"\n"
" Parameters:\n"
" e: A *\n"
" arg2: short\n"
" hello: int tuple[2]\n"
" f: double\n"
"\n"
" func3static(A e, short arg2, Tuple hello) -> int\n"
"\n"
" Parameters:\n"
" e: A *\n"
" arg2: short\n"
" hello: int tuple[2]\n"
"\n"
" "
)
check(A.variable_a.__doc__, "A_variable_a_get(self) -> int")
check(A.variable_b.__doc__, "A_variable_b_get(A self) -> int")
check(A.variable_c.__doc__, "\n"
"A_variable_c_get(self) -> int\n"
"\n"
"Parameters:\n"
" self: A *\n"
"\n"
)
check(A.variable_d.__doc__, "\n"
"A_variable_d_get(A self) -> int\n"
"\n"
"Parameters:\n"
" self: A *\n"
"\n"
)
check(B.__doc__, "Proxy of C++ B class")
check(C.__init__.__doc__, "__init__(self, a, b, h) -> C")
check(D.__init__.__doc__, "__init__(D self, int a, int b, Hola h) -> D")
check(E.__init__.__doc__, "\n"
" __init__(self, a, b, h) -> E\n"
"\n"
" Parameters:\n"
" a: special comment for parameter a\n"
" b: another special comment for parameter b\n"
" h: enum Hola\n"
"\n"
" "
)
check(F.__init__.__doc__, "\n"
" __init__(F self, int a, int b, Hola h) -> F\n"
"\n"
" Parameters:\n"
" a: special comment for parameter a\n"
" b: another special comment for parameter b\n"
" h: enum Hola\n"
"\n"
" "
)
check(B.funk.__doc__, "funk(B self, int c, int d) -> int")
check(funk.__doc__, "funk(A e, short arg2, int c, int d) -> int")
check(funkdefaults.__doc__, "\n"
" funkdefaults(A e, short arg2, int c, int d, double f=2) -> int\n"
" funkdefaults(A e, short arg2, int c, int d) -> int\n"
" "
)
check(func_input.__doc__, "func_input(int * INPUT) -> int")
check(func_output.__doc__, "func_output() -> int")
check(func_inout.__doc__, "func_inout(int * INOUT) -> int")
check(banana.__doc__, "banana(S a, S b, int c, Integer d)")

View file

@ -0,0 +1,36 @@
from char_binary import *
t = Test()
if t.strlen('hile') != 4:
print t.strlen('hile')
raise RuntimeError, "bad multi-arg typemap"
if t.strlen('hil\0') != 4:
raise RuntimeError, "bad multi-arg typemap"
#
# creating a raw char*
#
pc = new_pchar(5)
pchar_setitem(pc, 0, 'h')
pchar_setitem(pc, 1, 'o')
pchar_setitem(pc, 2, 'l')
pchar_setitem(pc, 3, 'a')
pchar_setitem(pc, 4, 0)
if t.strlen(pc) != 4:
raise RuntimeError, "bad multi-arg typemap"
cvar.var_pchar = pc
if cvar.var_pchar != "hola":
print cvar.var_pchar
raise RuntimeError, "bad pointer case"
cvar.var_namet = pc
#if cvar.var_namet != "hola\0":
if cvar.var_namet != "hola":
raise RuntimeError, "bad pointer case"
delete_pchar(pc)

View file

@ -0,0 +1,17 @@
from default_arg_values import *
d = Display()
if d.draw1() != 0:
raise RuntimeError
if d.draw1(12) != 12:
raise RuntimeError
p = createPtr(123);
if d.draw2() != 0:
raise RuntimeError
if d.draw2(p) != 123:
raise RuntimeError

View file

@ -1,3 +1,7 @@
# This test is expected to fail with -builtin option.
# It uses the old static syntax (e.g., dc.new_A() rather than dc.A()),
# which is not provided with the -builtin option.
import _default_constructor
dc = _default_constructor

View file

@ -0,0 +1,5 @@
from director_alternating import *
id = getBar().id()
if id != idFromGetBar():
raise RuntimeError, "Got wrong id: " + str(id)

View file

@ -66,11 +66,15 @@ except MyException, e:
if not ok:
raise RuntimeError
# This is expected to fail with -builtin option
# Throwing builtin classes as exceptions not supported
try:
raise Exception2()
except Exception2:
pass
# This is expected to fail with -builtin option
# Throwing builtin classes as exceptions not supported
try:
raise Exception1()
except Exception1:

View file

@ -12,11 +12,16 @@ class FooBar2(Bar):
def pang(self):
return "FooBar2::pang();"
class FooBar3(Bar):
def cheer(self):
return "FooBar3::cheer();"
b = Bar()
f = b.create()
fb = FooBar()
fb2 = FooBar2()
fb3 = FooBar3()
try:
@ -66,7 +71,7 @@ try:
except:
pass
if not protected:
raise RuntimeError,"Boo::ping is protected"
raise RuntimeError,"Foo::ping is protected"
protected=1
try:
@ -86,3 +91,39 @@ except:
pass
if not protected:
raise RuntimeError,"FooBar::pang is protected"
protected=1
try:
b.cheer()
protected=0
except:
pass
if not protected:
raise RuntimeError,"Bar::cheer is protected"
protected=1
try:
f.cheer()
protected=0
except:
pass
if not protected:
raise RuntimeError,"Foo::cheer is protected"
if fb3.cheer() != "FooBar3::cheer();":
raise RuntimeError, "bad fb3::cheer"
if fb2.callping() != "FooBar2::ping();":
raise RuntimeError, "bad fb2.callping"
if fb2.callcheer() != "FooBar2::pang();Bar::pong();Foo::pong();FooBar2::ping();":
raise RuntimeError, "bad fb2.callcheer"
if fb3.callping() != "Bar::ping();":
raise RuntimeError, "bad fb3.callping"
if fb3.callcheer() != "FooBar3::cheer();":
raise RuntimeError, "bad fb3.callcheer"

View file

@ -0,0 +1,10 @@
import enum_forward
f1 = enum_forward.get_enum1();
f1 = enum_forward.test_function1(f1);
f2 = enum_forward.get_enum2();
f2 = enum_forward.test_function2(f2);
f3 = enum_forward.get_enum3();
f3 = enum_forward.test_function3(f3);

View file

@ -1,5 +1,7 @@
from exception_order import *
# This test is expected to fail with -builtin option.
# Throwing builtin classes as exceptions not supported
a = A()

View file

@ -0,0 +1,40 @@
from global_namespace import *
k1 = Klass1()
k2 = Klass2()
k3 = Klass3()
k4 = Klass4()
k5 = Klass5()
k6 = Klass6()
k7 = Klass7()
KlassMethods.methodA(k1, k2, k3, k4, k5, k6, k7)
KlassMethods.methodB(k1, k2, k3, k4, k5, k6, k7)
k1 = getKlass1A()
k2 = getKlass2A()
k3 = getKlass3A()
k4 = getKlass4A()
k5 = getKlass5A()
k6 = getKlass6A()
k7 = getKlass7A()
KlassMethods.methodA(k1, k2, k3, k4, k5, k6, k7)
KlassMethods.methodB(k1, k2, k3, k4, k5, k6, k7)
k1 = getKlass1B()
k2 = getKlass2B()
k3 = getKlass3B()
k4 = getKlass4B()
k5 = getKlass5B()
k6 = getKlass6B()
k7 = getKlass7B()
KlassMethods.methodA(k1, k2, k3, k4, k5, k6, k7)
KlassMethods.methodB(k1, k2, k3, k4, k5, k6, k7)
XYZMethods.methodA(XYZ1(), XYZ2(), XYZ3(), XYZ4(), XYZ5(), XYZ6(), XYZ7())
XYZMethods.methodB(XYZ1(), XYZ2(), XYZ3(), XYZ4(), XYZ5(), XYZ6(), XYZ7())
TheEnumMethods.methodA(theenum1, theenum2, theenum3)
TheEnumMethods.methodA(theenum1, theenum2, theenum3)

View file

@ -1,5 +1,5 @@
from global_ns_arg import *
a = foo(1)
b = bar()
b = bar_fn()

View file

@ -11,3 +11,4 @@ if x != -37:
raise RuntimeError
grouping.cvar.test3 = 42
grouping.test3 = 42

View file

@ -0,0 +1,73 @@
from implicittest import *
def check(a, b):
if a != b:
raise RuntimeError(str(a) + " does not equal " + str(b))
#### Class ####
# No implicit conversion
check(1, A(1).get())
check(2, A(1.0).get())
check(3, A(B()).get())
check(4, A("hello").get())
check(1, get(1))
check(2, get(1.0))
check(3, get(B()))
# Explicit constructor:
try:
check(4, get("hello"))
raise RuntimeError
except TypeError:
pass
#### Template Class ####
# No implicit conversion
check(1, A_int(1).get())
check(2, A_int(1.0).get())
check(3, A_int(B()).get())
check(4, A_int("hello").get())
check(1, A_int.sget(1))
check(2, A_int.sget(1.0))
check(3, A_int.sget(B()))
# explicit constructor:
try:
check(4, A_int.sget("hello"))
raise RuntimeError
except TypeError:
pass
#### Global variable assignment ####
cvar.foo = Foo(1); check(cvar.foo.ii, 1)
cvar.foo = 1; check(cvar.foo.ii, 1)
cvar.foo = 1.0; check(cvar.foo.ii, 2)
cvar.foo = Foo("hello"); check(cvar.foo.ii, 3)
# explicit constructor:
try:
cvar.foo = "hello"
raise RuntimeError
except TypeError:
pass
#### Member variable assignment ####
# Note: also needs naturalvar
b = Bar(); check(b.f.ii, 0)
b.f = Foo("hello"); check(b.f.ii, 3)
b.f = 1; check(b.f.ii, 1)
b.f = 1.0; check(b.f.ii, 2)
# explicit constructor:
try:
b.f = "hello"
raise RuntimeError
except TypeError:
pass

View file

@ -0,0 +1,7 @@
import import_stl_b
import import_stl_a
v_new = import_stl_b.process_vector([1,2,3])
if v_new != (1,2,3,4):
raise RuntimeError, v_new

View file

@ -1,4 +1,4 @@
from python_kwargs import *
from kwargs_feature import *
class MyFoo(Foo):
def __init__(self, a , b = 0):

View file

@ -0,0 +1,30 @@
from li_boost_shared_ptr_template import *
b = BaseINTEGER()
d = DerivedINTEGER()
if b.bar() != 1:
raise RuntimeError
if d.bar() != 2:
raise RuntimeError
if bar_getter(b) != 1:
raise RuntimeError
# Fix reverted in rev 12953
#if bar_getter(d) != 2:
# raise RuntimeError
b = BaseDefaultInt()
d = DerivedDefaultInt()
d2 = DerivedDefaultInt2()
if b.bar2() != 3:
raise RuntimeError
if d.bar2() != 4:
raise RuntimeError
if d2.bar2() != 4:
raise RuntimeError
if bar2_getter(b) != 3:
raise RuntimeError
# Fix reverted in rev 12953
#if bar2_getter(d) != 4:
# raise RuntimeError
#if bar2_getter(d2) != 4:
# raise RuntimeError

View file

@ -0,0 +1,265 @@
# Check std::vector and std::list behaves the same as Python iterable types (list)
from li_std_containers_int import *
def failed(a, b, msg):
raise RuntimeError, msg + " " + str(list(a)) + " " + str(list(b))
def compare_sequences(a, b):
if len(a) != len(b):
failed(a, b, "different sizes")
for i in range(len(a)):
if a[i] != b[i]:
failed(a, b, "elements are different")
def compare_containers(pythonlist, swigvector, swiglist):
compare_sequences(pythonlist, swigvector)
compare_sequences(pythonlist, swiglist)
# Check std::vector and std::list assignment behaves same as Python list assignment including exceptions
def container_insert_step(i, j, step, newval):
ps = range(6)
iv = vector_int(ps)
il = list_int(ps)
# Python slice
try:
if step == None:
if j == None:
ps[i] = newval
else:
ps[i:j] = newval
else:
if j == None:
ps[i::step] = newval
else:
ps[i:j:step] = newval
ps_error = None
except ValueError, e:
ps_error = e
except IndexError, e:
ps_error = e
# std::vector<int>
try:
if step == None:
if j == None:
iv[i] = newval
else:
iv[i:j] = newval
else:
if j == None:
iv[i::step] = newval
else:
iv[i:j:step] = newval
iv_error = None
except ValueError, e:
iv_error = e
except IndexError, e:
iv_error = e
# std::list<int>
try:
if step == None:
if j == None:
il[i] = newval
else:
il[i:j] = newval
else:
if j == None:
il[i::step] = newval
else:
il[i:j:step] = newval
il_error = None
except ValueError, e:
il_error = e
except IndexError, e:
il_error = e
if not((type(ps_error) == type(iv_error)) and (type(ps_error) == type(il_error))):
raise RuntimeError, "ValueError exception not consistently thrown: " + str(ps_error) + " " + str(iv_error) + " " + str(il_error)
compare_containers(ps, iv, il)
# Check std::vector and std::list delete behaves same as Python list delete including exceptions
def container_delete_step(i, j, step):
ps = range(6)
iv = vector_int(ps)
il = list_int(ps)
# Python slice
try:
if step == None:
if j == None:
del ps[i]
else:
del ps[i:j]
else:
if j == None:
del ps[i::step]
else:
del ps[i:j:step]
ps_error = None
except ValueError, e:
ps_error = e
except IndexError, e:
ps_error = e
# std::vector<int>
try:
if step == None:
if j == None:
del iv[i]
else:
del iv[i:j]
else:
if j == None:
del iv[i::step]
else:
del iv[i:j:step]
iv_error = None
except ValueError, e:
iv_error = e
except IndexError, e:
iv_error = e
# std::list<int>
try:
if step == None:
if j == None:
del il[i]
else:
del il[i:j]
else:
if j == None:
del il[i::step]
else:
del il[i:j:step]
il_error = None
except ValueError, e:
il_error = e
except IndexError, e:
il_error = e
if not((type(ps_error) == type(iv_error)) and (type(ps_error) == type(il_error))):
raise RuntimeError, "ValueError exception not consistently thrown: " + str(ps_error) + " " + str(iv_error) + " " + str(il_error)
compare_containers(ps, iv, il)
ps = [0,1,2,3,4,5]
iv = vector_int(ps)
il = list_int(ps)
# slices
compare_containers(ps[0:0], iv[0:0], il[0:0])
compare_containers(ps[1:1], iv[1:1], il[1:1])
compare_containers(ps[1:3], iv[1:3], il[1:3])
compare_containers(ps[2:4], iv[2:4], il[2:4])
compare_containers(ps[0:3], iv[0:3], il[0:3])
compare_containers(ps[3:6], iv[3:6], il[3:6])
compare_containers(ps[3:10], iv[3:10], il[3:10]) # beyond end of range
# before beginning of range (negative indexing)
compare_containers(ps[-1:7], iv[-1:7], il[-1:7])
compare_containers(ps[-2:7], iv[-2:7], il[-2:7])
compare_containers(ps[-5:7], iv[-5:7], il[-5:7])
compare_containers(ps[-6:7], iv[-6:7], il[-6:7])
# before beginning of range (negative indexing, negative index is > container size)
compare_containers(ps[-7:7], iv[-7:7], il[-7:7])
compare_containers(ps[-100:7], iv[-100:7], il[-100:7])
compare_containers(ps[3:], iv[3:], il[3:])
compare_containers(ps[:3], iv[:3], il[:3])
compare_containers(ps[:], iv[:], il[:])
compare_containers(ps[-3:], iv[-3:], il[-3:])
compare_containers(ps[-7:], iv[-7:], il[-7:])
compare_containers(ps[:-1], iv[:-1], il[:-1])
compare_containers(ps[:-7], iv[:-7], il[:-7])
# step slicing
compare_containers(ps[1:5:1], iv[1:5:1], il[1:5:1])
compare_containers(ps[1:5:2], iv[1:5:2], il[1:5:2])
compare_containers(ps[1:5:3], iv[1:5:3], il[1:5:3])
compare_containers(ps[1:5:4], iv[1:5:4], il[1:5:4])
compare_containers(ps[1:6:5], iv[1:6:5], il[1:6:5])
compare_containers(ps[1:7:5], iv[1:7:5], il[1:7:5])
compare_containers(ps[-1:7:1], iv[-1:7:1], il[-1:7:1])
compare_containers(ps[-1:7:2], iv[-1:7:2], il[-1:7:2])
compare_containers(ps[-6:7:2], iv[-6:7:2], il[-6:7:2])
compare_containers(ps[-100:7:2], iv[-100:7:2], il[-100:7:2])
compare_containers(ps[::1], iv[::1], il[::1])
compare_containers(ps[::2], iv[::2], il[::2])
compare_containers(ps[::-1], iv[::-1], il[::-1])
compare_containers(ps[6::-1], iv[6::-1], il[6::-1])
compare_containers(ps[:-3:-1], iv[:-3:-1], il[:-3:-1])
compare_containers(ps[:-6:-1], iv[:-6:-1], il[:-6:-1])
compare_containers(ps[:-7:-1], iv[:-7:-1], il[:-7:-1])
compare_containers(ps[:-8:-1], iv[:-8:-1], il[:-8:-1])
compare_containers(ps[:-100:-1], iv[:-100:-1], il[:-100:-1])
compare_containers(ps[4:6:-1], iv[4:6:-1], il[4:6:-1])
compare_containers(ps[4:5:-1], iv[4:5:-1], il[4:5:-1])
compare_containers(ps[4:4:-1], iv[4:4:-1], il[4:4:-1])
compare_containers(ps[4:3:-1], iv[4:3:-1], il[4:3:-1])
compare_containers(ps[4:2:-1], iv[4:2:-1], il[4:2:-1])
compare_containers(ps[100:104:-1], iv[100:104:-1], il[100:104:-1])
compare_containers(ps[104:100:-1], iv[104:100:-1], il[104:100:-1])
compare_containers(ps[-100:-104:-1], iv[-100:-104:-1], il[-100:-104:-1])
compare_containers(ps[-104:-100:-1], iv[-104:-100:-1], il[-104:-100:-1])
compare_containers(ps[::-2], iv[::-2], il[::-2])
compare_containers(ps[::-3], iv[::-3], il[::-3])
compare_containers(ps[::-4], iv[::-4], il[::-4])
compare_containers(ps[::-5], iv[::-5], il[::-5])
# insert sequences (growing, shrinking and staying same size)
for start in [-102, -100, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 100, 102]:
# single element set/replace
container_insert_step(start, None, None, 111)
for end in [-102, -100, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 100, 102]:
container_insert_step(start, end, None, [111, 222, 333, 444, 555, 666, 777])
container_insert_step(start, end, None, [111, 222, 333, 444, 555, 666])
container_insert_step(start, end, None, [111, 222, 333, 444, 555])
container_insert_step(start, end, None, [111, 222, 333, 444])
container_insert_step(start, end, None, [111, 222, 333])
container_insert_step(start, end, None, [111, 222])
container_insert_step(start, end, None, [111])
container_insert_step(start, end, None, [])
# delete sequences (growing, shrinking and staying same size)
for start in [-102, -100, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 100, 102]:
# single element delete
container_delete_step(start, None, None)
for end in [-102, -100, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 100, 102]:
container_delete_step(start, end, None)
for step in range(-7,7):
container_delete_step(start, end, step)
ps = range(6)
iv = vector_int(ps)
il = list_int(ps)
del ps[:]; del iv[:]; del il[:]
compare_containers(ps, iv, il)
for end in range(7):
for step in range(-7,7):
for start in range(7):
container_insert_step(start, end, step, [111, 222, 333, 444, 555, 666, 777])
container_insert_step(start, end, step, [111, 222, 333, 444, 555, 666])
container_insert_step(start, end, step, [111, 222, 333, 444, 555])
container_insert_step(start, end, step, [111, 222, 333, 444])
container_insert_step(start, end, step, [111, 222, 333])
container_insert_step(start, end, step, [111, 222])
container_insert_step(start, end, step, [111])
container_insert_step(start, end, step, [])
try:
x = iv[::0]
raise RuntimeError("Zero step not caught")
except ValueError:
pass

View file

@ -0,0 +1,9 @@
from li_std_except_as_class import *
# std::domain_error hierarchy
try: test_domain_error()
except domain_error: pass
try: test_domain_error()
except logic_error: pass
try: test_domain_error()
except exception: pass

View file

@ -0,0 +1,11 @@
import li_std_map_member
a = li_std_map_member.mapita()
a[1] = li_std_map_member.TestA()
if (a[1].i != 1) :
raise RuntimeError("a[1] != 1")
a[1].i = 2
if (a[1].i != 2) :
raise RuntimeError("a[1] != 2")

View file

@ -0,0 +1,10 @@
from li_std_pair_using import *
one_tuple = ("one", "numero uno")
one = StringStringPair(one_tuple)
two_tuple = ("two", 2)
two = StringIntPair(two_tuple)
if bounce(one) != one_tuple:
raise RuntimeError

View file

@ -92,5 +92,5 @@ sum = ()
for i in s:
sum = sum + (i,)
if sum != (1, 'hello', (1, 2)):
if (len(sum) != 3 or (not 1 in sum) or (not 'hello' in sum) or (not (1, 2) in sum)) :
raise RuntimeError

View file

@ -54,9 +54,13 @@ if a + b != "hello world":
if a + " world" != "hello world":
raise RuntimeError, "bad string mapping"
# This is expected to fail with -builtin option
# Reverse operators not supported in builtin types
if "hello" + b != "hello world":
raise RuntimeError, "bad string mapping"
# This is expected to fail with -builtin option
# Reverse operators not supported in builtin types
c = "hello" + b
if c.find_last_of("l") != 9:
raise RuntimeError, "bad string mapping"

View file

@ -0,0 +1,24 @@
import li_std_vector_enum
def check(a, b):
if (a != b):
raise RuntimeError("Not equal: ", a, b)
ev = li_std_vector_enum.EnumVector()
check(ev.nums[0], 10)
check(ev.nums[1], 20)
check(ev.nums[2], 30)
it = ev.nums.iterator()
v = it.value()
check(v, 10)
it.next()
v = it.value()
check(v, 20)
expected = 10
for val in ev.nums:
check(val, expected)
expected += 10

View file

@ -0,0 +1,4 @@
from li_std_vector import *
if typedef_test(101) != 101:
raise RuntimeError

View file

@ -4,21 +4,21 @@ x=u"h"
if li_std_wstring.test_wcvalue(x) != x:
print li_std_wstring.test_wcvalue(x)
raise RuntimeError, "bad string mapping"
raise RuntimeError("bad string mapping")
x=u"hello"
if li_std_wstring.test_ccvalue(x) != x:
raise RuntimeError, "bad string mapping"
raise RuntimeError("bad string mapping")
if li_std_wstring.test_cvalue(x) != x:
raise RuntimeError, "bad string mapping"
raise RuntimeError("bad string mapping")
if li_std_wstring.test_value(x) != x:
print x, li_std_wstring.test_value(x)
raise RuntimeError, "bad string mapping"
raise RuntimeError("bad string mapping")
if li_std_wstring.test_const_reference(x) != x:
raise RuntimeError, "bad string mapping"
raise RuntimeError("bad string mapping")
s = li_std_wstring.wstring(u"he")
@ -26,39 +26,41 @@ s = s + u"llo"
if s != x:
print s, x
raise RuntimeError, "bad string mapping"
raise RuntimeError("bad string mapping")
if s[1:4] != x[1:4]:
raise RuntimeError, "bad string mapping"
raise RuntimeError("bad string mapping")
if li_std_wstring.test_value(s) != x:
raise RuntimeError, "bad string mapping"
raise RuntimeError("bad string mapping")
if li_std_wstring.test_const_reference(s) != x:
raise RuntimeError, "bad string mapping"
raise RuntimeError("bad string mapping")
a = li_std_wstring.A(s)
if li_std_wstring.test_value(a) != x:
raise RuntimeError, "bad string mapping"
raise RuntimeError("bad string mapping")
if li_std_wstring.test_const_reference(a) != x:
raise RuntimeError, "bad string mapping"
raise RuntimeError("bad string mapping")
b = li_std_wstring.wstring(" world")
if a + b != "hello world":
raise RuntimeError, "bad string mapping"
raise RuntimeError("bad string mapping")
if a + " world" != "hello world":
raise RuntimeError, "bad string mapping"
raise RuntimeError("bad string mapping")
# This is expected to fail if -builtin is used
if "hello" + b != "hello world":
raise RuntimeError, "bad string mapping"
raise RuntimeError("bad string mapping")
# This is expected to fail if -builtin is used
c = "hello" + b
if c.find_last_of("l") != 9:
raise RuntimeError, "bad string mapping"
raise RuntimeError("bad string mapping")
s = "hello world"
@ -66,11 +68,11 @@ b = li_std_wstring.B("hi")
b.name = li_std_wstring.wstring(u"hello")
if b.name != "hello":
raise RuntimeError, "bad string mapping"
raise RuntimeError("bad string mapping")
b.a = li_std_wstring.A("hello")
if b.a != u"hello":
raise RuntimeError, "bad string mapping"
raise RuntimeError("bad string mapping")

View file

@ -0,0 +1,16 @@
import pointer_reference
s = pointer_reference.get()
if s.value != 10:
raise RuntimeError, "get test failed"
ss = pointer_reference.Struct(20)
pointer_reference.set(ss)
if pointer_reference.cvar.Struct_instance.value != 20:
raise RuntimeError, "set test failed"
if pointer_reference.overloading(1) != 111:
raise RuntimeError, "overload test 1 failed"
if pointer_reference.overloading(ss) != 222:
raise RuntimeError, "overload test 2 failed"

View file

@ -0,0 +1,11 @@
import preproc_defined
if preproc_defined.call_checking() != 1:
raise RuntimeError
d = preproc_defined.Defined()
d.defined = 10
preproc_defined.thing(10)
preproc_defined.stuff(10)
preproc_defined.bumpf(10)

View file

@ -0,0 +1,23 @@
import preproc_include
if preproc_include.multiply10(10) != 100:
raise RuntimeError
if preproc_include.multiply20(10) != 200:
raise RuntimeError
if preproc_include.multiply30(10) != 300:
raise RuntimeError
if preproc_include.multiply40(10) != 400:
raise RuntimeError
if preproc_include.multiply50(10) != 500:
raise RuntimeError
if preproc_include.multiply60(10) != 600:
raise RuntimeError
if preproc_include.multiply70(10) != 700:
raise RuntimeError

View file

@ -188,14 +188,6 @@ if t.var_namet != 'hol':
raise RuntimeError
if t.strlen('hile') != 4:
print t.strlen('hile')
raise RuntimeError, "bad string typemap"
if t.strlen('hil\0') != 4:
raise RuntimeError, "bad string typemap"
cvar.var_char = '\0'
if cvar.var_char != '\0':
raise RuntimeError, "bad char '0' case"
@ -244,9 +236,6 @@ pchar_setitem(pc, 3, 'a')
pchar_setitem(pc, 4, 0)
if t.strlen(pc) != 4:
raise RuntimeError, "bad string typemap"
cvar.var_pchar = pc
if cvar.var_pchar != "hola":
print cvar.var_pchar

View file

@ -1,8 +1,20 @@
from python_abstractbase import *
from collections import *
# This is expected to fail with -builtin option
# Builtin types can't inherit from pure-python abstract bases
assert issubclass(Mapii, MutableMapping)
assert issubclass(Multimapii, MutableMapping)
assert issubclass(IntSet, MutableSet)
assert issubclass(IntMultiset, MutableSet)
assert issubclass(IntVector, MutableSequence)
assert issubclass(IntList, MutableSequence)
mapii = Mapii()
multimapii = Multimapii()
intset = IntSet()
intmultiset = IntMultiset()
intvector = IntVector()
intlist = IntList()

View file

@ -13,7 +13,6 @@ except:
if not err:
raise RuntimeError, "A is not static"
class B(python_nondynamic.A):
c = 4
def __init__(self):
@ -21,10 +20,19 @@ class B(python_nondynamic.A):
pass
pass
bb = B()
bb.c = 3
try:
bb.c = 3
err = 0
except:
err = 1
if not err:
print "bb.c = %d" % bb.c
print "B.c = %d" % B.c
raise RuntimeError, "B.c class variable messes up nondynamic-ness of B"
try:
bb.d = 2
err = 0
@ -33,7 +41,6 @@ except:
if not err:
raise RuntimeError, "B is not static"
cc = python_nondynamic.C()
cc.d = 3

View file

@ -0,0 +1,100 @@
import python_richcompare
base1 = python_richcompare.BaseClass(1)
base2 = python_richcompare.BaseClass(2)
base3 = python_richcompare.BaseClass(3)
a1 = python_richcompare.SubClassA(1)
a2 = python_richcompare.SubClassA(2)
a3 = python_richcompare.SubClassA(3)
b1 = python_richcompare.SubClassB(1)
b2 = python_richcompare.SubClassB(2)
b3 = python_richcompare.SubClassB(3)
# Check == and != within a single type
#-------------------------------------------------------------------------------
if not (base1 == base1) :
raise RuntimeError("Object not == to itself")
if not (base1 == python_richcompare.BaseClass(1)) :
raise RuntimeError("Object not == to an equivalent object")
if (base1 == base2) :
raise RuntimeError("Comparing non-equivalent objects of the same type, == returned True")
if (base1 != base1) :
raise RuntimeError("Object is != itself")
if (base1 != python_richcompare.BaseClass(1)) :
raise RuntimeError("Object is != an equivalent object")
if not (base1 != base2) :
raise RuntimeError("Comparing non-equivalent objects of the same type, != returned False")
# Check redefined operator== in SubClassA
#-------------------------------------------------------------------------------
if (a2 == base2) :
raise RuntimeError("Redefined operator== in SubClassA failed")
if (a2 == b2) :
raise RuntimeError("Redefined operator== in SubClassA failed")
if not (a1 == a2) :
raise RuntimeError("Redefined operator== in SubClassA failed")
# Check up-casting of subclasses
#-------------------------------------------------------------------------------
if (base2 != a2) :
raise RuntimeError("Comparing equivalent base and subclass instances, != returned True")
if (a2 == base2) :
raise RuntimeError("Comparing non-equivalent base and subclass instances, == returned True")
if (a1 == b1) :
raise RuntimeError("Comparing equivalent instances of different subclasses, == returned True")
if (b1 == a1) :
raise RuntimeError("Comparing equivalent instances of different subclasses, == returned True")
# Check inequalities
#-------------------------------------------------------------------------------
if (a2 > b2) :
raise RuntimeError("operator> failed")
if (a2 < b2) :
raise RuntimeError("operator< failed")
if not (a2 >= b2) :
raise RuntimeError("operator>= failed")
if not (a2 <= b2) :
raise RuntimeError("operator<= failed")
# Check inequalities used for ordering
#-------------------------------------------------------------------------------
x = sorted([a2, a3, a1])
if not (x[0] is a1) :
raise RuntimeError("Ordering failed")
if not (x[1] is a2) :
raise RuntimeError("Ordering failed")
if not (x[2] is a3) :
raise RuntimeError("Ordering failed")
x = sorted([base2, a3, b1])
if not (x[0] is b1) :
raise RuntimeError("Ordering failed")
if not (x[1] is base2) :
raise RuntimeError("Ordering failed")
if not (x[2] is a3) :
raise RuntimeError("Ordering failed")

View file

@ -0,0 +1,4 @@
import python_varargs_typemap
if (python_varargs_typemap.testfunc(1, 2.0, "three") != "three") :
raise RuntimeError("testfunc failed!")

View file

@ -10,14 +10,14 @@ b2 = B.create(a)
if a.ref_count() != 3:
print "This program will crash... now"
raise RuntimeError("Count = %d" % a.ref_count())
rca = b2.get_rca()
b3 = B.create(rca)
if a.ref_count() != 5:
print "This program will crash... now"
raise RuntimeError("Count = %d" % a.ref_count())
v = vector_A(2)
@ -27,6 +27,35 @@ v[1] = a
x = v[0]
del v
if a.ref_count() != 6:
raise RuntimeError("Count = %d" % a.ref_count())
# Check %newobject
b4 = b2.cloner()
if b4.ref_count() != 1:
raise RuntimeError
b5 = global_create(a)
if b5.ref_count() != 1:
raise RuntimeError
b6 = Factory.create(a)
if b6.ref_count() != 1:
raise RuntimeError
b7 = Factory().create2(a)
if b7.ref_count() != 1:
raise RuntimeError
if a.ref_count() != 10:
raise RuntimeError("Count = %d" % a.ref_count())
del b4
del b5
del b6
del b7
if a.ref_count() != 6:
raise RuntimeError("Count = %d" % a.ref_count())

View file

@ -0,0 +1,13 @@
from rename_pcre_encoder import *
s = SomeWidget()
s.putBorderWidth(3)
if s.getBorderWidth() != 3:
raise RuntimeError("Border should be 3, not %d" % (s.getBorderWidth(),))
s.putSize(4, 5)
a = AnotherWidget()
a.DoSomething()
evt = wxEVTSomeEvent()
t = xUnchangedName()

View file

@ -0,0 +1,123 @@
from smart_pointer_const_overload import *
CONST_ACCESS = 1
MUTABLE_ACCESS = 2
def test(b, f):
if f.x != 0:
raise RuntimeError
# Test member variable get
if b.x != 0:
raise RuntimeError
if f.access != CONST_ACCESS:
raise RuntimeError
# Test member variable set
b.x = 1
if f.x != 1:
raise RuntimeError
if f.access != MUTABLE_ACCESS:
raise RuntimeError
# Test const method
if b.getx() != 1:
raise RuntimeError
if f.access != CONST_ACCESS:
raise RuntimeError
# Test mutable method
b.setx(2)
if f.x != 2:
raise RuntimeError
if f.access != MUTABLE_ACCESS:
raise RuntimeError
# Test extended const method
if b.getx2() != 2:
raise RuntimeError
if f.access != CONST_ACCESS:
raise RuntimeError
# Test extended mutable method
b.setx2(3)
if f.x != 3:
raise RuntimeError
if f.access != MUTABLE_ACCESS:
raise RuntimeError
# Test static method
b.stat()
if f.access != CONST_ACCESS:
raise RuntimeError
# Test const member
f.access = MUTABLE_ACCESS
if b.y != 0:
raise RuntimeError
if f.access != CONST_ACCESS:
raise RuntimeError
# Test get through mutable pointer to const member
f.access = MUTABLE_ACCESS
if get_int(b.yp) != 0:
raise RuntimeError
if f.access != CONST_ACCESS:
raise RuntimeError
# Test get through const pointer to mutable member
f.x = 4
f.access = MUTABLE_ACCESS
if get_int(b.xp) != 4:
raise RuntimeError
if f.access != CONST_ACCESS:
raise RuntimeError
# Test set through const pointer to mutable member
f.access = MUTABLE_ACCESS
set_int(b.xp, 5)
if f.x != 5:
raise RuntimeError
if f.access != CONST_ACCESS:
raise RuntimeError
# Test set pointer to const member
b.yp = new_int(6)
if f.y != 0:
raise RuntimeError
if get_int(f.yp) != 6:
raise RuntimeError
if f.access != MUTABLE_ACCESS:
raise RuntimeError
delete_int(f.yp);
f = Foo()
b = Bar(f)
f2 = Foo()
b2 = Bar2(f2)
test(b, f)
test(b2, f2)

View file

@ -0,0 +1,37 @@
from template_typemaps_typedef2 import *
m1 = MultimapIntA()
dummy_pair = m1.make_dummy_pair()
val = m1.typemap_test(dummy_pair).val
if val != 1234:
raise RuntimeError, "typemaps not working"
m2 = MultimapAInt()
# TODO: typemaps and specializations not quite working as expected. T needs expanding, but at least the right typemap is being picked up.
#dummy_pair = m2.make_dummy_pair()
#val = m2.typemap_test(dummy_pair)
#print val
#if val != 4321:
# raise RuntimeError, "typemaps not working"
if typedef_test1(dummy_pair).val != 1234:
raise RuntimeError, "typedef_test1 not working"
if typedef_test2(dummy_pair).val != 1234:
raise RuntimeError, "typedef_test2 not working"
if typedef_test3(dummy_pair).val != 1234:
raise RuntimeError, "typedef_test3 not working"
if typedef_test4(dummy_pair).val != 1234:
raise RuntimeError, "typedef_test4 not working"
if typedef_test5(dummy_pair).val != 1234:
raise RuntimeError, "typedef_test5 not working"
if typedef_test6(dummy_pair).val != 1234:
raise RuntimeError, "typedef_test6 not working"

View file

@ -0,0 +1,37 @@
from template_typemaps_typedef import *
m1 = MultimapIntA()
dummy_pair = m1.make_dummy_pair()
val = m1.typemap_test(dummy_pair).val
if val != 1234:
raise RuntimeError, "typemaps not working"
m2 = MultimapAInt()
# TODO: typemaps and specializations not quite working as expected. T needs expanding, but at least the right typemap is being picked up.
#dummy_pair = m2.make_dummy_pair()
#val = m2.typemap_test(dummy_pair)
#print val
#if val != 4321:
# raise RuntimeError, "typemaps not working"
if typedef_test1(dummy_pair).val != 1234:
raise RuntimeError, "typedef_test1 not working"
if typedef_test2(dummy_pair).val != 1234:
raise RuntimeError, "typedef_test2 not working"
if typedef_test3(dummy_pair).val != 1234:
raise RuntimeError, "typedef_test3 not working"
if typedef_test4(dummy_pair).val != 1234:
raise RuntimeError, "typedef_test4 not working"
if typedef_test5(dummy_pair).val != 1234:
raise RuntimeError, "typedef_test5 not working"
if typedef_test6(dummy_pair).val != 1234:
raise RuntimeError, "typedef_test6 not working"

View file

@ -18,13 +18,15 @@ except RuntimeError,e:
if e.args[0] != "I died.":
raise RuntimeError
# This is expected fail with -builtin option
# Throwing builtin classes as exceptions not supported
try:
t.hosed()
except threads_exception.Exc,e:
if e.code != 42:
raise RuntimeError
if e.msg != "Hosed":
raise RuntimeError
raise RuntimeError, "bad... msg: %s" % e.msg
for i in range(1,4):
try:

View file

@ -0,0 +1,5 @@
from typemap_arrays import *
if sumA(None) != 60:
raise RuntimeError, "Sum is wrong"

View file

@ -5,8 +5,8 @@ b = typename.Bar()
x = typename.twoFoo(f)
if not isinstance(x,types.FloatType):
print "Wrong return type!"
raise RuntimeError,"Wrong return type (FloatType) !"
y = typename.twoBar(b)
if not isinstance(y,types.IntType):
print "Wrong return type!"
raise RuntimeError,"Wrong return type (IntType)!"

View file

@ -0,0 +1,31 @@
import varargs_overload
if varargs_overload.vararg_over1("Hello") != "Hello":
raise RuntimeError, "Failed"
if varargs_overload.vararg_over1(2) != "2":
raise RuntimeError, "Failed"
if varargs_overload.vararg_over2("Hello") != "Hello":
raise RuntimeError, "Failed"
if varargs_overload.vararg_over2(2, 2.2) != "2 2.2":
raise RuntimeError, "Failed"
if varargs_overload.vararg_over3("Hello") != "Hello":
raise RuntimeError, "Failed"
if varargs_overload.vararg_over3(2, 2.2, "hey") != "2 2.2 hey":
raise RuntimeError, "Failed"
if varargs_overload.vararg_over4("Hello") != "Hello":
raise RuntimeError, "Failed"
if varargs_overload.vararg_over4(123) != "123":
raise RuntimeError, "Failed"
if varargs_overload.vararg_over4("Hello", 123) != "Hello":
raise RuntimeError, "Failed"

View file

@ -16,3 +16,21 @@ if varargs.test_def("Hello",1) != "Hello":
if varargs.test_def("Hello") != "Hello":
raise RuntimeError, "Failed"
###
if varargs.test_plenty("Hello") != "Hello":
raise RuntimeError, "Failed"
if varargs.test_plenty("Hello", 1) != "Hello":
raise RuntimeError, "Failed"
if varargs.test_plenty("Hello", 1, 2) != "Hello":
raise RuntimeError, "Failed"
try:
varargs.test_plenty("Hello", 1, 2, 3)
raise RuntimeError
except NotImplementedError:
pass
except TypeError:
pass