mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 13:41:24 +00:00 
			
		
		
		
	 45876a90e2
			
		
	
	
		45876a90e2
		
			
		
	
	
	
	
		
			
			Move the bytes_methods.h header file to the internal C API as pycore_bytes_methods.h: it only contains private symbols (prefixed by "_Py"), except of the PyDoc_STRVAR_shared() macro.
		
			
				
	
	
		
			116 lines
		
	
	
	
		
			3 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
			
		
		
	
	
			116 lines
		
	
	
	
		
			3 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
| #if STRINGLIB_IS_UNICODE
 | |
| # error "ctype.h only compatible with byte-wise strings"
 | |
| #endif
 | |
| 
 | |
| #include "pycore_bytes_methods.h"
 | |
| 
 | |
| static PyObject*
 | |
| stringlib_isspace(PyObject *self, PyObject *Py_UNUSED(ignored))
 | |
| {
 | |
|     return _Py_bytes_isspace(STRINGLIB_STR(self), STRINGLIB_LEN(self));
 | |
| }
 | |
| 
 | |
| static PyObject*
 | |
| stringlib_isalpha(PyObject *self, PyObject *Py_UNUSED(ignored))
 | |
| {
 | |
|     return _Py_bytes_isalpha(STRINGLIB_STR(self), STRINGLIB_LEN(self));
 | |
| }
 | |
| 
 | |
| static PyObject*
 | |
| stringlib_isalnum(PyObject *self, PyObject *Py_UNUSED(ignored))
 | |
| {
 | |
|     return _Py_bytes_isalnum(STRINGLIB_STR(self), STRINGLIB_LEN(self));
 | |
| }
 | |
| 
 | |
| static PyObject*
 | |
| stringlib_isascii(PyObject *self, PyObject *Py_UNUSED(ignored))
 | |
| {
 | |
|     return _Py_bytes_isascii(STRINGLIB_STR(self), STRINGLIB_LEN(self));
 | |
| }
 | |
| 
 | |
| static PyObject*
 | |
| stringlib_isdigit(PyObject *self, PyObject *Py_UNUSED(ignored))
 | |
| {
 | |
|     return _Py_bytes_isdigit(STRINGLIB_STR(self), STRINGLIB_LEN(self));
 | |
| }
 | |
| 
 | |
| static PyObject*
 | |
| stringlib_islower(PyObject *self, PyObject *Py_UNUSED(ignored))
 | |
| {
 | |
|     return _Py_bytes_islower(STRINGLIB_STR(self), STRINGLIB_LEN(self));
 | |
| }
 | |
| 
 | |
| static PyObject*
 | |
| stringlib_isupper(PyObject *self, PyObject *Py_UNUSED(ignored))
 | |
| {
 | |
|     return _Py_bytes_isupper(STRINGLIB_STR(self), STRINGLIB_LEN(self));
 | |
| }
 | |
| 
 | |
| static PyObject*
 | |
| stringlib_istitle(PyObject *self, PyObject *Py_UNUSED(ignored))
 | |
| {
 | |
|     return _Py_bytes_istitle(STRINGLIB_STR(self), STRINGLIB_LEN(self));
 | |
| }
 | |
| 
 | |
| 
 | |
| /* functions that return a new object partially translated by ctype funcs: */
 | |
| 
 | |
| static PyObject*
 | |
| stringlib_lower(PyObject *self, PyObject *Py_UNUSED(ignored))
 | |
| {
 | |
|     PyObject* newobj;
 | |
|     newobj = STRINGLIB_NEW(NULL, STRINGLIB_LEN(self));
 | |
|     if (!newobj)
 | |
|             return NULL;
 | |
|     _Py_bytes_lower(STRINGLIB_STR(newobj), STRINGLIB_STR(self),
 | |
|                  STRINGLIB_LEN(self));
 | |
|     return newobj;
 | |
| }
 | |
| 
 | |
| static PyObject*
 | |
| stringlib_upper(PyObject *self, PyObject *Py_UNUSED(ignored))
 | |
| {
 | |
|     PyObject* newobj;
 | |
|     newobj = STRINGLIB_NEW(NULL, STRINGLIB_LEN(self));
 | |
|     if (!newobj)
 | |
|             return NULL;
 | |
|     _Py_bytes_upper(STRINGLIB_STR(newobj), STRINGLIB_STR(self),
 | |
|                  STRINGLIB_LEN(self));
 | |
|     return newobj;
 | |
| }
 | |
| 
 | |
| static PyObject*
 | |
| stringlib_title(PyObject *self, PyObject *Py_UNUSED(ignored))
 | |
| {
 | |
|     PyObject* newobj;
 | |
|     newobj = STRINGLIB_NEW(NULL, STRINGLIB_LEN(self));
 | |
|     if (!newobj)
 | |
|             return NULL;
 | |
|     _Py_bytes_title(STRINGLIB_STR(newobj), STRINGLIB_STR(self),
 | |
|                  STRINGLIB_LEN(self));
 | |
|     return newobj;
 | |
| }
 | |
| 
 | |
| static PyObject*
 | |
| stringlib_capitalize(PyObject *self, PyObject *Py_UNUSED(ignored))
 | |
| {
 | |
|     PyObject* newobj;
 | |
|     newobj = STRINGLIB_NEW(NULL, STRINGLIB_LEN(self));
 | |
|     if (!newobj)
 | |
|             return NULL;
 | |
|     _Py_bytes_capitalize(STRINGLIB_STR(newobj), STRINGLIB_STR(self),
 | |
|                       STRINGLIB_LEN(self));
 | |
|     return newobj;
 | |
| }
 | |
| 
 | |
| static PyObject*
 | |
| stringlib_swapcase(PyObject *self, PyObject *Py_UNUSED(ignored))
 | |
| {
 | |
|     PyObject* newobj;
 | |
|     newobj = STRINGLIB_NEW(NULL, STRINGLIB_LEN(self));
 | |
|     if (!newobj)
 | |
|             return NULL;
 | |
|     _Py_bytes_swapcase(STRINGLIB_STR(newobj), STRINGLIB_STR(self),
 | |
|                     STRINGLIB_LEN(self));
 | |
|     return newobj;
 | |
| }
 |