summaryrefslogtreecommitdiffstatshomepage
path: root/unix/file.c
Commit message (Collapse)AuthorAge
* 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
|
* unix, stmhal: Consistently use "FileIO" as class name for file objects.Paul Sokolovsky2014-04-08
| | | | | They correspond to io.FileIO in io module hierarchy (with small caveat that io.FileIO is raw file and works with bytes, not strings).
* 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.
* unix: Use STATIC modifier to enable code size analysis via map file.Paul Sokolovsky2014-04-04
|
* unix file: Implement context manager protocol (for "with" statement).Paul Sokolovsky2014-04-03
|
* Merge map.h into obj.h.Damien George2014-03-30
| | | | | | Pretty much everyone needs to include map.h, since it's such an integral part of the Micro Python object implementation. Thus, the definitions are now in obj.h instead. map.h is removed.
* Rename rt_* to mp_*.Damien George2014-03-30
| | | | | | | Mostly just a global search and replace. Except rt_is_true which becomes mp_obj_is_true. Still would like to tidy up some of the names, but this will do for now.
* Remove mp_obj_type_t.methods entry and use .locals_dict instead.Damien George2014-03-26
| | | | | | | | | | | | | | | | | | | | | | Originally, .methods was used for methods in a ROM class, and locals_dict for methods in a user-created class. That distinction is unnecessary, and we can use locals_dict for ROM classes now that we have ROMable maps. This removes an entry in the bloated mp_obj_type_t struct, saving a word for each ROM object and each RAM object. ROM objects that have a methods table (now a locals_dict) need an extra word in total (removed the methods pointer (1 word), no longer need the sentinel (2 words), but now need an mp_obj_dict_t wrapper (4 words)). But RAM objects save a word because they never used the methods entry. Overall the ROM usage is down by a few hundred bytes, and RAM usage is down 1 word per user-defined type/class. There is less code (no need to check 2 tables), and now consistent with the way ROM modules have their tables initialised. Efficiency is very close to equivaluent.
* Change mp_method_t.name from const char * to qstr.Damien George2014-03-26
| | | | Addresses issue #377.
* unix: Clean up includes.xbe2014-03-16
| | | | 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.
* Change mp_obj_type_t.name from const char * to qstr.Damien George2014-02-15
| | | | | | Ultimately all static strings should be qstr. This entry in the type structure is only used for printing error messages (to tell the type of the bad argument), and printing objects that don't supply a .print method.
* Allow ports to define statically builtin functions.Paul Sokolovsky2014-02-14
| | | | Convert unix open() to such.
* Fix some int casting that failed on 64 bit architecture.Damien George2014-02-10
|
* io.File, socket types: Add fileno() method.Paul Sokolovsky2014-02-08
| | | | | Implementation is duplicated, but tolerate this for now, because there's no clear idea how to de-dup it.
* 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
| * unix file: Refactor and add sys.stdout/stdin/stderr.Paul Sokolovsky2014-01-20
| |
| * unix io.FileIO: Add iteration support.Paul Sokolovsky2014-01-20
| | | | | | | | | | A file cannot be iterated concurrently, so we make io.FileIO its own iterator.
* | Revamp qstrs: they now include length and hash.Damien George2014-01-21
|/ | | | | Can now have null bytes in strings. Can define ROM qstrs per port using qstrdefsport.h
* Fix incorrect prototype of mp_builtin_open() after args refactor.Paul Sokolovsky2014-01-19
|