Damien George | 04b9147 | 2014-05-03 23:27:38 +0100 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the Micro Python project, http://micropython.org/ |
| 3 | * |
| 4 | * The MIT License (MIT) |
| 5 | * |
| 6 | * Copyright (c) 2013, 2014 Damien P. George |
Paul Sokolovsky | da9f092 | 2014-05-13 08:44:45 +0300 | [diff] [blame] | 7 | * Copyright (c) 2014 Paul Sokolovsky |
Damien George | 04b9147 | 2014-05-03 23:27:38 +0100 | [diff] [blame] | 8 | * |
| 9 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
| 10 | * of this software and associated documentation files (the "Software"), to deal |
| 11 | * in the Software without restriction, including without limitation the rights |
| 12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 13 | * copies of the Software, and to permit persons to whom the Software is |
| 14 | * furnished to do so, subject to the following conditions: |
| 15 | * |
| 16 | * The above copyright notice and this permission notice shall be included in |
| 17 | * all copies or substantial portions of the Software. |
| 18 | * |
| 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
| 25 | * THE SOFTWARE. |
| 26 | */ |
| 27 | |
Ilya Dmitrichenko | 5630b01 | 2014-04-12 16:44:32 +0100 | [diff] [blame] | 28 | #include <string.h> |
Paul Sokolovsky | e98cf40 | 2014-01-08 02:43:48 +0200 | [diff] [blame] | 29 | |
Paul Sokolovsky | f54bcbf | 2014-05-02 17:47:01 +0300 | [diff] [blame] | 30 | #include "mpconfig.h" |
Paul Sokolovsky | e98cf40 | 2014-01-08 02:43:48 +0200 | [diff] [blame] | 31 | #include "nlr.h" |
| 32 | #include "misc.h" |
Damien George | 55baff4 | 2014-01-21 21:40:13 +0000 | [diff] [blame] | 33 | #include "qstr.h" |
Paul Sokolovsky | e98cf40 | 2014-01-08 02:43:48 +0200 | [diff] [blame] | 34 | #include "obj.h" |
Paul Sokolovsky | a47b64a | 2014-05-15 07:28:19 +0300 | [diff] [blame] | 35 | #include "objstr.h" |
Paul Sokolovsky | f5f6c3b | 2014-06-15 23:23:36 +0300 | [diff] [blame] | 36 | #include "runtime.h" |
Paul Sokolovsky | e98cf40 | 2014-01-08 02:43:48 +0200 | [diff] [blame] | 37 | #include "stream.h" |
Paul Sokolovsky | 0ef015b | 2014-05-07 02:23:46 +0300 | [diff] [blame] | 38 | #if MICROPY_STREAMS_NON_BLOCK |
| 39 | #include <errno.h> |
stijn | ec6fa87 | 2014-06-28 21:04:20 +0200 | [diff] [blame] | 40 | #if defined(__MINGW32__) && !defined(__MINGW64_VERSION_MAJOR) |
| 41 | #define EWOULDBLOCK 140 |
| 42 | #endif |
Paul Sokolovsky | 0ef015b | 2014-05-07 02:23:46 +0300 | [diff] [blame] | 43 | #endif |
Paul Sokolovsky | e98cf40 | 2014-01-08 02:43:48 +0200 | [diff] [blame] | 44 | |
| 45 | // This file defines generic Python stream read/write methods which |
| 46 | // dispatch to the underlying stream interface of an object. |
| 47 | |
Paul Sokolovsky | b9be45e | 2014-05-07 01:51:07 +0300 | [diff] [blame] | 48 | // TODO: should be in mpconfig.h |
| 49 | #define DEFAULT_BUFFER_SIZE 256 |
| 50 | |
Paul Sokolovsky | 520e2f5 | 2014-02-12 18:31:30 +0200 | [diff] [blame] | 51 | STATIC mp_obj_t stream_readall(mp_obj_t self_in); |
Paul Sokolovsky | a671f89 | 2014-01-16 12:53:46 +0200 | [diff] [blame] | 52 | |
Paul Sokolovsky | 0ef015b | 2014-05-07 02:23:46 +0300 | [diff] [blame] | 53 | #if MICROPY_STREAMS_NON_BLOCK |
Paul Sokolovsky | a592104 | 2014-05-07 01:39:38 +0300 | [diff] [blame] | 54 | // TODO: This is POSIX-specific (but then POSIX is the only real thing, |
| 55 | // and anything else just emulates it, right?) |
| 56 | #define is_nonblocking_error(errno) ((errno) == EAGAIN || (errno) == EWOULDBLOCK) |
Paul Sokolovsky | 0ef015b | 2014-05-07 02:23:46 +0300 | [diff] [blame] | 57 | #else |
| 58 | #define is_nonblocking_error(errno) (0) |
| 59 | #endif |
Paul Sokolovsky | a592104 | 2014-05-07 01:39:38 +0300 | [diff] [blame] | 60 | |
Paul Sokolovsky | a47b64a | 2014-05-15 07:28:19 +0300 | [diff] [blame] | 61 | #define STREAM_CONTENT_TYPE(stream) (((stream)->is_bytes) ? &mp_type_bytes : &mp_type_str) |
| 62 | |
Paul Sokolovsky | 520e2f5 | 2014-02-12 18:31:30 +0200 | [diff] [blame] | 63 | STATIC mp_obj_t stream_read(uint n_args, const mp_obj_t *args) { |
Paul Sokolovsky | a671f89 | 2014-01-16 12:53:46 +0200 | [diff] [blame] | 64 | struct _mp_obj_base_t *o = (struct _mp_obj_base_t *)args[0]; |
Damien George | 27e735f | 2014-04-05 23:02:23 +0100 | [diff] [blame] | 65 | if (o->type->stream_p == NULL || o->type->stream_p->read == NULL) { |
Paul Sokolovsky | e98cf40 | 2014-01-08 02:43:48 +0200 | [diff] [blame] | 66 | // CPython: io.UnsupportedOperation, OSError subclass |
Damien George | ea13f40 | 2014-04-05 18:32:08 +0100 | [diff] [blame] | 67 | nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, "Operation not supported")); |
Paul Sokolovsky | e98cf40 | 2014-01-08 02:43:48 +0200 | [diff] [blame] | 68 | } |
| 69 | |
Damien George | 40f3c02 | 2014-07-03 13:25:24 +0100 | [diff] [blame^] | 70 | mp_int_t sz; |
Paul Sokolovsky | a671f89 | 2014-01-16 12:53:46 +0200 | [diff] [blame] | 71 | if (n_args == 1 || ((sz = mp_obj_get_int(args[1])) == -1)) { |
| 72 | return stream_readall(args[0]); |
| 73 | } |
Paul Sokolovsky | f5f6c3b | 2014-06-15 23:23:36 +0300 | [diff] [blame] | 74 | |
| 75 | #if MICROPY_PY_BUILTINS_STR_UNICODE |
| 76 | if (!o->type->stream_p->is_bytes) { |
| 77 | mp_not_implemented("Reading from unicode text streams by character count"); |
| 78 | } |
| 79 | #endif |
| 80 | |
Damien George | 5fa93b6 | 2014-01-22 14:35:10 +0000 | [diff] [blame] | 81 | byte *buf = m_new(byte, sz); |
Paul Sokolovsky | e98cf40 | 2014-01-08 02:43:48 +0200 | [diff] [blame] | 82 | int error; |
Damien George | 40f3c02 | 2014-07-03 13:25:24 +0100 | [diff] [blame^] | 83 | mp_int_t out_sz = o->type->stream_p->read(o, buf, sz, &error); |
Paul Sokolovsky | e98cf40 | 2014-01-08 02:43:48 +0200 | [diff] [blame] | 84 | if (out_sz == -1) { |
Paul Sokolovsky | a592104 | 2014-05-07 01:39:38 +0300 | [diff] [blame] | 85 | if (is_nonblocking_error(error)) { |
| 86 | // https://docs.python.org/3.4/library/io.html#io.RawIOBase.read |
| 87 | // "If the object is in non-blocking mode and no bytes are available, |
| 88 | // None is returned." |
| 89 | // This is actually very weird, as naive truth check will treat |
| 90 | // this as EOF. |
| 91 | return mp_const_none; |
| 92 | } |
Damien George | ea13f40 | 2014-04-05 18:32:08 +0100 | [diff] [blame] | 93 | nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError, "[Errno %d]", error)); |
Paul Sokolovsky | e98cf40 | 2014-01-08 02:43:48 +0200 | [diff] [blame] | 94 | } else { |
Damien George | f600a6a | 2014-05-25 22:34:34 +0100 | [diff] [blame] | 95 | mp_obj_t s = mp_obj_new_str_of_type(STREAM_CONTENT_TYPE(o->type->stream_p), buf, out_sz); // will reallocate to use exact size |
Damien George | 5fa93b6 | 2014-01-22 14:35:10 +0000 | [diff] [blame] | 96 | m_free(buf, sz); |
| 97 | return s; |
Paul Sokolovsky | e98cf40 | 2014-01-08 02:43:48 +0200 | [diff] [blame] | 98 | } |
| 99 | } |
| 100 | |
Paul Sokolovsky | 520e2f5 | 2014-02-12 18:31:30 +0200 | [diff] [blame] | 101 | STATIC mp_obj_t stream_write(mp_obj_t self_in, mp_obj_t arg) { |
Paul Sokolovsky | e98cf40 | 2014-01-08 02:43:48 +0200 | [diff] [blame] | 102 | struct _mp_obj_base_t *o = (struct _mp_obj_base_t *)self_in; |
Damien George | 27e735f | 2014-04-05 23:02:23 +0100 | [diff] [blame] | 103 | if (o->type->stream_p == NULL || o->type->stream_p->write == NULL) { |
Paul Sokolovsky | e98cf40 | 2014-01-08 02:43:48 +0200 | [diff] [blame] | 104 | // CPython: io.UnsupportedOperation, OSError subclass |
Damien George | ea13f40 | 2014-04-05 18:32:08 +0100 | [diff] [blame] | 105 | nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, "Operation not supported")); |
Paul Sokolovsky | e98cf40 | 2014-01-08 02:43:48 +0200 | [diff] [blame] | 106 | } |
| 107 | |
Paul Sokolovsky | 45fb143 | 2014-04-26 05:46:06 +0300 | [diff] [blame] | 108 | mp_buffer_info_t bufinfo; |
| 109 | mp_get_buffer_raise(arg, &bufinfo, MP_BUFFER_READ); |
| 110 | |
Paul Sokolovsky | e98cf40 | 2014-01-08 02:43:48 +0200 | [diff] [blame] | 111 | int error; |
Damien George | 40f3c02 | 2014-07-03 13:25:24 +0100 | [diff] [blame^] | 112 | mp_int_t out_sz = o->type->stream_p->write(self_in, bufinfo.buf, bufinfo.len, &error); |
Paul Sokolovsky | e98cf40 | 2014-01-08 02:43:48 +0200 | [diff] [blame] | 113 | if (out_sz == -1) { |
Paul Sokolovsky | a592104 | 2014-05-07 01:39:38 +0300 | [diff] [blame] | 114 | if (is_nonblocking_error(error)) { |
| 115 | // http://docs.python.org/3/library/io.html#io.RawIOBase.write |
| 116 | // "None is returned if the raw stream is set not to block and |
| 117 | // no single byte could be readily written to it." |
| 118 | // This is for consistency with read() behavior, still weird, |
| 119 | // see abobe. |
| 120 | return mp_const_none; |
| 121 | } |
Damien George | ea13f40 | 2014-04-05 18:32:08 +0100 | [diff] [blame] | 122 | nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError, "[Errno %d]", error)); |
Paul Sokolovsky | e98cf40 | 2014-01-08 02:43:48 +0200 | [diff] [blame] | 123 | } else { |
Paul Sokolovsky | e98cf40 | 2014-01-08 02:43:48 +0200 | [diff] [blame] | 124 | return MP_OBJ_NEW_SMALL_INT(out_sz); |
| 125 | } |
| 126 | } |
| 127 | |
Paul Sokolovsky | 520e2f5 | 2014-02-12 18:31:30 +0200 | [diff] [blame] | 128 | STATIC mp_obj_t stream_readall(mp_obj_t self_in) { |
Paul Sokolovsky | 5225450 | 2014-01-13 23:25:33 +0200 | [diff] [blame] | 129 | struct _mp_obj_base_t *o = (struct _mp_obj_base_t *)self_in; |
Damien George | 27e735f | 2014-04-05 23:02:23 +0100 | [diff] [blame] | 130 | if (o->type->stream_p == NULL || o->type->stream_p->read == NULL) { |
Paul Sokolovsky | 5225450 | 2014-01-13 23:25:33 +0200 | [diff] [blame] | 131 | // CPython: io.UnsupportedOperation, OSError subclass |
Damien George | ea13f40 | 2014-04-05 18:32:08 +0100 | [diff] [blame] | 132 | nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, "Operation not supported")); |
Paul Sokolovsky | 5225450 | 2014-01-13 23:25:33 +0200 | [diff] [blame] | 133 | } |
| 134 | |
| 135 | int total_size = 0; |
Paul Sokolovsky | b9be45e | 2014-05-07 01:51:07 +0300 | [diff] [blame] | 136 | vstr_t *vstr = vstr_new_size(DEFAULT_BUFFER_SIZE); |
Paul Sokolovsky | 5225450 | 2014-01-13 23:25:33 +0200 | [diff] [blame] | 137 | char *buf = vstr_str(vstr); |
| 138 | char *p = buf; |
| 139 | int error; |
Paul Sokolovsky | b9be45e | 2014-05-07 01:51:07 +0300 | [diff] [blame] | 140 | int current_read = DEFAULT_BUFFER_SIZE; |
Paul Sokolovsky | 5225450 | 2014-01-13 23:25:33 +0200 | [diff] [blame] | 141 | while (true) { |
Damien George | 40f3c02 | 2014-07-03 13:25:24 +0100 | [diff] [blame^] | 142 | mp_int_t out_sz = o->type->stream_p->read(self_in, p, current_read, &error); |
Paul Sokolovsky | 5225450 | 2014-01-13 23:25:33 +0200 | [diff] [blame] | 143 | if (out_sz == -1) { |
Paul Sokolovsky | 6e73143 | 2014-05-07 01:48:12 +0300 | [diff] [blame] | 144 | if (is_nonblocking_error(error)) { |
| 145 | // With non-blocking streams, we read as much as we can. |
| 146 | // If we read nothing, return None, just like read(). |
| 147 | // Otherwise, return data read so far. |
| 148 | if (total_size == 0) { |
| 149 | return mp_const_none; |
| 150 | } |
| 151 | break; |
| 152 | } |
Damien George | ea13f40 | 2014-04-05 18:32:08 +0100 | [diff] [blame] | 153 | nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError, "[Errno %d]", error)); |
Paul Sokolovsky | 5225450 | 2014-01-13 23:25:33 +0200 | [diff] [blame] | 154 | } |
| 155 | if (out_sz == 0) { |
| 156 | break; |
| 157 | } |
| 158 | total_size += out_sz; |
| 159 | if (out_sz < current_read) { |
| 160 | current_read -= out_sz; |
| 161 | p += out_sz; |
| 162 | } else { |
Paul Sokolovsky | b9be45e | 2014-05-07 01:51:07 +0300 | [diff] [blame] | 163 | current_read = DEFAULT_BUFFER_SIZE; |
Paul Sokolovsky | 5225450 | 2014-01-13 23:25:33 +0200 | [diff] [blame] | 164 | p = vstr_extend(vstr, current_read); |
| 165 | if (p == NULL) { |
| 166 | // TODO |
Damien George | ea13f40 | 2014-04-05 18:32:08 +0100 | [diff] [blame] | 167 | nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError/*&mp_type_RuntimeError*/, "Out of memory")); |
Paul Sokolovsky | 5225450 | 2014-01-13 23:25:33 +0200 | [diff] [blame] | 168 | } |
| 169 | } |
| 170 | } |
Damien George | 5fa93b6 | 2014-01-22 14:35:10 +0000 | [diff] [blame] | 171 | |
Damien George | f600a6a | 2014-05-25 22:34:34 +0100 | [diff] [blame] | 172 | mp_obj_t s = mp_obj_new_str_of_type(STREAM_CONTENT_TYPE(o->type->stream_p), (byte*)vstr->buf, total_size); |
Damien George | 5fa93b6 | 2014-01-22 14:35:10 +0000 | [diff] [blame] | 173 | vstr_free(vstr); |
| 174 | return s; |
Paul Sokolovsky | 5225450 | 2014-01-13 23:25:33 +0200 | [diff] [blame] | 175 | } |
| 176 | |
Paul Sokolovsky | 9953ca4 | 2014-01-15 23:39:44 +0200 | [diff] [blame] | 177 | // Unbuffered, inefficient implementation of readline() for raw I/O files. |
Paul Sokolovsky | 520e2f5 | 2014-02-12 18:31:30 +0200 | [diff] [blame] | 178 | STATIC mp_obj_t stream_unbuffered_readline(uint n_args, const mp_obj_t *args) { |
Paul Sokolovsky | 9953ca4 | 2014-01-15 23:39:44 +0200 | [diff] [blame] | 179 | struct _mp_obj_base_t *o = (struct _mp_obj_base_t *)args[0]; |
Damien George | 27e735f | 2014-04-05 23:02:23 +0100 | [diff] [blame] | 180 | if (o->type->stream_p == NULL || o->type->stream_p->read == NULL) { |
Paul Sokolovsky | 9953ca4 | 2014-01-15 23:39:44 +0200 | [diff] [blame] | 181 | // CPython: io.UnsupportedOperation, OSError subclass |
Damien George | ea13f40 | 2014-04-05 18:32:08 +0100 | [diff] [blame] | 182 | nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, "Operation not supported")); |
Paul Sokolovsky | 9953ca4 | 2014-01-15 23:39:44 +0200 | [diff] [blame] | 183 | } |
| 184 | |
Damien George | 40f3c02 | 2014-07-03 13:25:24 +0100 | [diff] [blame^] | 185 | mp_int_t max_size = -1; |
Paul Sokolovsky | 9953ca4 | 2014-01-15 23:39:44 +0200 | [diff] [blame] | 186 | if (n_args > 1) { |
| 187 | max_size = MP_OBJ_SMALL_INT_VALUE(args[1]); |
| 188 | } |
| 189 | |
| 190 | vstr_t *vstr; |
| 191 | if (max_size != -1) { |
Damien George | 55baff4 | 2014-01-21 21:40:13 +0000 | [diff] [blame] | 192 | vstr = vstr_new_size(max_size); |
Paul Sokolovsky | 9953ca4 | 2014-01-15 23:39:44 +0200 | [diff] [blame] | 193 | } else { |
| 194 | vstr = vstr_new(); |
| 195 | } |
| 196 | |
| 197 | int error; |
| 198 | while (max_size == -1 || max_size-- != 0) { |
| 199 | char *p = vstr_add_len(vstr, 1); |
| 200 | if (p == NULL) { |
Damien George | d5f5b2f | 2014-05-03 22:01:32 +0100 | [diff] [blame] | 201 | nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_MemoryError, "out of memory")); |
Paul Sokolovsky | 9953ca4 | 2014-01-15 23:39:44 +0200 | [diff] [blame] | 202 | } |
| 203 | |
Damien George | 40f3c02 | 2014-07-03 13:25:24 +0100 | [diff] [blame^] | 204 | mp_int_t out_sz = o->type->stream_p->read(o, p, 1, &error); |
Paul Sokolovsky | 9953ca4 | 2014-01-15 23:39:44 +0200 | [diff] [blame] | 205 | if (out_sz == -1) { |
Damien George | ea13f40 | 2014-04-05 18:32:08 +0100 | [diff] [blame] | 206 | nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError, "[Errno %d]", error)); |
Paul Sokolovsky | 9953ca4 | 2014-01-15 23:39:44 +0200 | [diff] [blame] | 207 | } |
Paul Sokolovsky | 0914371 | 2014-01-22 10:34:45 +0200 | [diff] [blame] | 208 | if (out_sz == 0) { |
| 209 | // Back out previously added byte |
| 210 | // TODO: This is a bit hacky, does it supported by vstr API contract? |
| 211 | // Consider, what's better - read a char and get OutOfMemory (so read |
| 212 | // char is lost), or allocate first as we do. |
| 213 | vstr_add_len(vstr, -1); |
| 214 | break; |
| 215 | } |
| 216 | if (*p == '\n') { |
Paul Sokolovsky | 9953ca4 | 2014-01-15 23:39:44 +0200 | [diff] [blame] | 217 | break; |
| 218 | } |
| 219 | } |
Damien George | d5f5b2f | 2014-05-03 22:01:32 +0100 | [diff] [blame] | 220 | // TODO need a string creation API that doesn't copy the given data |
Damien George | f600a6a | 2014-05-25 22:34:34 +0100 | [diff] [blame] | 221 | mp_obj_t ret = mp_obj_new_str_of_type(STREAM_CONTENT_TYPE(o->type->stream_p), (byte*)vstr->buf, vstr->len); |
Damien George | d5f5b2f | 2014-05-03 22:01:32 +0100 | [diff] [blame] | 222 | vstr_free(vstr); |
| 223 | return ret; |
Paul Sokolovsky | 9953ca4 | 2014-01-15 23:39:44 +0200 | [diff] [blame] | 224 | } |
| 225 | |
Damien George | d5f5b2f | 2014-05-03 22:01:32 +0100 | [diff] [blame] | 226 | // TODO take an optional extra argument (what does it do exactly?) |
| 227 | STATIC mp_obj_t stream_unbuffered_readlines(mp_obj_t self) { |
| 228 | mp_obj_t lines = mp_obj_new_list(0, NULL); |
| 229 | for (;;) { |
| 230 | mp_obj_t line = stream_unbuffered_readline(1, &self); |
Paul Sokolovsky | e22cddb | 2014-06-13 23:46:21 +0300 | [diff] [blame] | 231 | if (!mp_obj_is_true(line)) { |
Damien George | d5f5b2f | 2014-05-03 22:01:32 +0100 | [diff] [blame] | 232 | break; |
| 233 | } |
| 234 | mp_obj_list_append(lines, line); |
| 235 | } |
| 236 | return lines; |
| 237 | } |
| 238 | MP_DEFINE_CONST_FUN_OBJ_1(mp_stream_unbuffered_readlines_obj, stream_unbuffered_readlines); |
| 239 | |
Paul Sokolovsky | d54bef7 | 2014-01-20 18:35:32 +0200 | [diff] [blame] | 240 | mp_obj_t mp_stream_unbuffered_iter(mp_obj_t self) { |
| 241 | mp_obj_t l_in = stream_unbuffered_readline(1, &self); |
Paul Sokolovsky | e22cddb | 2014-06-13 23:46:21 +0300 | [diff] [blame] | 242 | if (mp_obj_is_true(l_in)) { |
Paul Sokolovsky | d54bef7 | 2014-01-20 18:35:32 +0200 | [diff] [blame] | 243 | return l_in; |
| 244 | } |
Damien George | ea8d06c | 2014-04-17 23:19:36 +0100 | [diff] [blame] | 245 | return MP_OBJ_STOP_ITERATION; |
Paul Sokolovsky | d54bef7 | 2014-01-20 18:35:32 +0200 | [diff] [blame] | 246 | } |
Paul Sokolovsky | 9953ca4 | 2014-01-15 23:39:44 +0200 | [diff] [blame] | 247 | |
Paul Sokolovsky | a671f89 | 2014-01-16 12:53:46 +0200 | [diff] [blame] | 248 | MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_stream_read_obj, 1, 2, stream_read); |
Paul Sokolovsky | 5225450 | 2014-01-13 23:25:33 +0200 | [diff] [blame] | 249 | MP_DEFINE_CONST_FUN_OBJ_1(mp_stream_readall_obj, stream_readall); |
Paul Sokolovsky | 9953ca4 | 2014-01-15 23:39:44 +0200 | [diff] [blame] | 250 | MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_stream_unbuffered_readline_obj, 1, 2, stream_unbuffered_readline); |
Paul Sokolovsky | e98cf40 | 2014-01-08 02:43:48 +0200 | [diff] [blame] | 251 | MP_DEFINE_CONST_FUN_OBJ_2(mp_stream_write_obj, stream_write); |