Merge branch 'master' into gsoc2009-matevz

Conflicts:
	Examples/Makefile.in
	Examples/guile/Makefile.in
	Lib/php/php.swg
	Makefile.in
	Source/CParse/parser.y
	configure.ac
This commit is contained in:
William S Fulton 2013-10-10 07:26:09 +01:00
commit bcb7aee022
585 changed files with 9528 additions and 12959 deletions

View file

@ -58,7 +58,7 @@ CPP_TEST_CASES += \
li_std_wstream \
li_std_wstring \
primitive_types \
python_abstractbase \
python_abstractbase \
python_append \
python_director \
python_nondynamic \
@ -110,16 +110,19 @@ VALGRIND_OPT += --suppressions=pythonswig.supp
# Rules for the different types of tests
%.cpptest:
+$(convert_testcase)
$(setup)
+$(swig_and_compile_cpp)
$(run_testcase)
%.ctest:
+$(convert_testcase)
$(setup)
+$(swig_and_compile_c)
$(run_testcase)
%.multicpptest:
+$(convert_testcase)
$(setup)
+$(swig_and_compile_multi_cpp)
$(run_testcase)
@ -139,17 +142,17 @@ run_python = env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH PYTHONPATH=.:$(srcdir):$$PY
py2_runme = $(srcdir)/$(SCRIPTPREFIX)$*$(PY2SCRIPTSUFFIX)
py3_runme = $(srcdir)/$(SCRIPTPREFIX)$*$(PY3SCRIPTSUFFIX)
ifeq (,$(PY3))
run_testcase = \
if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
$(run_python);\
fi
ifeq (,$(PY3))
convert_testcase =
else
run_testcase = \
convert_testcase = \
if [ -f $(py2_runme) ]; then \
$(MAKE) -f $(srcdir)/Makefile $(py3_runme) && $(run_python); \
elif [ -f $(py3_runme) ]; then \
$(run_python); \
$(MAKE) -f $(srcdir)/Makefile $(py3_runme); \
fi
endif
@ -162,6 +165,9 @@ endif
clean:
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile python_clean
rm -f hugemod.h hugemod_a.i hugemod_b.i hugemod_a.py hugemod_b.py hugemod_runme.py
rm -f clientdata_prop_a.py clientdata_prop_b.py import_stl_a.py import_stl_b.py
rm -f imports_a.py imports_b.py mod_a.py mod_b.py multi_import_a.py
rm -f multi_import_b.py packageoption_a.py packageoption_b.py packageoption_c.py
cvsignore:
@echo '*wrap* *.pyc *.so *.dll *.exp *.lib'

View file

@ -1,4 +1,5 @@
from autodoc import *
import sys
def check(got, expected):
if expected != got:
@ -121,22 +122,24 @@ check(A.func3static.__doc__, "\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"
)
if sys.version_info[0:2] > (2, 4):
# Python 2.4 does not seem to work
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")

View file

@ -1,7 +1,7 @@
import sys
import file_test
if sys.version_info < (3,0):
if sys.version_info[0:2] < (3, 0):
file_test.nfile(sys.stdout)
cstdout = file_test.GetStdOut()

View file

@ -11,6 +11,14 @@ check(1, A(1).get())
check(2, A(1.0).get())
check(3, A(B()).get())
check(4, A("hello").get())
try:
check(3, A(None).get())
raise RuntimeError
except ValueError:
# ValueError: invalid null reference in method 'new_A', argument 1 of type 'B const &'
# Arguably A(char *) should be chosen, but there is a bug to do with None passed to methods overloaded by value,
# references and pointers to different types, where pointers ought to be given a slightly higher precedence.
pass
check(1, get(1))
check(2, get(1.0))
@ -71,3 +79,47 @@ try:
except TypeError:
pass
#### Class testing None ####
# No implicit conversion
check(1, AA(1).get())
check(2, AA(1.0).get())
check(3, AA(B()).get())
check(3, AA(None).get())
check(4, AA("hello").get())
check(5, AA(BB()).get())
check(1, get_AA_val(1))
check(2, get_AA_val(1.0))
check(3, get_AA_val(B()))
check(3, get_AA_val(None))
check(5, get_AA_val(BB()))
# Explicit constructor:
try:
check(4, get_AA_val("hello"))
raise RuntimeError
except TypeError:
pass
check(1, get_AA_ref(1))
check(2, get_AA_ref(1.0))
check(3, get_AA_ref(B()))
check(3, get_AA_ref(None))
check(5, get_AA_ref(BB()))
# Explicit constructor:
try:
check(4, get_AA_ref("hello"))
raise RuntimeError
except TypeError:
pass
### overloading priority test ###
ccc = CCC(B())
check(ccc.checkvalue, 10)
check(ccc.xx(123), 11)
check(ccc.yy(123, 123), 111)

View file

@ -0,0 +1,67 @@
# Check usage of template attributes
import li_attribute_template
chell = li_attribute_template.Cintint(1,2,3)
def rassert( what, master ):
if what != master:
print what
raise RuntimeError
## Testing primitive by value attribute
rassert( chell.a, 1 )
chell.a = 3
rassert( chell.a, 3 )
## Testing primitive by ref attribute
rassert( chell.b, 2 )
chell.b = 5
rassert( chell.b,5 )
## Testing string
chell.str = "abc"
rassert( chell.str, "abc" )
# Testing class by value
rassert( chell.d.value, 1 )
chell.d = li_attribute_template.Foo(2)
rassert( chell.d.value, 2 )
# Testing class by reference
rassert( chell.e.value, 2 )
chell.e= li_attribute_template.Foo(3)
rassert( chell.e.value, 3 )
chell.e.value = 4
rassert( chell.e.value, 4 )
# Testing moderately complex template by value
rassert( chell.f.first, 1 )
rassert( chell.f.second, 2 )
pair = li_attribute_template.pair_intint(3,4)
chell.f = pair
rassert( chell.f.first, 3 )
rassert( chell.f.second, 4 )
# Testing moderately complex template by ref
rassert( chell.g.first, 2 )
rassert( chell.g.second, 3 )
pair = li_attribute_template.pair_intint(4,5)
chell.g = pair
rassert( chell.g.first, 4 )
rassert( chell.g.second, 5 )
chell.g.first = 6
chell.g.second = 7
rassert( chell.g.first, 6 )
rassert( chell.g.second, 7 )

View file

@ -1,6 +1,7 @@
# Check std::vector and std::list behaves the same as Python iterable types (list)
from li_std_containers_int import *
import sys
def failed(a, b, msg):
raise RuntimeError, msg + " " + str(list(a)) + " " + str(list(b))
@ -76,10 +77,13 @@ def container_insert_step(i, j, step, newval):
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)
# Python 2.6 contains bug fixes in extended slicing syntax: http://docs.python.org/2/whatsnew/2.6.html
skip_check = ps_error != None and(iv_error == il_error == None) and step > 0 and (sys.version_info[0:2] < (2, 6))
if not(skip_check):
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)
compare_containers(ps, iv, il)
# Check std::vector and std::list delete behaves same as Python list delete including exceptions

View file

@ -13,6 +13,12 @@ if li_std_wstring.test_ccvalue(x) != x:
if li_std_wstring.test_cvalue(x) != x:
raise RuntimeError("bad string mapping")
if li_std_wstring.test_wchar_overload(x) != x:
raise RuntimeError("bad string mapping")
if li_std_wstring.test_wchar_overload("not unicode") != "not unicode":
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")

View file

@ -0,0 +1,43 @@
from overload_numeric import *
import math
nums = Nums()
limits = Limits()
def check(got, expected):
if got != expected:
raise RuntimeError("got: " + got + " expected: " + expected)
check(nums.over(0), "signed char")
check(nums.over(0.0), "float")
check(nums.over(limits.schar_min()), "signed char")
check(nums.over(limits.schar_max()), "signed char")
check(nums.over(limits.schar_min()-1), "short")
check(nums.over(limits.schar_max()+1), "short")
check(nums.over(limits.shrt_min()), "short")
check(nums.over(limits.shrt_max()), "short")
check(nums.over(limits.shrt_min()-1), "int")
check(nums.over(limits.shrt_max()+1), "int")
check(nums.over(limits.int_min()), "int")
check(nums.over(limits.int_max()), "int")
check(nums.over(limits.flt_min()), "float")
check(nums.over(limits.flt_max()), "float")
check(nums.over(limits.flt_max()*10), "double")
check(nums.over(-limits.flt_max()*10), "double")
check(nums.over(limits.dbl_max()), "double")
check(nums.over(-limits.dbl_max()), "double")
check(nums.over(float("inf")), "float")
check(nums.over(float("-inf")), "float")
check(nums.over(float("nan")), "float")
# Just check if the following are accepted without exceptions being thrown
nums.doublebounce(float("inf"))
nums.doublebounce(float("-inf"))
nums.doublebounce(float("nan"))

View file

@ -275,10 +275,22 @@ try:
except TypeError:
if a != t.var_char:
error = 1
pass
pass
if error:
raise RuntimeError, "bad char typemap"
try:
error = 0
a = t.var_ushort
t.var_ushort = -1
error = 1
except OverflowError:
if a != t.var_ushort:
error = 1
pass
if error:
raise RuntimeError, "bad ushort typemap"
try:
error = 0
a = t.var_uint
@ -287,10 +299,34 @@ try:
except OverflowError:
if a != t.var_uint:
error = 1
pass
pass
if error:
raise RuntimeError, "bad uint typemap"
try:
error = 0
a = t.var_sizet
t.var_sizet = -1
error = 1
except OverflowError:
if a != t.var_sizet:
error = 1
pass
if error:
raise RuntimeError, "bad sizet typemap"
try:
error = 0
a = t.var_ulong
t.var_ulong = -1
error = 1
except OverflowError:
if a != t.var_ulong:
error = 1
pass
if error:
raise RuntimeError, "bad ulong typemap"
#
#
try:
@ -301,7 +337,7 @@ try:
except TypeError:
if a != t.var_namet:
error = 1
pass
pass
if error:
raise RuntimeError, "bad namet typemap"

View file

@ -2,3 +2,10 @@ from python_append import *
t=Test()
t.func()
t.static_func()
if grabpath() != os.path.dirname(mypath):
raise RuntimeError
if grabstaticpath() != os.path.basename(mypath):
raise RuntimeError

View file

@ -2,3 +2,6 @@ import python_varargs_typemap
if (python_varargs_typemap.testfunc(1, 2.0, "three") != "three") :
raise RuntimeError("testfunc failed!")
if (python_varargs_typemap.testfunc(1, 2.0, "three", "four", "five") != "threefourfive") :
raise RuntimeError("testfunc failed! {}")

View file

@ -9,6 +9,8 @@ if special_variable_macros.testJill(name) != "jilly":
raise "test failed"
if special_variable_macros.testMary(name) != "SWIGTYPE_p_NameWrap":
raise "test failed"
if special_variable_macros.testJames(name) != "SWIGTYPE_Name":
raise "test failed"
if special_variable_macros.testJim(name) != "multiname num":
raise "test failed"
if special_variable_macros.testJohn(special_variable_macros.PairIntBool(10, False)) != 123:

View file

@ -23,10 +23,12 @@ except RuntimeError,e:
try:
t.hosed()
except threads_exception.Exc,e:
if e.code != 42:
raise RuntimeError
if e.msg != "Hosed":
raise RuntimeError, "bad... msg: %s" % e.msg
code = e.code
if code != 42:
raise RuntimeError, "bad... code: %d" % code
msg = e.msg
if msg != "Hosed":
raise RuntimeError, "bad... msg: '%s' len: %d" % (msg, len(msg))
for i in range(1,4):
try: