blob: fd7b1bd49e54f73b40b352351d301e7b62803df4 [file] [log] [blame]
Serhiy Storchakabcde10a2016-05-16 09:42:29 +03001#if STRINGLIB_IS_UNICODE
2# error "ctype.h only compatible with byte-wise strings"
3#endif
Gregory P. Smith60d241f2007-10-16 06:31:30 +00004
5#include "bytes_methods.h"
6
7static PyObject*
8stringlib_isspace(PyObject *self)
9{
10 return _Py_bytes_isspace(STRINGLIB_STR(self), STRINGLIB_LEN(self));
11}
12
13static PyObject*
14stringlib_isalpha(PyObject *self)
15{
16 return _Py_bytes_isalpha(STRINGLIB_STR(self), STRINGLIB_LEN(self));
17}
18
19static PyObject*
20stringlib_isalnum(PyObject *self)
21{
22 return _Py_bytes_isalnum(STRINGLIB_STR(self), STRINGLIB_LEN(self));
23}
24
25static PyObject*
INADA Naokia49ac992018-01-27 14:06:21 +090026stringlib_isascii(PyObject *self)
27{
28 return _Py_bytes_isascii(STRINGLIB_STR(self), STRINGLIB_LEN(self));
29}
30
31static PyObject*
Gregory P. Smith60d241f2007-10-16 06:31:30 +000032stringlib_isdigit(PyObject *self)
33{
34 return _Py_bytes_isdigit(STRINGLIB_STR(self), STRINGLIB_LEN(self));
35}
36
37static PyObject*
38stringlib_islower(PyObject *self)
39{
40 return _Py_bytes_islower(STRINGLIB_STR(self), STRINGLIB_LEN(self));
41}
42
43static PyObject*
44stringlib_isupper(PyObject *self)
45{
46 return _Py_bytes_isupper(STRINGLIB_STR(self), STRINGLIB_LEN(self));
47}
48
49static PyObject*
50stringlib_istitle(PyObject *self)
51{
52 return _Py_bytes_istitle(STRINGLIB_STR(self), STRINGLIB_LEN(self));
53}
54
55
56/* functions that return a new object partially translated by ctype funcs: */
57
58static PyObject*
59stringlib_lower(PyObject *self)
60{
61 PyObject* newobj;
62 newobj = STRINGLIB_NEW(NULL, STRINGLIB_LEN(self));
63 if (!newobj)
64 return NULL;
65 _Py_bytes_lower(STRINGLIB_STR(newobj), STRINGLIB_STR(self),
66 STRINGLIB_LEN(self));
67 return newobj;
68}
69
70static PyObject*
71stringlib_upper(PyObject *self)
72{
73 PyObject* newobj;
74 newobj = STRINGLIB_NEW(NULL, STRINGLIB_LEN(self));
75 if (!newobj)
76 return NULL;
77 _Py_bytes_upper(STRINGLIB_STR(newobj), STRINGLIB_STR(self),
78 STRINGLIB_LEN(self));
79 return newobj;
80}
81
82static PyObject*
83stringlib_title(PyObject *self)
84{
85 PyObject* newobj;
86 newobj = STRINGLIB_NEW(NULL, STRINGLIB_LEN(self));
87 if (!newobj)
88 return NULL;
89 _Py_bytes_title(STRINGLIB_STR(newobj), STRINGLIB_STR(self),
90 STRINGLIB_LEN(self));
91 return newobj;
92}
93
94static PyObject*
95stringlib_capitalize(PyObject *self)
96{
97 PyObject* newobj;
98 newobj = STRINGLIB_NEW(NULL, STRINGLIB_LEN(self));
99 if (!newobj)
100 return NULL;
101 _Py_bytes_capitalize(STRINGLIB_STR(newobj), STRINGLIB_STR(self),
102 STRINGLIB_LEN(self));
103 return newobj;
104}
105
106static PyObject*
107stringlib_swapcase(PyObject *self)
108{
109 PyObject* newobj;
110 newobj = STRINGLIB_NEW(NULL, STRINGLIB_LEN(self));
111 if (!newobj)
112 return NULL;
113 _Py_bytes_swapcase(STRINGLIB_STR(newobj), STRINGLIB_STR(self),
114 STRINGLIB_LEN(self));
115 return newobj;
116}