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
85cfe7d8
Commit
85cfe7d8
authored
Mar 16, 2013
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
honour wraparound option in object slicing code
parent
fc193531
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
11 deletions
+14
-11
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+8
-5
Cython/Utility/ObjectHandling.c
Cython/Utility/ObjectHandling.c
+6
-6
No files found.
Cython/Compiler/ExprNodes.py
View file @
85cfe7d8
...
@@ -3678,12 +3678,13 @@ class SliceIndexNode(ExprNode):
...
@@ -3678,12 +3678,13 @@ class SliceIndexNode(ExprNode):
(
has_c_start
,
has_c_stop
,
c_start
,
c_stop
,
(
has_c_start
,
has_c_stop
,
c_start
,
c_stop
,
py_start
,
py_stop
,
py_slice
)
=
self
.
get_slice_config
()
py_start
,
py_stop
,
py_slice
)
=
self
.
get_slice_config
()
code
.
putln
(
code
.
putln
(
"%s = __Pyx_PyObject_GetSlice(%s, %s, %s, %s, %s, %s, %d, %d); %s"
%
(
"%s = __Pyx_PyObject_GetSlice(%s, %s, %s, %s, %s, %s, %d, %d
, %d
); %s"
%
(
result
,
result
,
self
.
base
.
py_result
(),
self
.
base
.
py_result
(),
c_start
,
c_stop
,
c_start
,
c_stop
,
py_start
,
py_stop
,
py_slice
,
py_start
,
py_stop
,
py_slice
,
has_c_start
,
has_c_stop
,
has_c_start
,
has_c_stop
,
bool
(
code
.
globalstate
.
directives
[
'wraparound'
]),
code
.
error_goto_if_null
(
result
,
self
.
pos
)))
code
.
error_goto_if_null
(
result
,
self
.
pos
)))
else
:
else
:
if
self
.
base
.
type
is
list_type
:
if
self
.
base
.
type
is
list_type
:
...
@@ -3713,12 +3714,13 @@ class SliceIndexNode(ExprNode):
...
@@ -3713,12 +3714,13 @@ class SliceIndexNode(ExprNode):
(
has_c_start
,
has_c_stop
,
c_start
,
c_stop
,
(
has_c_start
,
has_c_stop
,
c_start
,
c_stop
,
py_start
,
py_stop
,
py_slice
)
=
self
.
get_slice_config
()
py_start
,
py_stop
,
py_slice
)
=
self
.
get_slice_config
()
code
.
put_error_if_neg
(
self
.
pos
,
code
.
put_error_if_neg
(
self
.
pos
,
"__Pyx_PyObject_SetSlice(%s, %s, %s, %s, %s, %s, %s, %d, %d)"
%
(
"__Pyx_PyObject_SetSlice(%s, %s, %s, %s, %s, %s, %s, %d, %d
, %d
)"
%
(
self
.
base
.
py_result
(),
self
.
base
.
py_result
(),
rhs
.
py_result
(),
rhs
.
py_result
(),
c_start
,
c_stop
,
c_start
,
c_stop
,
py_start
,
py_stop
,
py_slice
,
py_start
,
py_stop
,
py_slice
,
has_c_start
,
has_c_stop
))
has_c_start
,
has_c_stop
,
bool
(
code
.
globalstate
.
directives
[
'wraparound'
])))
else
:
else
:
start_offset
=
''
start_offset
=
''
if
self
.
start
:
if
self
.
start
:
...
@@ -3754,11 +3756,12 @@ class SliceIndexNode(ExprNode):
...
@@ -3754,11 +3756,12 @@ class SliceIndexNode(ExprNode):
(
has_c_start
,
has_c_stop
,
c_start
,
c_stop
,
(
has_c_start
,
has_c_stop
,
c_start
,
c_stop
,
py_start
,
py_stop
,
py_slice
)
=
self
.
get_slice_config
()
py_start
,
py_stop
,
py_slice
)
=
self
.
get_slice_config
()
code
.
put_error_if_neg
(
self
.
pos
,
code
.
put_error_if_neg
(
self
.
pos
,
"__Pyx_PyObject_DelSlice(%s, %s, %s, %s, %s, %s, %d, %d)"
%
(
"__Pyx_PyObject_DelSlice(%s, %s, %s, %s, %s, %s, %d, %d
, %d
)"
%
(
self
.
base
.
py_result
(),
self
.
base
.
py_result
(),
c_start
,
c_stop
,
c_start
,
c_stop
,
py_start
,
py_stop
,
py_slice
,
py_start
,
py_stop
,
py_slice
,
has_c_start
,
has_c_stop
))
has_c_start
,
has_c_stop
,
bool
(
code
.
globalstate
.
directives
[
'wraparound'
])))
self
.
generate_subexpr_disposal_code
(
code
)
self
.
generate_subexpr_disposal_code
(
code
)
self
.
free_subexpr_temps
(
code
)
self
.
free_subexpr_temps
(
code
)
...
...
Cython/Utility/ObjectHandling.c
View file @
85cfe7d8
...
@@ -451,16 +451,16 @@ static CYTHON_INLINE int __Pyx_DelItemInt_Fast(PyObject *o, Py_ssize_t i,
...
@@ -451,16 +451,16 @@ static CYTHON_INLINE int __Pyx_DelItemInt_Fast(PyObject *o, Py_ssize_t i,
static
CYTHON_INLINE
PyObject
*
__Pyx_PyObject_GetSlice
(
static
CYTHON_INLINE
PyObject
*
__Pyx_PyObject_GetSlice
(
PyObject
*
obj
,
Py_ssize_t
cstart
,
Py_ssize_t
cstop
,
PyObject
*
obj
,
Py_ssize_t
cstart
,
Py_ssize_t
cstop
,
PyObject
**
py_start
,
PyObject
**
py_stop
,
PyObject
**
py_slice
,
PyObject
**
py_start
,
PyObject
**
py_stop
,
PyObject
**
py_slice
,
int
has_cstart
,
int
has_cstop
);
int
has_cstart
,
int
has_cstop
,
int
wraparound
);
{{
else
}}
{{
else
}}
#define __Pyx_PyObject_DelSlice(obj, cstart, cstop, py_start, py_stop, py_slice, has_cstart, has_cstop) \
#define __Pyx_PyObject_DelSlice(obj, cstart, cstop, py_start, py_stop, py_slice, has_cstart, has_cstop
, wraparound
) \
__Pyx_PyObject_SetSlice(obj, (PyObject*)NULL, cstart, cstop, py_start, py_stop, py_slice, has_cstart, has_cstop)
__Pyx_PyObject_SetSlice(obj, (PyObject*)NULL, cstart, cstop, py_start, py_stop, py_slice, has_cstart, has_cstop
, wraparound
)
// we pass pointer addresses to show the C compiler what is NULL and what isn't
// we pass pointer addresses to show the C compiler what is NULL and what isn't
static
CYTHON_INLINE
int
__Pyx_PyObject_SetSlice
(
static
CYTHON_INLINE
int
__Pyx_PyObject_SetSlice
(
PyObject
*
obj
,
PyObject
*
value
,
Py_ssize_t
cstart
,
Py_ssize_t
cstop
,
PyObject
*
obj
,
PyObject
*
value
,
Py_ssize_t
cstart
,
Py_ssize_t
cstop
,
PyObject
**
py_start
,
PyObject
**
py_stop
,
PyObject
**
py_slice
,
PyObject
**
py_start
,
PyObject
**
py_stop
,
PyObject
**
py_slice
,
int
has_cstart
,
int
has_cstop
);
int
has_cstart
,
int
has_cstop
,
int
wraparound
);
{{
endif
}}
{{
endif
}}
/////////////// SliceObject ///////////////
/////////////// SliceObject ///////////////
...
@@ -473,7 +473,7 @@ static CYTHON_INLINE int __Pyx_PyObject_SetSlice(
...
@@ -473,7 +473,7 @@ static CYTHON_INLINE int __Pyx_PyObject_SetSlice(
PyObject
*
obj
,
PyObject
*
value
,
Py_ssize_t
cstart
,
Py_ssize_t
cstop
,
PyObject
*
obj
,
PyObject
*
value
,
Py_ssize_t
cstart
,
Py_ssize_t
cstop
,
{{
endif
}}
{{
endif
}}
PyObject
**
_py_start
,
PyObject
**
_py_stop
,
PyObject
**
_py_slice
,
PyObject
**
_py_start
,
PyObject
**
_py_stop
,
PyObject
**
_py_slice
,
int
has_cstart
,
int
has_cstop
)
{
int
has_cstart
,
int
has_cstop
,
CYTHON_UNUSED
int
wraparound
)
{
PyMappingMethods
*
mp
;
PyMappingMethods
*
mp
;
#if PY_MAJOR_VERSION < 3
#if PY_MAJOR_VERSION < 3
PySequenceMethods
*
ms
=
Py_TYPE
(
obj
)
->
tp_as_sequence
;
PySequenceMethods
*
ms
=
Py_TYPE
(
obj
)
->
tp_as_sequence
;
...
@@ -492,7 +492,7 @@ static CYTHON_INLINE int __Pyx_PyObject_SetSlice(
...
@@ -492,7 +492,7 @@ static CYTHON_INLINE int __Pyx_PyObject_SetSlice(
}
else
}
else
cstop
=
PY_SSIZE_T_MAX
;
cstop
=
PY_SSIZE_T_MAX
;
}
}
if
(
unlikely
((
cstart
<
0
)
|
(
cstop
<
0
))
&&
likely
(
ms
->
sq_length
))
{
if
(
wraparound
&&
unlikely
((
cstart
<
0
)
|
(
cstop
<
0
))
&&
likely
(
ms
->
sq_length
))
{
Py_ssize_t
l
=
ms
->
sq_length
(
obj
);
Py_ssize_t
l
=
ms
->
sq_length
(
obj
);
if
(
likely
(
l
>=
0
))
{
if
(
likely
(
l
>=
0
))
{
if
(
cstop
<
0
)
{
if
(
cstop
<
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