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
Gwenaël Samain
cython
Commits
8a133cf5
Commit
8a133cf5
authored
Aug 04, 2012
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
reduce code duplication for DECREF code generation
parent
8c04e6f9
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
26 deletions
+25
-26
Cython/Compiler/Code.py
Cython/Compiler/Code.py
+25
-26
No files found.
Cython/Compiler/Code.py
View file @
8a133cf5
...
...
@@ -1613,10 +1613,7 @@ class CCodeWriter(object):
self
.
putln
(
"Py_INCREF(%s);"
%
self
.
as_pyobject
(
cname
,
type
))
def
put_decref
(
self
,
cname
,
type
,
nanny
=
True
):
if
nanny
:
self
.
putln
(
"__Pyx_DECREF(%s);"
%
self
.
as_pyobject
(
cname
,
type
))
else
:
self
.
putln
(
"Py_DECREF(%s);"
%
self
.
as_pyobject
(
cname
,
type
))
self
.
_put_decref
(
cname
,
type
,
nanny
,
null_check
=
False
,
clear
=
False
)
def
put_var_gotref
(
self
,
entry
):
if
entry
.
type
.
is_pyobject
:
...
...
@@ -1638,36 +1635,38 @@ class CCodeWriter(object):
if
entry
.
type
.
is_pyobject
:
self
.
putln
(
"__Pyx_INCREF(%s);"
%
self
.
entry_as_pyobject
(
entry
))
def
put_decref_clear
(
self
,
cname
,
type
,
nanny
=
True
):
from
PyrexTypes
import
py_object_type
,
typecast
if
nanny
:
self
.
putln
(
"__Pyx_DECREF(%s); %s = 0;"
%
(
typecast
(
py_object_type
,
type
,
cname
),
cname
))
else
:
self
.
putln
(
"Py_DECREF(%s); %s = 0;"
%
(
typecast
(
py_object_type
,
type
,
cname
),
cname
))
def
put_decref_clear
(
self
,
cname
,
type
,
nanny
=
True
,
clear_before_decref
=
False
):
self
.
_put_decref
(
cname
,
type
,
nanny
,
null_check
=
False
,
clear
=
True
,
clear_before_decref
=
clear_before_decref
)
def
put_xdecref
(
self
,
cname
,
type
,
nanny
=
True
,
have_gil
=
True
):
if
type
.
is_memoryviewslice
:
self
.
put_xdecref_memoryviewslice
(
cname
,
have_gil
=
have_gil
)
return
self
.
_put_decref
(
cname
,
type
,
nanny
,
null_check
=
True
,
have_gil
=
have_gil
,
clear
=
False
)
if
nanny
:
self
.
putln
(
"__Pyx_XDECREF(%s);"
%
self
.
as_pyobject
(
cname
,
type
))
else
:
self
.
putln
(
"Py_XDECREF(%s);"
%
self
.
as_pyobject
(
cname
,
type
))
def
put_xdecref_clear
(
self
,
cname
,
type
,
nanny
=
True
,
clear_before_decref
=
False
):
self
.
_put_decref
(
cname
,
type
,
nanny
,
null_check
=
True
,
clear
=
True
,
clear_before_decref
=
clear_before_decref
)
def
put_xdecref_clear
(
self
,
cname
,
type
,
nanny
=
True
):
def
_put_decref
(
self
,
cname
,
type
,
nanny
=
True
,
null_check
=
False
,
have_gil
=
True
,
clear
=
False
,
clear_before_decref
=
False
):
if
type
.
is_memoryviewslice
:
self
.
put_xdecref_memoryviewslice
(
cname
)
self
.
put_xdecref_memoryviewslice
(
cname
,
have_gil
=
have_gil
)
return
if
nanny
:
self
.
putln
(
"__Pyx_XDECREF(%s); %s = 0;"
%
(
self
.
as_pyobject
(
cname
,
type
),
cname
))
prefix
=
nanny
and
'__Pyx'
or
'Py'
X
=
null_check
and
'X'
or
''
if
clear
:
if
clear_before_decref
:
if
not
nanny
:
X
=
''
# CPython doesn't have a Py_XCLEAR()
self
.
putln
(
"%s_%sCLEAR(%s);"
%
(
prefix
,
X
,
cname
))
else
:
self
.
putln
(
"%s_%sDECREF(%s); %s = 0;"
%
(
prefix
,
X
,
self
.
as_pyobject
(
cname
,
type
),
cname
))
else
:
self
.
putln
(
"
Py_XDECREF(%s); %s = 0
;"
%
(
self
.
as_pyobject
(
cname
,
type
),
cname
))
self
.
putln
(
"
%s_%sDECREF(%s)
;"
%
(
prefix
,
X
,
self
.
as_pyobject
(
cname
,
type
)
))
def
put_var_decref
(
self
,
entry
):
if
entry
.
type
.
is_pyobject
:
...
...
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