OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Declarations shared between the different parts of the io module |
| 3 */ |
| 4 |
| 5 /* ABCs */ |
| 6 extern PyTypeObject PyIOBase_Type; |
| 7 extern PyTypeObject PyRawIOBase_Type; |
| 8 extern PyTypeObject PyBufferedIOBase_Type; |
| 9 extern PyTypeObject PyTextIOBase_Type; |
| 10 |
| 11 /* Concrete classes */ |
| 12 extern PyTypeObject PyFileIO_Type; |
| 13 extern PyTypeObject PyBytesIO_Type; |
| 14 extern PyTypeObject PyStringIO_Type; |
| 15 extern PyTypeObject PyBufferedReader_Type; |
| 16 extern PyTypeObject PyBufferedWriter_Type; |
| 17 extern PyTypeObject PyBufferedRWPair_Type; |
| 18 extern PyTypeObject PyBufferedRandom_Type; |
| 19 extern PyTypeObject PyTextIOWrapper_Type; |
| 20 extern PyTypeObject PyIncrementalNewlineDecoder_Type; |
| 21 |
| 22 /* These functions are used as METH_NOARGS methods, are normally called |
| 23 * with args=NULL, and return a new reference. |
| 24 * BUT when args=Py_True is passed, they return a borrowed reference. |
| 25 */ |
| 26 extern PyObject* _PyIOBase_checkReadable(PyObject *self, PyObject *args); |
| 27 extern PyObject* _PyIOBase_checkWritable(PyObject *self, PyObject *args); |
| 28 extern PyObject* _PyIOBase_checkSeekable(PyObject *self, PyObject *args); |
| 29 extern PyObject* _PyIOBase_checkClosed(PyObject *self, PyObject *args); |
| 30 |
| 31 /* Helper for finalization. |
| 32 This function will revive an object ready to be deallocated and try to |
| 33 close() it. It returns 0 if the object can be destroyed, or -1 if it |
| 34 is alive again. */ |
| 35 extern int _PyIOBase_finalize(PyObject *self); |
| 36 |
| 37 /* Returns true if the given FileIO object is closed. |
| 38 Doesn't check the argument type, so be careful! */ |
| 39 extern int _PyFileIO_closed(PyObject *self); |
| 40 |
| 41 /* Shortcut to the core of the IncrementalNewlineDecoder.decode method */ |
| 42 extern PyObject *_PyIncrementalNewlineDecoder_decode( |
| 43 PyObject *self, PyObject *input, int final); |
| 44 |
| 45 /* Finds the first line ending between `start` and `end`. |
| 46 If found, returns the index after the line ending and doesn't touch |
| 47 `*consumed`. |
| 48 If not found, returns -1 and sets `*consumed` to the number of characters |
| 49 which can be safely put aside until another search. |
| 50 ··· |
| 51 NOTE: for performance reasons, `end` must point to a NUL character ('\0').· |
| 52 Otherwise, the function will scan further and return garbage. */ |
| 53 extern Py_ssize_t _PyIO_find_line_ending( |
| 54 int translated, int universal, PyObject *readnl, |
| 55 Py_UNICODE *start, Py_UNICODE *end, Py_ssize_t *consumed); |
| 56 |
| 57 |
| 58 #define DEFAULT_BUFFER_SIZE (8 * 1024) /* bytes */ |
| 59 |
| 60 typedef struct { |
| 61 PyException_HEAD |
| 62 PyObject *myerrno; |
| 63 PyObject *strerror; |
| 64 PyObject *filename; /* Not used, but part of the IOError object */ |
| 65 Py_ssize_t written; |
| 66 } PyBlockingIOErrorObject; |
| 67 PyObject *PyExc_BlockingIOError; |
| 68 |
| 69 /* |
| 70 * Offset type for positioning. |
| 71 */ |
| 72 |
| 73 #if defined(MS_WIN64) || defined(MS_WINDOWS) |
| 74 |
| 75 /* Windows uses long long for offsets */ |
| 76 typedef PY_LONG_LONG Py_off_t; |
| 77 # define PyLong_AsOff_t PyLong_AsLongLong |
| 78 # define PyLong_FromOff_t PyLong_FromLongLong |
| 79 # define PY_OFF_T_MAX PY_LLONG_MAX |
| 80 # define PY_OFF_T_MIN PY_LLONG_MIN |
| 81 |
| 82 #else |
| 83 |
| 84 /* Other platforms use off_t */ |
| 85 typedef off_t Py_off_t; |
| 86 #if (SIZEOF_OFF_T == SIZEOF_SIZE_T) |
| 87 # define PyLong_AsOff_t PyLong_AsSsize_t |
| 88 # define PyLong_FromOff_t PyLong_FromSsize_t |
| 89 # define PY_OFF_T_MAX PY_SSIZE_T_MAX |
| 90 # define PY_OFF_T_MIN PY_SSIZE_T_MIN |
| 91 #elif (SIZEOF_OFF_T == SIZEOF_LONG_LONG) |
| 92 # define PyLong_AsOff_t PyLong_AsLongLong |
| 93 # define PyLong_FromOff_t PyLong_FromLongLong |
| 94 # define PY_OFF_T_MAX PY_LLONG_MAX |
| 95 # define PY_OFF_T_MIN PY_LLONG_MIN |
| 96 #elif (SIZEOF_OFF_T == SIZEOF_LONG) |
| 97 # define PyLong_AsOff_t PyLong_AsLong |
| 98 # define PyLong_FromOff_t PyLong_FromLong |
| 99 # define PY_OFF_T_MAX LONG_MAX |
| 100 # define PY_OFF_T_MIN LONG_MIN |
| 101 #else |
| 102 # error off_t does not match either size_t, long, or long long! |
| 103 #endif |
| 104 |
| 105 #endif |
| 106 |
| 107 extern Py_off_t PyNumber_AsOff_t(PyObject *item, PyObject *err); |
| 108 |
| 109 /* Implementation details */ |
| 110 |
| 111 /* IO module structure */ |
| 112 |
| 113 extern PyModuleDef _PyIO_Module; |
| 114 |
| 115 typedef struct { |
| 116 int initialized; |
| 117 PyObject *os_module; |
| 118 PyObject *locale_module; |
| 119 |
| 120 PyObject *unsupported_operation; |
| 121 } _PyIO_State; |
| 122 |
| 123 #define IO_MOD_STATE(mod) ((_PyIO_State *)PyModule_GetState(mod)) |
| 124 #define IO_STATE IO_MOD_STATE(PyState_FindModule(&_PyIO_Module)) |
| 125 |
| 126 extern PyObject *_PyIO_str_close; |
| 127 extern PyObject *_PyIO_str_closed; |
| 128 extern PyObject *_PyIO_str_decode; |
| 129 extern PyObject *_PyIO_str_encode; |
| 130 extern PyObject *_PyIO_str_fileno; |
| 131 extern PyObject *_PyIO_str_flush; |
| 132 extern PyObject *_PyIO_str_getstate; |
| 133 extern PyObject *_PyIO_str_isatty; |
| 134 extern PyObject *_PyIO_str_newlines; |
| 135 extern PyObject *_PyIO_str_nl; |
| 136 extern PyObject *_PyIO_str_read; |
| 137 extern PyObject *_PyIO_str_read1; |
| 138 extern PyObject *_PyIO_str_readable; |
| 139 extern PyObject *_PyIO_str_readinto; |
| 140 extern PyObject *_PyIO_str_readline; |
| 141 extern PyObject *_PyIO_str_reset; |
| 142 extern PyObject *_PyIO_str_seek; |
| 143 extern PyObject *_PyIO_str_seekable; |
| 144 extern PyObject *_PyIO_str_tell; |
| 145 extern PyObject *_PyIO_str_truncate; |
| 146 extern PyObject *_PyIO_str_writable; |
| 147 extern PyObject *_PyIO_str_write; |
| 148 |
| 149 extern PyObject *_PyIO_empty_str; |
| 150 extern PyObject *_PyIO_empty_bytes; |
OLD | NEW |