Mercurial > cpython-lru_cache-weakref
annotate Include/bytesobject.h @ 42821:bb288e04b8e5
Fix typo in comment
| author | Neal Norwitz <nnorwitz@gmail.com> |
|---|---|
| date | Sat, 25 Aug 2007 05:22:02 +0000 |
| parents | 2c51be9904de |
| children | 0cc552ab76bd |
| rev | line source |
|---|---|
|
37927
a7f3765ea464
Here is a bytes type. It's very minimal but it's a start.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1 /* Bytes object interface */ |
|
a7f3765ea464
Here is a bytes type. It's very minimal but it's a start.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
2 |
|
a7f3765ea464
Here is a bytes type. It's very minimal but it's a start.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
3 #ifndef Py_BYTESOBJECT_H |
|
a7f3765ea464
Here is a bytes type. It's very minimal but it's a start.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
4 #define Py_BYTESOBJECT_H |
|
a7f3765ea464
Here is a bytes type. It's very minimal but it's a start.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
5 #ifdef __cplusplus |
|
a7f3765ea464
Here is a bytes type. It's very minimal but it's a start.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
6 extern "C" { |
|
a7f3765ea464
Here is a bytes type. It's very minimal but it's a start.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
7 #endif |
|
a7f3765ea464
Here is a bytes type. It's very minimal but it's a start.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
8 |
|
a7f3765ea464
Here is a bytes type. It's very minimal but it's a start.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
9 #include <stdarg.h> |
|
a7f3765ea464
Here is a bytes type. It's very minimal but it's a start.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
10 |
|
a7f3765ea464
Here is a bytes type. It's very minimal but it's a start.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
11 /* Type PyBytesObject represents a mutable array of bytes. |
|
a7f3765ea464
Here is a bytes type. It's very minimal but it's a start.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
12 * The Python API is that of a sequence; |
|
a7f3765ea464
Here is a bytes type. It's very minimal but it's a start.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
13 * the bytes are mapped to ints in [0, 256). |
|
a7f3765ea464
Here is a bytes type. It's very minimal but it's a start.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
14 * Bytes are not characters; they may be used to encode characters. |
|
a7f3765ea464
Here is a bytes type. It's very minimal but it's a start.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
15 * The only way to go between bytes and str/unicode is via encoding |
|
a7f3765ea464
Here is a bytes type. It's very minimal but it's a start.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
16 * and decoding. |
| 42821 | 17 * For the convenience of C programmers, the bytes type is considered |
|
37927
a7f3765ea464
Here is a bytes type. It's very minimal but it's a start.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
18 * to contain a char pointer, not an unsigned char pointer. |
|
a7f3765ea464
Here is a bytes type. It's very minimal but it's a start.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
19 */ |
|
a7f3765ea464
Here is a bytes type. It's very minimal but it's a start.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
20 |
|
a7f3765ea464
Here is a bytes type. It's very minimal but it's a start.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
21 /* Object layout */ |
|
a7f3765ea464
Here is a bytes type. It's very minimal but it's a start.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
22 typedef struct { |
|
a7f3765ea464
Here is a bytes type. It's very minimal but it's a start.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
23 PyObject_VAR_HEAD |
|
42669
2c51be9904de
Code review of the new buffer protocol. Mostly add questions that should
Neal Norwitz <nnorwitz@gmail.com>
parents:
42665
diff
changeset
|
24 /* XXX(nnorwitz): should ob_exports be Py_ssize_t? */ |
|
42665
85c22b4d4455
Merged in py3k-buffer branch to main line. All objects now use the buffer protocol in PEP 3118.
Travis E. Oliphant <oliphant@enthought.com>
parents:
42335
diff
changeset
|
25 int ob_exports; /* how many buffer exports */ |
|
38115
a6a1359aab84
Optimizations for bytes reallocation.
Guido van Rossum <guido@python.org>
parents:
37960
diff
changeset
|
26 Py_ssize_t ob_alloc; /* How many bytes allocated */ |
|
37960
e0b7e34b5971
Added much functionality to the bytes type.
Guido van Rossum <guido@python.org>
parents:
37927
diff
changeset
|
27 char *ob_bytes; |
|
37927
a7f3765ea464
Here is a bytes type. It's very minimal but it's a start.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
28 } PyBytesObject; |
|
a7f3765ea464
Here is a bytes type. It's very minimal but it's a start.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
29 |
|
a7f3765ea464
Here is a bytes type. It's very minimal but it's a start.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
30 /* Type object */ |
|
a7f3765ea464
Here is a bytes type. It's very minimal but it's a start.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
31 PyAPI_DATA(PyTypeObject) PyBytes_Type; |
|
a7f3765ea464
Here is a bytes type. It's very minimal but it's a start.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
32 |
|
a7f3765ea464
Here is a bytes type. It's very minimal but it's a start.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
33 /* Type check macros */ |
|
a7f3765ea464
Here is a bytes type. It's very minimal but it's a start.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
34 #define PyBytes_Check(self) PyObject_TypeCheck(self, &PyBytes_Type) |
|
42334
e70cdce0e8b2
Merged revisions 56467-56482 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
42091
diff
changeset
|
35 #define PyBytes_CheckExact(self) (Py_Type(self) == &PyBytes_Type) |
|
37927
a7f3765ea464
Here is a bytes type. It's very minimal but it's a start.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
36 |
|
a7f3765ea464
Here is a bytes type. It's very minimal but it's a start.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
37 /* Direct API functions */ |
|
37960
e0b7e34b5971
Added much functionality to the bytes type.
Guido van Rossum <guido@python.org>
parents:
37927
diff
changeset
|
38 PyAPI_FUNC(PyObject *) PyBytes_FromObject(PyObject *); |
|
41450
d1c3dd184e38
Rough and dirty job -- allow concatenation of bytes and arbitrary
Guido van Rossum <guido@python.org>
parents:
38115
diff
changeset
|
39 PyAPI_FUNC(PyObject *) PyBytes_Concat(PyObject *, PyObject *); |
|
37927
a7f3765ea464
Here is a bytes type. It's very minimal but it's a start.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
40 PyAPI_FUNC(PyObject *) PyBytes_FromStringAndSize(const char *, Py_ssize_t); |
|
a7f3765ea464
Here is a bytes type. It's very minimal but it's a start.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
41 PyAPI_FUNC(Py_ssize_t) PyBytes_Size(PyObject *); |
|
a7f3765ea464
Here is a bytes type. It's very minimal but it's a start.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
42 PyAPI_FUNC(char *) PyBytes_AsString(PyObject *); |
|
a7f3765ea464
Here is a bytes type. It's very minimal but it's a start.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
43 PyAPI_FUNC(int) PyBytes_Resize(PyObject *, Py_ssize_t); |
|
a7f3765ea464
Here is a bytes type. It's very minimal but it's a start.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
44 |
|
a7f3765ea464
Here is a bytes type. It's very minimal but it's a start.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
45 /* Macros, trading safety for speed */ |
|
42091
72fc7d029d3d
Add asserts to PyBytes_AS_STRING and PyBytes_GET_SIZE.
Guido van Rossum <guido@python.org>
parents:
41450
diff
changeset
|
46 #define PyBytes_AS_STRING(self) (assert(PyBytes_Check(self)),((PyBytesObject *)(self))->ob_bytes) |
| 42335 | 47 #define PyBytes_GET_SIZE(self) (assert(PyBytes_Check(self)),Py_Size(self)) |
|
37927
a7f3765ea464
Here is a bytes type. It's very minimal but it's a start.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
48 |
|
a7f3765ea464
Here is a bytes type. It's very minimal but it's a start.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
49 #ifdef __cplusplus |
|
a7f3765ea464
Here is a bytes type. It's very minimal but it's a start.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
50 } |
|
a7f3765ea464
Here is a bytes type. It's very minimal but it's a start.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
51 #endif |
|
a7f3765ea464
Here is a bytes type. It's very minimal but it's a start.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
52 #endif /* !Py_BYTESOBJECT_H */ |
