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
Boxiang Sun
cython
Commits
eb3e1da1
Commit
eb3e1da1
authored
Aug 04, 2008
by
Dag Sverre Seljebotn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed some typedef bugs with buffers
parent
5658d1f1
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
92 additions
and
0 deletions
+92
-0
Cython/Compiler/PyrexTypes.py
Cython/Compiler/PyrexTypes.py
+2
-0
tests/errors/e_bufaccess2.pyx
tests/errors/e_bufaccess2.pyx
+10
-0
tests/errors/e_bufaccess_pxd.pxd
tests/errors/e_bufaccess_pxd.pxd
+3
-0
tests/run/bufaccess.pyx
tests/run/bufaccess.pyx
+77
-0
No files found.
Cython/Compiler/PyrexTypes.py
View file @
eb3e1da1
...
@@ -149,6 +149,7 @@ class CTypedefType(BaseType):
...
@@ -149,6 +149,7 @@ class CTypedefType(BaseType):
# typedef_base_type PyrexType
# typedef_base_type PyrexType
is_typedef
=
1
is_typedef
=
1
typestring
=
None
# Because typedefs are not known exactly
def
__init__
(
self
,
cname
,
base_type
):
def
__init__
(
self
,
cname
,
base_type
):
self
.
typedef_cname
=
cname
self
.
typedef_cname
=
cname
...
@@ -1043,6 +1044,7 @@ class ErrorType(PyrexType):
...
@@ -1043,6 +1044,7 @@ class ErrorType(PyrexType):
exception_check
=
0
exception_check
=
0
to_py_function
=
"dummy"
to_py_function
=
"dummy"
from_py_function
=
"dummy"
from_py_function
=
"dummy"
typestring
=
None
def
declaration_code
(
self
,
entity_code
,
def
declaration_code
(
self
,
entity_code
,
for_display
=
0
,
dll_linkage
=
None
,
pyrex
=
0
):
for_display
=
0
,
dll_linkage
=
None
,
pyrex
=
0
):
...
...
tests/errors/e_bufaccess2.pyx
0 → 100644
View file @
eb3e1da1
cimport
e_bufaccess_pxd
# was needed to provoke a bug involving ErrorType
def
f
():
cdef
object
[
e_bufaccess_pxd
.
T
]
buf
_ERRORS
=
u"""
3:17: Syntax error in ctypedef statement
4:31: 'T' is not a type identifier
4:31: 'T' is not declared
"""
tests/errors/e_bufaccess_pxd.pxd
0 → 100644
View file @
eb3e1da1
# See e_bufaccess2.pyx
ctypedef
nothing
T
tests/run/bufaccess.pyx
View file @
eb3e1da1
...
@@ -576,6 +576,76 @@ def printbuf_float(o, shape):
...
@@ -576,6 +576,76 @@ def printbuf_float(o, shape):
print
print
#
# Typedefs
#
ctypedef
int
cytypedef_int
cdef
extern
from
"bufaccess.h"
:
ctypedef
cytypedef_int
htypedef_short
# Defined as short, but Cython doesn't know this!
ctypedef
htypedef_short
cytypedef2
@
testcase
def
printbuf_cytypedef_int
(
object
[
cytypedef_int
]
buf
,
shape
):
"""
>>> printbuf_cytypedef_int(IntMockBuffer("A", range(3)), (3,))
acquired A
0 1 2
released A
>>> printbuf_cytypedef_int(ShortMockBuffer("B", range(3)), (3,))
Traceback (most recent call last):
...
ValueError: Buffer datatype mismatch (rejecting on 'h')
"""
cdef
int
i
for
i
in
range
(
shape
[
0
]):
print
buf
[
i
],
print
@
testcase
def
printbuf_htypedef_short
(
object
[
htypedef_short
]
buf
,
shape
):
"""
>>> printbuf_htypedef_short(ShortMockBuffer("A", range(3)), (3,))
acquired A
0 1 2
released A
>>> printbuf_htypedef_short(IntMockBuffer("B", range(3)), (3,))
Traceback (most recent call last):
...
ValueError: Buffer datatype mismatch (rejecting on 'i')
"""
cdef
int
i
for
i
in
range
(
shape
[
0
]):
print
buf
[
i
],
print
@
testcase
def
printbuf_cytypedef2
(
object
[
cytypedef2
]
buf
,
shape
):
"""
>>> printbuf_cytypedef2(ShortMockBuffer("A", range(3)), (3,))
acquired A
0 1 2
released A
>>> printbuf_cytypedef2(IntMockBuffer("B", range(3)), (3,))
Traceback (most recent call last):
...
ValueError: Buffer datatype mismatch (rejecting on 'i')
"""
cdef
int
i
for
i
in
range
(
shape
[
0
]):
print
buf
[
i
],
print
#
# Testcase support code
#
available_flags
=
(
available_flags
=
(
(
'FORMAT'
,
python_buffer
.
PyBUF_FORMAT
),
(
'FORMAT'
,
python_buffer
.
PyBUF_FORMAT
),
(
'INDIRECT'
,
python_buffer
.
PyBUF_INDIRECT
),
(
'INDIRECT'
,
python_buffer
.
PyBUF_INDIRECT
),
...
@@ -736,6 +806,13 @@ cdef class IntMockBuffer(MockBuffer):
...
@@ -736,6 +806,13 @@ cdef class IntMockBuffer(MockBuffer):
cdef
get_itemsize
(
self
):
return
sizeof
(
int
)
cdef
get_itemsize
(
self
):
return
sizeof
(
int
)
cdef
get_default_format
(
self
):
return
"=i"
cdef
get_default_format
(
self
):
return
"=i"
cdef
class
ShortMockBuffer
(
MockBuffer
):
cdef
int
write
(
self
,
char
*
buf
,
object
value
)
except
-
1
:
(
<
short
*>
buf
)[
0
]
=
<
short
>
value
return
0
cdef
get_itemsize
(
self
):
return
sizeof
(
short
)
cdef
get_default_format
(
self
):
return
"=h"
cdef
class
UnsignedShortMockBuffer
(
MockBuffer
):
cdef
class
UnsignedShortMockBuffer
(
MockBuffer
):
cdef
int
write
(
self
,
char
*
buf
,
object
value
)
except
-
1
:
cdef
int
write
(
self
,
char
*
buf
,
object
value
)
except
-
1
:
(
<
unsigned
short
*>
buf
)[
0
]
=
<
unsigned
short
>
value
(
<
unsigned
short
*>
buf
)[
0
]
=
<
unsigned
short
>
value
...
...
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