Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

bytearrayobject.h 2.1 KB

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
  1. /* ByteArray object interface */
  2. #ifndef Py_BYTEARRAYOBJECT_H
  3. #define Py_BYTEARRAYOBJECT_H
  4. #ifdef __cplusplus
  5. extern "C" {
  6. #endif
  7. #include <stdarg.h>
  8. /* Type PyByteArrayObject represents a mutable array of bytes.
  9. * The Python API is that of a sequence;
  10. * the bytes are mapped to ints in [0, 256).
  11. * Bytes are not characters; they may be used to encode characters.
  12. * The only way to go between bytes and str/unicode is via encoding
  13. * and decoding.
  14. * For the convenience of C programmers, the bytes type is considered
  15. * to contain a char pointer, not an unsigned char pointer.
  16. */
  17. /* Object layout */
  18. #ifndef Py_LIMITED_API
  19. typedef struct {
  20. PyObject_VAR_HEAD
  21. Py_ssize_t ob_alloc; /* How many bytes allocated in ob_bytes */
  22. char *ob_bytes; /* Physical backing buffer */
  23. char *ob_start; /* Logical start inside ob_bytes */
  24. /* XXX(nnorwitz): should ob_exports be Py_ssize_t? */
  25. int ob_exports; /* How many buffer exports */
  26. } PyByteArrayObject;
  27. #endif
  28. /* Type object */
  29. PyAPI_DATA(PyTypeObject) PyByteArray_Type;
  30. PyAPI_DATA(PyTypeObject) PyByteArrayIter_Type;
  31. /* Type check macros */
  32. #define PyByteArray_Check(self) PyObject_TypeCheck(self, &PyByteArray_Type)
  33. #define PyByteArray_CheckExact(self) (Py_TYPE(self) == &PyByteArray_Type)
  34. /* Direct API functions */
  35. PyAPI_FUNC(PyObject *) PyByteArray_FromObject(PyObject *);
  36. PyAPI_FUNC(PyObject *) PyByteArray_Concat(PyObject *, PyObject *);
  37. PyAPI_FUNC(PyObject *) PyByteArray_FromStringAndSize(const char *, Py_ssize_t);
  38. PyAPI_FUNC(Py_ssize_t) PyByteArray_Size(PyObject *);
  39. PyAPI_FUNC(char *) PyByteArray_AsString(PyObject *);
  40. PyAPI_FUNC(int) PyByteArray_Resize(PyObject *, Py_ssize_t);
  41. /* Macros, trading safety for speed */
  42. #ifndef Py_LIMITED_API
  43. #define PyByteArray_AS_STRING(self) \
  44. (assert(PyByteArray_Check(self)), \
  45. Py_SIZE(self) ? ((PyByteArrayObject *)(self))->ob_start : _PyByteArray_empty_string)
  46. #define PyByteArray_GET_SIZE(self) (assert(PyByteArray_Check(self)), Py_SIZE(self))
  47. PyAPI_DATA(char) _PyByteArray_empty_string[];
  48. #endif
  49. #ifdef __cplusplus
  50. }
  51. #endif
  52. #endif /* !Py_BYTEARRAYOBJECT_H */
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...