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