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
021488a5
Commit
021488a5
authored
Sep 10, 2009
by
Lisandro Dalcin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
extern ctypedef integral <-> python object conversion (ticket #333)
parent
e02c1b0b
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
845 additions
and
46 deletions
+845
-46
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+2
-3
Cython/Compiler/Nodes.py
Cython/Compiler/Nodes.py
+3
-2
Cython/Compiler/PyrexTypes.py
Cython/Compiler/PyrexTypes.py
+141
-41
tests/run/ctypedef_int_types_T333.pyx
tests/run/ctypedef_int_types_T333.pyx
+674
-0
tests/run/ctypedef_int_types_chdr_T333.h
tests/run/ctypedef_int_types_chdr_T333.h
+10
-0
tests/run/ctypedef_int_types_defs_T333.pxd
tests/run/ctypedef_int_types_defs_T333.pxd
+15
-0
No files found.
Cython/Compiler/ExprNodes.py
View file @
021488a5
...
...
@@ -3933,8 +3933,7 @@ class TypecastNode(NewTempExprNode):
if
from_py
and
not
to_py
and
self
.
operand
.
is_ephemeral
()
and
not
self
.
type
.
is_numeric
:
error
(
self
.
pos
,
"Casting temporary Python object to non-numeric non-Python type"
)
if
to_py
and
not
from_py
:
if
(
self
.
operand
.
type
.
to_py_function
and
self
.
operand
.
type
.
create_to_py_utility_code
(
env
)):
if
self
.
operand
.
type
.
create_to_py_utility_code
(
env
):
self
.
result_ctype
=
py_object_type
self
.
operand
=
self
.
operand
.
coerce_to_pyobject
(
env
)
else
:
...
...
@@ -3942,7 +3941,7 @@ class TypecastNode(NewTempExprNode):
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
)
elif
from_py
and
not
to_py
:
if
self
.
type
.
from_py_function
:
if
self
.
type
.
create_from_py_utility_code
(
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
):
error
(
self
.
pos
,
"Python objects cannot be casted to pointers of primitive types"
)
...
...
Cython/Compiler/Nodes.py
View file @
021488a5
...
...
@@ -1964,8 +1964,9 @@ class DefNode(FuncDefNode):
or
self
.
starstar_arg
is
not
None
or
has_kwonly_args
for
arg
in
self
.
args
:
if
not
arg
.
type
.
is_pyobject
and
arg
.
type
.
from_py_function
is
None
:
arg
.
type
.
create_from_py_utility_code
(
env
)
if
not
arg
.
type
.
is_pyobject
:
done
=
arg
.
type
.
create_from_py_utility_code
(
env
)
if
not
done
:
pass
# will fail later
if
not
self
.
signature_has_generic_args
():
if
has_star_or_kw_args
:
...
...
Cython/Compiler/PyrexTypes.py
View file @
021488a5
This diff is collapsed.
Click to expand it.
tests/run/ctypedef_int_types_T333.pyx
0 → 100644
View file @
021488a5
This diff is collapsed.
Click to expand it.
tests/run/ctypedef_int_types_chdr_T333.h
0 → 100644
View file @
021488a5
typedef
signed
char
SChar
;
typedef
unsigned
char
UChar
;
typedef
signed
short
SShort
;
typedef
unsigned
short
UShort
;
typedef
signed
int
SInt
;
typedef
unsigned
int
UInt
;
typedef
signed
long
SLong
;
typedef
unsigned
long
ULong
;
typedef
signed
long
long
SLongLong
;
typedef
unsigned
long
long
ULongLong
;
tests/run/ctypedef_int_types_defs_T333.pxd
0 → 100644
View file @
021488a5
cdef
extern
from
"ctypedef_int_types_chdr_T333.h"
:
ctypedef
int
SChar
## "signed char"
ctypedef
int
UChar
## "unsigned char"
ctypedef
int
SShort
## "signed short"
ctypedef
int
UShort
## "unsigned short"
ctypedef
int
SInt
## "signed int"
ctypedef
int
UInt
## "unsigned int"
ctypedef
int
SLong
## "signed long"
ctypedef
int
ULong
## "unsigned long"
ctypedef
int
SLongLong
## "signed PY_LONG_LONG"
ctypedef
int
ULongLong
## "unsigned PY_LONG_LONG"
cdef
extern
from
*
:
ctypedef
int
ExtSInt
"signed short"
ctypedef
int
ExtUInt
"unsigned short"
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