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
1f6e8650
Commit
1f6e8650
authored
Oct 15, 2009
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow explicit casts between object and void*/struct*.
parent
51d1bd1c
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
3 deletions
+8
-3
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+8
-3
No files found.
Cython/Compiler/ExprNodes.py
View file @
1f6e8650
...
@@ -4187,14 +4187,19 @@ class TypecastNode(ExprNode):
...
@@ -4187,14 +4187,19 @@ class TypecastNode(ExprNode):
self
.
result_ctype
=
py_object_type
self
.
result_ctype
=
py_object_type
self
.
operand
=
self
.
operand
.
coerce_to_pyobject
(
env
)
self
.
operand
=
self
.
operand
.
coerce_to_pyobject
(
env
)
else
:
else
:
if
not
(
self
.
operand
.
type
.
is_ptr
and
self
.
operand
.
type
.
base_type
.
is_void
):
if
self
.
operand
.
type
.
is_ptr
:
if
not
(
self
.
operand
.
type
.
base_type
.
is_void
or
self
.
operand
.
type
.
base_type
.
is_struct
):
error
(
self
.
pos
,
"Python objects cannot be cast from pointers of primitive types"
)
else
:
# Should this be an error?
warning
(
self
.
pos
,
"No conversion from %s to %s, python object pointer used."
%
(
self
.
operand
.
type
,
self
.
type
))
warning
(
self
.
pos
,
"No conversion from %s to %s, python object pointer used."
%
(
self
.
operand
.
type
,
self
.
type
))
self
.
operand
=
self
.
operand
.
coerce_to_simple
(
env
)
self
.
operand
=
self
.
operand
.
coerce_to_simple
(
env
)
elif
from_py
and
not
to_py
:
elif
from_py
and
not
to_py
:
if
self
.
type
.
create_from_py_utility_code
(
env
):
if
self
.
type
.
create_from_py_utility_code
(
env
):
self
.
operand
=
self
.
operand
.
coerce_to
(
self
.
type
,
env
)
self
.
operand
=
self
.
operand
.
coerce_to
(
self
.
type
,
env
)
elif
self
.
type
.
is_ptr
and
not
(
self
.
type
.
base_type
.
is_void
or
self
.
type
.
base_type
.
is_struct
):
elif
self
.
type
.
is_ptr
:
error
(
self
.
pos
,
"Python objects cannot be casted to pointers of primitive types"
)
if
not
(
self
.
type
.
base_type
.
is_void
or
self
.
type
.
base_type
.
is_struct
):
error
(
self
.
pos
,
"Python objects cannot be cast to pointers of primitive types"
)
else
:
else
:
warning
(
self
.
pos
,
"No conversion from %s to %s, python object pointer used."
%
(
self
.
type
,
self
.
operand
.
type
))
warning
(
self
.
pos
,
"No conversion from %s to %s, python object pointer used."
%
(
self
.
type
,
self
.
operand
.
type
))
elif
from_py
and
to_py
:
elif
from_py
and
to_py
:
...
...
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