Implement reference_internal with a keep_alive

reference_internal requires an `instance` field to track the returned
reference's parent, but that's just a duplication of what
keep_alive<0,1> does, so use a keep alive to do this to eliminate the
duplication.
This commit is contained in:
Jason Rhinelander
2016-08-10 12:08:04 -04:00
parent efc2aa7ee7
commit f2ecd8927e
7 changed files with 48 additions and 23 deletions

View File

@@ -95,3 +95,17 @@ print_NestA(c.b.a)
print_NestB(b)
print_NestB(c.b)
print_NestC(c)
abase = a.as_base()
print(abase.value)
a.as_base().value += 44
print(abase.value)
print(c.b.a.as_base().value)
c.b.a.as_base().value += 44
print(c.b.a.as_base().value)
del c
gc.collect()
del a # Should't delete while abase is still alive
gc.collect()
print(abase.value)
del abase
gc.collect()