summaryrefslogtreecommitdiffstatshomepage
path: root/py/stream.c
Commit message (Collapse)AuthorAge
* py: Change vstr so that it doesn't null terminate buffer by default.Damien George2015-01-28
| | | | | | | | | This cleans up vstr so that it's a pure "variable buffer", and the user can decide whether they need to add a terminating null byte. In most places where vstr is used, the vstr did not need to be null terminated and so this patch saves code size, a tiny bit of RAM, and makes vstr usage more efficient. When null termination is needed it must be done explicitly using vstr_null_terminate.
* stream: readall(): Make sure there's a trailing NUL char.Paul Sokolovsky2015-01-24
|
* stream: Fix readall() implementation in respect to NUL terminator bytes.Paul Sokolovsky2015-01-23
| | | | After vstr refactor. Fixes #1084.
* py: Remove mp_obj_str_builder and use vstr instead.Damien George2015-01-21
| | | | | | | | | | | | With this patch str/bytes construction is streamlined. Always use a vstr to build a str/bytes object. If the size is known beforehand then use vstr_init_len to allocate only required memory. Otherwise use vstr_init and the vstr will grow as needed. Then use mp_obj_new_str_from_vstr to create a str/bytes object using the vstr memory. Saves code ROM: 68 bytes on stmhal, 108 bytes on bare-arm, and 336 bytes on unix x64.
* py: Add mp_obj_new_str_from_vstr, and use it where relevant.Damien George2015-01-21
| | | | | | | | This patch allows to reuse vstr memory when creating str/bytes object. This improves memory usage. Also saves code ROM: 128 bytes on stmhal, 92 bytes on bare-arm, and 88 bytes on unix x64.
* py: Move to guarded includes, everywhere in py/ core.Damien George2015-01-01
| | | | Addresses issue #1022.
* py: Rename mp_obj_int_get to mp_obj_int_get_truncated; fix struct.pack.Damien George2014-12-05
| | | | | | | | | | | mp_obj_int_get_truncated is used as a "fast path" int accessor that doesn't check for overflow and returns the int truncated to the machine word size, ie mp_int_t. Use mp_obj_int_get_truncated to fix struct.pack when packing maximum word sized values. Addresses issues #779 and #998.
* py: Make stream seek correctly check for ioctl fn; add seek for textio.Damien George2014-11-16
|
* stream: Implement seek operation support via ioctl, wrapped in generic method.Paul Sokolovsky2014-11-17
| | | | Also, implement for unix port.
* py: Use mp_uint_t where appropriate in stream functions.Damien George2014-10-24
|
* stream: Add optional 2nd "length" arg to .readinto() - extension to CPython.Paul Sokolovsky2014-10-23
| | | | | While extension to file.readinto() definition of CPython, the additional arg is similar to what in CPython available in socket.recv_into().
* 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.
* py: Improve stream_read so it doesn't need to alloc 2 bits of heap.Damien George2014-10-17
|
* stream: Handle non-blocking errors in readline() properly.Paul Sokolovsky2014-10-16
| | | | | | Just like they handled in other read*(). Note that behavior of readline() in case there's no data when it's called is underspecified in Python lib spec, implemented to behave as read() - return None.
* stream: Return errno value as first arg of OSError exception.Paul Sokolovsky2014-10-16
| | | | This is CPython-compatible convention established yet in acb13886fc837a1bb9.
* py: Small cleanup in stream.c.Damien George2014-08-22
|
* py: Change stream protocol API: fns return uint; is_text for text.Damien George2014-07-27
|
* streams: Treat non-error output size as unsigned.Paul Sokolovsky2014-07-23
|
* stream: Revert to checking for the correct error value.Paul Sokolovsky2014-07-23
|
* Deal with reading a buffer less than what was allocated.Dave Hylands2014-07-21
| | | | With this fix, file_long_read now passes.
* py: Add stream reading of n unicode chars; unicode support by default.Damien George2014-07-19
| | | | | | | | | | | | | With unicode enabled, this patch allows reading a fixed number of characters from text-mode streams; eg file.read(5) will read 5 unicode chars, which can made of more than 5 bytes. For an ASCII stream (ie no chars > 127) it only needs to do 1 read. If there are lots of non-ASCII chars in a stream, then it needs multiple reads of the underlying object. Adds a new test for this case. Enables unicode support by default on unix and stmhal ports.
* stream: Factor out mp_stream_write() method to write a memstring to stream.Paul Sokolovsky2014-07-13
|
* Rename machine_(u)int_t to mp_(u)int_t.Damien George2014-07-03
| | | | See discussion in issue #50.
* windows: Sync mpconfigport.h with the unix' versionstijn2014-06-29
| | | | | | - rearrange/add definitions that were not there so it's easier to compare both - use MICROPY_PY_SYS_PLATFORM in main.c since it's available anyway - define EWOULDBLOCK, it is missing from ingw32
* streams: Reading by char count from unicode text streams is not implemented.Paul Sokolovsky2014-06-27
|
* stream: Use mp_obj_is_true() for EOF testing.Paul Sokolovsky2014-06-13
| | | | | Getting a length of string may be expensive, depending on the underlying implementation.
* py: Slightly improve efficiency of mp_obj_new_str; rename str_new.Damien George2014-05-25
| | | | | | Reorder interning logic in mp_obj_new_str, to be more efficient. str_new is globally accessible, so should be prefixed with mp_obj_.
* objstringio: Implement io.BytesIO.Paul Sokolovsky2014-05-15
| | | | | Done in generalized manner, allowing any stream class to be specified as working with bytes.
* py, unix: Add copyright for modules I worked closely on.Paul Sokolovsky2014-05-13
|
* stream: Make non-blcoking stream support configurable.Paul Sokolovsky2014-05-07
| | | | Enable only on unix. To avoid unpleasant surprises with error codes.
* stream: Use standard name of DEFAULT_BUFFER_SIZE.Paul Sokolovsky2014-05-07
|
* stream: Add compliant handling of non-blocking readall().Paul Sokolovsky2014-05-07
|
* stream: Add compliant handling of non-blocking read()/write().Paul Sokolovsky2014-05-07
| | | | | | | | | | | In case of empty non-blocking read()/write(), both return None. read() cannot return 0, as that means EOF, so returns another value, and then write() just follows. This is still pretty unexpected, and typical "if not len:" check would treat this as EOF. Well, non-blocking files require special handling! This also kind of makes it depending on POSIX, but well, anything else should emulate POSIX anyway ;-).
* 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
|
* py, unix: Make "mpconfig.h" be first included, as other headers depend on it.Paul Sokolovsky2014-05-02
| | | | Specifically, nlr.h does.
* streams: Make .write() support arbitrary objects with buffer interface.Paul Sokolovsky2014-04-26
| | | | This in particular fixes writing str vs bytes.
* py: Add MP_OBJ_STOP_ITERATION and make good use of it.Damien George2014-04-17
| | | | | Also make consistent use of MP_OBJ_NOT_SUPPORTED and MP_OBJ_NULL. This helps a lot in debugging and understanding of function API.
* py: the entire `<unistd.h>` shouldn't be neededIlya Dmitrichenko2014-04-12
|
* py: Replace stream_p with *stream_p in mp_obj_type_t.Damien George2014-04-05
| | | | | | | | This is to reduce ROM usage. stream_p is used in file and socket types only (at the moment), so seems a good idea to make the protocol functions a pointer instead of the actual structure. It saves 308 bytes of ROM in the stmhal/ port, 928 in unix/.
* py: Change nlr_jump to nlr_raise, to aid in debugging.Damien George2014-04-05
| | | | | | This does not affect code size or performance when debugging turned off. To address issue #420.
* py: Replace mp_const_stop_iteration object with MP_OBJ_NULL.Damien George2014-03-26
|
* py: Clean up includes.xbe2014-03-17
| | | | Remove unnecessary includes. Add includes that improve portability.
* Implement proper exception type hierarchy.Damien George2014-02-15
| | | | | | | | | | | | | | Each built-in exception is now a type, with base type BaseException. C exceptions are created by passing a pointer to the exception type to make an instance of. When raising an exception from the VM, an instance is created automatically if an exception type is raised (as opposed to an exception instance). Exception matching (RT_BINARY_OP_EXCEPTION_MATCH) is now proper. Handling of parse error changed to match new exceptions. mp_const_type renamed to mp_type_type for consistency.
* Replace global "static" -> "STATIC", to allow "analysis builds". Part 2.Paul Sokolovsky2014-02-12
|
* Make mp_obj_str_get_data return char* instead of byte*.Damien George2014-02-08
| | | | | Can't decide which is better for string type, char or byte pointer. Changing to char removes a few casts. Really need to do proper unicode.
* file.readline(): Use mp_obj_str_get_data() and fix off-by-one error on EOF.Paul Sokolovsky2014-01-22
|
* Second stage of qstr revamp: uPy str object can be qstr or not.Damien George2014-01-22
|
* Merge branch 'master' of github.com:micropython/micropythonDamien George2014-01-21
|\ | | | | | | | | | | | | | | | | Conflicts: py/objstr.c py/py.mk py/stream.c unix/main.c unix/socket.c
| * stream_read(): Shrink memory block to actual read size.Paul Sokolovsky2014-01-20
| |