Commit 38323671 authored by Xavier Thompson's avatar Xavier Thompson

Rename 'consume' as 'recover'

parent 608c29a9
...@@ -11369,8 +11369,8 @@ class SizeofVarNode(SizeofNode): ...@@ -11369,8 +11369,8 @@ class SizeofVarNode(SizeofNode):
pass pass
class ConsumeNode(ExprNode): class RecoverNode(ExprNode):
# Consume expression # Recover expression
# #
# operand ExprNode # operand ExprNode
# #
...@@ -11396,7 +11396,7 @@ class ConsumeNode(ExprNode): ...@@ -11396,7 +11396,7 @@ class ConsumeNode(ExprNode):
self.operand = self.operand.analyse_types(env) self.operand = self.operand.analyse_types(env)
operand_type = self.operand.type operand_type = self.operand.type
if not operand_type.is_cyp_class: if not operand_type.is_cyp_class:
error(self.pos, "Can only consume cypclass (not '%s')" % operand_type) error(self.pos, "Can only recover cypclass (not '%s')" % operand_type)
self.type = PyrexTypes.error_type self.type = PyrexTypes.error_type
return self return self
if operand_type.is_qualified_cyp_class: if operand_type.is_qualified_cyp_class:
...@@ -11419,7 +11419,7 @@ class ConsumeNode(ExprNode): ...@@ -11419,7 +11419,7 @@ class ConsumeNode(ExprNode):
self.is_temp = self.operand_is_named or (self.generate_runtime_check and not solid_operand.is_temp) self.is_temp = self.operand_is_named or (self.generate_runtime_check and not solid_operand.is_temp)
self.solid_operand = solid_operand self.solid_operand = solid_operand
if self.operand_is_named: if self.operand_is_named:
solid_operand.entry.is_consumed = True solid_operand.entry.is_recovered = True
return self return self
def may_be_none(self): def may_be_none(self):
...@@ -11429,7 +11429,7 @@ class ConsumeNode(ExprNode): ...@@ -11429,7 +11429,7 @@ class ConsumeNode(ExprNode):
return self.operand.is_simple() return self.operand.is_simple()
def make_owned_reference(self, code): def make_owned_reference(self, code):
# We steal the reference of the consumed operand. # We steal the reference of the recovered operand.
pass pass
def calculate_result_code(self): def calculate_result_code(self):
...@@ -11451,7 +11451,7 @@ class ConsumeNode(ExprNode): ...@@ -11451,7 +11451,7 @@ class ConsumeNode(ExprNode):
code.putln("#ifdef WITH_THREAD") code.putln("#ifdef WITH_THREAD")
code.putln("PyGILState_STATE _save = PyGILState_Ensure();") code.putln("PyGILState_STATE _save = PyGILState_Ensure();")
code.putln("#endif") code.putln("#endif")
code.putln("PyErr_SetString(PyExc_TypeError, \"'consume' operand is not isolated\");") code.putln("PyErr_SetString(PyExc_TypeError, \"'recover' operand is not isolated\");")
if self.nogil: if self.nogil:
code.putln("#ifdef WITH_THREAD") code.putln("#ifdef WITH_THREAD")
code.putln("PyGILState_Release(_save);") code.putln("PyGILState_Release(_save);")
......
...@@ -2199,7 +2199,7 @@ class FuncDefNode(StatNode, BlockNode): ...@@ -2199,7 +2199,7 @@ class FuncDefNode(StatNode, BlockNode):
if entry.type.is_cyp_class: if entry.type.is_cyp_class:
# CyObjects use another refcounting convention. # CyObjects use another refcounting convention.
# Except for the 'self' argument. # Except for the 'self' argument.
if entry.is_self_arg and (entry.is_consumed or entry.cf_is_reassigned) and not entry.in_closure: if entry.is_self_arg and (entry.is_recovered or entry.cf_is_reassigned) and not entry.in_closure:
code.put_var_incref(entry) code.put_var_incref(entry)
elif (acquire_gil or entry.cf_is_reassigned) and not entry.in_closure: elif (acquire_gil or entry.cf_is_reassigned) and not entry.in_closure:
code.put_var_incref(entry) code.put_var_incref(entry)
...@@ -2419,8 +2419,8 @@ class FuncDefNode(StatNode, BlockNode): ...@@ -2419,8 +2419,8 @@ class FuncDefNode(StatNode, BlockNode):
continue continue
elif entry.type.is_cyp_class: elif entry.type.is_cyp_class:
# CyObject arguments are systematically decrefed. # CyObject arguments are systematically decrefed.
# Except for the 'self' argument when it has not been reassigned or consumed. # Except for the 'self' argument when it has not been reassigned or recovered.
if entry.is_self_arg and not (entry.is_consumed or entry.cf_is_reassigned): if entry.is_self_arg and not (entry.is_recovered or entry.cf_is_reassigned):
continue continue
else: else:
if entry.in_closure: if entry.in_closure:
......
...@@ -309,8 +309,8 @@ def _p_factor(s): ...@@ -309,8 +309,8 @@ def _p_factor(s):
return p_typecast(s) return p_typecast(s)
elif sy == 'IDENT' and s.systring == "sizeof": elif sy == 'IDENT' and s.systring == "sizeof":
return p_sizeof(s) return p_sizeof(s)
elif sy == 'IDENT' and s.systring == "consume": elif sy == 'IDENT' and s.systring == "recover":
return p_consume(s) return p_recover(s)
return p_power(s) return p_power(s)
def p_typecast(s): def p_typecast(s):
...@@ -360,12 +360,12 @@ def p_sizeof(s): ...@@ -360,12 +360,12 @@ def p_sizeof(s):
s.expect(')') s.expect(')')
return node return node
def p_consume(s): def p_recover(s):
# s.sy == ident "consume" # s.sy == ident "recover"
pos = s.position() pos = s.position()
s.next() s.next()
operand = p_factor(s) operand = p_factor(s)
return ExprNodes.ConsumeNode(pos, operand = operand) return ExprNodes.RecoverNode(pos, operand = operand)
def p_yield_expression(s): def p_yield_expression(s):
......
...@@ -181,7 +181,7 @@ class Entry(object): ...@@ -181,7 +181,7 @@ class Entry(object):
# #
# active_entry Entry Entry for the active version of an asyncable cypclass method # active_entry Entry Entry for the active version of an asyncable cypclass method
# #
# is_consumed boolean The entry is the operand of a 'consume' expression. # is_recovered boolean The entry is the operand of a 'recover' expression.
# #
# is_specialised boolean The entry is a template specialisation. # is_specialised boolean The entry is a template specialisation.
...@@ -262,7 +262,7 @@ class Entry(object): ...@@ -262,7 +262,7 @@ class Entry(object):
static_cname = None static_cname = None
original_name = None original_name = None
active_entry = None active_entry = None
is_consumed = False is_recovered = False
is_specialised = False is_specialised = False
def __init__(self, name, cname, type, pos = None, init = None): def __init__(self, name, cname, type, pos = None, init = None):
......
...@@ -34,21 +34,21 @@ def test_aliasing(): ...@@ -34,21 +34,21 @@ def test_aliasing():
active_b = A() active_b = A()
cdef active A active_c cdef active A active_c
active_c = consume A() active_c = recover A()
cdef active A active_d cdef active A active_d
active_d = <lock A> consume A() active_d = <lock A> recover A()
def test_calling(): def test_calling():
a = activate(consume A()) a = activate(recover A())
a.f(NULL, A()) a.f(NULL, A())
a.f(NULL, consume A()) a.f(NULL, recover A())
cdef iso A iso_a cdef iso A iso_a
a.f_iso(NULL, consume iso_a) a.f_iso(NULL, recover iso_a)
cdef lock A lock_a cdef lock A lock_a
a.f_lock(NULL, lock_a) a.f_lock(NULL, lock_a)
...@@ -62,7 +62,7 @@ def test_typecast(): ...@@ -62,7 +62,7 @@ def test_typecast():
# Casting from active # Casting from active
cdef iso A iso_a cdef iso A iso_a
iso_a = consume <iso A> active_a iso_a = recover <iso A> active_a
cdef lock A lock_a cdef lock A lock_a
lock_a = <lock A> active_a lock_a = <lock A> active_a
...@@ -75,10 +75,10 @@ def test_typecast(): ...@@ -75,10 +75,10 @@ def test_typecast():
active_b = <active A> A() active_b = <active A> A()
cdef active A active_c cdef active A active_c
active_c = <active A> <iso A> consume A() active_c = <active A> <iso A> recover A()
cdef active A active_d cdef active A active_d
active_d = <active A> <lock A> consume A() active_d = <active A> <lock A> recover A()
_ERRORS = u''' _ERRORS = u'''
......
...@@ -7,7 +7,7 @@ cdef cypclass A activable: ...@@ -7,7 +7,7 @@ cdef cypclass A activable:
def test_name_aliasing(): def test_name_aliasing():
cdef iso A iso_a cdef iso A iso_a
iso_a = consume A() iso_a = recover A()
# Aliasing to iso # Aliasing to iso
cdef iso A iso_b cdef iso A iso_b
...@@ -17,7 +17,7 @@ def test_name_aliasing(): ...@@ -17,7 +17,7 @@ def test_name_aliasing():
iso_c = A() iso_c = A()
cdef iso A iso_d cdef iso A iso_d
iso_d = activate(consume A()) iso_d = activate(recover A())
cdef iso A iso_e cdef iso A iso_e
iso_e = <object> A() iso_e = <object> A()
...@@ -50,11 +50,11 @@ cdef cypclass Origin: ...@@ -50,11 +50,11 @@ cdef cypclass Origin:
return other return other
def test_field_aliasing(): def test_field_aliasing():
cdef iso Origin o = consume Origin() cdef iso Origin o = recover Origin()
cdef object py_field cdef object py_field
# OK - can pass consumed arguments # OK - can pass recovered arguments
o.bar(consume Field()).foo(consume Field()) o.bar(recover Field()).foo(recover Field())
# ERR - aliasing field of iso to pyobject # ERR - aliasing field of iso to pyobject
py_field = o.field py_field = o.field
...@@ -66,25 +66,25 @@ def test_field_aliasing(): ...@@ -66,25 +66,25 @@ def test_field_aliasing():
field = o.field field = o.field
# ERR - consuming field of iso # ERR - consuming field of iso
field2 = consume o.field field2 = recover o.field
# ERR - non_consumed argument # ERR - non_recovered argument
o.bar(Field()) o.bar(Field())
# ERR - aliasing the returned reference # ERR - aliasing the returned reference
c = o.bar(consume Field()) c = o.bar(recover Field())
def test_typecast(): def test_typecast():
cdef iso A iso_a cdef iso A iso_a
iso_a = consume A() iso_a = recover A()
# Casting to iso # Casting to iso
cdef iso A iso_b cdef iso A iso_b
iso_b = <iso A> A() iso_b = <iso A> A()
cdef iso A iso_c cdef iso A iso_c
iso_c = <iso A> activate(consume A()) iso_c = <iso A> activate(recover A())
cdef iso A iso_d cdef iso A iso_d
iso_d = <iso A> <object> A() iso_d = <iso A> <object> A()
...@@ -103,7 +103,7 @@ def test_typecast(): ...@@ -103,7 +103,7 @@ def test_typecast():
iso_e = <iso A> iso_a iso_e = <iso A> iso_a
cdef iso A iso_f cdef iso A iso_f
iso_f = consume <iso A> iso_a iso_f = recover <iso A> iso_a
_ERRORS = u''' _ERRORS = u'''
......
...@@ -40,10 +40,10 @@ def test_aliasing(): ...@@ -40,10 +40,10 @@ def test_aliasing():
lock_b = A() lock_b = A()
cdef lock A lock_c cdef lock A lock_c
lock_c = consume A() lock_c = recover A()
cdef lock A lock_d cdef lock A lock_d
lock_d = <lock A> consume A() lock_d = <lock A> recover A()
cdef lock A lock_e cdef lock A lock_e
cdef locked A locked_b cdef locked A locked_b
...@@ -55,12 +55,12 @@ def test_calling(): ...@@ -55,12 +55,12 @@ def test_calling():
a.f(A()) a.f(A())
a.f(consume A()) a.f(recover A())
a.f_locked_self() a.f_locked_self()
cdef iso A iso_a cdef iso A iso_a
a.f_iso(consume iso_a) a.f_iso(recover iso_a)
cdef lock A lock_a cdef lock A lock_a
a.f_lock(lock_a) a.f_lock(lock_a)
...@@ -74,7 +74,7 @@ def test_typecast(): ...@@ -74,7 +74,7 @@ def test_typecast():
# Casting from lock # Casting from lock
cdef iso A iso_a cdef iso A iso_a
iso_a = consume <iso A> lock_a iso_a = recover <iso A> lock_a
cdef active A active_a cdef active A active_a
active_a = <active A> lock_a active_a = <active A> lock_a
...@@ -90,10 +90,10 @@ def test_typecast(): ...@@ -90,10 +90,10 @@ def test_typecast():
lock_b = <lock A> A() lock_b = <lock A> A()
cdef lock A lock_c cdef lock A lock_c
lock_c = <lock A> <iso A> consume A() lock_c = <lock A> <iso A> recover A()
cdef lock A lock_d cdef lock A lock_d
lock_d = <lock A> activate(consume A()) lock_d = <lock A> activate(recover A())
cdef lock A lock_e cdef lock A lock_e
cdef locked A locked_b cdef locked A locked_b
......
...@@ -134,7 +134,7 @@ cdef cypclass A activable: ...@@ -134,7 +134,7 @@ cdef cypclass A activable:
__init__(self): __init__(self):
self.a = 0 self.a = 0
self._active_result_class = WaitResult.construct self._active_result_class = WaitResult.construct
self._active_queue_class = consume BasicQueue() self._active_queue_class = recover BasicQueue()
int getter(const self): int getter(const self):
return self.a return self.a
void setter(self, int a): void setter(self, int a):
...@@ -147,12 +147,12 @@ def test_acthon_chain(n): ...@@ -147,12 +147,12 @@ def test_acthon_chain(n):
""" """
cdef ActhonResultInterface res cdef ActhonResultInterface res
cdef lock ActhonQueueInterface queue cdef lock ActhonQueueInterface queue
sync1 = <lock ActivityCounterSync> consume ActivityCounterSync() sync1 = <lock ActivityCounterSync> recover ActivityCounterSync()
after_sync1 = <lock ActivityCounterSync> consume ActivityCounterSync(sync1) after_sync1 = <lock ActivityCounterSync> recover ActivityCounterSync(sync1)
obj = A() obj = A()
queue = obj._active_queue_class queue = obj._active_queue_class
obj_actor = activate(consume obj) obj_actor = activate(recover obj)
# Pushing things in the queue # Pushing things in the queue
obj_actor.setter(sync1, n) obj_actor.setter(sync1, n)
......
...@@ -139,16 +139,16 @@ cdef object cyobject_to_pyobject(Refcounted r): ...@@ -139,16 +139,16 @@ cdef object cyobject_to_pyobject(Refcounted r):
cdef Refcounted pyobject_to_cyobject(object o): cdef Refcounted pyobject_to_cyobject(object o):
return o return o
cdef void consume_cyobject(Refcounted r): cdef void recover_cyobject(Refcounted r):
pass pass
def consume_wrapped_cyobject(Refcounted r): def recover_wrapped_cyobject(Refcounted r):
pass pass
def wrapped_cyobject_to_pyobject(Refcounted r): def wrapped_cyobject_to_pyobject(Refcounted r):
return r return r
def consume_wrapped_cyobject_with_generic_args(Refcounted r, **kwargs): def recover_wrapped_cyobject_with_generic_args(Refcounted r, **kwargs):
pass pass
def wrapped_cyobject_to_pyobject_with_generic_args(Refcounted r, dummy=2, unused="unused"): def wrapped_cyobject_to_pyobject_with_generic_args(Refcounted r, dummy=2, unused="unused"):
...@@ -169,39 +169,39 @@ def test_recfcount_round_trip_conversions(): ...@@ -169,39 +169,39 @@ def test_recfcount_round_trip_conversions():
return Cy_GETREF(r) return Cy_GETREF(r)
def test_recfcount_consume_cyobject(): def test_recfcount_recover_cyobject():
""" """
>>> test_recfcount_consume_cyobject() >>> test_recfcount_recover_cyobject()
2 2
""" """
cdef Refcounted r = Refcounted() cdef Refcounted r = Refcounted()
for i in range(10): for i in range(10):
consume_cyobject(r) recover_cyobject(r)
return Cy_GETREF(r) return Cy_GETREF(r)
def test_recfcount_consume_converted_cyobject(): def test_recfcount_recover_converted_cyobject():
""" """
>>> test_recfcount_consume_converted_cyobject() >>> test_recfcount_recover_converted_cyobject()
2 2
""" """
cdef Refcounted r = Refcounted() cdef Refcounted r = Refcounted()
for i in range(10): for i in range(10):
consume_cyobject(<object> r) recover_cyobject(<object> r)
return Cy_GETREF(r) return Cy_GETREF(r)
def test_recfcount_consume_wrapped_cyobject(): def test_recfcount_recover_wrapped_cyobject():
""" """
>>> test_recfcount_consume_wrapped_cyobject() >>> test_recfcount_recover_wrapped_cyobject()
2 2
""" """
cdef Refcounted r = Refcounted() cdef Refcounted r = Refcounted()
for i in range(10): for i in range(10):
consume_wrapped_cyobject(r) recover_wrapped_cyobject(r)
return Cy_GETREF(r) return Cy_GETREF(r)
...@@ -217,15 +217,15 @@ def test_recfcount_convert_wrapped_cyobject(): ...@@ -217,15 +217,15 @@ def test_recfcount_convert_wrapped_cyobject():
return Cy_GETREF(r) return Cy_GETREF(r)
def test_recfcount_consume_wrapped_cyobject_with_generic_args(): def test_recfcount_recover_wrapped_cyobject_with_generic_args():
""" """
>>> test_recfcount_consume_wrapped_cyobject_with_generic_args() >>> test_recfcount_recover_wrapped_cyobject_with_generic_args()
2 2
""" """
cdef Refcounted r = Refcounted() cdef Refcounted r = Refcounted()
for i in range(10): for i in range(10):
consume_wrapped_cyobject_with_generic_args(r) recover_wrapped_cyobject_with_generic_args(r)
return Cy_GETREF(r) return Cy_GETREF(r)
......
...@@ -10,26 +10,26 @@ from libcythonplus.set cimport cypset ...@@ -10,26 +10,26 @@ from libcythonplus.set cimport cypset
cdef cypclass Leaf activable: cdef cypclass Leaf activable:
int value int value
def test_consume_isolated_leaf(): def test_recover_isolated_leaf():
""" """
>>> test_consume_isolated_leaf() >>> test_recover_isolated_leaf()
0 0
""" """
try: try:
l = consume Leaf() l = recover Leaf()
return 0 return 0
except TypeError as e: except TypeError as e:
print(e) print(e)
return -1 return -1
def test_consume_isolated_named_leaf(): def test_recover_isolated_named_leaf():
""" """
>>> test_consume_isolated_named_leaf() >>> test_recover_isolated_named_leaf()
0 0
""" """
leaf = Leaf() leaf = Leaf()
try: try:
l = consume leaf l = recover leaf
if leaf is not NULL: if leaf is not NULL:
return -1 return -1
return 0 return 0
...@@ -37,45 +37,45 @@ def test_consume_isolated_named_leaf(): ...@@ -37,45 +37,45 @@ def test_consume_isolated_named_leaf():
print(e) print(e)
return -2 return -2
def test_consume_aliased_leaf(): def test_recover_aliased_leaf():
""" """
>>> test_consume_aliased_leaf() >>> test_recover_aliased_leaf()
'consume' operand is not isolated 'recover' operand is not isolated
0 0
""" """
leaf = Leaf() leaf = Leaf()
leaf2 = leaf leaf2 = leaf
try: try:
l = consume leaf l = recover leaf
return -1 return -1
except TypeError as e: except TypeError as e:
print(e) print(e)
return 0 return 0
def test_nogil_consume_isolated_leaf(): def test_nogil_recover_isolated_leaf():
""" """
>>> test_nogil_consume_isolated_leaf() >>> test_nogil_recover_isolated_leaf()
0 0
""" """
try: try:
with nogil: with nogil:
l = consume Leaf() l = recover Leaf()
return 0 return 0
except TypeError as e: except TypeError as e:
print(e) print(e)
return -1 return -1
def test_nogil_consume_aliased_leaf(): def test_nogil_recover_aliased_leaf():
""" """
>>> test_nogil_consume_aliased_leaf() >>> test_nogil_recover_aliased_leaf()
'consume' operand is not isolated 'recover' operand is not isolated
0 0
""" """
leaf = Leaf() leaf = Leaf()
leaf2 = leaf leaf2 = leaf
try: try:
with nogil: with nogil:
l = consume leaf l = recover leaf
return -1 return -1
except TypeError as e: except TypeError as e:
print(e) print(e)
...@@ -86,14 +86,14 @@ cdef cypclass Convertible: ...@@ -86,14 +86,14 @@ cdef cypclass Convertible:
Leaf __Leaf__(self): Leaf __Leaf__(self):
return Leaf() return Leaf()
def test_consume_isolated_cast_named_leaf(): def test_recover_isolated_cast_named_leaf():
""" """
>>> test_consume_isolated_cast_named_leaf() >>> test_recover_isolated_cast_named_leaf()
0 0
""" """
leaf = Leaf() leaf = Leaf()
try: try:
l = consume <Leaf> leaf l = recover <Leaf> leaf
if leaf is not NULL: if leaf is not NULL:
return -1 return -1
return 0 return 0
...@@ -101,13 +101,13 @@ def test_consume_isolated_cast_named_leaf(): ...@@ -101,13 +101,13 @@ def test_consume_isolated_cast_named_leaf():
print(e) print(e)
return -2 return -2
def test_consume_isolated_cast_converted_leaf(): def test_recover_isolated_cast_converted_leaf():
""" """
>>> test_consume_isolated_cast_converted_leaf() >>> test_recover_isolated_cast_converted_leaf()
0 0
""" """
try: try:
l = consume <Leaf> Convertible() l = recover <Leaf> Convertible()
return 0 return 0
except TypeError as e: except TypeError as e:
print(e) print(e)
...@@ -123,41 +123,41 @@ cdef cypclass Origin: ...@@ -123,41 +123,41 @@ cdef cypclass Origin:
__init__(self): __init__(self):
self.field = Field() self.field = Field()
def test_consume_isolated_origin(): def test_recover_isolated_origin():
""" """
>>> test_consume_isolated_origin() >>> test_recover_isolated_origin()
0 0
""" """
try: try:
o = consume Origin() o = recover Origin()
return 0 return 0
except TypeError as e: except TypeError as e:
print(e) print(e)
return -1 return -1
def test_consume_origin_with_aliased_field(): def test_recover_origin_with_aliased_field():
""" """
>>> test_consume_origin_with_aliased_field() >>> test_recover_origin_with_aliased_field()
'consume' operand is not isolated 'recover' operand is not isolated
0 0
""" """
origin = Origin() origin = Origin()
field = origin.field field = origin.field
try: try:
o = consume origin o = recover origin
return -1 return -1
except TypeError as e: except TypeError as e:
print(e) print(e)
return 0 return 0
def test_consume_field(): def test_recover_field():
""" """
>>> test_consume_field() >>> test_recover_field()
0 0
""" """
origin = Origin() origin = Origin()
try: try:
f = consume origin.field f = recover origin.field
if origin.field is not NULL: if origin.field is not NULL:
return -1 return -1
return 0 return 0
...@@ -165,28 +165,28 @@ def test_consume_field(): ...@@ -165,28 +165,28 @@ def test_consume_field():
print(e) print(e)
return -2 return -2
def test_consume_field_from_temporary_origin(): def test_recover_field_from_temporary_origin():
""" """
>>> test_consume_field_from_temporary_origin() >>> test_recover_field_from_temporary_origin()
0 0
""" """
try: try:
f = consume Origin().field f = recover Origin().field
return 0 return 0
except TypeError as e: except TypeError as e:
print(e) print(e)
return -1 return -1
def test_consume_aliased_field(): def test_recover_aliased_field():
""" """
>>> test_consume_aliased_field() >>> test_recover_aliased_field()
'consume' operand is not isolated 'recover' operand is not isolated
0 0
""" """
origin = Origin() origin = Origin()
field = origin.field field = origin.field
try: try:
f = consume origin.field f = recover origin.field
return -1 return -1
except TypeError as e: except TypeError as e:
print(e) print(e)
...@@ -200,41 +200,41 @@ cdef cypclass DoubleOrigin(Origin): ...@@ -200,41 +200,41 @@ cdef cypclass DoubleOrigin(Origin):
self.field2 = self.field = Field() self.field2 = self.field = Field()
def test_consume_isolated_double_origin(): def test_recover_isolated_double_origin():
""" """
>>> test_consume_isolated_double_origin() >>> test_recover_isolated_double_origin()
0 0
""" """
try: try:
o = consume DoubleOrigin() o = recover DoubleOrigin()
return 0 return 0
except TypeError as e: except TypeError as e:
print(e) print(e)
return -1 return -1
def test_consume_double_origin_with_aliased_field(): def test_recover_double_origin_with_aliased_field():
""" """
>>> test_consume_double_origin_with_aliased_field() >>> test_recover_double_origin_with_aliased_field()
'consume' operand is not isolated 'recover' operand is not isolated
0 0
""" """
origin = DoubleOrigin() origin = DoubleOrigin()
field = origin.field field = origin.field
try: try:
o = consume origin o = recover origin
return -1 return -1
except TypeError as e: except TypeError as e:
print(e) print(e)
return 0 return 0
def test_consume_field_from_double_origin(): def test_recover_field_from_double_origin():
""" """
>>> test_consume_field_from_double_origin() >>> test_recover_field_from_double_origin()
'consume' operand is not isolated 'recover' operand is not isolated
0 0
""" """
try: try:
f = consume DoubleOrigin().field f = recover DoubleOrigin().field
return -1 return -1
except TypeError as e: except TypeError as e:
print(e) print(e)
...@@ -247,52 +247,52 @@ cdef cypclass Cycle: ...@@ -247,52 +247,52 @@ cdef cypclass Cycle:
__init__(self): __init__(self):
self.field = self self.field = self
def test_consume_isolated_cycle(): def test_recover_isolated_cycle():
""" """
>>> test_consume_isolated_cycle() >>> test_recover_isolated_cycle()
0 0
""" """
try: try:
c = consume Cycle() c = recover Cycle()
return 0 return 0
except TypeError as e: except TypeError as e:
print(e) print(e)
return -1 return -1
cdef iso Leaf consume_arg(Leaf arg) except NULL: cdef iso Leaf recover_arg(Leaf arg) except NULL:
return consume arg return recover arg
def test_consume_isolated_arg(): def test_recover_isolated_arg():
""" """
>>> test_consume_isolated_arg() >>> test_recover_isolated_arg()
0 0
""" """
try: try:
l = consume_arg(Leaf()) l = recover_arg(Leaf())
return 0 return 0
except TypeError as e: except TypeError as e:
print(e) print(e)
return -1 return -1
def test_consume_aliased_arg(): def test_recover_aliased_arg():
""" """
>>> test_consume_aliased_arg() >>> test_recover_aliased_arg()
'consume' operand is not isolated 'recover' operand is not isolated
0 0
""" """
leaf = Leaf() leaf = Leaf()
try: try:
l = consume_arg(leaf) l = recover_arg(leaf)
return -1 return -1
except TypeError as e: except TypeError as e:
print(e) print(e)
return 0 return 0
def test_consume_isolated_leaf_list(): def test_recover_isolated_leaf_list():
""" """
>>> test_consume_isolated_leaf_list() >>> test_recover_isolated_leaf_list()
0 0
""" """
leaflist = cyplist[Leaf]() leaflist = cyplist[Leaf]()
...@@ -300,16 +300,16 @@ def test_consume_isolated_leaf_list(): ...@@ -300,16 +300,16 @@ def test_consume_isolated_leaf_list():
leaflist.append(Leaf()) leaflist.append(Leaf())
try: try:
l = consume leaflist l = recover leaflist
return 0 return 0
except TypeError as e: except TypeError as e:
print(e) print(e)
return -1 return -1
def test_consume_leaf_list_with_aliased_element(): def test_recover_leaf_list_with_aliased_element():
""" """
>>> test_consume_leaf_list_with_aliased_element() >>> test_recover_leaf_list_with_aliased_element()
'consume' operand is not isolated 'recover' operand is not isolated
0 0
""" """
leaflist = cyplist[Leaf]() leaflist = cyplist[Leaf]()
...@@ -318,16 +318,16 @@ def test_consume_leaf_list_with_aliased_element(): ...@@ -318,16 +318,16 @@ def test_consume_leaf_list_with_aliased_element():
leaf = leaflist[0] leaf = leaflist[0]
try: try:
l = consume leaflist l = recover leaflist
return -1 return -1
except TypeError as e: except TypeError as e:
print(e) print(e)
return 0 return 0
def test_consume_isolated_leaf_set(): def test_recover_isolated_leaf_set():
""" """
>>> test_consume_isolated_leaf_set() >>> test_recover_isolated_leaf_set()
0 0
""" """
leafset = cypset[Leaf]() leafset = cypset[Leaf]()
...@@ -335,16 +335,16 @@ def test_consume_isolated_leaf_set(): ...@@ -335,16 +335,16 @@ def test_consume_isolated_leaf_set():
leafset.add(Leaf()) leafset.add(Leaf())
try: try:
s = consume leafset s = recover leafset
return 0 return 0
except TypeError as e: except TypeError as e:
print(e) print(e)
return -1 return -1
def test_consume_leaf_set_with_aliased_element(): def test_recover_leaf_set_with_aliased_element():
""" """
>>> test_consume_leaf_set_with_aliased_element() >>> test_recover_leaf_set_with_aliased_element()
'consume' operand is not isolated 'recover' operand is not isolated
0 0
""" """
leafset = cypset[Leaf]() leafset = cypset[Leaf]()
...@@ -354,16 +354,16 @@ def test_consume_leaf_set_with_aliased_element(): ...@@ -354,16 +354,16 @@ def test_consume_leaf_set_with_aliased_element():
leafset.add(leaf) leafset.add(leaf)
try: try:
s = consume leafset s = recover leafset
return -1 return -1
except TypeError as e: except TypeError as e:
print(e) print(e)
return 0 return 0
def test_consume_isolated_leaf_dict(): def test_recover_isolated_leaf_dict():
""" """
>>> test_consume_isolated_leaf_set() >>> test_recover_isolated_leaf_set()
0 0
""" """
leafdict = cypdict[Leaf, Leaf]() leafdict = cypdict[Leaf, Leaf]()
...@@ -371,16 +371,16 @@ def test_consume_isolated_leaf_dict(): ...@@ -371,16 +371,16 @@ def test_consume_isolated_leaf_dict():
leafdict[Leaf()] = Leaf() leafdict[Leaf()] = Leaf()
try: try:
d = consume leafdict d = recover leafdict
return 0 return 0
except TypeError as e: except TypeError as e:
print(e) print(e)
return -1 return -1
def test_consume_leaf_dict_with_aliased_key(): def test_recover_leaf_dict_with_aliased_key():
""" """
>>> test_consume_leaf_dict_with_aliased_key() >>> test_recover_leaf_dict_with_aliased_key()
'consume' operand is not isolated 'recover' operand is not isolated
0 0
""" """
leafdict = cypdict[Leaf, Leaf]() leafdict = cypdict[Leaf, Leaf]()
...@@ -390,16 +390,16 @@ def test_consume_leaf_dict_with_aliased_key(): ...@@ -390,16 +390,16 @@ def test_consume_leaf_dict_with_aliased_key():
leafdict[leaf] = Leaf() leafdict[leaf] = Leaf()
try: try:
d = consume leafdict d = recover leafdict
return -1 return -1
except TypeError as e: except TypeError as e:
print(e) print(e)
return 0 return 0
def test_consume_leaf_dict_with_aliased_value(): def test_recover_leaf_dict_with_aliased_value():
""" """
>>> test_consume_leaf_dict_with_aliased_value() >>> test_recover_leaf_dict_with_aliased_value()
'consume' operand is not isolated 'recover' operand is not isolated
0 0
""" """
leafdict = cypdict[Leaf, Leaf]() leafdict = cypdict[Leaf, Leaf]()
...@@ -409,16 +409,16 @@ def test_consume_leaf_dict_with_aliased_value(): ...@@ -409,16 +409,16 @@ def test_consume_leaf_dict_with_aliased_value():
leafdict[Leaf()] = leaf leafdict[Leaf()] = leaf
try: try:
d = consume leafdict d = recover leafdict
return -1 return -1
except TypeError as e: except TypeError as e:
print(e) print(e)
return 0 return 0
def test_consume_isolated_nested_container(): def test_recover_isolated_nested_container():
""" """
>>> test_consume_isolated_nested_container() >>> test_recover_isolated_nested_container()
0 0
""" """
nestedlist = cyplist[cyplist[Leaf]]() nestedlist = cyplist[cyplist[Leaf]]()
...@@ -430,16 +430,16 @@ def test_consume_isolated_nested_container(): ...@@ -430,16 +430,16 @@ def test_consume_isolated_nested_container():
del innerlist del innerlist
try: try:
l = consume nestedlist l = recover nestedlist
return 0 return 0
except TypeError as e: except TypeError as e:
print(e) print(e)
return -1 return -1
def test_consume_nested_container_with_aliased_leaf(): def test_recover_nested_container_with_aliased_leaf():
""" """
>>> test_consume_nested_container_with_aliased_leaf() >>> test_recover_nested_container_with_aliased_leaf()
'consume' operand is not isolated 'recover' operand is not isolated
0 0
""" """
nestedlist = cyplist[cyplist[Leaf]]() nestedlist = cyplist[cyplist[Leaf]]()
...@@ -451,16 +451,16 @@ def test_consume_nested_container_with_aliased_leaf(): ...@@ -451,16 +451,16 @@ def test_consume_nested_container_with_aliased_leaf():
leaf = nestedlist[0][0] leaf = nestedlist[0][0]
try: try:
l = consume nestedlist l = recover nestedlist
return -1 return -1
except TypeError as e: except TypeError as e:
print(e) print(e)
return 0 return 0
def test_consume_nested_container_with_aliased_list(): def test_recover_nested_container_with_aliased_list():
""" """
>>> test_consume_nested_container_with_aliased_list() >>> test_recover_nested_container_with_aliased_list()
'consume' operand is not isolated 'recover' operand is not isolated
0 0
""" """
nestedlist = cyplist[cyplist[Leaf]]() nestedlist = cyplist[cyplist[Leaf]]()
...@@ -472,7 +472,7 @@ def test_consume_nested_container_with_aliased_list(): ...@@ -472,7 +472,7 @@ def test_consume_nested_container_with_aliased_list():
leaflist = nestedlist[0] leaflist = nestedlist[0]
try: try:
l = consume nestedlist l = recover nestedlist
return -1 return -1
except TypeError as e: except TypeError as e:
print(e) print(e)
...@@ -482,25 +482,25 @@ def test_consume_nested_container_with_aliased_list(): ...@@ -482,25 +482,25 @@ def test_consume_nested_container_with_aliased_list():
cdef cypclass Template[T]: cdef cypclass Template[T]:
T field T field
def test_consume_isolated_template(): def test_recover_isolated_template():
""" """
>>> test_consume_isolated_template() >>> test_recover_isolated_template()
0 0
""" """
template = Template[Leaf]() template = Template[Leaf]()
template.field = Leaf() template.field = Leaf()
try: try:
t = consume template t = recover template
return 0 return 0
except TypeError as e: except TypeError as e:
print(e) print(e)
return -1 return -1
def test_consume_template_with_aliased_field(): def test_recover_template_with_aliased_field():
""" """
>>> test_consume_template_with_aliased_field() >>> test_recover_template_with_aliased_field()
'consume' operand is not isolated 'recover' operand is not isolated
0 0
""" """
template = Template[Leaf]() template = Template[Leaf]()
...@@ -508,39 +508,39 @@ def test_consume_template_with_aliased_field(): ...@@ -508,39 +508,39 @@ def test_consume_template_with_aliased_field():
template.field = leaf template.field = leaf
try: try:
t = consume template t = recover template
return -1 return -1
except TypeError as e: except TypeError as e:
print(e) print(e)
return 0 return 0
def test_consume_template_with_aliased_lock_field(): def test_recover_template_with_aliased_lock_field():
""" """
>>> test_consume_template_with_aliased_lock_field() >>> test_recover_template_with_aliased_lock_field()
0 0
""" """
template = <Template[lock Leaf]> new Template[lock Leaf]() template = <Template[lock Leaf]> new Template[lock Leaf]()
leaf = <lock Leaf> consume Leaf() leaf = <lock Leaf> recover Leaf()
template.field = leaf template.field = leaf
try: try:
t = consume template t = recover template
return 0 return 0
except TypeError as e: except TypeError as e:
print(e) print(e)
return -1 return -1
def test_consume_template_with_aliased_active_field(): def test_recover_template_with_aliased_active_field():
""" """
>>> test_consume_template_with_aliased_active_field() >>> test_recover_template_with_aliased_active_field()
0 0
""" """
template = <Template[active Leaf]> new Template[active Leaf]() template = <Template[active Leaf]> new Template[active Leaf]()
leaf = activate(consume Leaf()) leaf = activate(recover Leaf())
template.field = leaf template.field = leaf
try: try:
t = consume template t = recover template
return 0 return 0
except TypeError as e: except TypeError as e:
print(e) print(e)
......
...@@ -8,9 +8,9 @@ cdef cypclass Refcounted: ...@@ -8,9 +8,9 @@ cdef cypclass Refcounted:
print("Refcounted destroyed") print("Refcounted destroyed")
def test_consume_name(): def test_recover_name():
""" """
>>> test_consume_name() >>> test_recover_name()
Refcounted destroyed Refcounted destroyed
0 0
""" """
...@@ -18,7 +18,7 @@ def test_consume_name(): ...@@ -18,7 +18,7 @@ def test_consume_name():
if Cy_GETREF(r0) != 2: if Cy_GETREF(r0) != 2:
return -1 return -1
cdef Refcounted r1 = consume r0 cdef Refcounted r1 = recover r0
if r0 is not NULL: if r0 is not NULL:
return -2 return -2
if Cy_GETREF(r1) != 2: if Cy_GETREF(r1) != 2:
...@@ -26,15 +26,15 @@ def test_consume_name(): ...@@ -26,15 +26,15 @@ def test_consume_name():
return 0 return 0
def test_consume_iso_name(): def test_recover_iso_name():
""" """
>>> test_consume_iso_name() >>> test_recover_iso_name()
Refcounted destroyed Refcounted destroyed
0 0
""" """
cdef iso Refcounted r0 = consume Refcounted() cdef iso Refcounted r0 = recover Refcounted()
cdef Refcounted r1 = consume r0 cdef Refcounted r1 = recover r0
if r0 is not NULL: if r0 is not NULL:
return -2 return -2
if Cy_GETREF(r1) != 2: if Cy_GETREF(r1) != 2:
...@@ -42,58 +42,58 @@ def test_consume_iso_name(): ...@@ -42,58 +42,58 @@ def test_consume_iso_name():
return 0 return 0
def test_consume_and_drop_name(): def test_recover_and_drop_name():
""" """
>>> test_consume_and_drop_name() >>> test_recover_and_drop_name()
Refcounted destroyed Refcounted destroyed
consumed recovered
0 0
""" """
r = Refcounted() r = Refcounted()
if Cy_GETREF(r) != 2: if Cy_GETREF(r) != 2:
return -1 return -1
consume r recover r
print("consumed") print("recovered")
if r is not NULL: if r is not NULL:
return -2 return -2
return 0 return 0
def test_consume_constructed(): def test_recover_constructed():
""" """
>>> test_consume_constructed() >>> test_recover_constructed()
Refcounted destroyed Refcounted destroyed
0 0
""" """
cdef Refcounted r = consume Refcounted() cdef Refcounted r = recover Refcounted()
if Cy_GETREF(r) != 2: if Cy_GETREF(r) != 2:
return -1 return -1
return 0 return 0
def test_consume_iso_constructed(): def test_recover_iso_constructed():
""" """
>>> test_consume_iso_constructed() >>> test_recover_iso_constructed()
Refcounted destroyed Refcounted destroyed
0 0
""" """
cdef Refcounted r = consume new Refcounted() cdef Refcounted r = recover new Refcounted()
if Cy_GETREF(r) != 2: if Cy_GETREF(r) != 2:
return -1 return -1
return 0 return 0
def test_consume_and_drop_constructed(): def test_recover_and_drop_constructed():
""" """
>>> test_consume_and_drop_constructed() >>> test_recover_and_drop_constructed()
Refcounted destroyed Refcounted destroyed
consumed recovered
0 0
""" """
consume Refcounted() recover Refcounted()
print("consumed") print("recovered")
return 0 return 0
...@@ -107,47 +107,47 @@ cdef cypclass OriginIso: ...@@ -107,47 +107,47 @@ cdef cypclass OriginIso:
iso Refcounted field iso Refcounted field
__init__(self): __init__(self):
self.field = consume Refcounted() self.field = recover Refcounted()
def test_consume_field(): def test_recover_field():
""" """
>>> test_consume_field() >>> test_recover_field()
Refcounted destroyed Refcounted destroyed
0 0
""" """
cdef Refcounted r = consume Origin().field cdef Refcounted r = recover Origin().field
if Cy_GETREF(r) != 2: if Cy_GETREF(r) != 2:
return -1 return -1
return 0 return 0
def test_consume_iso_field(): def test_recover_iso_field():
""" """
>>> test_consume_iso_field() >>> test_recover_iso_field()
Refcounted destroyed Refcounted destroyed
0 0
""" """
cdef Refcounted r = consume OriginIso().field cdef Refcounted r = recover OriginIso().field
if Cy_GETREF(r) != 2: if Cy_GETREF(r) != 2:
return -1 return -1
return 0 return 0
def test_consume_and_drop_field(): def test_recover_and_drop_field():
""" """
>>> test_consume_and_drop_field() >>> test_recover_and_drop_field()
Refcounted destroyed Refcounted destroyed
consumed recovered
0 0
""" """
consume Origin().field recover Origin().field
print("consumed") print("recovered")
return 0 return 0
def test_consume_cast_name(): def test_recover_cast_name():
""" """
>>> test_consume_cast_name() >>> test_recover_cast_name()
Refcounted destroyed Refcounted destroyed
0 0
""" """
...@@ -155,7 +155,7 @@ def test_consume_cast_name(): ...@@ -155,7 +155,7 @@ def test_consume_cast_name():
if Cy_GETREF(r0) != 2: if Cy_GETREF(r0) != 2:
return -1 return -1
cdef Refcounted r1 = consume <Refcounted> r0 cdef Refcounted r1 = recover <Refcounted> r0
if r0 is not NULL: if r0 is not NULL:
return -2 return -2
if Cy_GETREF(r1) != 2: if Cy_GETREF(r1) != 2:
...@@ -163,25 +163,25 @@ def test_consume_cast_name(): ...@@ -163,25 +163,25 @@ def test_consume_cast_name():
return 0 return 0
def test_consume_cast_constructed(): def test_recover_cast_constructed():
""" """
>>> test_consume_cast_constructed() >>> test_recover_cast_constructed()
Refcounted destroyed Refcounted destroyed
0 0
""" """
cdef Refcounted r = consume <Refcounted> Refcounted() cdef Refcounted r = recover <Refcounted> Refcounted()
if Cy_GETREF(r) != 2: if Cy_GETREF(r) != 2:
return -1 return -1
return 0 return 0
def test_consume_cast_field(): def test_recover_cast_field():
""" """
>>> test_consume_cast_field() >>> test_recover_cast_field()
Refcounted destroyed Refcounted destroyed
0 0
""" """
cdef Refcounted r = consume <Refcounted> Origin().field cdef Refcounted r = recover <Refcounted> Origin().field
if Cy_GETREF(r) != 2: if Cy_GETREF(r) != 2:
return -1 return -1
...@@ -193,9 +193,9 @@ cdef cypclass Convertible: ...@@ -193,9 +193,9 @@ cdef cypclass Convertible:
__dealloc__(self) with gil: __dealloc__(self) with gil:
print("Convertible destroyed") print("Convertible destroyed")
def test_consume_converted_name(): def test_recover_converted_name():
""" """
>>> test_consume_converted_name() >>> test_recover_converted_name()
Convertible destroyed Convertible destroyed
Refcounted destroyed Refcounted destroyed
0 0
...@@ -204,7 +204,7 @@ def test_consume_converted_name(): ...@@ -204,7 +204,7 @@ def test_consume_converted_name():
if Cy_GETREF(c) != 2: if Cy_GETREF(c) != 2:
return -1 return -1
cdef Refcounted r = consume <Refcounted> c cdef Refcounted r = recover <Refcounted> c
if c is NULL: if c is NULL:
return -2 return -2
if Cy_GETREF(c) != 2: if Cy_GETREF(c) != 2:
...@@ -215,14 +215,14 @@ def test_consume_converted_name(): ...@@ -215,14 +215,14 @@ def test_consume_converted_name():
del c del c
return 0 return 0
def test_consume_converted_constructed(): def test_recover_converted_constructed():
""" """
>>> test_consume_converted_constructed() >>> test_recover_converted_constructed()
Convertible destroyed Convertible destroyed
Refcounted destroyed Refcounted destroyed
0 0
""" """
cdef Refcounted r = consume <Refcounted> Convertible() cdef Refcounted r = recover <Refcounted> Convertible()
if Cy_GETREF(r) != 2: if Cy_GETREF(r) != 2:
return -1 return -1
...@@ -235,9 +235,9 @@ cdef cypclass OriginConvertible: ...@@ -235,9 +235,9 @@ cdef cypclass OriginConvertible:
self.field = Convertible() self.field = Convertible()
def test_consume_converted_field(): def test_recover_converted_field():
""" """
>>> test_consume_converted_field() >>> test_recover_converted_field()
Convertible destroyed Convertible destroyed
Refcounted destroyed Refcounted destroyed
0 0
...@@ -246,7 +246,7 @@ def test_consume_converted_field(): ...@@ -246,7 +246,7 @@ def test_consume_converted_field():
if Cy_GETREF(o.field) != 2: if Cy_GETREF(o.field) != 2:
return -1 return -1
cdef Refcounted r = consume <Refcounted> o.field cdef Refcounted r = recover <Refcounted> o.field
if o.field is NULL: if o.field is NULL:
return -2 return -2
if Cy_GETREF(o.field) != 2: if Cy_GETREF(o.field) != 2:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment