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
Gwenaël Samain
cython
Commits
92db64f1
Commit
92db64f1
authored
Jul 19, 2012
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
moved C string decoding utility code from Optimize.c to StringTools.c
parent
646af4e4
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
76 additions
and
76 deletions
+76
-76
Cython/Compiler/Optimize.py
Cython/Compiler/Optimize.py
+1
-1
Cython/Utility/Optimize.c
Cython/Utility/Optimize.c
+0
-75
Cython/Utility/StringTools.c
Cython/Utility/StringTools.c
+75
-0
No files found.
Cython/Compiler/Optimize.py
View file @
92db64f1
...
@@ -2712,7 +2712,7 @@ class OptimizeBuiltinCalls(Visitor.MethodDispatcherTransform):
...
@@ -2712,7 +2712,7 @@ class OptimizeBuiltinCalls(Visitor.MethodDispatcherTransform):
node
.
pos
,
'__Pyx_%s'
%
utility_code_name
,
helper_func_type
,
node
.
pos
,
'__Pyx_%s'
%
utility_code_name
,
helper_func_type
,
args
=
[
string_node
,
start
,
stop
,
encoding_node
,
error_handling_node
,
decode_function
],
args
=
[
string_node
,
start
,
stop
,
encoding_node
,
error_handling_node
,
decode_function
],
is_temp
=
node
.
is_temp
,
is_temp
=
node
.
is_temp
,
utility_code
=
UtilityCode
.
load_cached
(
utility_code_name
,
'
Optimize
.c'
),
utility_code
=
UtilityCode
.
load_cached
(
utility_code_name
,
'
StringTools
.c'
),
)
)
for
temp
in
temps
[::
-
1
]:
for
temp
in
temps
[::
-
1
]:
...
...
Cython/Utility/Optimize.c
View file @
92db64f1
...
@@ -487,78 +487,3 @@ static double __Pyx__PyObject_AsDouble(PyObject* obj) {
...
@@ -487,78 +487,3 @@ static double __Pyx__PyObject_AsDouble(PyObject* obj) {
bad:
bad:
return
(
double
)
-
1
;
return
(
double
)
-
1
;
}
}
/////////////// decode_cpp_string.proto ///////////////
#include <string>
static
CYTHON_INLINE
PyObject
*
__Pyx_decode_cpp_string
(
std
::
string
cppstring
,
Py_ssize_t
start
,
Py_ssize_t
stop
,
const
char
*
encoding
,
const
char
*
errors
,
PyObject
*
(
*
decode_func
)(
const
char
*
s
,
Py_ssize_t
size
,
const
char
*
errors
));
/////////////// decode_cpp_string ///////////////
static
CYTHON_INLINE
PyObject
*
__Pyx_decode_cpp_string
(
std
::
string
cppstring
,
Py_ssize_t
start
,
Py_ssize_t
stop
,
const
char
*
encoding
,
const
char
*
errors
,
PyObject
*
(
*
decode_func
)(
const
char
*
s
,
Py_ssize_t
size
,
const
char
*
errors
))
{
const
char
*
cstring
=
cppstring
.
data
();
Py_ssize_t
length
=
cppstring
.
size
();
if
(
unlikely
(
start
<
0
))
{
start
+=
length
;
if
(
unlikely
(
start
<
0
))
start
=
0
;
}
if
(
unlikely
(
stop
<
0
))
stop
+=
length
;
else
if
(
stop
>=
length
)
stop
=
length
;
if
(
unlikely
(
start
>=
stop
))
return
PyUnicode_FromUnicode
(
NULL
,
0
);
cstring
+=
start
;
length
=
stop
-
start
;
if
(
decode_func
)
{
return
decode_func
(
cstring
,
length
,
errors
);
}
else
{
return
PyUnicode_Decode
(
cstring
,
length
,
encoding
,
errors
);
}
}
/////////////// decode_c_string.proto ///////////////
static
CYTHON_INLINE
PyObject
*
__Pyx_decode_c_string
(
const
char
*
cstring
,
Py_ssize_t
start
,
Py_ssize_t
stop
,
const
char
*
encoding
,
const
char
*
errors
,
PyObject
*
(
*
decode_func
)(
const
char
*
s
,
Py_ssize_t
size
,
const
char
*
errors
));
/////////////// decode_c_string ///////////////
//@requires StringTools.c::IncludeStringH
static
CYTHON_INLINE
PyObject
*
__Pyx_decode_c_string
(
const
char
*
cstring
,
Py_ssize_t
start
,
Py_ssize_t
stop
,
const
char
*
encoding
,
const
char
*
errors
,
PyObject
*
(
*
decode_func
)(
const
char
*
s
,
Py_ssize_t
size
,
const
char
*
errors
))
{
Py_ssize_t
length
;
if
(
unlikely
((
start
<
0
)
|
(
stop
<
0
)))
{
length
=
strlen
(
cstring
);
if
(
start
<
0
)
{
start
+=
length
;
if
(
start
<
0
)
start
=
0
;
}
if
(
stop
<
0
)
stop
+=
length
;
}
length
=
stop
-
start
;
if
(
unlikely
(
length
<=
0
))
return
PyUnicode_FromUnicode
(
NULL
,
0
);
cstring
+=
start
;
if
(
decode_func
)
{
return
decode_func
(
cstring
,
length
,
errors
);
}
else
{
return
PyUnicode_Decode
(
cstring
,
length
,
encoding
,
errors
);
}
}
Cython/Utility/StringTools.c
View file @
92db64f1
...
@@ -223,3 +223,78 @@ static CYTHON_INLINE Py_UCS4 __Pyx_GetItemInt_Unicode_Generic(PyObject* ustring,
...
@@ -223,3 +223,78 @@ static CYTHON_INLINE Py_UCS4 __Pyx_GetItemInt_Unicode_Generic(PyObject* ustring,
Py_DECREF
(
uchar_string
);
Py_DECREF
(
uchar_string
);
return
uchar
;
return
uchar
;
}
}
/////////////// decode_cpp_string.proto ///////////////
#include <string>
static
CYTHON_INLINE
PyObject
*
__Pyx_decode_cpp_string
(
std
::
string
cppstring
,
Py_ssize_t
start
,
Py_ssize_t
stop
,
const
char
*
encoding
,
const
char
*
errors
,
PyObject
*
(
*
decode_func
)(
const
char
*
s
,
Py_ssize_t
size
,
const
char
*
errors
));
/////////////// decode_cpp_string ///////////////
static
CYTHON_INLINE
PyObject
*
__Pyx_decode_cpp_string
(
std
::
string
cppstring
,
Py_ssize_t
start
,
Py_ssize_t
stop
,
const
char
*
encoding
,
const
char
*
errors
,
PyObject
*
(
*
decode_func
)(
const
char
*
s
,
Py_ssize_t
size
,
const
char
*
errors
))
{
const
char
*
cstring
=
cppstring
.
data
();
Py_ssize_t
length
=
cppstring
.
size
();
if
(
unlikely
(
start
<
0
))
{
start
+=
length
;
if
(
unlikely
(
start
<
0
))
start
=
0
;
}
if
(
unlikely
(
stop
<
0
))
stop
+=
length
;
else
if
(
stop
>=
length
)
stop
=
length
;
if
(
unlikely
(
start
>=
stop
))
return
PyUnicode_FromUnicode
(
NULL
,
0
);
cstring
+=
start
;
length
=
stop
-
start
;
if
(
decode_func
)
{
return
decode_func
(
cstring
,
length
,
errors
);
}
else
{
return
PyUnicode_Decode
(
cstring
,
length
,
encoding
,
errors
);
}
}
/////////////// decode_c_string.proto ///////////////
static
CYTHON_INLINE
PyObject
*
__Pyx_decode_c_string
(
const
char
*
cstring
,
Py_ssize_t
start
,
Py_ssize_t
stop
,
const
char
*
encoding
,
const
char
*
errors
,
PyObject
*
(
*
decode_func
)(
const
char
*
s
,
Py_ssize_t
size
,
const
char
*
errors
));
/////////////// decode_c_string ///////////////
//@requires IncludeStringH
static
CYTHON_INLINE
PyObject
*
__Pyx_decode_c_string
(
const
char
*
cstring
,
Py_ssize_t
start
,
Py_ssize_t
stop
,
const
char
*
encoding
,
const
char
*
errors
,
PyObject
*
(
*
decode_func
)(
const
char
*
s
,
Py_ssize_t
size
,
const
char
*
errors
))
{
Py_ssize_t
length
;
if
(
unlikely
((
start
<
0
)
|
(
stop
<
0
)))
{
length
=
strlen
(
cstring
);
if
(
start
<
0
)
{
start
+=
length
;
if
(
start
<
0
)
start
=
0
;
}
if
(
stop
<
0
)
stop
+=
length
;
}
length
=
stop
-
start
;
if
(
unlikely
(
length
<=
0
))
return
PyUnicode_FromUnicode
(
NULL
,
0
);
cstring
+=
start
;
if
(
decode_func
)
{
return
decode_func
(
cstring
,
length
,
errors
);
}
else
{
return
PyUnicode_Decode
(
cstring
,
length
,
encoding
,
errors
);
}
}
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