blob: e973261efff50e2659fee1889018d121c0965c50 [file] [log] [blame]
Gregory P. Smith60d241f2007-10-16 06:31:30 +00001#ifndef Py_BYTES_CTYPE_H
2#define Py_BYTES_CTYPE_H
3
4/*
Christian Heimes9c4756e2008-05-26 13:22:05 +00005 * The internal implementation behind PyBytes (bytes) and PyByteArray (bytearray)
Gregory P. Smith60d241f2007-10-16 06:31:30 +00006 * methods of the given names, they operate on ASCII byte strings.
7 */
8extern PyObject* _Py_bytes_isspace(const char *cptr, Py_ssize_t len);
9extern PyObject* _Py_bytes_isalpha(const char *cptr, Py_ssize_t len);
10extern PyObject* _Py_bytes_isalnum(const char *cptr, Py_ssize_t len);
11extern PyObject* _Py_bytes_isdigit(const char *cptr, Py_ssize_t len);
12extern PyObject* _Py_bytes_islower(const char *cptr, Py_ssize_t len);
13extern PyObject* _Py_bytes_isupper(const char *cptr, Py_ssize_t len);
14extern PyObject* _Py_bytes_istitle(const char *cptr, Py_ssize_t len);
15
16/* These store their len sized answer in the given preallocated *result arg. */
17extern void _Py_bytes_lower(char *result, const char *cptr, Py_ssize_t len);
18extern void _Py_bytes_upper(char *result, const char *cptr, Py_ssize_t len);
19extern void _Py_bytes_title(char *result, char *s, Py_ssize_t len);
20extern void _Py_bytes_capitalize(char *result, char *s, Py_ssize_t len);
21extern void _Py_bytes_swapcase(char *result, char *s, Py_ssize_t len);
22
Georg Brandlabc38772009-04-12 15:51:51 +000023/* This one gets the raw argument list. */
24extern PyObject* _Py_bytes_maketrans(PyObject *args);
25
Gregory P. Smith60d241f2007-10-16 06:31:30 +000026/* Shared __doc__ strings. */
27extern const char _Py_isspace__doc__[];
28extern const char _Py_isalpha__doc__[];
29extern const char _Py_isalnum__doc__[];
30extern const char _Py_isdigit__doc__[];
31extern const char _Py_islower__doc__[];
32extern const char _Py_isupper__doc__[];
33extern const char _Py_istitle__doc__[];
34extern const char _Py_lower__doc__[];
35extern const char _Py_upper__doc__[];
36extern const char _Py_title__doc__[];
37extern const char _Py_capitalize__doc__[];
38extern const char _Py_swapcase__doc__[];
Georg Brandlabc38772009-04-12 15:51:51 +000039extern const char _Py_maketrans__doc__[];
Gregory P. Smith60d241f2007-10-16 06:31:30 +000040
41#define FLAG_LOWER 0x01
42#define FLAG_UPPER 0x02
43#define FLAG_ALPHA (FLAG_LOWER|FLAG_UPPER)
44#define FLAG_DIGIT 0x04
45#define FLAG_ALNUM (FLAG_ALPHA|FLAG_DIGIT)
46#define FLAG_SPACE 0x08
47#define FLAG_XDIGIT 0x10
48
49extern const unsigned int _Py_ctype_table[256];
50
Christian Heimesbbe741d2008-03-28 10:53:29 +000051#define ISLOWER(c) (_Py_ctype_table[Py_CHARMASK(c)] & FLAG_LOWER)
52#define ISUPPER(c) (_Py_ctype_table[Py_CHARMASK(c)] & FLAG_UPPER)
53#define ISALPHA(c) (_Py_ctype_table[Py_CHARMASK(c)] & FLAG_ALPHA)
54#define ISDIGIT(c) (_Py_ctype_table[Py_CHARMASK(c)] & FLAG_DIGIT)
55#define ISXDIGIT(c) (_Py_ctype_table[Py_CHARMASK(c)] & FLAG_XDIGIT)
56#define ISALNUM(c) (_Py_ctype_table[Py_CHARMASK(c)] & FLAG_ALNUM)
57#define ISSPACE(c) (_Py_ctype_table[Py_CHARMASK(c)] & FLAG_SPACE)
Gregory P. Smith60d241f2007-10-16 06:31:30 +000058
59#undef islower
60#define islower(c) undefined_islower(c)
61#undef isupper
62#define isupper(c) undefined_isupper(c)
63#undef isalpha
64#define isalpha(c) undefined_isalpha(c)
65#undef isdigit
66#define isdigit(c) undefined_isdigit(c)
67#undef isxdigit
68#define isxdigit(c) undefined_isxdigit(c)
69#undef isalnum
70#define isalnum(c) undefined_isalnum(c)
71#undef isspace
72#define isspace(c) undefined_isspace(c)
73
74extern const unsigned char _Py_ctype_tolower[256];
75extern const unsigned char _Py_ctype_toupper[256];
76
77#define TOLOWER(c) (_Py_ctype_tolower[Py_CHARMASK(c)])
78#define TOUPPER(c) (_Py_ctype_toupper[Py_CHARMASK(c)])
79
80#undef tolower
81#define tolower(c) undefined_tolower(c)
82#undef toupper
83#define toupper(c) undefined_toupper(c)
84
85/* this is needed because some docs are shared from the .o, not static */
86#define PyDoc_STRVAR_shared(name,str) const char name[] = PyDoc_STR(str)
87
88#endif /* !Py_BYTES_CTYPE_H */