|
1 | 1 |
|
2 | | -/* Bytes (String) object interface */ |
| 2 | +/* String (Bytes) object interface */ |
3 | 3 |
|
4 | 4 | #ifndef Py_BYTESOBJECT_H |
5 | 5 | #define Py_BYTESOBJECT_H |
@@ -10,7 +10,7 @@ extern "C" { |
10 | 10 | #include <stdarg.h> |
11 | 11 |
|
12 | 12 | /* |
13 | | -Type PyBytesObject represents a character string. An extra zero byte is |
| 13 | +Type PyStringObject represents a character string. An extra zero byte is |
14 | 14 | reserved at the end to ensure it is zero-terminated, but a size is |
15 | 15 | present so strings with null bytes in them can be represented. This |
16 | 16 | is an immutable object type. |
@@ -46,61 +46,61 @@ typedef struct { |
46 | 46 | * 'interned' dictionary; in this case the two references |
47 | 47 | * from 'interned' to this object are *not counted* in ob_refcnt. |
48 | 48 | */ |
49 | | -} PyBytesObject; |
| 49 | +} PyStringObject; |
50 | 50 |
|
51 | 51 | #define SSTATE_NOT_INTERNED 0 |
52 | 52 | #define SSTATE_INTERNED_MORTAL 1 |
53 | 53 | #define SSTATE_INTERNED_IMMORTAL 2 |
54 | 54 |
|
55 | 55 | PyAPI_DATA(PyTypeObject) PyBaseString_Type; |
56 | | -PyAPI_DATA(PyTypeObject) PyBytes_Type; |
| 56 | +PyAPI_DATA(PyTypeObject) PyString_Type; |
57 | 57 |
|
58 | | -#define PyBytes_Check(op) \ |
| 58 | +#define PyString_Check(op) \ |
59 | 59 | PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_STRING_SUBCLASS) |
60 | | -#define PyBytes_CheckExact(op) (Py_TYPE(op) == &PyBytes_Type) |
| 60 | +#define PyString_CheckExact(op) (Py_TYPE(op) == &PyString_Type) |
61 | 61 |
|
62 | | -PyAPI_FUNC(PyObject *) PyBytes_FromStringAndSize(const char *, Py_ssize_t); |
63 | | -PyAPI_FUNC(PyObject *) PyBytes_FromString(const char *); |
64 | | -PyAPI_FUNC(PyObject *) PyBytes_FromFormatV(const char*, va_list) |
| 62 | +PyAPI_FUNC(PyObject *) PyString_FromStringAndSize(const char *, Py_ssize_t); |
| 63 | +PyAPI_FUNC(PyObject *) PyString_FromString(const char *); |
| 64 | +PyAPI_FUNC(PyObject *) PyString_FromFormatV(const char*, va_list) |
65 | 65 | Py_GCC_ATTRIBUTE((format(printf, 1, 0))); |
66 | | -PyAPI_FUNC(PyObject *) PyBytes_FromFormat(const char*, ...) |
| 66 | +PyAPI_FUNC(PyObject *) PyString_FromFormat(const char*, ...) |
67 | 67 | Py_GCC_ATTRIBUTE((format(printf, 1, 2))); |
68 | | -PyAPI_FUNC(Py_ssize_t) PyBytes_Size(PyObject *); |
69 | | -PyAPI_FUNC(char *) PyBytes_AsString(PyObject *); |
70 | | -PyAPI_FUNC(PyObject *) PyBytes_Repr(PyObject *, int); |
71 | | -PyAPI_FUNC(void) PyBytes_Concat(PyObject **, PyObject *); |
72 | | -PyAPI_FUNC(void) PyBytes_ConcatAndDel(PyObject **, PyObject *); |
73 | | -PyAPI_FUNC(int) _PyBytes_Resize(PyObject **, Py_ssize_t); |
74 | | -PyAPI_FUNC(int) _PyBytes_Eq(PyObject *, PyObject*); |
75 | | -PyAPI_FUNC(PyObject *) PyBytes_Format(PyObject *, PyObject *); |
76 | | -PyAPI_FUNC(PyObject *) _PyBytes_FormatLong(PyObject*, int, int, |
| 68 | +PyAPI_FUNC(Py_ssize_t) PyString_Size(PyObject *); |
| 69 | +PyAPI_FUNC(char *) PyString_AsString(PyObject *); |
| 70 | +PyAPI_FUNC(PyObject *) PyString_Repr(PyObject *, int); |
| 71 | +PyAPI_FUNC(void) PyString_Concat(PyObject **, PyObject *); |
| 72 | +PyAPI_FUNC(void) PyString_ConcatAndDel(PyObject **, PyObject *); |
| 73 | +PyAPI_FUNC(int) _PyString_Resize(PyObject **, Py_ssize_t); |
| 74 | +PyAPI_FUNC(int) _PyString_Eq(PyObject *, PyObject*); |
| 75 | +PyAPI_FUNC(PyObject *) PyString_Format(PyObject *, PyObject *); |
| 76 | +PyAPI_FUNC(PyObject *) _PyString_FormatLong(PyObject*, int, int, |
77 | 77 | int, char**, int*); |
78 | | -PyAPI_FUNC(PyObject *) PyBytes_DecodeEscape(const char *, Py_ssize_t, |
| 78 | +PyAPI_FUNC(PyObject *) PyString_DecodeEscape(const char *, Py_ssize_t, |
79 | 79 | const char *, Py_ssize_t, |
80 | 80 | const char *); |
81 | 81 |
|
82 | | -PyAPI_FUNC(void) PyBytes_InternInPlace(PyObject **); |
83 | | -PyAPI_FUNC(void) PyBytes_InternImmortal(PyObject **); |
84 | | -PyAPI_FUNC(PyObject *) PyBytes_InternFromString(const char *); |
| 82 | +PyAPI_FUNC(void) PyString_InternInPlace(PyObject **); |
| 83 | +PyAPI_FUNC(void) PyString_InternImmortal(PyObject **); |
| 84 | +PyAPI_FUNC(PyObject *) PyString_InternFromString(const char *); |
85 | 85 | PyAPI_FUNC(void) _Py_ReleaseInternedStrings(void); |
86 | 86 |
|
87 | 87 | /* Use only if you know it's a string */ |
88 | | -#define PyBytes_CHECK_INTERNED(op) (((PyBytesObject *)(op))->ob_sstate) |
| 88 | +#define PyString_CHECK_INTERNED(op) (((PyStringObject *)(op))->ob_sstate) |
89 | 89 |
|
90 | 90 | /* Macro, trading safety for speed */ |
91 | | -#define PyBytes_AS_STRING(op) (((PyBytesObject *)(op))->ob_sval) |
92 | | -#define PyBytes_GET_SIZE(op) Py_SIZE(op) |
| 91 | +#define PyString_AS_STRING(op) (((PyStringObject *)(op))->ob_sval) |
| 92 | +#define PyString_GET_SIZE(op) Py_SIZE(op) |
93 | 93 |
|
94 | | -/* _PyBytes_Join(sep, x) is like sep.join(x). sep must be PyBytesObject*, |
| 94 | +/* _PyString_Join(sep, x) is like sep.join(x). sep must be PyStringObject*, |
95 | 95 | x must be an iterable object. */ |
96 | | -PyAPI_FUNC(PyObject *) _PyBytes_Join(PyObject *sep, PyObject *x); |
| 96 | +PyAPI_FUNC(PyObject *) _PyString_Join(PyObject *sep, PyObject *x); |
97 | 97 |
|
98 | 98 | /* --- Generic Codecs ----------------------------------------------------- */ |
99 | 99 |
|
100 | 100 | /* Create an object by decoding the encoded string s of the |
101 | 101 | given size. */ |
102 | 102 |
|
103 | | -PyAPI_FUNC(PyObject*) PyBytes_Decode( |
| 103 | +PyAPI_FUNC(PyObject*) PyString_Decode( |
104 | 104 | const char *s, /* encoded string */ |
105 | 105 | Py_ssize_t size, /* size of buffer */ |
106 | 106 | const char *encoding, /* encoding */ |
@@ -110,7 +110,7 @@ PyAPI_FUNC(PyObject*) PyBytes_Decode( |
110 | 110 | /* Encodes a char buffer of the given size and returns a |
111 | 111 | Python object. */ |
112 | 112 |
|
113 | | -PyAPI_FUNC(PyObject*) PyBytes_Encode( |
| 113 | +PyAPI_FUNC(PyObject*) PyString_Encode( |
114 | 114 | const char *s, /* string char buffer */ |
115 | 115 | Py_ssize_t size, /* number of chars to encode */ |
116 | 116 | const char *encoding, /* encoding */ |
@@ -120,7 +120,7 @@ PyAPI_FUNC(PyObject*) PyBytes_Encode( |
120 | 120 | /* Encodes a string object and returns the result as Python |
121 | 121 | object. */ |
122 | 122 |
|
123 | | -PyAPI_FUNC(PyObject*) PyBytes_AsEncodedObject( |
| 123 | +PyAPI_FUNC(PyObject*) PyString_AsEncodedObject( |
124 | 124 | PyObject *str, /* string object */ |
125 | 125 | const char *encoding, /* encoding */ |
126 | 126 | const char *errors /* error handling */ |
@@ -132,9 +132,9 @@ PyAPI_FUNC(PyObject*) PyBytes_AsEncodedObject( |
132 | 132 | If the codec returns an Unicode object, the object is converted |
133 | 133 | back to a string using the default encoding. |
134 | 134 |
|
135 | | - DEPRECATED - use PyBytes_AsEncodedObject() instead. */ |
| 135 | + DEPRECATED - use PyString_AsEncodedObject() instead. */ |
136 | 136 |
|
137 | | -PyAPI_FUNC(PyObject*) PyBytes_AsEncodedString( |
| 137 | +PyAPI_FUNC(PyObject*) PyString_AsEncodedString( |
138 | 138 | PyObject *str, /* string object */ |
139 | 139 | const char *encoding, /* encoding */ |
140 | 140 | const char *errors /* error handling */ |
@@ -143,7 +143,7 @@ PyAPI_FUNC(PyObject*) PyBytes_AsEncodedString( |
143 | 143 | /* Decodes a string object and returns the result as Python |
144 | 144 | object. */ |
145 | 145 |
|
146 | | -PyAPI_FUNC(PyObject*) PyBytes_AsDecodedObject( |
| 146 | +PyAPI_FUNC(PyObject*) PyString_AsDecodedObject( |
147 | 147 | PyObject *str, /* string object */ |
148 | 148 | const char *encoding, /* encoding */ |
149 | 149 | const char *errors /* error handling */ |
@@ -155,9 +155,9 @@ PyAPI_FUNC(PyObject*) PyBytes_AsDecodedObject( |
155 | 155 | If the codec returns an Unicode object, the object is converted |
156 | 156 | back to a string using the default encoding. |
157 | 157 |
|
158 | | - DEPRECATED - use PyBytes_AsDecodedObject() instead. */ |
| 158 | + DEPRECATED - use PyString_AsDecodedObject() instead. */ |
159 | 159 |
|
160 | | -PyAPI_FUNC(PyObject*) PyBytes_AsDecodedString( |
| 160 | +PyAPI_FUNC(PyObject*) PyString_AsDecodedString( |
161 | 161 | PyObject *str, /* string object */ |
162 | 162 | const char *encoding, /* encoding */ |
163 | 163 | const char *errors /* error handling */ |
@@ -169,7 +169,7 @@ PyAPI_FUNC(PyObject*) PyBytes_AsDecodedString( |
169 | 169 | 0-terminated (passing a string with embedded NULL characters will |
170 | 170 | cause an exception). */ |
171 | 171 |
|
172 | | -PyAPI_FUNC(int) PyBytes_AsStringAndSize( |
| 172 | +PyAPI_FUNC(int) PyString_AsStringAndSize( |
173 | 173 | register PyObject *obj, /* string or Unicode object */ |
174 | 174 | register char **s, /* pointer to buffer variable */ |
175 | 175 | register Py_ssize_t *len /* pointer to length variable or NULL |
@@ -181,7 +181,7 @@ PyAPI_FUNC(int) PyBytes_AsStringAndSize( |
181 | 181 | into the string pointed to by buffer. For the argument descriptions, |
182 | 182 | see Objects/stringlib/localeutil.h */ |
183 | 183 |
|
184 | | -PyAPI_FUNC(int) _PyBytes_InsertThousandsGrouping(char *buffer, |
| 184 | +PyAPI_FUNC(int) _PyString_InsertThousandsGrouping(char *buffer, |
185 | 185 | Py_ssize_t len, |
186 | 186 | char *plast, |
187 | 187 | Py_ssize_t buf_size, |
|