Eric Smith | 8c66326 | 2007-08-25 02:26:07 +0000 | [diff] [blame] | 1 | #ifndef STRINGLIB_UNICODEDEFS_H |
| 2 | #define STRINGLIB_UNICODEDEFS_H |
| 3 | |
| 4 | /* this is sort of a hack. there's at least one place (formatting |
| 5 | floats) where some stringlib code takes a different path if it's |
| 6 | compiled as unicode. */ |
| 7 | #define STRINGLIB_IS_UNICODE 1 |
| 8 | |
| 9 | #define STRINGLIB_CHAR Py_UNICODE |
| 10 | #define STRINGLIB_TYPE_NAME "unicode" |
Eric Smith | 37f1038 | 2007-09-01 10:56:01 +0000 | [diff] [blame] | 11 | #define STRINGLIB_PARSE_CODE "U" |
Eric Smith | 8c66326 | 2007-08-25 02:26:07 +0000 | [diff] [blame] | 12 | #define STRINGLIB_EMPTY unicode_empty |
| 13 | #define STRINGLIB_ISDECIMAL Py_UNICODE_ISDECIMAL |
| 14 | #define STRINGLIB_TODECIMAL Py_UNICODE_TODECIMAL |
| 15 | #define STRINGLIB_TOUPPER Py_UNICODE_TOUPPER |
| 16 | #define STRINGLIB_TOLOWER Py_UNICODE_TOLOWER |
| 17 | #define STRINGLIB_FILL Py_UNICODE_FILL |
| 18 | #define STRINGLIB_STR PyUnicode_AS_UNICODE |
| 19 | #define STRINGLIB_LEN PyUnicode_GET_SIZE |
| 20 | #define STRINGLIB_NEW PyUnicode_FromUnicode |
| 21 | #define STRINGLIB_RESIZE PyUnicode_Resize |
| 22 | #define STRINGLIB_CHECK PyUnicode_Check |
Thomas Heller | 519a042 | 2007-11-15 20:48:54 +0000 | [diff] [blame] | 23 | #define STRINGLIB_TOSTR PyObject_Str |
Eric Smith | 8c66326 | 2007-08-25 02:26:07 +0000 | [diff] [blame] | 24 | |
Gregory P. Smith | 60d241f | 2007-10-16 06:31:30 +0000 | [diff] [blame] | 25 | #define STRINGLIB_WANT_CONTAINS_OBJ 1 |
| 26 | |
Eric Smith | 79710cd | 2007-08-28 09:45:15 +0000 | [diff] [blame] | 27 | /* STRINGLIB_CMP was defined as: |
| 28 | |
Eric Smith | 8c66326 | 2007-08-25 02:26:07 +0000 | [diff] [blame] | 29 | Py_LOCAL_INLINE(int) |
| 30 | STRINGLIB_CMP(const Py_UNICODE* str, const Py_UNICODE* other, Py_ssize_t len) |
| 31 | { |
| 32 | if (str[0] != other[0]) |
| 33 | return 1; |
| 34 | return memcmp((void*) str, (void*) other, len * sizeof(Py_UNICODE)); |
| 35 | } |
| 36 | |
Eric Smith | 79710cd | 2007-08-28 09:45:15 +0000 | [diff] [blame] | 37 | but unfortunately that gives a error if the function isn't used in a file that |
| 38 | includes this file. So, reluctantly convert it to a macro instead. */ |
| 39 | |
| 40 | #define STRINGLIB_CMP(str, other, len) \ |
| 41 | (((str)[0] != (other)[0]) ? \ |
| 42 | 1 : \ |
| 43 | memcmp((void*) (str), (void*) (other), (len) * sizeof(Py_UNICODE))) |
| 44 | |
| 45 | |
Eric Smith | 8c66326 | 2007-08-25 02:26:07 +0000 | [diff] [blame] | 46 | #endif /* !STRINGLIB_UNICODEDEFS_H */ |