1#if STRINGLIB_IS_UNICODE
2# error "ctype.h only compatible with byte-wise strings"
3#endif
4
5#include "pycore_bytes_methods.h"
6
7static PyObject*
8stringlib_isspace(PyObject *self, PyObject *Py_UNUSED(ignored))
9{
10 return _Py_bytes_isspace(STRINGLIB_STR(self), STRINGLIB_LEN(self));
11}
12
13static PyObject*
14stringlib_isalpha(PyObject *self, PyObject *Py_UNUSED(ignored))
15{
16 return _Py_bytes_isalpha(STRINGLIB_STR(self), STRINGLIB_LEN(self));
17}
18
19static PyObject*
20stringlib_isalnum(PyObject *self, PyObject *Py_UNUSED(ignored))
21{
22 return _Py_bytes_isalnum(STRINGLIB_STR(self), STRINGLIB_LEN(self));
23}
24
25static PyObject*
26stringlib_isascii(PyObject *self, PyObject *Py_UNUSED(ignored))
27{
28 return _Py_bytes_isascii(STRINGLIB_STR(self), STRINGLIB_LEN(self));
29}
30
31static PyObject*
32stringlib_isdigit(PyObject *self, PyObject *Py_UNUSED(ignored))
33{
34 return _Py_bytes_isdigit(STRINGLIB_STR(self), STRINGLIB_LEN(self));
35}
36
37static PyObject*
38stringlib_islower(PyObject *self, PyObject *Py_UNUSED(ignored))
39{
40 return _Py_bytes_islower(STRINGLIB_STR(self), STRINGLIB_LEN(self));
41}
42
43static PyObject*
44stringlib_isupper(PyObject *self, PyObject *Py_UNUSED(ignored))
45{
46 return _Py_bytes_isupper(STRINGLIB_STR(self), STRINGLIB_LEN(self));
47}
48
49static PyObject*
50stringlib_istitle(PyObject *self, PyObject *Py_UNUSED(ignored))
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, PyObject *Py_UNUSED(ignored))
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, PyObject *Py_UNUSED(ignored))
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, PyObject *Py_UNUSED(ignored))
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, PyObject *Py_UNUSED(ignored))
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, PyObject *Py_UNUSED(ignored))
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}
117