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
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
cython
Commits
778f29a7
Commit
778f29a7
authored
Jan 12, 2009
by
Dag Sverre Seljebotn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refnanny: Added missing casts.
parent
77a40c90
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
52 additions
and
36 deletions
+52
-36
Cython/Compiler/Code.py
Cython/Compiler/Code.py
+15
-3
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+27
-27
Cython/Compiler/Nodes.py
Cython/Compiler/Nodes.py
+5
-5
Cython/Compiler/PyrexTypes.py
Cython/Compiler/PyrexTypes.py
+5
-1
No files found.
Cython/Compiler/Code.py
View file @
778f29a7
...
...
@@ -729,8 +729,8 @@ class CCodeWriter(object):
def
entry_as_pyobject
(
self
,
entry
):
type
=
entry
.
type
if
(
not
entry
.
is_self_arg
and
not
entry
.
type
.
is_complete
()
)
\
or
(
entry
.
type
.
is_extension_type
and
entry
.
type
.
base
_type
):
if
(
not
entry
.
is_self_arg
and
not
entry
.
type
.
is_complete
()
or
entry
.
type
.
is_extension
_type
):
return
"(PyObject *)"
+
entry
.
cname
else
:
return
entry
.
cname
...
...
@@ -752,7 +752,19 @@ class CCodeWriter(object):
def
put_decref
(
self
,
cname
,
type
):
self
.
putln
(
"__Pyx_DECREF(%s);"
%
self
.
as_pyobject
(
cname
,
type
))
def
put_var_gotref
(
self
,
entry
):
if
entry
.
type
.
is_pyobject
:
self
.
putln
(
"__Pyx_GOTREF(%s);"
%
self
.
entry_as_pyobject
(
entry
))
def
put_var_giveref
(
self
,
entry
):
if
entry
.
type
.
is_pyobject
:
self
.
putln
(
"__Pyx_GIVEREF(%s);"
%
self
.
entry_as_pyobject
(
entry
))
def
put_var_xgiveref
(
self
,
entry
):
if
entry
.
type
.
is_pyobject
:
self
.
putln
(
"__Pyx_XGIVEREF(%s);"
%
self
.
entry_as_pyobject
(
entry
))
def
put_var_incref
(
self
,
entry
):
if
entry
.
type
.
is_pyobject
:
self
.
putln
(
"__Pyx_INCREF(%s);"
%
self
.
entry_as_pyobject
(
entry
))
...
...
Cython/Compiler/ExprNodes.py
View file @
778f29a7
...
...
@@ -1017,7 +1017,7 @@ class LongNode(AtomicNewTempExprNode):
self
.
result
(),
self
.
value
,
code
.
error_goto_if_null
(
self
.
result
(),
self
.
pos
)))
code
.
put_gotref
(
self
.
result
())
code
.
put_gotref
(
self
.
py_
result
())
class
ImagNode
(
AtomicNewTempExprNode
):
...
...
@@ -1044,7 +1044,7 @@ class ImagNode(AtomicNewTempExprNode):
self
.
result
(),
self
.
value
,
code
.
error_goto_if_null
(
self
.
result
(),
self
.
pos
)))
code
.
put_gotref
(
self
.
result
())
code
.
put_gotref
(
self
.
py_
result
())
...
...
@@ -1266,7 +1266,7 @@ class NameNode(AtomicExprNode):
namespace
,
self
.
interned_cname
,
code
.
error_goto_if_null
(
self
.
result
(),
self
.
pos
)))
code
.
put_gotref
(
self
.
result
())
code
.
put_gotref
(
self
.
py_
result
())
elif
entry
.
is_local
and
False
:
# control flow not good enough yet
...
...
@@ -1413,7 +1413,7 @@ class BackquoteNode(ExprNode):
self
.
result
(),
self
.
arg
.
py_result
(),
code
.
error_goto_if_null
(
self
.
result
(),
self
.
pos
)))
code
.
put_gotref
(
self
.
result
())
code
.
put_gotref
(
self
.
py_
result
())
...
...
@@ -1451,7 +1451,7 @@ class ImportNode(ExprNode):
self
.
module_name
.
py_result
(),
name_list_code
,
code
.
error_goto_if_null
(
self
.
result
(),
self
.
pos
)))
code
.
put_gotref
(
self
.
result
())
code
.
put_gotref
(
self
.
py_
result
())
class
IteratorNode
(
NewTempExprNode
):
...
...
@@ -1510,7 +1510,7 @@ class IteratorNode(NewTempExprNode):
self
.
result
(),
self
.
sequence
.
py_result
(),
code
.
error_goto_if_null
(
self
.
result
(),
self
.
pos
)))
code
.
put_gotref
(
self
.
result
())
code
.
put_gotref
(
self
.
py_
result
())
code
.
putln
(
"}"
)
...
...
@@ -1569,7 +1569,7 @@ class NextNode(AtomicNewTempExprNode):
code
.
putln
(
code
.
error_goto_if_PyErr
(
self
.
pos
))
code
.
putln
(
"break;"
)
code
.
putln
(
"}"
)
code
.
put_gotref
(
self
.
result
())
code
.
put_gotref
(
self
.
py_
result
())
code
.
putln
(
"}"
)
...
...
@@ -1831,7 +1831,7 @@ class IndexNode(ExprNode):
self
.
index_unsigned_parameter
(),
self
.
result
(),
code
.
error_goto
(
self
.
pos
)))
code
.
put_gotref
(
self
.
result
())
code
.
put_gotref
(
self
.
py_
result
())
def
generate_setitem_code
(
self
,
value_code
,
code
):
if
self
.
index
.
type
.
is_int
:
...
...
@@ -2007,7 +2007,7 @@ class SliceIndexNode(ExprNode):
self
.
start_code
(),
self
.
stop_code
(),
code
.
error_goto_if_null
(
self
.
result
(),
self
.
pos
)))
code
.
put_gotref
(
self
.
result
())
code
.
put_gotref
(
self
.
py_
result
())
def
generate_assignment_code
(
self
,
rhs
,
code
):
self
.
generate_subexpr_evaluation_code
(
code
)
...
...
@@ -2172,7 +2172,7 @@ class SliceNode(ExprNode):
self
.
stop
.
py_result
(),
self
.
step
.
py_result
(),
code
.
error_goto_if_null
(
self
.
result
(),
self
.
pos
)))
code
.
put_gotref
(
self
.
result
())
code
.
put_gotref
(
self
.
py_
result
())
class
CallNode
(
NewTempExprNode
):
...
...
@@ -2393,7 +2393,7 @@ class SimpleCallNode(CallNode):
self
.
function
.
py_result
(),
arg_code
,
code
.
error_goto_if_null
(
self
.
result
(),
self
.
pos
)))
code
.
put_gotref
(
self
.
result
())
code
.
put_gotref
(
self
.
py_
result
())
elif
func_type
.
is_cfunction
:
if
self
.
has_optional_args
:
actual_nargs
=
len
(
self
.
args
)
...
...
@@ -2449,7 +2449,7 @@ class SimpleCallNode(CallNode):
goto_error
=
""
code
.
putln
(
"%s%s; %s"
%
(
lhs
,
rhs
,
goto_error
))
if
self
.
type
.
is_pyobject
and
self
.
result
():
code
.
put_gotref
(
self
.
result
())
code
.
put_gotref
(
self
.
py_
result
())
class
GeneralCallNode
(
CallNode
):
...
...
@@ -2526,7 +2526,7 @@ class GeneralCallNode(CallNode):
self
.
result
(),
call_code
,
code
.
error_goto_if_null
(
self
.
result
(),
self
.
pos
)))
code
.
put_gotref
(
self
.
result
())
code
.
put_gotref
(
self
.
py_
result
())
class
AsTupleNode
(
ExprNode
):
...
...
@@ -2562,7 +2562,7 @@ class AsTupleNode(ExprNode):
self
.
result
(),
self
.
arg
.
py_result
(),
code
.
error_goto_if_null
(
self
.
result
(),
self
.
pos
)))
code
.
put_gotref
(
self
.
result
())
code
.
put_gotref
(
self
.
py_
result
())
class
AttributeNode
(
ExprNode
):
...
...
@@ -2832,7 +2832,7 @@ class AttributeNode(ExprNode):
self
.
obj
.
py_result
(),
self
.
interned_attr_cname
,
code
.
error_goto_if_null
(
self
.
result
(),
self
.
pos
)))
code
.
put_gotref
(
self
.
result
())
code
.
put_gotref
(
self
.
py_
result
())
else
:
# result_code contains what is needed, but we may need to insert
# a check and raise an exception
...
...
@@ -3002,7 +3002,7 @@ class SequenceNode(NewTempExprNode):
self
.
iterator
.
result
(),
rhs
.
py_result
(),
code
.
error_goto_if_null
(
self
.
iterator
.
result
(),
self
.
pos
)))
code
.
put_gotref
(
self
.
iterator
.
result
())
code
.
put_gotref
(
self
.
iterator
.
py_
result
())
rhs
.
generate_disposal_code
(
code
)
for
i
in
range
(
len
(
self
.
args
)):
item
=
self
.
unpacked_items
[
i
]
...
...
@@ -3013,7 +3013,7 @@ class SequenceNode(NewTempExprNode):
item
.
result
(),
typecast
(
item
.
ctype
(),
py_object_type
,
unpack_code
),
code
.
error_goto_if_null
(
item
.
result
(),
self
.
pos
)))
code
.
put_gotref
(
item
.
result
())
code
.
put_gotref
(
item
.
py_
result
())
value_node
=
self
.
coerced_unpacked_items
[
i
]
value_node
.
generate_evaluation_code
(
code
)
code
.
put_error_if_neg
(
self
.
pos
,
...
...
@@ -3080,7 +3080,7 @@ class TupleNode(SequenceNode):
self
.
result
(),
len
(
self
.
args
),
code
.
error_goto_if_null
(
self
.
result
(),
self
.
pos
)))
code
.
put_gotref
(
self
.
result
())
code
.
put_gotref
(
self
.
py_
result
())
for
i
in
range
(
len
(
self
.
args
)):
arg
=
self
.
args
[
i
]
if
not
arg
.
result_in_temp
():
...
...
@@ -3176,7 +3176,7 @@ class ListNode(SequenceNode):
(
self
.
result
(),
len
(
self
.
args
),
code
.
error_goto_if_null
(
self
.
result
(),
self
.
pos
)))
code
.
put_gotref
(
self
.
result
())
code
.
put_gotref
(
self
.
py_
result
())
for
i
in
range
(
len
(
self
.
args
)):
arg
=
self
.
args
[
i
]
#if not arg.is_temp:
...
...
@@ -3425,7 +3425,7 @@ class DictNode(ExprNode):
"%s = PyDict_New(); %s"
%
(
self
.
result
(),
code
.
error_goto_if_null
(
self
.
result
(),
self
.
pos
)))
code
.
put_gotref
(
self
.
result
())
code
.
put_gotref
(
self
.
py_
result
())
for
item
in
self
.
key_value_pairs
:
item
.
generate_evaluation_code
(
code
)
if
self
.
type
.
is_pyobject
:
...
...
@@ -3521,7 +3521,7 @@ class ClassNode(ExprNode):
self
.
cname
,
self
.
module_name
,
code
.
error_goto_if_null
(
self
.
result
(),
self
.
pos
)))
code
.
put_gotref
(
self
.
result
())
code
.
put_gotref
(
self
.
py_
result
())
class
UnboundMethodNode
(
ExprNode
):
...
...
@@ -3549,7 +3549,7 @@ class UnboundMethodNode(ExprNode):
self
.
function
.
py_result
(),
self
.
class_cname
,
code
.
error_goto_if_null
(
self
.
result
(),
self
.
pos
)))
code
.
put_gotref
(
self
.
result
())
code
.
put_gotref
(
self
.
py_
result
())
class
PyCFunctionNode
(
AtomicNewTempExprNode
):
# Helper class used in the implementation of Python
...
...
@@ -3571,7 +3571,7 @@ class PyCFunctionNode(AtomicNewTempExprNode):
self
.
result
(),
self
.
pymethdef_cname
,
code
.
error_goto_if_null
(
self
.
result
(),
self
.
pos
)))
code
.
put_gotref
(
self
.
result
())
code
.
put_gotref
(
self
.
py_
result
())
#-------------------------------------------------------------------
#
...
...
@@ -3650,7 +3650,7 @@ class UnopNode(ExprNode):
function
,
self
.
operand
.
py_result
(),
code
.
error_goto_if_null
(
self
.
result
(),
self
.
pos
)))
code
.
put_gotref
(
self
.
result
())
code
.
put_gotref
(
self
.
py_
result
())
def
type_error
(
self
):
if
not
self
.
operand
.
type
.
is_error
:
...
...
@@ -4057,7 +4057,7 @@ class BinopNode(NewTempExprNode):
self
.
operand2
.
py_result
(),
extra_args
,
code
.
error_goto_if_null
(
self
.
result
(),
self
.
pos
)))
code
.
put_gotref
(
self
.
result
())
code
.
put_gotref
(
self
.
py_
result
())
else
:
if
self
.
is_temp
:
self
.
generate_c_operation_code
(
code
)
...
...
@@ -4957,7 +4957,7 @@ class CoerceToPyTypeNode(CoercionNode):
function
,
self
.
arg
.
result
(),
code
.
error_goto_if_null
(
self
.
result
(),
self
.
pos
)))
code
.
put_gotref
(
self
.
result
())
code
.
put_gotref
(
self
.
py_
result
())
class
CoerceFromPyTypeNode
(
CoercionNode
):
...
...
@@ -4990,7 +4990,7 @@ class CoerceFromPyTypeNode(CoercionNode):
rhs
,
code
.
error_goto_if
(
self
.
type
.
error_condition
(
self
.
result
()),
self
.
pos
)))
if
self
.
type
.
is_pyobject
:
code
.
put_gotref
(
self
.
result
())
code
.
put_gotref
(
self
.
py_
result
())
class
CoerceToBooleanNode
(
CoercionNode
):
...
...
Cython/Compiler/Nodes.py
View file @
778f29a7
...
...
@@ -1143,7 +1143,7 @@ class FuncDefNode(StatNode, BlockNode):
if
err_val
is
None
and
default_retval
:
err_val
=
default_retval
if
self
.
return_type
.
is_pyobject
:
code
.
put_xgiveref
(
Naming
.
retval_cname
)
code
.
put_xgiveref
(
self
.
return_type
.
as_pyobject
(
Naming
.
retval_cname
)
)
if
err_val
is
None
:
code
.
putln
(
'__Pyx_FinishRefcountContext();'
)
else
:
...
...
@@ -2287,7 +2287,7 @@ class DefNode(FuncDefNode):
func
,
arg
.
hdr_cname
,
code
.
error_goto_if_null
(
arg
.
entry
.
cname
,
arg
.
pos
)))
code
.
put_
gotref
(
arg
.
entry
.
cname
)
code
.
put_
var_gotref
(
arg
.
entry
)
else
:
error
(
arg
.
pos
,
"Cannot convert argument of type '%s' to Python object"
...
...
@@ -2367,7 +2367,7 @@ class OverrideCheckNode(StatNode):
else
:
code
.
putln
(
"else if (unlikely(Py_TYPE(%s)->tp_dictoffset != 0)) {"
%
self_arg
)
err
=
code
.
error_goto_if_null
(
self
.
func_node
.
result
(),
self
.
pos
)
code
.
put_gotref
(
self
.
func_node
.
result
())
code
.
put_gotref
(
self
.
func_node
.
py_
result
())
# need to get attribute manually--scope would return cdef method
code
.
putln
(
"%s = PyObject_GetAttr(%s, %s); %s"
%
(
self
.
func_node
.
result
(),
self_arg
,
self
.
py_func
.
interned_attr_cname
,
err
))
# It appears that this type is not anywhere exposed in the Python/C API
...
...
@@ -3068,7 +3068,7 @@ class InPlaceAssignmentNode(AssignmentNode):
self
.
rhs
.
py_result
(),
extra
,
code
.
error_goto_if_null
(
self
.
result_value
.
py_result
(),
self
.
pos
)))
code
.
put_gotref
(
self
.
result_value
.
result
())
code
.
put_gotref
(
self
.
result_value
.
py_
result
())
self
.
result_value
.
generate_evaluation_code
(
code
)
# May be a type check...
self
.
rhs
.
generate_disposal_code
(
code
)
self
.
rhs
.
free_temps
(
code
)
...
...
@@ -4580,7 +4580,7 @@ class FromImportStatNode(StatNode):
self
.
module
.
py_result
(),
cname
,
code
.
error_goto_if_null
(
self
.
item
.
result
(),
self
.
pos
)))
code
.
put_gotref
(
self
.
item
.
result
())
code
.
put_gotref
(
self
.
item
.
py_
result
())
target
.
generate_assignment_code
(
self
.
item
,
code
)
self
.
module
.
generate_disposal_code
(
code
)
self
.
module
.
free_temps
(
code
)
...
...
Cython/Compiler/PyrexTypes.py
View file @
778f29a7
...
...
@@ -20,7 +20,6 @@ class BaseType(object):
else
:
return
base_code
class
PyrexType
(
BaseType
):
#
# Base class for all Pyrex types.
...
...
@@ -257,6 +256,11 @@ class PyObjectType(PyrexType):
else
:
return
"%s *%s"
%
(
public_decl
(
"PyObject"
,
dll_linkage
),
entity_code
)
def
as_pyobject
(
self
,
cname
):
if
(
not
self
.
is_complete
())
or
self
.
is_extension_type
:
return
"(PyObject *)"
+
cname
else
:
return
cname
class
BuiltinObjectType
(
PyObjectType
):
...
...
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