Merge branch 'master' into doxygen

Fix the usual conflicts in autodoc unit test due to fixing the
divergences in autodoc generation between builtin and default cases in
this branch.
This commit is contained in:
Vadim Zeitlin 2017-09-19 13:54:41 +02:00
commit db65ae5aea
371 changed files with 9815 additions and 3191 deletions

View file

@ -73,18 +73,21 @@ CPP_TEST_CASES += \
simutry \
std_containers \
swigobject \
template_matrix
template_matrix \
# li_std_carray
# director_profile
# python_pybuf
CPP11_TEST_CASES = \
cpp11_hash_tables \
C_TEST_CASES += \
file_test \
li_cstring \
li_cwstring \
python_nondynamic \
python_varargs_typemap
python_varargs_typemap \
#
# This test only works with modern C compilers
@ -159,7 +162,7 @@ convert_testcase = \
$(MAKE) $(SCRIPTDIR)/$(py_runme); \
fi
$(SCRIPTDIR)/$(SCRIPTPREFIX)%$(SCRIPTSUFFIX): $(srcdir)/$(SCRIPTPREFIX)%$(PY2SCRIPTSUFFIX)
$(SCRIPTDIR)/$(SCRIPTPREFIX)%$(SCRIPTSUFFIX): $(abspath $(srcdir)/$(SCRIPTPREFIX)%$(PY2SCRIPTSUFFIX))
test x$< = x$@ || cp $< $@ || exit 1
test x$(PY3) = x || $(PY2TO3) -w $@ >/dev/null 2>&1 || exit 1
@ -179,19 +182,6 @@ clean:
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'
@echo Makefile
@for i in ${CPP_TEST_CASES} ${C_TEST_CASES}; do echo $$i.py; done
@for i in ${CPP_TEST_CASES} ${C_TEST_CASES}; do if grep -q $${i}_runme.py CVS/Entries ; then echo $${i}_runme.py; fi; done
@echo clientdata_prop_a.py
@echo clientdata_prop_b.py
@echo imports_a.py
@echo imports_b.py
@echo mod_a.py mod_b.py
@echo hugemod.h hugemod_a.i hugemod_b.i hugemod_a.py hugemod_b.py hugemod_runme.py
@echo template_typedef_import.py
hugemod_runme = hugemod$(SCRIPTPREFIX)
hugemod:

View file

@ -201,3 +201,7 @@ check(inspect.getdoc(func_output), "func_output() -> int")
check(inspect.getdoc(func_inout), "func_inout(int * INOUT) -> int")
check(inspect.getdoc(func_cb), "func_cb(int c, int d) -> int")
check(inspect.getdoc(banana), "banana(S a, S b, int c, Integer d)")
check(inspect.getdoc(TInteger), "Proxy of C++ T< int > class.", "::T< int >")
check(inspect.getdoc(TInteger.__init__), "__init__(TInteger self) -> TInteger", None, skip)
check(inspect.getdoc(TInteger.inout), "inout(TInteger self, TInteger t) -> TInteger")

View file

@ -15,3 +15,9 @@ try:
complextest.Copy_h(v)
except:
pass
p = complextest.ComplexPair()
p.z1 = complex(0, 1)
p.z2 = complex(0, -1)
if complextest.Conj(p.z2) != p.z1:
raise RuntimeError, "bad complex mapping"

View file

@ -4,11 +4,20 @@ a = cpp11_alternate_function_syntax.SomeStruct()
res = a.addNormal(4, 5)
if res != 9:
raise RuntimeError, ("SomeStruct::addNormal(4,5) returns ",
res, " should be 9.")
raise RuntimeError, ("SomeStruct::addNormal(4,5) returns ", res, " should be 9.")
res = a.addAlternate(4, 5)
if res != 9:
raise RuntimeError, ("SomeStruct::addAlternate(4,5) returns ",
res, " should be 9.")
raise RuntimeError, ("SomeStruct::addAlternate(4,5) returns ", res, " should be 9.")
res = a.addAlternateConst(4, 5)
if res != 9:
raise RuntimeError, ("SomeStruct::addAlternateConst(4,5) returns ", res, " should be 9.")
res = a.addAlternateNoExcept(4, 5)
if res != 9:
raise RuntimeError, ("SomeStruct::addAlternateNoExcept(4,5) returns ", res, " should be 9.")
res = a.addAlternateConstNoExcept(4, 5)
if res != 9:
raise RuntimeError, ("SomeStruct::addAlternateConstNoExcept(4,5) returns ", res, " should be 9.")

View file

@ -0,0 +1,54 @@
import cpp11_hash_tables
def swig_assert_equal(a, b):
if a != b:
raise RuntimeError(str(a) + " != " + str(b))
for x in [cpp11_hash_tables.MapIntInt({1:7}),
cpp11_hash_tables.MultiMapIntInt({1:7}),
# TODO: fix for -builtin
# cpp11_hash_tables.UnorderedMapIntInt({1:7}),
# cpp11_hash_tables.UnorderedMultiMapIntInt({1:7})
]:
swig_assert_equal([(k, v) for k, v in x.iteritems()], [(1, 7)])
swig_assert_equal(x[1], 7)
swig_assert_equal(2 in x, False)
x[2] = 9
swig_assert_equal(x[2], 9)
del x[2]
swig_assert_equal(2 in x, False)
swig_assert_equal(x.empty(), False)
del x[1]
swig_assert_equal(x.empty(), True)
swig_assert_equal(1 in x, False)
for x in [cpp11_hash_tables.MultiMapIntInt({1:7}),
cpp11_hash_tables.UnorderedMultiMapIntInt({1:7})]:
x[1] = 9
# TODO: fix for -builtin
# swig_assert_equal(sorted([v for k, v in x.iteritems()]), [7, 9])
# Is this broken?...
# swig_assert_equal(sorted([v for v in x[1]]), [7, 9])
for x in [cpp11_hash_tables.SetInt([1]),
cpp11_hash_tables.MultiSetInt([1]),
cpp11_hash_tables.UnorderedSetInt([1]),
cpp11_hash_tables.UnorderedMultiSetInt([1])]:
swig_assert_equal([e for e in x], [1])
swig_assert_equal(1 in x, True)
swig_assert_equal(2 in x, False)
x.append(2)
swig_assert_equal(2 in x, True)
x.erase(2)
swig_assert_equal(x.empty(), False)
x.erase(1)
swig_assert_equal(x.empty(), True)
for x in [cpp11_hash_tables.MultiSetInt([1]),
cpp11_hash_tables.UnorderedMultiSetInt([1])]:
x.append(1)
swig_assert_equal(x.count(1), 2)

View file

@ -0,0 +1,45 @@
import cpp11_ref_qualifiers
h = cpp11_ref_qualifiers.Host()
# Basic testing
h.h1()
h.h2()
h.h6()
h.h7()
h.h()
# %feature testing
f = cpp11_ref_qualifiers.Features()
if f.F1() != "F1":
raise RuntimeException("Fail")
if f.F2() != "F2":
raise RuntimeException("Fail")
if f.F3() != "F3":
raise RuntimeException("Fail")
if f.C1(0) != "C1":
raise RuntimeException("Fail")
if f.C2(0) != "C2":
raise RuntimeException("Fail")
if f.C3(0) != "C3":
raise RuntimeException("Fail")
# %rename testing
r = cpp11_ref_qualifiers.Renames()
r.RR1()
r.RR2()
r.RR3()
r.SS1(0)
r.SS2(0)
r.SS3(0)
# Conversion operators
co = cpp11_ref_qualifiers.ConversionOperators()
s = co.StringConvertCopy()
s = co.StringConvertMove()
co2 = cpp11_ref_qualifiers.ConversionOperators2()
s = co2.StringConvertMove()

View file

@ -0,0 +1,4 @@
import cpp11_ref_qualifiers_rvalue_unignore
cpp11_ref_qualifiers_rvalue_unignore.RefQualifier().m1()
cpp11_ref_qualifiers_rvalue_unignore.RefQualifier().m2()

View file

@ -32,6 +32,8 @@ def run(module_name):
f.newname()
f.newname(1)
f.defaulted1()
f.defaulted2()
if f.double_if_void_ptr_is_null(2, None) != 4:
raise RuntimeError
@ -113,15 +115,39 @@ def run(module_name):
if Klass_inc().val != 0:
raise RuntimeError("Klass::inc failed")
default_args.trickyvalue1(10)
default_args.trickyvalue1(10, 10)
default_args.trickyvalue2(10)
default_args.trickyvalue2(10, 10)
default_args.trickyvalue3(10)
default_args.trickyvalue3(10, 10)
tricky_failure = False
tricky = default_args.TrickyInPython()
if tricky.value_m1(10) != -1:
print "trickyvalue_m1 failed"
tricky_failure = True
if tricky.value_m1(10, 10) != 10:
print "trickyvalue_m1 failed"
tricky_failure = True
if tricky.value_0xabcdef(10) != 0xabcdef:
print "trickyvalue_0xabcdef failed"
tricky_failure = True
if tricky.value_0644(10) != 420:
print "trickyvalue_0644 failed"
tricky_failure = True
if tricky.value_perm(10) != 420:
print "trickyvalue_perm failed"
tricky_failure = True
if tricky.value_m01(10) != -1:
print "trickyvalue_m01 failed"
tricky_failure = True
if not tricky.booltest2():
print "booltest2 failed"
tricky_failure = True
if tricky_failure:
raise RuntimeError
default_args.seek()
default_args.seek(10)
if not default_args.booltest():
raise RuntimeError("booltest failed")
if default_args.slightly_off_square(10) != 102:
raise RuntimeError

View file

@ -15,6 +15,20 @@ class director_smartptr_MyBarFoo(Foo):
def makeFoo(self):
return Foo()
class director_smartptr_MyBarFooDerived(FooDerived):
def ping(self):
return "director_smartptr_MyBarFooDerived.ping()"
def pong(self):
return "director_smartptr_MyBarFooDerived.pong();" + self.ping()
def upcall(self, fooBarPtr):
return "overrideDerived;" + fooBarPtr.FooBarDo()
def makeFoo(self):
return Foo()
def check(got, expected):
if (got != expected):
raise RuntimeError, "Failed, got: " + got + " expected: " + expected
@ -35,3 +49,8 @@ myFoo2 = Foo().makeFoo()
check(myFoo2.pong(), "Foo::pong();Foo::ping()")
check(Foo.callPong(myFoo2), "Foo::pong();Foo::ping()")
check(myFoo2.upcall(FooBar()), "Bar::Foo2::Foo2Bar()")
myBarFooDerived = director_smartptr_MyBarFooDerived()
check(myBarFooDerived.ping(), "director_smartptr_MyBarFooDerived.ping()")
check(FooDerived.callPong(myBarFooDerived), "director_smartptr_MyBarFooDerived.pong();director_smartptr_MyBarFooDerived.ping()")
check(FooDerived.callUpcall(myBarFooDerived, fooBar), "overrideDerived;Bar::Foo2::Foo2Bar()")

View file

@ -0,0 +1,51 @@
# Example using pointers to member functions
from member_pointer_const import *
def check(what, expected, actual):
if expected != actual:
raise RuntimeError(
"Failed: ", what, " Expected: ", expected, " Actual: ", actual)
# Get the pointers
area_pt = areapt()
perim_pt = perimeterpt()
# Create some objects
s = Square(10)
# Do some calculations
check("Square area ", 100.0, do_op(s, area_pt))
check("Square perim", 40.0, do_op(s, perim_pt))
memberPtr = cvar.areavar
memberPtr = cvar.perimetervar
# Try the variables
check("Square area ", 100.0, do_op(s, cvar.areavar))
check("Square perim", 40.0, do_op(s, cvar.perimetervar))
# Modify one of the variables
cvar.areavar = perim_pt
check("Square perimeter", 40.0, do_op(s, cvar.areavar))
# Try the constants
memberPtr = AREAPT
memberPtr = PERIMPT
memberPtr = NULLPT
check("Square area ", 100.0, do_op(s, AREAPT))
check("Square perim", 40.0, do_op(s, PERIMPT))
# Typedefs
check("Square perim", 40.0, do_op_td(s, perim_pt));
check("Add by value", 3, call1(ADD_BY_VALUE, 1, 2))
#check("Add by pointer", 7, call2(ADD_BY_POINTER, 3, 4))
#check("Add by reference", 11, call3(ADD_BY_REFERENCE, 5, 6))

View file

@ -43,6 +43,9 @@ memberPtr = NULLPT
check("Square area ", 100.0, do_op(s, AREAPT))
check("Square perim", 40.0, do_op(s, PERIMPT))
# Typedefs
check("Square perim", 40.0, do_op_td(s, perim_pt));
check("Add by value", 3, call1(ADD_BY_VALUE, 1, 2))
check("Add by pointer", 7, call2(ADD_BY_POINTER, 3, 4))
check("Add by reference", 11, call3(ADD_BY_REFERENCE, 5, 6))

View file

@ -14,3 +14,6 @@ if 2 * preproc.one != preproc.two:
if preproc.methodX(99) != 199:
raise RuntimeError
t1 = preproc.tcxMessageTest()
t2 = preproc.tcxMessageBug()

View file

@ -9,7 +9,7 @@ if is_python_builtin():
exit(0)
t = Test()
t.func()
t.funk()
if is_new_style_class(Test):
t.static_func()
else:

View file

@ -1,4 +1,13 @@
import python_richcompare
import sys
def check_unorderable_types(exception):
# if str(exception).find("unorderable types") == -1:
# raise RuntimeError("A TypeError 'unorderable types' exception was expected"), None, sys.exc_info()[2]
pass # Exception message seems to vary from one version of Python to another
def is_new_style_class(cls):
return hasattr(cls, "__class__")
base1 = python_richcompare.BaseClass(1)
base2 = python_richcompare.BaseClass(2)
@ -65,6 +74,18 @@ if (b1 == a1):
raise RuntimeError(
"Comparing equivalent instances of different subclasses, == returned True")
# Check comparison to other objects
#-------------------------------------------------------------------------------
if (base1 == 42) :
raise RuntimeError("Comparing class to incompatible type, == returned True")
if not (base1 != 42) :
raise RuntimeError("Comparing class to incompatible type, != returned False")
if (a1 == 42) :
raise RuntimeError("Comparing class (with overloaded operator ==) to incompatible type, == returned True")
if not (a1 != 42) :
raise RuntimeError("Comparing class (with overloaded operator ==) to incompatible type, != returned False")
# Check inequalities
#-------------------------------------------------------------------------
@ -80,6 +101,42 @@ if not (a2 >= b2):
if not (a2 <= b2):
raise RuntimeError("operator<= failed")
# Check inequalities to other objects
#-------------------------------------------------------------------------------
if is_new_style_class(python_richcompare.BaseClass):
# Skip testing -classic option
if sys.version_info[0:2] < (3, 0):
if (base1 < 42):
raise RuntimeError("Comparing class to incompatible type, < returned True")
if (base1 <= 42):
raise RuntimeError("Comparing class to incompatible type, <= returned True")
if not (base1 > 42):
raise RuntimeError("Comparing class to incompatible type, > returned False")
if not (base1 >= 42):
raise RuntimeError("Comparing class to incompatible type, >= returned False")
else:
# Python 3 throws: TypeError: unorderable types
try:
res = base1 < 42
raise RuntimeError("Failed to throw")
except TypeError,e:
check_unorderable_types(e)
try:
res = base1 <= 42
raise RuntimeError("Failed to throw")
except TypeError,e:
check_unorderable_types(e)
try:
res = base1 > 42
raise RuntimeError("Failed to throw")
except TypeError,e:
check_unorderable_types(e)
try:
res = base1 >= 42
raise RuntimeError("Failed to throw")
except TypeError,e:
check_unorderable_types(e)
# Check inequalities used for ordering
#-------------------------------------------------------------------------

View file

@ -0,0 +1,15 @@
import template_using_directive_typedef
vo = template_using_directive_typedef.Vector_Obj();
h = template_using_directive_typedef.Holder();
h.holder_use1(vo, vo, vo);
h.holder_use2(vo, vo, vo);
h.holder_use3(vo, vo, vo);
template_using_directive_typedef.tns_holder_use(vo, vo);
template_using_directive_typedef.tns_use(vo, vo, vo);
template_using_directive_typedef.global_holder_use(vo);
template_using_directive_typedef.global_use(vo, vo, vo);
template_using_directive_typedef.ns1_holder_use(vo);
template_using_directive_typedef.ns2_holder_use(vo, vo, vo, vo);

View file

@ -0,0 +1,20 @@
import typedef_funcptr
a = 100
b = 10
if typedef_funcptr.do_op(a,b,typedef_funcptr.addf) != 110:
raise RuntimeError("addf failed")
if typedef_funcptr.do_op(a,b,typedef_funcptr.subf) != 90:
raise RuntimeError("subf failed")
if typedef_funcptr.do_op_typedef_int(a,b,typedef_funcptr.addf) != 110:
raise RuntimeError("addf failed")
if typedef_funcptr.do_op_typedef_int(a,b,typedef_funcptr.subf) != 90:
raise RuntimeError("subf failed")
if typedef_funcptr.do_op_typedef_Integer(a,b,typedef_funcptr.addf) != 110:
raise RuntimeError("addf failed")
if typedef_funcptr.do_op_typedef_Integer(a,b,typedef_funcptr.subf) != 90:
raise RuntimeError("subf failed")

View file

@ -0,0 +1,32 @@
from typemap_template_typedef import *
def check(got, expected):
if got != expected:
raise RuntimeError("got: " + str(got) + " expected: " + str(expected))
x = XXXInt()
check(x.aa1(0), 0)
check(x.aa2(0), 55)
check(x.aa3(0), 0)
check(aa1(0), 0)
check(aa2(0), 0)
check(x.bb1(0), 0)
check(x.bb2(0), 66)
check(x.bb3(0), 0)
check(bb1(0), 0)
check(bb2(0), 0)
check(x.cc1(0), 0)
check(x.cc2(0), 77)
check(x.cc3(0), 77)
check(cc1(0), 0)
check(cc2(0), 0)
check(x.dd1(0), 0)
check(x.dd2(0), 88)
check(x.dd3(0), 0)
check(dd1(0), 0)
check(dd2(0), 0)