summaryrefslogtreecommitdiffstatshomepage
path: root/unix/file.c
Commit message (Collapse)AuthorAge
* all: Use the name MicroPython consistently in commentsAlexander Steffen2017-07-31
| | | | | There were several different spellings of MicroPython present in comments, when there should be only one.
* py: Add iter_buf to getiter type method.Damien George2017-02-16
| | | | | | | | | | | | | | | Allows to iterate over the following without allocating on the heap: - tuple - list - string, bytes - bytearray, array - dict (not dict.keys, dict.values, dict.items) - set, frozenset Allows to call the following without heap memory: - all, any, min, max, sum TODO: still need to allocate stack memory in bytecode for iter_buf.
* 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.
* unix: Use mp_raise_OSError helper function.Damien George2016-10-07
|
* unix/moduselect: Allow poll.register(), etc. accept fd-like objects.Paul Sokolovsky2016-08-07
| | | | | | | This includes file and socket objects, backed by Unix file descriptor. This improves compatibility with stmhal's uselect (and convenience of use), though not completely: return value from poll.poll() is still raw file descriptor.
* unix/file: Use generic stream flush() method.Paul Sokolovsky2016-07-28
|
* unix/file: fdfile_ioctl(): Fix argument to check_fd_is_open().Paul Sokolovsky2016-07-27
|
* unix/file: ioctl(): Check that file is open before operations.Paul Sokolovsky2016-07-27
|
* unix/file: Implement MP_STREAM_FLUSH ioctl.Paul Sokolovsky2016-07-27
|
* unix/file: If write syscall returns because of EINTR then try again.Damien George2016-06-28
| | | | As per PEP-475.
* all: Rename mp_obj_type_t::stream_p to protocol.Paul Sokolovsky2016-06-18
| | | | | It's now used for more than just stream protocol (e.g. pin protocol), so don't use false names.
* unix/file: "encoding" arg to open() isn't kw-only.Paul Sokolovsky2016-04-02
| | | | | And with "buffering" arg introduced, it's non possible to make it non-kwonly.
* unix/file: Parse "buffering" argument of open() builtin.Paul Sokolovsky2016-04-02
| | | | | It's ignored (unbuffered, raw I/O is used), but least makes it compatible with CPython.
* unix/file: Stop assuming that O_RDWR == O_RDONLY | O_WRONLY.Paul Sokolovsky2016-02-06
| | | | That's not true e.g. on Linux.
* py: Change first arg of type.make_new from mp_obj_t to mp_obj_type_t*.Damien George2016-01-11
| | | | | | | | The first argument to the type.make_new method is naturally a uPy type, and all uses of this argument cast it directly to a pointer to a type structure. So it makes sense to just have it a pointer to a type from the very beginning (and a const pointer at that). This patch makes such a change, and removes all unnecessary casting to/from mp_obj_t.
* py: Change type signature of builtin funs that take variable or kw args.Damien George2016-01-11
| | | | | With this patch the n_args parameter is changed type from mp_uint_t to size_t.
* py: Change type of .make_new and .call args: mp_uint_t becomes size_t.Damien George2016-01-11
| | | | | | | This patch changes the type signature of .make_new and .call object method slots to use size_t for n_args and n_kw (was mp_uint_t. Makes code more efficient when mp_uint_t is larger than a machine word. Doesn't affect ports when size_t and mp_uint_t have the same size.
* unix: Implement uos.dupterm(). Conditional on MICROPY_PY_OS_DUPTERM.Paul Sokolovsky2015-12-28
|
* 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: Add MP_ROM_* macros and mp_rom_* types and use them.Damien George2015-11-29
|
* py: Add stream_tell method, and use for unix and stmhal file tell.blmorris2015-08-13
|
* unix: Add O_WRONLY | O_CREAT to open call when opening file for append ("a").Ari Suutari2015-06-21
| | | | To comply with Python semantics.
* py: Overhaul and simplify printf/pfenv mechanism.Damien George2015-04-16
| | | | | | | | | | | | | | | | | | | | | | Previous to this patch the printing mechanism was a bit of a tangled mess. This patch attempts to consolidate printing into one interface. All (non-debug) printing now uses the mp_print* family of functions, mainly mp_printf. All these functions take an mp_print_t structure as their first argument, and this structure defines the printing backend through the "print_strn" function of said structure. Printing from the uPy core can reach the platform-defined print code via two paths: either through mp_sys_stdout_obj (defined pert port) in conjunction with mp_stream_write; or through the mp_plat_print structure which uses the MP_PLAT_PRINT_STRN macro to define how string are printed on the platform. The former is only used when MICROPY_PY_IO is defined. With this new scheme printing is generally more efficient (less layers to go through, less arguments to pass), and, given an mp_print_t* structure, one can call mp_print_str for efficiency instead of mp_printf("%s", ...). Code size is also reduced by around 200 bytes on Thumb2 archs.
* py, unix: Allow to compile with -Wunused-parameter.Damien George2015-01-20
| | | | See issue #699.
* unix: Add target to build "minimal" uPy interpreter.Damien George2015-01-16
|
* py: Can compile with -Wmissing-declarations and -Wmissing-prototypes.Damien George2015-01-12
|
* unix: Prefix includes with py/; remove need for -I../py.Damien George2015-01-01
|
* py: Make functions static where appropriate.Damien George2014-12-10
|
* 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.
* Implement kwargs for builtin open() and _io.FileIOstijn2014-10-21
| | | | | | | This makes open() and _io.FileIO() more CPython compliant. The mode kwarg is fully iplemented. The encoding kwarg is allowed but not implemented; mainly to allow the tests to specify encoding for CPython, see #874
* 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.
* Change some parts of the core API to use mp_uint_t instead of uint/int.Damien George2014-08-30
| | | | Addressing issue #50, still some way to go yet.
* py: Make MP_OBJ_NEW_SMALL_INT cast arg to mp_int_t itself.Damien George2014-07-31
| | | | Addresses issue #724.
* py: Change stream protocol API: fns return uint; is_text for text.Damien George2014-07-27
|
* Add fsync for windows, i.e. _commit. See dce8876stijn2014-07-16
|
* unix: file: No fsync() on Windows.v1.2Paul Sokolovsky2014-07-13
|
* unix: file: Implement .flush() method.Paul Sokolovsky2014-07-13
| | | | This method apparently should be part of stream interface.
* Rename machine_(u)int_t to mp_(u)int_t.Damien George2014-07-03
| | | | See discussion in issue #50.
* Rename configuration variables controling Python features.Damien George2014-05-24
| | | | Now of the form MICROPY_PY_*. See issue #35.
* py: Implement proper separation between io.FileIO and io.TextIOWrapper.Paul Sokolovsky2014-05-19
| | | | | | | io.FileIO is binary I/O, ans actually optional. Default file type is io.TextIOWrapper, which provides str results. CPython3 explicitly describes io.TextIOWrapper as buffered I/O, but we don't have buffering support yet 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
|
* unix, file.c: adhere to coding conventions.Damien George2014-05-03
|
* CPython compatibility: raise an error for operations on a closed file descriptorstijn2014-05-03
| | | | | In CPython any operations on a file that has been closed already reaises a ValueError with message "I/O operation on closed file"
* py, unix: Make "mpconfig.h" be first included, as other headers depend on it.Paul Sokolovsky2014-05-02
| | | | Specifically, nlr.h does.
* unix: Workaround MP_OBJ_NEW_SMALL_INT() 64-bit issues.Paul Sokolovsky2014-04-22
|
* unix: OSError's args[0] should be errno numeric value.Paul Sokolovsky2014-04-22
| | | | Well, Python3 also defines an attribute for that, but that's bloat.
* unix file: mingw32 has STDIN_FILENO and friends in stdio.h .Paul Sokolovsky2014-04-20
| | | | TODO: Never "optimize" includes any more!
* py, unix: Convert sys module to static representation.Paul Sokolovsky2014-04-13
|