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
bd587ae5
Commit
bd587ae5
authored
Mar 10, 2010
by
Lisandro Dalcin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
casting to typedef pointer/array types (ticket #518)
parent
f9d5e812
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
2 deletions
+23
-2
Cython/Compiler/PyrexTypes.py
Cython/Compiler/PyrexTypes.py
+3
-2
tests/compile/cast_ctypedef_array_T518.pyx
tests/compile/cast_ctypedef_array_T518.pyx
+15
-0
tests/compile/cast_ctypedef_array_T518_helper.h
tests/compile/cast_ctypedef_array_T518_helper.h
+5
-0
No files found.
Cython/Compiler/PyrexTypes.py
View file @
bd587ae5
...
@@ -228,8 +228,9 @@ class CTypedefType(BaseType):
...
@@ -228,8 +228,9 @@ class CTypedefType(BaseType):
def
cast_code
(
self
,
expr_code
):
def
cast_code
(
self
,
expr_code
):
# If self is really an array (rather than pointer), we can't cast.
# If self is really an array (rather than pointer), we can't cast.
# For example, the gmp mpz_t.
# For example, the gmp mpz_t.
if
self
.
typedef_base_type
.
is_ptr
:
if
self
.
typedef_base_type
.
is_array
:
return
self
.
typedef_base_type
.
cast_code
(
expr_code
)
base_type
=
self
.
typedef_base_type
.
base_type
return
CPtrType
(
base_type
).
cast_code
(
expr_code
)
else
:
else
:
return
BaseType
.
cast_code
(
self
,
expr_code
)
return
BaseType
.
cast_code
(
self
,
expr_code
)
...
...
tests/compile/cast_ctypedef_array_T518.pyx
0 → 100644
View file @
bd587ae5
cdef
extern
from
"cast_ctypedef_array_T518_helper.h"
:
cdef
struct
__foo_struct
:
int
i
,
j
ctypedef
__foo_struct
foo_t
[
1
]
void
foo_init
(
foo_t
)
void
foo_clear
(
foo_t
)
cdef
foo_t
value
foo_init
(
value
)
foo_clear
(
value
)
cdef
void
*
pointer
=
<
void
*>
value
foo_init
(
<
foo_t
>
pointer
)
foo_clear
(
<
foo_t
>
pointer
)
tests/compile/cast_ctypedef_array_T518_helper.h
0 → 100644
View file @
bd587ae5
struct
__foo_struct
{
int
i
,
j
;
};
typedef
struct
__foo_struct
foo_t
[
1
];
static
void
foo_init
(
foo_t
v
)
{
v
[
0
].
i
=
0
;
v
[
0
].
j
=
0
;
}
static
void
foo_clear
(
foo_t
v
)
{
v
[
0
].
i
=
0
;
v
[
0
].
j
=
0
;
}
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