Fix %newobject when used in conjunction with %feature(ref). The code from the ref feature was not always being generated for the function specified by %newobject. Documentation for ref and unref moved from Python to the C++ chapter.

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12783 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
William S Fulton 2011-08-23 19:29:10 +00:00
commit c794d08597
8 changed files with 262 additions and 160 deletions

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())