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
f8e18013
Commit
f8e18013
authored
Jul 25, 2008
by
Dag Sverre Seljebotn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added test case and fixed bug with unsigned indexing
parent
0a86ec8f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
3 deletions
+17
-3
Cython/Compiler/Buffer.py
Cython/Compiler/Buffer.py
+1
-1
tests/run/bufaccess.pyx
tests/run/bufaccess.pyx
+16
-2
No files found.
Cython/Compiler/Buffer.py
View file @
f8e18013
...
...
@@ -128,7 +128,7 @@ def put_access(entry, index_types, index_cnames, tmp_cname, pos, code):
code
.
unlikely
(
"%s < 0"
%
cname
),
tmp_cname
,
idx
))
code
.
put
(
"} else "
)
else
:
if
idx
>
0
:
code
.
put
(
"
}
else "
)
if
idx
>
0
:
code
.
put
(
"else "
)
if
boundscheck
:
# check bounds in positive direction
code
.
putln
(
"if (%s) %s = %d;"
%
(
...
...
tests/run/bufaccess.pyx
View file @
f8e18013
...
...
@@ -91,7 +91,15 @@ Out-of-bounds errors:
...
IndexError: Out of bounds on buffer access (axis 1)
Unsigned indexing:
>>> get_int_2d_uintindex(C, 0, 0)
acquired C
released C
0
>>> get_int_2d_uintindex(C, 1, 2)
acquired C
released C
5
"""
...
...
@@ -154,7 +162,13 @@ def printbuf_int_2d(o, shape):
def
get_int_2d
(
object
[
int
,
2
]
buf
,
int
i
,
int
j
):
return
buf
[
i
,
j
]
def
get_int_2d_uintindex
(
object
[
int
,
2
]
buf
,
unsigned
int
i
,
unsigned
int
j
):
# This is most interesting with regards to the C code
# generated.
return
buf
[
i
,
j
]
cdef
class
MockBuffer
:
cdef
object
format
cdef
char
*
buffer
...
...
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