~ubuntu-branches/ubuntu/maverick/python3.1/maverick

« back to all changes in this revision

Viewing changes to Objects/stringlib/unicodedefs.h

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2009-03-23 00:01:27 UTC
  • Revision ID: james.westby@ubuntu.com-20090323000127-5fstfxju4ufrhthq
Tags: upstream-3.1~a1+20090322
ImportĀ upstreamĀ versionĀ 3.1~a1+20090322

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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_OBJECT         PyUnicodeObject
 
10
#define STRINGLIB_CHAR           Py_UNICODE
 
11
#define STRINGLIB_TYPE_NAME      "unicode"
 
12
#define STRINGLIB_PARSE_CODE     "U"
 
13
#define STRINGLIB_EMPTY          unicode_empty
 
14
#define STRINGLIB_ISDECIMAL      Py_UNICODE_ISDECIMAL
 
15
#define STRINGLIB_TODECIMAL      Py_UNICODE_TODECIMAL
 
16
#define STRINGLIB_TOUPPER        Py_UNICODE_TOUPPER
 
17
#define STRINGLIB_TOLOWER        Py_UNICODE_TOLOWER
 
18
#define STRINGLIB_FILL           Py_UNICODE_FILL
 
19
#define STRINGLIB_STR            PyUnicode_AS_UNICODE
 
20
#define STRINGLIB_LEN            PyUnicode_GET_SIZE
 
21
#define STRINGLIB_NEW            PyUnicode_FromUnicode
 
22
#define STRINGLIB_RESIZE         PyUnicode_Resize
 
23
#define STRINGLIB_CHECK          PyUnicode_Check
 
24
#define STRINGLIB_GROUPING       _PyUnicode_InsertThousandsGrouping
 
25
 
 
26
#if PY_VERSION_HEX < 0x03000000
 
27
#define STRINGLIB_TOSTR          PyObject_Unicode
 
28
#define STRINGLIB_TOASCII        PyObject_Repr
 
29
#else
 
30
#define STRINGLIB_TOSTR          PyObject_Str
 
31
#define STRINGLIB_TOASCII        PyObject_ASCII
 
32
#endif
 
33
 
 
34
#define STRINGLIB_WANT_CONTAINS_OBJ 1
 
35
 
 
36
/* STRINGLIB_CMP was defined as:
 
37
 
 
38
Py_LOCAL_INLINE(int)
 
39
STRINGLIB_CMP(const Py_UNICODE* str, const Py_UNICODE* other, Py_ssize_t len)
 
40
{
 
41
    if (str[0] != other[0])
 
42
        return 1;
 
43
    return memcmp((void*) str, (void*) other, len * sizeof(Py_UNICODE));
 
44
}
 
45
 
 
46
but unfortunately that gives a error if the function isn't used in a file that
 
47
includes this file.  So, reluctantly convert it to a macro instead. */
 
48
 
 
49
#define STRINGLIB_CMP(str, other, len) \
 
50
    (((str)[0] != (other)[0]) ? \
 
51
     1 : \
 
52
     memcmp((void*) (str), (void*) (other), (len) * sizeof(Py_UNICODE)))
 
53
 
 
54
 
 
55
#endif /* !STRINGLIB_UNICODEDEFS_H */