Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Xavier Thompson
cython
Commits
38323671
Commit
38323671
authored
Jan 20, 2021
by
Xavier Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename 'consume' as 'recover'
parent
608c29a9
Changes
11
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
228 additions
and
228 deletions
+228
-228
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+6
-6
Cython/Compiler/Nodes.py
Cython/Compiler/Nodes.py
+3
-3
Cython/Compiler/Parsing.py
Cython/Compiler/Parsing.py
+5
-5
Cython/Compiler/Symtab.py
Cython/Compiler/Symtab.py
+2
-2
tests/errors/cypclass_active_errors.pyx
tests/errors/cypclass_active_errors.pyx
+8
-8
tests/errors/cypclass_iso_errors.pyx
tests/errors/cypclass_iso_errors.pyx
+11
-11
tests/errors/cypclass_lock_errors.pyx
tests/errors/cypclass_lock_errors.pyx
+7
-7
tests/run/cypclass_acthon.pyx
tests/run/cypclass_acthon.pyx
+4
-4
tests/run/cypclass_pyobject_conversion.pyx
tests/run/cypclass_pyobject_conversion.pyx
+15
-15
tests/run/cypclass_recover.pyx
tests/run/cypclass_recover.pyx
+114
-114
tests/run/cypclass_recover_refcount.pyx
tests/run/cypclass_recover_refcount.pyx
+53
-53
No files found.
Cython/Compiler/ExprNodes.py
View file @
38323671
...
...
@@ -11369,8 +11369,8 @@ class SizeofVarNode(SizeofNode):
pass
class
Consume
Node
(
ExprNode
):
#
Consume
expression
class
Recover
Node
(
ExprNode
):
#
Recover
expression
#
# operand ExprNode
#
...
...
@@ -11396,7 +11396,7 @@ class ConsumeNode(ExprNode):
self
.
operand
=
self
.
operand
.
analyse_types
(
env
)
operand_type
=
self
.
operand
.
type
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
return
self
if
operand_type
.
is_qualified_cyp_class
:
...
...
@@ -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
.
solid_operand
=
solid_operand
if
self
.
operand_is_named
:
solid_operand
.
entry
.
is_
consum
ed
=
True
solid_operand
.
entry
.
is_
recover
ed
=
True
return
self
def
may_be_none
(
self
):
...
...
@@ -11429,7 +11429,7 @@ class ConsumeNode(ExprNode):
return
self
.
operand
.
is_simple
()
def
make_owned_reference
(
self
,
code
):
# We steal the reference of the
consum
ed operand.
# We steal the reference of the
recover
ed operand.
pass
def
calculate_result_code
(
self
):
...
...
@@ -11451,7 +11451,7 @@ class ConsumeNode(ExprNode):
code
.
putln
(
"#ifdef WITH_THREAD"
)
code
.
putln
(
"PyGILState_STATE _save = PyGILState_Ensure();"
)
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
:
code
.
putln
(
"#ifdef WITH_THREAD"
)
code
.
putln
(
"PyGILState_Release(_save);"
)
...
...
Cython/Compiler/Nodes.py
View file @
38323671
...
...
@@ -2199,7 +2199,7 @@ class FuncDefNode(StatNode, BlockNode):
if
entry
.
type
.
is_cyp_class
:
# CyObjects use another refcounting convention.
# Except for the 'self' argument.
if
entry
.
is_self_arg
and
(
entry
.
is_
consum
ed
or
entry
.
cf_is_reassigned
)
and
not
entry
.
in_closure
:
if
entry
.
is_self_arg
and
(
entry
.
is_
recover
ed
or
entry
.
cf_is_reassigned
)
and
not
entry
.
in_closure
:
code
.
put_var_incref
(
entry
)
elif
(
acquire_gil
or
entry
.
cf_is_reassigned
)
and
not
entry
.
in_closure
:
code
.
put_var_incref
(
entry
)
...
...
@@ -2419,8 +2419,8 @@ class FuncDefNode(StatNode, BlockNode):
continue
elif
entry
.
type
.
is_cyp_class
:
# CyObject arguments are systematically decrefed.
# Except for the 'self' argument when it has not been reassigned or
consum
ed.
if
entry
.
is_self_arg
and
not
(
entry
.
is_
consum
ed
or
entry
.
cf_is_reassigned
):
# Except for the 'self' argument when it has not been reassigned or
recover
ed.
if
entry
.
is_self_arg
and
not
(
entry
.
is_
recover
ed
or
entry
.
cf_is_reassigned
):
continue
else
:
if
entry
.
in_closure
:
...
...
Cython/Compiler/Parsing.py
View file @
38323671
...
...
@@ -309,8 +309,8 @@ def _p_factor(s):
return
p_typecast
(
s
)
elif
sy
==
'IDENT'
and
s
.
systring
==
"sizeof"
:
return
p_sizeof
(
s
)
elif
sy
==
'IDENT'
and
s
.
systring
==
"
consume
"
:
return
p_
consume
(
s
)
elif
sy
==
'IDENT'
and
s
.
systring
==
"
recover
"
:
return
p_
recover
(
s
)
return
p_power
(
s
)
def
p_typecast
(
s
):
...
...
@@ -360,12 +360,12 @@ def p_sizeof(s):
s
.
expect
(
')'
)
return
node
def
p_
consume
(
s
):
# s.sy == ident "
consume
"
def
p_
recover
(
s
):
# s.sy == ident "
recover
"
pos
=
s
.
position
()
s
.
next
()
operand
=
p_factor
(
s
)
return
ExprNodes
.
Consume
Node
(
pos
,
operand
=
operand
)
return
ExprNodes
.
Recover
Node
(
pos
,
operand
=
operand
)
def
p_yield_expression
(
s
):
...
...
Cython/Compiler/Symtab.py
View file @
38323671
...
...
@@ -181,7 +181,7 @@ class Entry(object):
#
# 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.
...
...
@@ -262,7 +262,7 @@ class Entry(object):
static_cname
=
None
original_name
=
None
active_entry
=
None
is_
consum
ed
=
False
is_
recover
ed
=
False
is_specialised
=
False
def
__init__
(
self
,
name
,
cname
,
type
,
pos
=
None
,
init
=
None
):
...
...
tests/errors/cypclass_active_errors.pyx
View file @
38323671
...
...
@@ -34,21 +34,21 @@ def test_aliasing():
active_b
=
A
()
cdef
active
A
active_c
active_c
=
consume
A
()
active_c
=
recover
A
()
cdef
active
A
active_d
active_d
=
<
lock
A
>
consume
A
()
active_d
=
<
lock
A
>
recover
A
()
def
test_calling
():
a
=
activate
(
consume
A
())
a
=
activate
(
recover
A
())
a
.
f
(
NULL
,
A
())
a
.
f
(
NULL
,
consume
A
())
a
.
f
(
NULL
,
recover
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
a
.
f_lock
(
NULL
,
lock_a
)
...
...
@@ -62,7 +62,7 @@ def test_typecast():
# Casting from active
cdef
iso
A
iso_a
iso_a
=
consume
<
iso
A
>
active_a
iso_a
=
recover
<
iso
A
>
active_a
cdef
lock
A
lock_a
lock_a
=
<
lock
A
>
active_a
...
...
@@ -75,10 +75,10 @@ def test_typecast():
active_b
=
<
active
A
>
A
()
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
active_d
=
<
active
A
>
<
lock
A
>
consume
A
()
active_d
=
<
active
A
>
<
lock
A
>
recover
A
()
_ERRORS
=
u'''
...
...
tests/errors/cypclass_iso_errors.pyx
View file @
38323671
...
...
@@ -7,7 +7,7 @@ cdef cypclass A activable:
def
test_name_aliasing
():
cdef
iso
A
iso_a
iso_a
=
consume
A
()
iso_a
=
recover
A
()
# Aliasing to iso
cdef
iso
A
iso_b
...
...
@@ -17,7 +17,7 @@ def test_name_aliasing():
iso_c
=
A
()
cdef
iso
A
iso_d
iso_d
=
activate
(
consume
A
())
iso_d
=
activate
(
recover
A
())
cdef
iso
A
iso_e
iso_e
=
<
object
>
A
()
...
...
@@ -50,11 +50,11 @@ cdef cypclass Origin:
return
other
def
test_field_aliasing
():
cdef
iso
Origin
o
=
consume
Origin
()
cdef
iso
Origin
o
=
recover
Origin
()
cdef
object
py_field
# OK - can pass
consum
ed arguments
o
.
bar
(
consume
Field
()).
foo
(
consume
Field
())
# OK - can pass
recover
ed arguments
o
.
bar
(
recover
Field
()).
foo
(
recover
Field
())
# ERR - aliasing field of iso to pyobject
py_field
=
o
.
field
...
...
@@ -66,25 +66,25 @@ def test_field_aliasing():
field
=
o
.
field
# ERR - consuming field of iso
field2
=
consume
o
.
field
field2
=
recover
o
.
field
# ERR - non_
consum
ed argument
# ERR - non_
recover
ed argument
o
.
bar
(
Field
())
# ERR - aliasing the returned reference
c
=
o
.
bar
(
consume
Field
())
c
=
o
.
bar
(
recover
Field
())
def
test_typecast
():
cdef
iso
A
iso_a
iso_a
=
consume
A
()
iso_a
=
recover
A
()
# Casting to iso
cdef
iso
A
iso_b
iso_b
=
<
iso
A
>
A
()
cdef
iso
A
iso_c
iso_c
=
<
iso
A
>
activate
(
consume
A
())
iso_c
=
<
iso
A
>
activate
(
recover
A
())
cdef
iso
A
iso_d
iso_d
=
<
iso
A
>
<
object
>
A
()
...
...
@@ -103,7 +103,7 @@ def test_typecast():
iso_e
=
<
iso
A
>
iso_a
cdef
iso
A
iso_f
iso_f
=
consume
<
iso
A
>
iso_a
iso_f
=
recover
<
iso
A
>
iso_a
_ERRORS
=
u'''
...
...
tests/errors/cypclass_lock_errors.pyx
View file @
38323671
...
...
@@ -40,10 +40,10 @@ def test_aliasing():
lock_b
=
A
()
cdef
lock
A
lock_c
lock_c
=
consume
A
()
lock_c
=
recover
A
()
cdef
lock
A
lock_d
lock_d
=
<
lock
A
>
consume
A
()
lock_d
=
<
lock
A
>
recover
A
()
cdef
lock
A
lock_e
cdef
locked
A
locked_b
...
...
@@ -55,12 +55,12 @@ def test_calling():
a
.
f
(
A
())
a
.
f
(
consume
A
())
a
.
f
(
recover
A
())
a
.
f_locked_self
()
cdef
iso
A
iso_a
a
.
f_iso
(
consume
iso_a
)
a
.
f_iso
(
recover
iso_a
)
cdef
lock
A
lock_a
a
.
f_lock
(
lock_a
)
...
...
@@ -74,7 +74,7 @@ def test_typecast():
# Casting from lock
cdef
iso
A
iso_a
iso_a
=
consume
<
iso
A
>
lock_a
iso_a
=
recover
<
iso
A
>
lock_a
cdef
active
A
active_a
active_a
=
<
active
A
>
lock_a
...
...
@@ -90,10 +90,10 @@ def test_typecast():
lock_b
=
<
lock
A
>
A
()
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
lock_d
=
<
lock
A
>
activate
(
consume
A
())
lock_d
=
<
lock
A
>
activate
(
recover
A
())
cdef
lock
A
lock_e
cdef
locked
A
locked_b
...
...
tests/run/cypclass_acthon.pyx
View file @
38323671
...
...
@@ -134,7 +134,7 @@ cdef cypclass A activable:
__init__
(
self
):
self
.
a
=
0
self
.
_active_result_class
=
WaitResult
.
construct
self
.
_active_queue_class
=
consume
BasicQueue
()
self
.
_active_queue_class
=
recover
BasicQueue
()
int
getter
(
const
self
):
return
self
.
a
void
setter
(
self
,
int
a
):
...
...
@@ -147,12 +147,12 @@ def test_acthon_chain(n):
"""
cdef
ActhonResultInterface
res
cdef
lock
ActhonQueueInterface
queue
sync1
=
<
lock
ActivityCounterSync
>
consume
ActivityCounterSync
()
after_sync1
=
<
lock
ActivityCounterSync
>
consume
ActivityCounterSync
(
sync1
)
sync1
=
<
lock
ActivityCounterSync
>
recover
ActivityCounterSync
()
after_sync1
=
<
lock
ActivityCounterSync
>
recover
ActivityCounterSync
(
sync1
)
obj
=
A
()
queue
=
obj
.
_active_queue_class
obj_actor
=
activate
(
consume
obj
)
obj_actor
=
activate
(
recover
obj
)
# Pushing things in the queue
obj_actor
.
setter
(
sync1
,
n
)
...
...
tests/run/cypclass_pyobject_conversion.pyx
View file @
38323671
...
...
@@ -139,16 +139,16 @@ cdef object cyobject_to_pyobject(Refcounted r):
cdef
Refcounted
pyobject_to_cyobject
(
object
o
):
return
o
cdef
void
consume
_cyobject
(
Refcounted
r
):
cdef
void
recover
_cyobject
(
Refcounted
r
):
pass
def
consume
_wrapped_cyobject
(
Refcounted
r
):
def
recover
_wrapped_cyobject
(
Refcounted
r
):
pass
def
wrapped_cyobject_to_pyobject
(
Refcounted
r
):
return
r
def
consume
_wrapped_cyobject_with_generic_args
(
Refcounted
r
,
**
kwargs
):
def
recover
_wrapped_cyobject_with_generic_args
(
Refcounted
r
,
**
kwargs
):
pass
def
wrapped_cyobject_to_pyobject_with_generic_args
(
Refcounted
r
,
dummy
=
2
,
unused
=
"unused"
):
...
...
@@ -169,39 +169,39 @@ def test_recfcount_round_trip_conversions():
return
Cy_GETREF
(
r
)
def
test_recfcount_
consume
_cyobject
():
def
test_recfcount_
recover
_cyobject
():
"""
>>> test_recfcount_
consume
_cyobject()
>>> test_recfcount_
recover
_cyobject()
2
"""
cdef
Refcounted
r
=
Refcounted
()
for
i
in
range
(
10
):
consume
_cyobject
(
r
)
recover
_cyobject
(
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
"""
cdef
Refcounted
r
=
Refcounted
()
for
i
in
range
(
10
):
consume
_cyobject
(
<
object
>
r
)
recover
_cyobject
(
<
object
>
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
"""
cdef
Refcounted
r
=
Refcounted
()
for
i
in
range
(
10
):
consume
_wrapped_cyobject
(
r
)
recover
_wrapped_cyobject
(
r
)
return
Cy_GETREF
(
r
)
...
...
@@ -217,15 +217,15 @@ def test_recfcount_convert_wrapped_cyobject():
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
"""
cdef
Refcounted
r
=
Refcounted
()
for
i
in
range
(
10
):
consume
_wrapped_cyobject_with_generic_args
(
r
)
recover
_wrapped_cyobject_with_generic_args
(
r
)
return
Cy_GETREF
(
r
)
...
...
tests/run/cypclass_
consume
.pyx
→
tests/run/cypclass_
recover
.pyx
View file @
38323671
This diff is collapsed.
Click to expand it.
tests/run/cypclass_
consume
_refcount.pyx
→
tests/run/cypclass_
recover
_refcount.pyx
View file @
38323671
...
...
@@ -8,9 +8,9 @@ cdef cypclass Refcounted:
print
(
"Refcounted destroyed"
)
def
test_
consume
_name
():
def
test_
recover
_name
():
"""
>>> test_
consume
_name()
>>> test_
recover
_name()
Refcounted destroyed
0
"""
...
...
@@ -18,7 +18,7 @@ def test_consume_name():
if
Cy_GETREF
(
r0
)
!=
2
:
return
-
1
cdef
Refcounted
r1
=
consume
r0
cdef
Refcounted
r1
=
recover
r0
if
r0
is
not
NULL
:
return
-
2
if
Cy_GETREF
(
r1
)
!=
2
:
...
...
@@ -26,15 +26,15 @@ def test_consume_name():
return
0
def
test_
consume
_iso_name
():
def
test_
recover
_iso_name
():
"""
>>> test_
consume
_iso_name()
>>> test_
recover
_iso_name()
Refcounted destroyed
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
:
return
-
2
if
Cy_GETREF
(
r1
)
!=
2
:
...
...
@@ -42,58 +42,58 @@ def test_consume_iso_name():
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
consum
ed
recover
ed
0
"""
r
=
Refcounted
()
if
Cy_GETREF
(
r
)
!=
2
:
return
-
1
consume
r
print
(
"
consum
ed"
)
recover
r
print
(
"
recover
ed"
)
if
r
is
not
NULL
:
return
-
2
return
0
def
test_
consume
_constructed
():
def
test_
recover
_constructed
():
"""
>>> test_
consume
_constructed()
>>> test_
recover
_constructed()
Refcounted destroyed
0
"""
cdef
Refcounted
r
=
consume
Refcounted
()
cdef
Refcounted
r
=
recover
Refcounted
()
if
Cy_GETREF
(
r
)
!=
2
:
return
-
1
return
0
def
test_
consume
_iso_constructed
():
def
test_
recover
_iso_constructed
():
"""
>>> test_
consume
_iso_constructed()
>>> test_
recover
_iso_constructed()
Refcounted destroyed
0
"""
cdef
Refcounted
r
=
consume
new
Refcounted
()
cdef
Refcounted
r
=
recover
new
Refcounted
()
if
Cy_GETREF
(
r
)
!=
2
:
return
-
1
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
consum
ed
recover
ed
0
"""
consume
Refcounted
()
print
(
"
consum
ed"
)
recover
Refcounted
()
print
(
"
recover
ed"
)
return
0
...
...
@@ -107,47 +107,47 @@ cdef cypclass OriginIso:
iso
Refcounted
field
__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
0
"""
cdef
Refcounted
r
=
consume
Origin
().
field
cdef
Refcounted
r
=
recover
Origin
().
field
if
Cy_GETREF
(
r
)
!=
2
:
return
-
1
return
0
def
test_
consume
_iso_field
():
def
test_
recover
_iso_field
():
"""
>>> test_
consume
_iso_field()
>>> test_
recover
_iso_field()
Refcounted destroyed
0
"""
cdef
Refcounted
r
=
consume
OriginIso
().
field
cdef
Refcounted
r
=
recover
OriginIso
().
field
if
Cy_GETREF
(
r
)
!=
2
:
return
-
1
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
consum
ed
recover
ed
0
"""
consume
Origin
().
field
print
(
"
consum
ed"
)
recover
Origin
().
field
print
(
"
recover
ed"
)
return
0
def
test_
consume
_cast_name
():
def
test_
recover
_cast_name
():
"""
>>> test_
consume
_cast_name()
>>> test_
recover
_cast_name()
Refcounted destroyed
0
"""
...
...
@@ -155,7 +155,7 @@ def test_consume_cast_name():
if
Cy_GETREF
(
r0
)
!=
2
:
return
-
1
cdef
Refcounted
r1
=
consume
<
Refcounted
>
r0
cdef
Refcounted
r1
=
recover
<
Refcounted
>
r0
if
r0
is
not
NULL
:
return
-
2
if
Cy_GETREF
(
r1
)
!=
2
:
...
...
@@ -163,25 +163,25 @@ def test_consume_cast_name():
return
0
def
test_
consume
_cast_constructed
():
def
test_
recover
_cast_constructed
():
"""
>>> test_
consume
_cast_constructed()
>>> test_
recover
_cast_constructed()
Refcounted destroyed
0
"""
cdef
Refcounted
r
=
consume
<
Refcounted
>
Refcounted
()
cdef
Refcounted
r
=
recover
<
Refcounted
>
Refcounted
()
if
Cy_GETREF
(
r
)
!=
2
:
return
-
1
return
0
def
test_
consume
_cast_field
():
def
test_
recover
_cast_field
():
"""
>>> test_
consume
_cast_field()
>>> test_
recover
_cast_field()
Refcounted destroyed
0
"""
cdef
Refcounted
r
=
consume
<
Refcounted
>
Origin
().
field
cdef
Refcounted
r
=
recover
<
Refcounted
>
Origin
().
field
if
Cy_GETREF
(
r
)
!=
2
:
return
-
1
...
...
@@ -193,9 +193,9 @@ cdef cypclass Convertible:
__dealloc__
(
self
)
with
gil
:
print
(
"Convertible destroyed"
)
def
test_
consume
_converted_name
():
def
test_
recover
_converted_name
():
"""
>>> test_
consume
_converted_name()
>>> test_
recover
_converted_name()
Convertible destroyed
Refcounted destroyed
0
...
...
@@ -204,7 +204,7 @@ def test_consume_converted_name():
if
Cy_GETREF
(
c
)
!=
2
:
return
-
1
cdef
Refcounted
r
=
consume
<
Refcounted
>
c
cdef
Refcounted
r
=
recover
<
Refcounted
>
c
if
c
is
NULL
:
return
-
2
if
Cy_GETREF
(
c
)
!=
2
:
...
...
@@ -215,14 +215,14 @@ def test_consume_converted_name():
del
c
return
0
def
test_
consume
_converted_constructed
():
def
test_
recover
_converted_constructed
():
"""
>>> test_
consume
_converted_constructed()
>>> test_
recover
_converted_constructed()
Convertible destroyed
Refcounted destroyed
0
"""
cdef
Refcounted
r
=
consume
<
Refcounted
>
Convertible
()
cdef
Refcounted
r
=
recover
<
Refcounted
>
Convertible
()
if
Cy_GETREF
(
r
)
!=
2
:
return
-
1
...
...
@@ -235,9 +235,9 @@ cdef cypclass OriginConvertible:
self
.
field
=
Convertible
()
def
test_
consume
_converted_field
():
def
test_
recover
_converted_field
():
"""
>>> test_
consume
_converted_field()
>>> test_
recover
_converted_field()
Convertible destroyed
Refcounted destroyed
0
...
...
@@ -246,7 +246,7 @@ def test_consume_converted_field():
if
Cy_GETREF
(
o
.
field
)
!=
2
:
return
-
1
cdef
Refcounted
r
=
consume
<
Refcounted
>
o
.
field
cdef
Refcounted
r
=
recover
<
Refcounted
>
o
.
field
if
o
.
field
is
NULL
:
return
-
2
if
Cy_GETREF
(
o
.
field
)
!=
2
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment