Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
9491968f
Commit
9491968f
authored
Sep 28, 2011
by
Victor Stinner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Mark PyUnicode_CONVERT_BYTES as private
parent
6817db31
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
25 deletions
+25
-25
Include/unicodeobject.h
Include/unicodeobject.h
+0
-15
Objects/unicodeobject.c
Objects/unicodeobject.c
+25
-10
No files found.
Include/unicodeobject.h
View file @
9491968f
...
@@ -468,21 +468,6 @@ PyAPI_DATA(PyTypeObject) PyUnicodeIter_Type;
...
@@ -468,21 +468,6 @@ PyAPI_DATA(PyTypeObject) PyUnicodeIter_Type;
(PyUnicode_IS_READY(op) ? \
(PyUnicode_IS_READY(op) ? \
0 : _PyUnicode_Ready((PyUnicodeObject *)(op))))
0 : _PyUnicode_Ready((PyUnicodeObject *)(op))))
/* Generic helper macro to convert characters of different types.
from_type and to_type have to be valid type names, begin and end
are pointers to the source characters which should be of type
"from_type *". to is a pointer of type "to_type *" and points to the
buffer where the result characters are written to. */
#define PyUnicode_CONVERT_BYTES(from_type, to_type, begin, end, to) \
do { \
const from_type *iter_; to_type *to_; \
for (iter_ = (begin), to_ = (to_type *)(to); \
iter_ < (end); \
++iter_, ++to_) { \
*to_ = (to_type)*iter_; \
} \
} while (0)
/* Return a maximum character value which is suitable for creating another
/* Return a maximum character value which is suitable for creating another
string based on op. This is always an approximation but more efficient
string based on op. This is always an approximation but more efficient
than interating over the string. */
than interating over the string. */
...
...
Objects/unicodeobject.c
View file @
9491968f
...
@@ -90,6 +90,21 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
...
@@ -90,6 +90,21 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
extern
"C"
{
extern
"C"
{
#endif
#endif
/* Generic helper macro to convert characters of different types.
from_type and to_type have to be valid type names, begin and end
are pointers to the source characters which should be of type
"from_type *". to is a pointer of type "to_type *" and points to the
buffer where the result characters are written to. */
#define _PyUnicode_CONVERT_BYTES(from_type, to_type, begin, end, to) \
do { \
const from_type *iter_; to_type *to_; \
for (iter_ = (begin), to_ = (to_type *)(to); \
iter_ < (end); \
++iter_, ++to_) { \
*to_ = (to_type)*iter_; \
} \
} while (0)
#define _PyUnicode_WSTR(op) (((PyASCIIObject*)(op))->wstr)
#define _PyUnicode_WSTR(op) (((PyASCIIObject*)(op))->wstr)
#define _PyUnicode_WSTR_LENGTH(op) (((PyCompactUnicodeObject*)(op))->wstr_length)
#define _PyUnicode_WSTR_LENGTH(op) (((PyCompactUnicodeObject*)(op))->wstr_length)
#define _PyUnicode_LENGTH(op) (((PyASCIIObject *)(op))->length)
#define _PyUnicode_LENGTH(op) (((PyASCIIObject *)(op))->length)
...
@@ -622,7 +637,7 @@ PyUnicode_CopyCharacters(PyObject *to, Py_ssize_t to_start,
...
@@ -622,7 +637,7 @@ PyUnicode_CopyCharacters(PyObject *to, Py_ssize_t to_start,
case
PyUnicode_1BYTE_KIND
:
case
PyUnicode_1BYTE_KIND
:
switch
(
to_kind
)
{
switch
(
to_kind
)
{
case
PyUnicode_2BYTE_KIND
:
case
PyUnicode_2BYTE_KIND
:
PyUnicode_CONVERT_BYTES
(
_
PyUnicode_CONVERT_BYTES
(
unsigned
char
,
Py_UCS2
,
unsigned
char
,
Py_UCS2
,
PyUnicode_1BYTE_DATA
(
from
)
+
from_start
,
PyUnicode_1BYTE_DATA
(
from
)
+
from_start
,
PyUnicode_1BYTE_DATA
(
from
)
+
from_start
+
how_many
,
PyUnicode_1BYTE_DATA
(
from
)
+
from_start
+
how_many
,
...
@@ -630,7 +645,7 @@ PyUnicode_CopyCharacters(PyObject *to, Py_ssize_t to_start,
...
@@ -630,7 +645,7 @@ PyUnicode_CopyCharacters(PyObject *to, Py_ssize_t to_start,
);
);
break
;
break
;
case
PyUnicode_4BYTE_KIND
:
case
PyUnicode_4BYTE_KIND
:
PyUnicode_CONVERT_BYTES
(
_
PyUnicode_CONVERT_BYTES
(
unsigned
char
,
Py_UCS4
,
unsigned
char
,
Py_UCS4
,
PyUnicode_1BYTE_DATA
(
from
)
+
from_start
,
PyUnicode_1BYTE_DATA
(
from
)
+
from_start
,
PyUnicode_1BYTE_DATA
(
from
)
+
from_start
+
how_many
,
PyUnicode_1BYTE_DATA
(
from
)
+
from_start
+
how_many
,
...
@@ -644,7 +659,7 @@ PyUnicode_CopyCharacters(PyObject *to, Py_ssize_t to_start,
...
@@ -644,7 +659,7 @@ PyUnicode_CopyCharacters(PyObject *to, Py_ssize_t to_start,
case
PyUnicode_2BYTE_KIND
:
case
PyUnicode_2BYTE_KIND
:
switch
(
to_kind
)
{
switch
(
to_kind
)
{
case
PyUnicode_1BYTE_KIND
:
case
PyUnicode_1BYTE_KIND
:
PyUnicode_CONVERT_BYTES
(
_
PyUnicode_CONVERT_BYTES
(
Py_UCS2
,
unsigned
char
,
Py_UCS2
,
unsigned
char
,
PyUnicode_2BYTE_DATA
(
from
)
+
from_start
,
PyUnicode_2BYTE_DATA
(
from
)
+
from_start
,
PyUnicode_2BYTE_DATA
(
from
)
+
from_start
+
how_many
,
PyUnicode_2BYTE_DATA
(
from
)
+
from_start
+
how_many
,
...
@@ -652,7 +667,7 @@ PyUnicode_CopyCharacters(PyObject *to, Py_ssize_t to_start,
...
@@ -652,7 +667,7 @@ PyUnicode_CopyCharacters(PyObject *to, Py_ssize_t to_start,
);
);
break
;
break
;
case
PyUnicode_4BYTE_KIND
:
case
PyUnicode_4BYTE_KIND
:
PyUnicode_CONVERT_BYTES
(
_
PyUnicode_CONVERT_BYTES
(
Py_UCS2
,
Py_UCS4
,
Py_UCS2
,
Py_UCS4
,
PyUnicode_2BYTE_DATA
(
from
)
+
from_start
,
PyUnicode_2BYTE_DATA
(
from
)
+
from_start
,
PyUnicode_2BYTE_DATA
(
from
)
+
from_start
+
how_many
,
PyUnicode_2BYTE_DATA
(
from
)
+
from_start
+
how_many
,
...
@@ -666,7 +681,7 @@ PyUnicode_CopyCharacters(PyObject *to, Py_ssize_t to_start,
...
@@ -666,7 +681,7 @@ PyUnicode_CopyCharacters(PyObject *to, Py_ssize_t to_start,
case
PyUnicode_4BYTE_KIND
:
case
PyUnicode_4BYTE_KIND
:
switch
(
to_kind
)
{
switch
(
to_kind
)
{
case
PyUnicode_1BYTE_KIND
:
case
PyUnicode_1BYTE_KIND
:
PyUnicode_CONVERT_BYTES
(
_
PyUnicode_CONVERT_BYTES
(
Py_UCS4
,
unsigned
char
,
Py_UCS4
,
unsigned
char
,
PyUnicode_4BYTE_DATA
(
from
)
+
from_start
,
PyUnicode_4BYTE_DATA
(
from
)
+
from_start
,
PyUnicode_4BYTE_DATA
(
from
)
+
from_start
+
how_many
,
PyUnicode_4BYTE_DATA
(
from
)
+
from_start
+
how_many
,
...
@@ -674,7 +689,7 @@ PyUnicode_CopyCharacters(PyObject *to, Py_ssize_t to_start,
...
@@ -674,7 +689,7 @@ PyUnicode_CopyCharacters(PyObject *to, Py_ssize_t to_start,
);
);
break
;
break
;
case
PyUnicode_2BYTE_KIND
:
case
PyUnicode_2BYTE_KIND
:
PyUnicode_CONVERT_BYTES
(
_
PyUnicode_CONVERT_BYTES
(
Py_UCS4
,
Py_UCS2
,
Py_UCS4
,
Py_UCS2
,
PyUnicode_4BYTE_DATA
(
from
)
+
from_start
,
PyUnicode_4BYTE_DATA
(
from
)
+
from_start
,
PyUnicode_4BYTE_DATA
(
from
)
+
from_start
+
how_many
,
PyUnicode_4BYTE_DATA
(
from
)
+
from_start
+
how_many
,
...
@@ -792,7 +807,7 @@ _PyUnicode_Ready(PyUnicodeObject *unicode)
...
@@ -792,7 +807,7 @@ _PyUnicode_Ready(PyUnicodeObject *unicode)
PyErr_NoMemory
();
PyErr_NoMemory
();
return
-
1
;
return
-
1
;
}
}
PyUnicode_CONVERT_BYTES
(
wchar_t
,
unsigned
char
,
_
PyUnicode_CONVERT_BYTES
(
wchar_t
,
unsigned
char
,
_PyUnicode_WSTR
(
unicode
),
end
,
_PyUnicode_WSTR
(
unicode
),
end
,
PyUnicode_1BYTE_DATA
(
unicode
));
PyUnicode_1BYTE_DATA
(
unicode
));
PyUnicode_1BYTE_DATA
(
unicode
)[
_PyUnicode_WSTR_LENGTH
(
unicode
)]
=
'\0'
;
PyUnicode_1BYTE_DATA
(
unicode
)[
_PyUnicode_WSTR_LENGTH
(
unicode
)]
=
'\0'
;
...
@@ -834,7 +849,7 @@ _PyUnicode_Ready(PyUnicodeObject *unicode)
...
@@ -834,7 +849,7 @@ _PyUnicode_Ready(PyUnicodeObject *unicode)
PyErr_NoMemory
();
PyErr_NoMemory
();
return
-
1
;
return
-
1
;
}
}
PyUnicode_CONVERT_BYTES
(
wchar_t
,
Py_UCS2
,
_
PyUnicode_CONVERT_BYTES
(
wchar_t
,
Py_UCS2
,
_PyUnicode_WSTR
(
unicode
),
end
,
_PyUnicode_WSTR
(
unicode
),
end
,
PyUnicode_2BYTE_DATA
(
unicode
));
PyUnicode_2BYTE_DATA
(
unicode
));
PyUnicode_2BYTE_DATA
(
unicode
)[
_PyUnicode_WSTR_LENGTH
(
unicode
)]
=
'\0'
;
PyUnicode_2BYTE_DATA
(
unicode
)[
_PyUnicode_WSTR_LENGTH
(
unicode
)]
=
'\0'
;
...
@@ -1023,14 +1038,14 @@ PyUnicode_FromUnicode(const Py_UNICODE *u, Py_ssize_t size)
...
@@ -1023,14 +1038,14 @@ PyUnicode_FromUnicode(const Py_UNICODE *u, Py_ssize_t size)
switch
(
PyUnicode_KIND
(
unicode
))
{
switch
(
PyUnicode_KIND
(
unicode
))
{
case
PyUnicode_1BYTE_KIND
:
case
PyUnicode_1BYTE_KIND
:
PyUnicode_CONVERT_BYTES
(
Py_UNICODE
,
unsigned
char
,
_
PyUnicode_CONVERT_BYTES
(
Py_UNICODE
,
unsigned
char
,
u
,
u
+
size
,
PyUnicode_1BYTE_DATA
(
unicode
));
u
,
u
+
size
,
PyUnicode_1BYTE_DATA
(
unicode
));
break
;
break
;
case
PyUnicode_2BYTE_KIND
:
case
PyUnicode_2BYTE_KIND
:
#if Py_UNICODE_SIZE == 2
#if Py_UNICODE_SIZE == 2
Py_MEMCPY
(
PyUnicode_2BYTE_DATA
(
unicode
),
u
,
size
*
2
);
Py_MEMCPY
(
PyUnicode_2BYTE_DATA
(
unicode
),
u
,
size
*
2
);
#else
#else
PyUnicode_CONVERT_BYTES
(
Py_UNICODE
,
Py_UCS2
,
_
PyUnicode_CONVERT_BYTES
(
Py_UNICODE
,
Py_UCS2
,
u
,
u
+
size
,
PyUnicode_2BYTE_DATA
(
unicode
));
u
,
u
+
size
,
PyUnicode_2BYTE_DATA
(
unicode
));
#endif
#endif
break
;
break
;
...
...
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