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
38e618fc
Commit
38e618fc
authored
Jun 28, 2015
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
clean up some old buffer indexing code
parent
f9efd59d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
14 deletions
+14
-14
Cython/Compiler/Buffer.py
Cython/Compiler/Buffer.py
+14
-14
No files found.
Cython/Compiler/Buffer.py
View file @
38e618fc
...
@@ -415,6 +415,7 @@ def put_assign_to_buffer(lhs_cname, rhs_cname, buf_entry,
...
@@ -415,6 +415,7 @@ def put_assign_to_buffer(lhs_cname, rhs_cname, buf_entry,
code
.
putln
(
"}"
)
# Release stack
code
.
putln
(
"}"
)
# Release stack
def
put_buffer_lookup_code
(
entry
,
index_signeds
,
index_cnames
,
directives
,
def
put_buffer_lookup_code
(
entry
,
index_signeds
,
index_cnames
,
directives
,
pos
,
code
,
negative_indices
,
in_nogil_context
):
pos
,
code
,
negative_indices
,
in_nogil_context
):
"""
"""
...
@@ -435,21 +436,21 @@ def put_buffer_lookup_code(entry, index_signeds, index_cnames, directives,
...
@@ -435,21 +436,21 @@ def put_buffer_lookup_code(entry, index_signeds, index_cnames, directives,
if
directives
[
'boundscheck'
]:
if
directives
[
'boundscheck'
]:
# Check bounds and fix negative indices.
# Check bounds and fix negative indices.
# We allocate a temporary which is initialized to -1, meaning OK (!).
# We allocate a temporary which is initialized to -1, meaning OK (!).
# If an error occurs, the temp is set to the dimension index the
# If an error occurs, the temp is set to the index dimension the
# error is occuring at.
# error is occurring at.
tmp_cname
=
code
.
funcstate
.
allocate_temp
(
PyrexTypes
.
c_int_type
,
manage_ref
=
False
)
failed_dim_temp
=
code
.
funcstate
.
allocate_temp
(
PyrexTypes
.
c_int_type
,
manage_ref
=
False
)
code
.
putln
(
"%s = -1;"
%
tmp_cname
)
code
.
putln
(
"%s = -1;"
%
failed_dim_temp
)
for
dim
,
(
signed
,
cname
,
shape
)
in
enumerate
(
zip
(
index_signeds
,
index_cnames
,
for
dim
,
(
signed
,
cname
,
shape
)
in
enumerate
(
zip
(
index_signeds
,
index_cnames
,
entry
.
get_buf_shapevars
())):
entry
.
get_buf_shapevars
())):
if
signed
!=
0
:
if
signed
!=
0
:
# not unsigned, deal with negative index
# not unsigned, deal with negative index
code
.
putln
(
"if (%s < 0) {"
%
cname
)
code
.
putln
(
"if (%s < 0) {"
%
cname
)
if
negative_indices
:
if
negative_indices
:
code
.
putln
(
"%s += %s;"
%
(
cname
,
shape
))
code
.
putln
(
"%s += %s;"
%
(
cname
,
shape
))
code
.
putln
(
"if (%s) %s = %d;"
%
(
code
.
putln
(
"if (%s) %s = %d;"
%
(
code
.
unlikely
(
"%s < 0"
%
cname
),
tmp_cname
,
dim
))
code
.
unlikely
(
"%s < 0"
%
cname
),
failed_dim_temp
,
dim
))
else
:
else
:
code
.
putln
(
"%s = %d;"
%
(
tmp_cname
,
dim
))
code
.
putln
(
"%s = %d;"
%
(
failed_dim_temp
,
dim
))
code
.
put
(
"} else "
)
code
.
put
(
"} else "
)
# check bounds in positive direction
# check bounds in positive direction
if
signed
!=
0
:
if
signed
!=
0
:
...
@@ -458,7 +459,7 @@ def put_buffer_lookup_code(entry, index_signeds, index_cnames, directives,
...
@@ -458,7 +459,7 @@ def put_buffer_lookup_code(entry, index_signeds, index_cnames, directives,
cast
=
"(size_t)"
cast
=
"(size_t)"
code
.
putln
(
"if (%s) %s = %d;"
%
(
code
.
putln
(
"if (%s) %s = %d;"
%
(
code
.
unlikely
(
"%s >= %s%s"
%
(
cname
,
cast
,
shape
)),
code
.
unlikely
(
"%s >= %s%s"
%
(
cname
,
cast
,
shape
)),
tmp_cname
,
dim
))
failed_dim_temp
,
dim
))
if
in_nogil_context
:
if
in_nogil_context
:
code
.
globalstate
.
use_utility_code
(
raise_indexerror_nogil
)
code
.
globalstate
.
use_utility_code
(
raise_indexerror_nogil
)
...
@@ -467,15 +468,14 @@ def put_buffer_lookup_code(entry, index_signeds, index_cnames, directives,
...
@@ -467,15 +468,14 @@ def put_buffer_lookup_code(entry, index_signeds, index_cnames, directives,
code
.
globalstate
.
use_utility_code
(
raise_indexerror_code
)
code
.
globalstate
.
use_utility_code
(
raise_indexerror_code
)
func
=
'__Pyx_RaiseBufferIndexError'
func
=
'__Pyx_RaiseBufferIndexError'
code
.
putln
(
"if (%s) {"
%
code
.
unlikely
(
"%s != -1"
%
tmp_cname
))
code
.
putln
(
"if (%s) {"
%
code
.
unlikely
(
"%s != -1"
%
failed_dim_temp
))
code
.
putln
(
'%s(%s);'
%
(
func
,
tmp_cname
))
code
.
putln
(
'%s(%s);'
%
(
func
,
failed_dim_temp
))
code
.
putln
(
code
.
error_goto
(
pos
))
code
.
putln
(
code
.
error_goto
(
pos
))
code
.
putln
(
'}'
)
code
.
putln
(
'}'
)
code
.
funcstate
.
release_temp
(
tmp_cname
)
code
.
funcstate
.
release_temp
(
failed_dim_temp
)
elif
negative_indices
:
elif
negative_indices
:
# Only fix negative indices.
# Only fix negative indices.
for
signed
,
cname
,
shape
in
zip
(
index_signeds
,
index_cnames
,
for
signed
,
cname
,
shape
in
zip
(
index_signeds
,
index_cnames
,
entry
.
get_buf_shapevars
()):
entry
.
get_buf_shapevars
()):
if
signed
!=
0
:
if
signed
!=
0
:
code
.
putln
(
"if (%s < 0) %s += %s;"
%
(
cname
,
cname
,
shape
))
code
.
putln
(
"if (%s < 0) %s += %s;"
%
(
cname
,
cname
,
shape
))
...
...
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