Merge branch 'master' into doxygen

This commit is contained in:
Vadim Zeitlin 2018-03-19 21:54:46 +01:00
commit b7f78dd5a7
232 changed files with 5648 additions and 2419 deletions

View file

@ -10,13 +10,13 @@ endif
LANGUAGE = python
PYTHON = $(PYBIN)
PEP8 = @PEP8@
PEP8_FLAGS = --ignore=E30,E402,E501,E731,W291,W391
PYCODESTYLE = @PYCODESTYLE@
PYCODESTYLE_FLAGS = --ignore=E30,E402,E501,E731,W291,W391
#*_runme.py for Python 2.x, *_runme3.py for Python 3.x
PY2SCRIPTSUFFIX = _runme.py
PY3SCRIPTSUFFIX = _runme3.py
PY2TO3 = 2to3 -x import
PY2TO3 = @PY2TO3@ -x import
ifeq (,$(PY3))
SCRIPTSUFFIX = $(PY2SCRIPTSUFFIX)
@ -70,6 +70,7 @@ CPP_TEST_CASES += \
python_pythoncode \
python_richcompare \
python_strict_unicode \
python_threads \
simutry \
std_containers \
swigobject \
@ -81,6 +82,10 @@ CPP_TEST_CASES += \
CPP11_TEST_CASES = \
cpp11_hash_tables \
cpp11_shared_ptr_const \
cpp11_shared_ptr_nullptr_in_containers \
cpp11_shared_ptr_overload \
cpp11_shared_ptr_upcast \
C_TEST_CASES += \
file_test \
@ -136,12 +141,12 @@ py_runme = $(SCRIPTPREFIX)$*$(SCRIPTSUFFIX)
py2_runme = $(SCRIPTPREFIX)$*$(PY2SCRIPTSUFFIX)
py3_runme = $(SCRIPTPREFIX)$*$(PY3SCRIPTSUFFIX)
ifneq (,$(PEP8))
check_pep8 = $(COMPILETOOL) $(PEP8) $(PEP8_FLAGS) $(SCRIPTPREFIX)$*.py
ifneq (,$(PYCODESTYLE))
check_pep8 = $(COMPILETOOL) $(PYCODESTYLE) $(PYCODESTYLE_FLAGS) $(SCRIPTPREFIX)$*.py
check_pep8_multi_cpp = \
for f in `cat $(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)/$*.list` ; do \
$(COMPILETOOL) $(PEP8) $(PEP8_FLAGS) $$f.py; \
$(COMPILETOOL) $(PYCODESTYLE) $(PYCODESTYLE_FLAGS) $$f.py; \
done
endif

View file

@ -8,13 +8,20 @@ if complextest.Conj(a) != a.conjugate():
if complextest.Conjf(a) != a.conjugate():
raise RuntimeError, "bad complex mapping"
if complextest.Conj2(a) != a.conjugate():
raise RuntimeError, "bad complex mapping"
if complextest.Conjf2(a) != a.conjugate():
raise RuntimeError, "bad complex mapping"
v = (complex(1, 2), complex(2, 3), complex(4, 3), 1)
try:
complextest.Copy_h(v)
except:
pass
if len(complextest.CopyHalf(v)) != 2:
raise RuntimeError("CopyHalf failed")
if len(complextest.CopyHalfRef(v)) != 2:
raise RuntimeError("CopyHalfRef failed")
p = complextest.ComplexPair()
p.z1 = complex(0, 1)

View file

@ -0,0 +1,45 @@
import cpp11_shared_ptr_overload
from cpp11_shared_ptr_overload import MyType
# ref
ret = cpp11_shared_ptr_overload.UseA(MyType("123"))
if ret != "123 ref": raise RuntimeError("UseA fail:" + ret)
ret = cpp11_shared_ptr_overload.UseB(0, MyType("123"))
if ret != "123 ref": raise RuntimeError("UseB fail:" + ret)
ret = cpp11_shared_ptr_overload.UseC(0, MyType("123"), MyType("456"))
if ret != "123 ref": raise RuntimeError("UseC fail:" + ret)
# sharedptr
ret = cpp11_shared_ptr_overload.UseX(MyType("123"))
if ret != "123 sharedptr": raise RuntimeError("UseX fail:" + ret)
ret = cpp11_shared_ptr_overload.UseY(0, MyType("123"))
if ret != "123 sharedptr": raise RuntimeError("UseY fail:" + ret)
ret = cpp11_shared_ptr_overload.UseZ(0, MyType("123"), MyType("456"))
if ret != "123 sharedptr": raise RuntimeError("UseZ fail:" + ret)
# Combo1-4
ret = cpp11_shared_ptr_overload.Combo1(MyType("XXX"))
if ret != "XXXCombo1": raise RuntimeError("Combo1 fail:" + ret)
ret = cpp11_shared_ptr_overload.Combo2(MyType("XXX"))
if ret != "XXXCombo2": raise RuntimeError("Combo2 fail:" + ret)
ret = cpp11_shared_ptr_overload.Combo3(MyType("XXX"))
if ret != "XXXCombo3": raise RuntimeError("Combo3 fail:" + ret)
ret = cpp11_shared_ptr_overload.Combo4(MyType("XXX"))
if ret != "XXXCombo4": raise RuntimeError("Combo4 fail:" + ret)
# Combo5-7
ret = cpp11_shared_ptr_overload.Combo5(MyType("XXX"))
if ret != "XXXCombo5": raise RuntimeError("Combo5 fail:" + ret)
ret = cpp11_shared_ptr_overload.Combo6(MyType("XXX"))
if ret != "XXXCombo6": raise RuntimeError("Combo6 fail:" + ret)
ret = cpp11_shared_ptr_overload.Combo7(MyType("XXX"))
if ret != "XXXCombo7": raise RuntimeError("Combo7 fail:" + ret)

View file

@ -139,6 +139,21 @@ def run(module_name):
print "booltest2 failed"
tricky_failure = True
if tricky.max_32bit_int1() != 0x7FFFFFFF:
print "max_32bit_int1 failed"
tricky_failure = True
if tricky.min_32bit_int1() != -2147483648:
print "min_32bit_int1 failed"
tricky_failure = True
if tricky.max_32bit_int2() != 0x7FFFFFFF:
print "max_32bit_int2 failed"
tricky_failure = True
tricky.too_big_32bit_int1()
tricky.too_small_32bit_int1()
tricky.too_big_32bit_int2()
tricky.too_small_32bit_int2()
if tricky_failure:
raise RuntimeError

View file

@ -0,0 +1,80 @@
from li_boost_shared_ptr_director import *
class Derived(Base):
def __init__(self, flag):
self.return_none = flag
Base.__init__(self)
def ret_c_shared_ptr(self):
if self.return_none:
return None
else:
return C()
def ret_c_by_value(self):
return C()
def take_c_by_value(self,c):
return c.get_m()
def take_c_by_ref(self,c):
return c.get_m()
def take_c_by_pointer(self,c):
if c:
return c.get_m()
else:
return -2
def take_c_by_pointer_ref(self,c):
if c:
return c.get_m()
else:
return -3
def take_c_shared_ptr_by_value(self,c):
if c:
return c.get_m()
else:
return -4
def take_c_shared_ptr_by_ref(self,c):
if c:
return c.get_m()
else:
return -5
def take_c_shared_ptr_by_pointer(self,c):
if c:
return c.get_m()
else:
return -6
def take_c_shared_ptr_by_pointer_ref(self,c):
if c:
return c.get_m()
else:
return -7
a = Derived(False)
b = Derived(True)
assert call_ret_c_shared_ptr(a) == 1
assert call_ret_c_shared_ptr(b) == -1
assert call_ret_c_by_value(a) == 1
assert call_take_c_by_value(a) == 5
assert call_take_c_by_ref(a) == 6
assert call_take_c_by_pointer(a) == 7
assert call_take_c_by_pointer_ref(a) == 8
assert call_take_c_shared_ptr_by_value(a) == 9
assert call_take_c_shared_ptr_by_ref(a) == 10
assert call_take_c_shared_ptr_by_pointer(a) == 11
assert call_take_c_shared_ptr_by_pointer_ref(a) == 12
assert call_take_c_by_pointer_with_null(a) == -2
assert call_take_c_by_pointer_ref_with_null(a) == -3
assert call_take_c_shared_ptr_by_value_with_null(a) == -4
assert call_take_c_shared_ptr_by_ref_with_null(a) == -5
assert call_take_c_shared_ptr_by_pointer_with_null(a) == -6
assert call_take_c_shared_ptr_by_pointer_ref_with_null(a) == -7

View file

@ -87,6 +87,24 @@ if li_std_string_extra.test_value_basic2(x) != x:
if li_std_string_extra.test_value_basic3(x) != x:
raise RuntimeError, "bad string mapping"
if li_std_string_extra.test_value_basic_overload(x) != x:
raise RuntimeError, "bad overload string"
if li_std_string_extra.test_value_basic_overload(123) != "int":
raise RuntimeError, "bad overload int"
try:
li_std_string_extra.test_value_basic_overload([x])
raise RuntimeError, "should throw NotImplementedError"
except NotImplementedError:
pass
try:
li_std_string_extra.test_value_basic_overload([123])
raise RuntimeError, "should throw NotImplementedError"
except NotImplementedError:
pass
# Global variables
s = "initial string"
if li_std_string_extra.cvar.GlobalString2 != "global string 2":

View file

@ -5,11 +5,11 @@ pInt = None
# Check the correct constructors are available
p = Pop(pInt)
p = Pop(pInt, 0)
p = Pop(pInt, False)
# Check overloaded in const only and pointers/references which target
# languages cannot disambiguate
if p.hip(0) != 701:
if p.hip(False) != 701:
raise RuntimeError, "Test 1 failed"
if p.hip(pInt) != 702:
@ -19,14 +19,14 @@ if p.hip(pInt) != 702:
if p.hop(pInt) != 805:
raise RuntimeError, "Test 3 failed"
if p.hop(0) != 801:
if p.hop(False) != 801:
raise RuntimeError, "Test 4 failed"
# Few more variations and order shuffled
if p.pop(0) != 901:
if p.pop(False) != 901:
raise RuntimeError, "Test 5 failed"
if p.pop(pInt) != 902:
if p.pop(pInt) != 904:
raise RuntimeError, "Test 6 failed"
if p.pop() != 905:
@ -36,11 +36,11 @@ if p.pop() != 905:
if p.bop(pInt) != 1001:
raise RuntimeError, "Test 8 failed"
if p.bip(pInt) != 2001:
if p.bip(pInt) != 2002:
raise RuntimeError, "Test 9 failed"
# Globals
if muzak(0) != 3001:
if muzak(False) != 3001:
raise RuntimeError, "Test 10 failed"
if muzak(pInt) != 3002:

View file

@ -0,0 +1,42 @@
from template_class_reuse_name import *
Bool1().tt()
Bool1False().ff()
Bool2().tt()
Bool2False().ff()
Bool3().tt()
Bool3False().ff()
Bool4().tt()
Bool4False().ff()
BoolForward1().tt()
BoolForward1False().ff()
BoolForward2().tt()
BoolForward2False().ff()
BoolForward3().tt()
BoolForward3False().ff()
BoolForward4().tt()
BoolForward4False().ff()
IntBool1().tt()
IntBool1False().ff()
IntBool2().tt()
IntBool2False().ff()
IntBool3().tt()
IntBool3False().ff()
IntBool4().tt()
IntBool4False().ff()
Duplicate2_0().n()
Duplicate3().n()

View file

@ -0,0 +1,11 @@
from typedef_classforward_same_name import *
foo = Foo()
foo.x = 5
if extractFoo(foo) != 5:
raise RuntimeError("unexpected value")
boo = Boo()
boo.x = 5
if extractBoo(boo) != 5:
raise RuntimeError("unexpected value")

View file

@ -25,3 +25,13 @@ if sys.version_info[0:2] < (3, 0):
check(unicode_strings.charstring(unicode("hello4")), "hello4")
unicode_strings.charstring(u"hell\xb05")
unicode_strings.charstring(u"hell\u00f66")
low_surrogate_string = u"\udcff"
try:
unicode_strings.instring(low_surrogate_string)
# Will succeed with Python 2
except TypeError, e:
# Python 3 will fail the PyUnicode_AsUTF8String conversion resulting in a TypeError.
# The real error is actually:
# UnicodeEncodeError: 'utf-8' codec can't encode character '\udcff' in position 0: surrogates not allowed
pass