Mercurial > cpython-lru_cache-weakref
annotate Objects/stringlib/unicodedefs.h @ 48416:fb02fedfe647
Merged revisions 64677 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r64677 | brett.cannon | 2008-07-02 14:52:42 -0700 (Wed, 02 Jul 2008) | 2 lines
Revert r64673 and instead just change the file encoding.
........
| author | Brett Cannon <bcannon@gmail.com> |
|---|---|
| date | Wed, 02 Jul 2008 22:06:12 +0000 |
| parents | da47e7e135ae |
| children | 28096ed73153 |
| rev | line source |
|---|---|
|
42817
5355337709e1
Implementation of PEP 3101, Advanced String Formatting.
Eric Smith <eric@trueblade.com>
parents:
diff
changeset
|
1 #ifndef STRINGLIB_UNICODEDEFS_H |
|
5355337709e1
Implementation of PEP 3101, Advanced String Formatting.
Eric Smith <eric@trueblade.com>
parents:
diff
changeset
|
2 #define STRINGLIB_UNICODEDEFS_H |
|
5355337709e1
Implementation of PEP 3101, Advanced String Formatting.
Eric Smith <eric@trueblade.com>
parents:
diff
changeset
|
3 |
|
5355337709e1
Implementation of PEP 3101, Advanced String Formatting.
Eric Smith <eric@trueblade.com>
parents:
diff
changeset
|
4 /* this is sort of a hack. there's at least one place (formatting |
|
5355337709e1
Implementation of PEP 3101, Advanced String Formatting.
Eric Smith <eric@trueblade.com>
parents:
diff
changeset
|
5 floats) where some stringlib code takes a different path if it's |
|
5355337709e1
Implementation of PEP 3101, Advanced String Formatting.
Eric Smith <eric@trueblade.com>
parents:
diff
changeset
|
6 compiled as unicode. */ |
|
5355337709e1
Implementation of PEP 3101, Advanced String Formatting.
Eric Smith <eric@trueblade.com>
parents:
diff
changeset
|
7 #define STRINGLIB_IS_UNICODE 1 |
|
5355337709e1
Implementation of PEP 3101, Advanced String Formatting.
Eric Smith <eric@trueblade.com>
parents:
diff
changeset
|
8 |
|
45382
7af955843929
Fixes for shared 2.6 code that implements PEP 3101, advanced string
Eric Smith <eric@trueblade.com>
parents:
43866
diff
changeset
|
9 #define STRINGLIB_OBJECT PyUnicodeObject |
|
42817
5355337709e1
Implementation of PEP 3101, Advanced String Formatting.
Eric Smith <eric@trueblade.com>
parents:
diff
changeset
|
10 #define STRINGLIB_CHAR Py_UNICODE |
|
5355337709e1
Implementation of PEP 3101, Advanced String Formatting.
Eric Smith <eric@trueblade.com>
parents:
diff
changeset
|
11 #define STRINGLIB_TYPE_NAME "unicode" |
|
43172
d842457e4b0e
Changed to use 'U' argument to PyArg_ParseTuple, instead of manually checking for unicode objects.
Eric Smith <eric@trueblade.com>
parents:
42946
diff
changeset
|
12 #define STRINGLIB_PARSE_CODE "U" |
|
42817
5355337709e1
Implementation of PEP 3101, Advanced String Formatting.
Eric Smith <eric@trueblade.com>
parents:
diff
changeset
|
13 #define STRINGLIB_EMPTY unicode_empty |
|
5355337709e1
Implementation of PEP 3101, Advanced String Formatting.
Eric Smith <eric@trueblade.com>
parents:
diff
changeset
|
14 #define STRINGLIB_ISDECIMAL Py_UNICODE_ISDECIMAL |
|
5355337709e1
Implementation of PEP 3101, Advanced String Formatting.
Eric Smith <eric@trueblade.com>
parents:
diff
changeset
|
15 #define STRINGLIB_TODECIMAL Py_UNICODE_TODECIMAL |
|
5355337709e1
Implementation of PEP 3101, Advanced String Formatting.
Eric Smith <eric@trueblade.com>
parents:
diff
changeset
|
16 #define STRINGLIB_TOUPPER Py_UNICODE_TOUPPER |
|
5355337709e1
Implementation of PEP 3101, Advanced String Formatting.
Eric Smith <eric@trueblade.com>
parents:
diff
changeset
|
17 #define STRINGLIB_TOLOWER Py_UNICODE_TOLOWER |
|
5355337709e1
Implementation of PEP 3101, Advanced String Formatting.
Eric Smith <eric@trueblade.com>
parents:
diff
changeset
|
18 #define STRINGLIB_FILL Py_UNICODE_FILL |
|
5355337709e1
Implementation of PEP 3101, Advanced String Formatting.
Eric Smith <eric@trueblade.com>
parents:
diff
changeset
|
19 #define STRINGLIB_STR PyUnicode_AS_UNICODE |
|
5355337709e1
Implementation of PEP 3101, Advanced String Formatting.
Eric Smith <eric@trueblade.com>
parents:
diff
changeset
|
20 #define STRINGLIB_LEN PyUnicode_GET_SIZE |
|
5355337709e1
Implementation of PEP 3101, Advanced String Formatting.
Eric Smith <eric@trueblade.com>
parents:
diff
changeset
|
21 #define STRINGLIB_NEW PyUnicode_FromUnicode |
|
5355337709e1
Implementation of PEP 3101, Advanced String Formatting.
Eric Smith <eric@trueblade.com>
parents:
diff
changeset
|
22 #define STRINGLIB_RESIZE PyUnicode_Resize |
|
5355337709e1
Implementation of PEP 3101, Advanced String Formatting.
Eric Smith <eric@trueblade.com>
parents:
diff
changeset
|
23 #define STRINGLIB_CHECK PyUnicode_Check |
|
46909
ef4ec968fdb6
Merged revisions 63078 via svnmerge from
Eric Smith <eric@trueblade.com>
parents:
45382
diff
changeset
|
24 #define STRINGLIB_GROUPING _PyUnicode_InsertThousandsGrouping |
|
45382
7af955843929
Fixes for shared 2.6 code that implements PEP 3101, advanced string
Eric Smith <eric@trueblade.com>
parents:
43866
diff
changeset
|
25 |
|
7af955843929
Fixes for shared 2.6 code that implements PEP 3101, advanced string
Eric Smith <eric@trueblade.com>
parents:
43866
diff
changeset
|
26 #if PY_VERSION_HEX < 0x03000000 |
|
7af955843929
Fixes for shared 2.6 code that implements PEP 3101, advanced string
Eric Smith <eric@trueblade.com>
parents:
43866
diff
changeset
|
27 #define STRINGLIB_TOSTR PyObject_Unicode |
|
47611
da47e7e135ae
#2630: Implement PEP 3138.
Georg Brandl <georg@python.org>
parents:
46909
diff
changeset
|
28 #define STRINGLIB_TOASCII PyObject_Repr |
|
45382
7af955843929
Fixes for shared 2.6 code that implements PEP 3101, advanced string
Eric Smith <eric@trueblade.com>
parents:
43866
diff
changeset
|
29 #else |
|
43866
8ed0280c2ab6
Replace PyObject_Unicode with PyObject_Str everywhere, and remove the
Thomas Heller <theller@ctypes.org>
parents:
43576
diff
changeset
|
30 #define STRINGLIB_TOSTR PyObject_Str |
|
47611
da47e7e135ae
#2630: Implement PEP 3138.
Georg Brandl <georg@python.org>
parents:
46909
diff
changeset
|
31 #define STRINGLIB_TOASCII PyObject_ASCII |
|
45382
7af955843929
Fixes for shared 2.6 code that implements PEP 3101, advanced string
Eric Smith <eric@trueblade.com>
parents:
43866
diff
changeset
|
32 #endif |
|
42817
5355337709e1
Implementation of PEP 3101, Advanced String Formatting.
Eric Smith <eric@trueblade.com>
parents:
diff
changeset
|
33 |
|
43576
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
43172
diff
changeset
|
34 #define STRINGLIB_WANT_CONTAINS_OBJ 1 |
|
697cc31a83f6
For PEP3137: Adds missing methods to the mutable PyBytes object (soon
Gregory P. Smith <greg@mad-scientist.com>
parents:
43172
diff
changeset
|
35 |
|
42946
9a13e8fb1a3b
Changed STRINGLIB_CMP from an inline function to a macro in order to avoid a 'defined but not used' warning.
Eric Smith <eric@trueblade.com>
parents:
42817
diff
changeset
|
36 /* STRINGLIB_CMP was defined as: |
|
9a13e8fb1a3b
Changed STRINGLIB_CMP from an inline function to a macro in order to avoid a 'defined but not used' warning.
Eric Smith <eric@trueblade.com>
parents:
42817
diff
changeset
|
37 |
|
42817
5355337709e1
Implementation of PEP 3101, Advanced String Formatting.
Eric Smith <eric@trueblade.com>
parents:
diff
changeset
|
38 Py_LOCAL_INLINE(int) |
|
5355337709e1
Implementation of PEP 3101, Advanced String Formatting.
Eric Smith <eric@trueblade.com>
parents:
diff
changeset
|
39 STRINGLIB_CMP(const Py_UNICODE* str, const Py_UNICODE* other, Py_ssize_t len) |
|
5355337709e1
Implementation of PEP 3101, Advanced String Formatting.
Eric Smith <eric@trueblade.com>
parents:
diff
changeset
|
40 { |
|
5355337709e1
Implementation of PEP 3101, Advanced String Formatting.
Eric Smith <eric@trueblade.com>
parents:
diff
changeset
|
41 if (str[0] != other[0]) |
|
5355337709e1
Implementation of PEP 3101, Advanced String Formatting.
Eric Smith <eric@trueblade.com>
parents:
diff
changeset
|
42 return 1; |
|
5355337709e1
Implementation of PEP 3101, Advanced String Formatting.
Eric Smith <eric@trueblade.com>
parents:
diff
changeset
|
43 return memcmp((void*) str, (void*) other, len * sizeof(Py_UNICODE)); |
|
5355337709e1
Implementation of PEP 3101, Advanced String Formatting.
Eric Smith <eric@trueblade.com>
parents:
diff
changeset
|
44 } |
|
5355337709e1
Implementation of PEP 3101, Advanced String Formatting.
Eric Smith <eric@trueblade.com>
parents:
diff
changeset
|
45 |
|
42946
9a13e8fb1a3b
Changed STRINGLIB_CMP from an inline function to a macro in order to avoid a 'defined but not used' warning.
Eric Smith <eric@trueblade.com>
parents:
42817
diff
changeset
|
46 but unfortunately that gives a error if the function isn't used in a file that |
|
9a13e8fb1a3b
Changed STRINGLIB_CMP from an inline function to a macro in order to avoid a 'defined but not used' warning.
Eric Smith <eric@trueblade.com>
parents:
42817
diff
changeset
|
47 includes this file. So, reluctantly convert it to a macro instead. */ |
|
9a13e8fb1a3b
Changed STRINGLIB_CMP from an inline function to a macro in order to avoid a 'defined but not used' warning.
Eric Smith <eric@trueblade.com>
parents:
42817
diff
changeset
|
48 |
|
9a13e8fb1a3b
Changed STRINGLIB_CMP from an inline function to a macro in order to avoid a 'defined but not used' warning.
Eric Smith <eric@trueblade.com>
parents:
42817
diff
changeset
|
49 #define STRINGLIB_CMP(str, other, len) \ |
|
9a13e8fb1a3b
Changed STRINGLIB_CMP from an inline function to a macro in order to avoid a 'defined but not used' warning.
Eric Smith <eric@trueblade.com>
parents:
42817
diff
changeset
|
50 (((str)[0] != (other)[0]) ? \ |
|
9a13e8fb1a3b
Changed STRINGLIB_CMP from an inline function to a macro in order to avoid a 'defined but not used' warning.
Eric Smith <eric@trueblade.com>
parents:
42817
diff
changeset
|
51 1 : \ |
|
9a13e8fb1a3b
Changed STRINGLIB_CMP from an inline function to a macro in order to avoid a 'defined but not used' warning.
Eric Smith <eric@trueblade.com>
parents:
42817
diff
changeset
|
52 memcmp((void*) (str), (void*) (other), (len) * sizeof(Py_UNICODE))) |
|
9a13e8fb1a3b
Changed STRINGLIB_CMP from an inline function to a macro in order to avoid a 'defined but not used' warning.
Eric Smith <eric@trueblade.com>
parents:
42817
diff
changeset
|
53 |
|
9a13e8fb1a3b
Changed STRINGLIB_CMP from an inline function to a macro in order to avoid a 'defined but not used' warning.
Eric Smith <eric@trueblade.com>
parents:
42817
diff
changeset
|
54 |
|
42817
5355337709e1
Implementation of PEP 3101, Advanced String Formatting.
Eric Smith <eric@trueblade.com>
parents:
diff
changeset
|
55 #endif /* !STRINGLIB_UNICODEDEFS_H */ |
