summaryrefslogtreecommitdiffstatshomepage
path: root/py/stream.h
Commit message (Collapse)AuthorAge
* all: Remove readall() method, which is equivalent to read() w/o args.Paul Sokolovsky2016-11-14
| | | | | | Its addition was due to an early exploration on how to add CPython-like stream interface. It's clear that it's not needed and just takes up bytes in all ports.
* py: Be more specific with MP_DECLARE_CONST_FUN_OBJ macros.Damien George2016-10-21
| | | | | | | In order to have more fine-grained control over how builtin functions are constructed, the MP_DECLARE_CONST_FUN_OBJ macros are made more specific, with suffix of _0, _1, _2, _3, _VAR, _VAR_BETEEN or _KW. These names now match the MP_DEFINE_CONST_FUN_OBJ macros.
* py/mpconfig.h: Add MICROPY_STREAMS_POSIX_API setting.Paul Sokolovsky2016-07-30
| | | | | | To filter out even prototypes of mp_stream_posix_*() functions, which require POSIX types like ssize_t & off_t, which may be not available in some ports.
* py/stream: Add adapter methods with POSIX-compatible signatures.Paul Sokolovsky2016-07-30
| | | | | Previoussly such read() and write() methods were used by modussl_axtls, move to py/stream for reuse.
* py/stream: Implement generic flush() method, in terms of C-level ioctl.Paul Sokolovsky2016-07-27
|
* py/stream: Stream module works with errno's, so should include mperrno.h.Paul Sokolovsky2016-07-26
|
* py/stream.h: Remove dated comment of POSIX-specificity of EAGAIN.Paul Sokolovsky2016-07-25
| | | | We have adopted POSIX-compatible error numbers as MicroPython's native.
* py/stream.h: Move mp_stream_write_adaptor() inside ifdef block.Paul Sokolovsky2016-07-25
|
* py/stream: Add mp_stream_close() helper function.Paul Sokolovsky2016-05-20
|
* py/stream: Support both "exact size" and "one underlying call" operations.Paul Sokolovsky2016-05-18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Both read and write operations support variants where either a) a single call is made to the undelying stream implementation and returned buffer length may be less than requested, or b) calls are repeated until requested amount of data is collected, shorter amount is returned only in case of EOF or error. These operations are available from the level of C support functions to be used by other C modules to implementations of Python methods to be used in user-facing objects. The rationale of these changes is to allow to write concise and robust code to work with *blocking* streams of types prone to short reads, like serial interfaces and sockets. Particular object types may select "exact" vs "once" types of methods depending on their needs. E.g., for sockets, revc() and send() methods continue to be "once", while read() and write() thus converted to "exactly" versions. These changes don't affect non-blocking handling, e.g. trying "exact" method on the non-blocking socket will return as much data as available without blocking. No data available is continued to be signaled as None return value to read() and write(). From the point of view of CPython compatibility, this model is a cross between its io.RawIOBase and io.BufferedIOBase abstract classes. For blocking streams, it works as io.BufferedIOBase model (guaranteeing lack of short reads/writes), while for non-blocking - as io.RawIOBase, returning None in case of lack of data (instead of raising expensive exception, as required by io.BufferedIOBase). Such a cross-behavior should be optimal for MicroPython needs.
* py/stream: Add Python-level ioctl() method.Paul Sokolovsky2016-04-10
| | | | | | | Will call underlying C virtual methods of stream interface. This isn't intended to be added to every stream object (it's not in CPython), but is convenient way to expose extra operation on Python side without adding bunch of Python-level methods.
* py/stream.h: Add bigger inventory of stream ioctl's.Paul Sokolovsky2016-04-10
|
* py: Move stream-related declarations from obj.h to stream.h.Paul Sokolovsky2016-04-05
|
* py/stream: Add mp_stream_writeall() helper function.Paul Sokolovsky2016-03-24
| | | | | Spools entire output buffer to a blocking stream (chunk by chunk if needed).
* py: Add mp_get_stream_raise to factor out check for stream methods.Damien George2015-12-09
|
* py: Wrap all obj-ptr conversions in MP_OBJ_TO_PTR/MP_OBJ_FROM_PTR.Damien George2015-11-29
| | | | | | | | | This allows the mp_obj_t type to be configured to something other than a pointer-sized primitive type. This patch also includes additional changes to allow the code to compile when sizeof(mp_uint_t) != sizeof(void*), such as using size_t instead of mp_uint_t, and various casts.
* py: Change mp_print_strn_t func type to use size_t for the str length.Damien George2015-11-29
|
* py/stream: Allow to reuse is_nonblocking_error().Paul Sokolovsky2015-10-18
|
* py: Add stream_tell method, and use for unix and stmhal file tell.blmorris2015-08-13
|
* py: Move to guarded includes, everywhere in py/ core.Damien George2015-01-01
| | | | Addresses issue #1022.
* stream: Implement seek operation support via ioctl, wrapped in generic method.Paul Sokolovsky2014-11-17
| | | | Also, implement for unix port.
* unix, stmhal: Implement file.readinto() method.Paul Sokolovsky2014-10-18
| | | | | | Also, usocket.readinto(). Known issue is that .readinto() should be available only for binary files, but micropython uses single method table for both binary and text files.
* stream: Factor out mp_stream_write() method to write a memstring to stream.Paul Sokolovsky2014-07-13
|
* Add license header to (almost) all files.Damien George2014-05-03
| | | | | | | Blanket wide to all .c and .h files. Some files originating from ST are difficult to deal with (license wise) so it was left out of those. Also merged modpyb.h, modos.h, modstm.h and modtime.h in stmhal/.
* py, stream: Implement readlines for a stream.Damien George2014-05-03
|
* stream: Add generic unbuffered iternext method.Paul Sokolovsky2014-01-20
| | | | Uses stream_unbuffered_readline underline.
* Add unbuffered readline() implementation for Raw I/O files.Paul Sokolovsky2014-01-15
|
* Add generic impl of stream .readall() method. Use one for unix io.FileIO.Paul Sokolovsky2014-01-13
|
* Add generic implementations of Python read()/write methods for streams.Paul Sokolovsky2014-01-08
These can be used for any object which implements stream protocol (mp_stream_p_t).