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
478b939a
Commit
478b939a
authored
Dec 16, 2012
by
Mark Florisson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cast extension types in memoryviews for C++ code
parent
0f6eb255
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
2 deletions
+12
-2
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+12
-2
No files found.
Cython/Compiler/ExprNodes.py
View file @
478b939a
...
...
@@ -274,6 +274,13 @@ class ExprNode(Node):
def
result_as
(
self
,
type
=
None
):
# Return the result code cast to the specified C type.
if
(
self
.
is_temp
and
self
.
type
.
is_pyobject
and
type
!=
py_object_type
):
# Allocated temporaries are always PyObject *, which may not
# reflect the actual type (e.g. an extension type)
return
typecast
(
type
,
py_object_type
,
self
.
result
())
return
typecast
(
type
,
self
.
ctype
(),
self
.
result
())
return
typecast
(
type
,
self
.
ctype
(),
self
.
result
())
def
py_result
(
self
):
...
...
@@ -3080,8 +3087,11 @@ class IndexNode(ExprNode):
buffer_entry
,
self
.
buffer_ptr_code
=
self
.
buffer_lookup_code
(
code
)
if
self
.
type
.
is_pyobject
:
# is_temp is True, so must pull out value and incref it.
code
.
putln
(
"%s = *%s;"
%
(
self
.
result
(),
self
.
buffer_ptr_code
))
code
.
putln
(
"__Pyx_INCREF((PyObject*)%s);"
%
self
.
result
())
# NOTE: object temporary results for nodes are declared
# as PyObject *, so we need a cast
code
.
putln
(
"%s = (PyObject *) *%s;"
%
(
self
.
temp_code
,
self
.
buffer_ptr_code
))
code
.
putln
(
"__Pyx_INCREF((PyObject*)%s);"
%
self
.
temp_code
)
elif
self
.
memslice_slice
:
self
.
put_memoryviewslice_slice_code
(
code
)
...
...
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