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
Kirill Smelkov
cython
Commits
a19e36ee
Commit
a19e36ee
authored
Aug 07, 2008
by
Dag Sverre Seljebotn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Buffers: Allow repeat count of 1 on single item format strings
parent
acdacfe9
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
2 deletions
+4
-2
Cython/Compiler/Buffer.py
Cython/Compiler/Buffer.py
+2
-0
tests/run/bufaccess.pyx
tests/run/bufaccess.pyx
+2
-2
No files found.
Cython/Compiler/Buffer.py
View file @
a19e36ee
...
@@ -450,6 +450,7 @@ def get_ts_check_item(dtype, writer):
...
@@ -450,6 +450,7 @@ def get_ts_check_item(dtype, writer):
if
char
is
not
None
:
if
char
is
not
None
:
# Can use direct comparison
# Can use direct comparison
code
=
dedent
(
"""
\
code
=
dedent
(
"""
\
if (*ts == '1') ++ts;
if (*ts != '%s') {
if (*ts != '%s') {
PyErr_Format(PyExc_ValueError, "Buffer datatype mismatch (rejecting on '%%s')", ts);
PyErr_Format(PyExc_ValueError, "Buffer datatype mismatch (rejecting on '%%s')", ts);
return NULL;
return NULL;
...
@@ -461,6 +462,7 @@ def get_ts_check_item(dtype, writer):
...
@@ -461,6 +462,7 @@ def get_ts_check_item(dtype, writer):
ctype
=
dtype
.
declaration_code
(
""
)
ctype
=
dtype
.
declaration_code
(
""
)
code
=
dedent
(
"""
\
code
=
dedent
(
"""
\
int ok;
int ok;
if (*ts == '1') ++ts;
switch (*ts) {"""
,
2
)
switch (*ts) {"""
,
2
)
if
dtype
.
is_int
:
if
dtype
.
is_int
:
types
=
[
types
=
[
...
...
tests/run/bufaccess.pyx
View file @
a19e36ee
...
@@ -944,14 +944,14 @@ cdef class ShortMockBuffer(MockBuffer):
...
@@ -944,14 +944,14 @@ cdef class ShortMockBuffer(MockBuffer):
(
<
short
*>
buf
)[
0
]
=
<
short
>
value
(
<
short
*>
buf
)[
0
]
=
<
short
>
value
return
0
return
0
cdef
get_itemsize
(
self
):
return
sizeof
(
short
)
cdef
get_itemsize
(
self
):
return
sizeof
(
short
)
cdef
get_default_format
(
self
):
return
"
=h"
cdef
get_default_format
(
self
):
return
"
h"
# Try without endian specifier
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
return
0
return
0
cdef
get_itemsize
(
self
):
return
sizeof
(
unsigned
short
)
cdef
get_itemsize
(
self
):
return
sizeof
(
unsigned
short
)
cdef
get_default_format
(
self
):
return
"=
H"
cdef
get_default_format
(
self
):
return
"=
1H"
# Try with repeat count
cdef
extern
from
*
:
cdef
extern
from
*
:
void
*
addr_of_pyobject
"(void*)"
(
object
)
void
*
addr_of_pyobject
"(void*)"
(
object
)
...
...
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