Commit Graph

790 Commits

Author SHA1 Message Date
Damien George ae8d867586 py: Add iter_buf to getiter type method.
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.
2017-02-16 18:38:06 +11:00
Paul Sokolovsky 16a3534ad4 unix/moduselect: Implement ipoll() method with no-allocation policy.
ipoll() allows to poll streams without allocating any memory: this method
returns an iterator (a poll object itself), and the iterator yields
preallocated "callee-owned tuple" with polling results for each active
stream. The only operation a caller is allowed to do with this tuple is
extracting values from it (storing the tuple as a whole somewhere is
not allowed).
2017-02-13 00:23:23 +03:00
dmazzella 18e6569166 py/objtype: Implement __delattr__ and __setattr__.
This patch implements support for class methods __delattr__ and __setattr__
for customising attribute access.  It is controlled by the config option
MICROPY_PY_DELATTR_SETATTR and is disabled by default.
2017-02-09 12:40:15 +11:00
Paul Sokolovsky de48a27d60 unix/main: Properly handle MICROPYPATH starting with ':'.
In other words, where first path component is an empty string.
2017-02-07 02:13:01 +03:00
Nikita Melentev 5bea6ea808 unix: Fix freedos port build problems. 2017-02-06 15:25:42 +11:00
Nicko van Someren df0117c8ae py: Added optimised support for 3-argument calls to builtin.pow()
Updated modbuiltin.c to add conditional support for 3-arg calls to
pow() using MICROPY_PY_BUILTINS_POW3 config parameter. Added support in
objint_mpz.c for for optimised implementation.
2017-02-02 22:23:10 +03:00
Damien George 30beed119f unix/modos: Remove VfsFat from uos module, it's now in uos_vfs module. 2017-01-30 12:26:08 +11:00
Damien George 0bd61d23b9 extmod/vfs_fat: Remove MICROPY_FATFS_OO config option.
Everyone should now be using the new ooFatFs library.  The old one is no
longer supported and will be removed.
2017-01-30 12:26:07 +11:00
Damien George 95635ade8b unix/mpconfigport.h: Remove obsolete MICROPY_FATFS_VOLUMES config. 2017-01-30 12:26:07 +11:00
Damien George 1808b2e8d5 extmod: Remove MICROPY_FSUSERMOUNT and related files.
Replaced by MICROPY_VFS and the VFS sub-system.
2017-01-30 12:26:07 +11:00
Damien George 9225ce6a14 unix/fatfs_port: Include new oofatfs header. 2017-01-27 23:22:15 +11:00
Damien George f1e04148a1 unix: Change to use new generic VFS sub-system in coverage build.
This patch includes a new module "uos_vfs" which can be used for testing
the VFS syb-system.
2017-01-27 17:21:45 +11:00
Damien George 32a1138b9f extmod: Rename vfs_fat_file.h to vfs_fat.h.
And move declaration of mp_fat_vfs_type to this file.
2017-01-27 15:04:17 +11:00
Damien George 143fa0ffeb unix: Get minimal version compiling again. 2017-01-27 13:32:15 +11:00
Damien George 5395f5bc71 unix: Switch to OO version of FatFS library. 2017-01-27 13:19:10 +11:00
Damien George 1abaf74293 unix: Enable MICROPY_PY_BUILTINS_HELP_MODULES in coverage build. 2017-01-22 12:14:26 +11:00
Damien George 51c89e4f4e unix: Enable builtin help function in coverage build. 2017-01-22 11:56:16 +11:00
Rami Ali 751e379533 tests: Improve frozen import test coverage. 2017-01-16 16:59:03 +11:00
Damien George 9317fee523 unix/coverage: Move coverage #if guard back to top of file. 2017-01-16 16:20:49 +11:00
Rami Ali 8d01bd3a1c tests: Improve stream.c test coverage. 2017-01-16 15:57:10 +11:00
Damien George a722ed532f tests/unix/extra_coverage: Add tests for importing frozen packages. 2017-01-08 22:45:55 +11:00
Damien George 5d0d61586c unix/Makefile: Allow cache-map-lookup optimisation with frozen bytecode. 2017-01-05 15:55:06 +11:00
Damien George 1551309575 unix: Enable and add basic frozen str and frozen mpy in coverage build. 2017-01-05 14:55:57 +11:00
Damien George ea00151ffa unix/Makefile: Split long line for coverage target, easier to modify. 2017-01-05 14:48:48 +11:00
Rami Ali d7e168428b tests/unix: Improve formatfloat.c test coverage using C. 2017-01-05 12:31:05 +11:00
Rami Ali ec72db8a39 tests: Improve warning.c test coverage. 2017-01-05 12:23:40 +11:00
Paul Sokolovsky eac22e29a5 all: Consistently update signatures of .make_new and .call methods.
Otherwise, they serve reoccurring source of copy-paste mistakes and
breaking nanbox build.
2017-01-04 16:10:42 +03:00
Paul Sokolovsky 5efd6508ec unix/moduselect: Fix nanbox build with recent changes. 2016-12-31 11:19:25 +03:00
Paul Sokolovsky 093a8f5fa2 unix/moduselect: If file object passed to .register(), return it in .poll().
This makes unix "uselect" compatible with baremetal "uselect". Previosuly,
unix version accepted file/socket objects, but internally converted that
to file descriptors, and that's what .poll() returned. To acheive new
behavior, file-like objects are stored internally in an array, in addition
to existing array of struct pollfd. This array is created only on first
case of file-like object being passed to .register(). If only raw fd's are
passed, there will be no additional memory used comparing to the original
implementation.
2016-12-31 00:07:18 +03:00
Rami Ali 75aa7befec tests/unix: Improve runtime_utils.c test coverage. 2016-12-29 18:24:03 +11:00
Damien George efa206d955 unix/Makefile: Make "coverage_test" target mirror Travis test actions. 2016-12-22 11:28:29 +11:00
Damien George ebb8413178 unix/main: Allow to print the parse tree in coverage build.
Passing -v -v -v on the command line of the coverage build will now print
the parse tree (as well as other things at this verbosity level).
2016-12-22 10:56:11 +11:00
Paul Sokolovsky 64b1d5f878 unix: Enable utimeq module. 2016-12-22 00:33:44 +03:00
Damien George e30ca0e102 unix/Makefile: Update freedos target for change of USELECT config name. 2016-11-21 15:49:46 +11:00
Paul Sokolovsky 87dfc76570 unix: Rename define for unix moduselect to MICROPY_PY_USELECT_POSIX.
To not conflict with recently made available globally baremetal
moduselect.
2016-11-21 00:48:55 +03:00
Damien George 6b239c271c py: Factor out persistent-code reader into separate files.
Implementations of persistent-code reader are provided for POSIX systems
and systems using FatFS.  Macros to use these are MICROPY_READER_POSIX and
MICROPY_READER_FATFS respectively.  If an alternative implementation is
needed then a port can define the function mp_reader_new_file.
2016-11-16 18:13:50 +11:00
Paul Sokolovsky 59a1201da9 all: Remove readall() method, which is equivalent to read() w/o args.
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.
2016-11-14 00:24:22 +03:00
Damien George e3626b484c unix: Add symlinks for upip to make it frozen into binary. 2016-11-08 14:47:29 +11:00
Damien George bdf33bc136 py: Move frozen bytecode Makefile rules from ports to common mk files.
Now, to use frozen bytecode all a port needs to do is define
FROZEN_MPY_DIR to the directory containing the .py files to freeze, and
define MICROPY_MODULE_FROZEN_MPY and MICROPY_QSTR_EXTRA_POOL.
2016-11-08 14:28:30 +11:00
Paul Sokolovsky 61d74fdef8 tools, unix: Replace upip tarball with just source files.
To make its inclusion as frozen modules in multiple ports less magic.
Ports are just expected to symlink 2 files into their scripts/modules
subdirs.

Unix port updated to use this and in general follow frozen modules setup
tested and tried on baremetal ports, where there's "scripts" predefined
dir (overridable with FROZEN_DIR make var), and a user just drops Python
files there.
2016-11-07 18:39:41 +03:00
stijn 3272afe57f windows: Implement mp_hal_ticks_cpu in terms of QueryPerformanceCounter 2016-11-03 10:31:58 +01:00
Jan Pochyla ffb04a5845 unix: fix symbol references for x86 Mac 2016-11-02 00:42:04 +03:00
Paul Sokolovsky d86cac4b82 extmod/utime_mphal: Implement ticks_add(), add to all maintained ports. 2016-10-29 17:30:05 +03:00
Paul Sokolovsky c62679bdaa unix/mphalport.h: Add dummy definition of mp_hal_ticks_cpu().
To fix coverage build.
2016-10-29 17:23:05 +03:00
Paul Sokolovsky 3cc87b1e2a unix/modtime: Switch ticks/sleep_ms/us() to utime_mphal. 2016-10-29 14:17:02 +03:00
Paul Sokolovsky 99ed0f25cb unix/mphalport.h: Add warning of mp_hal_delay_ms() implementation.
It's implemented in terms of usleep(), and POSIX doesn't guarantee that
usleep() can sleep for more than a second. This restriction unlikely
applies to any real-world system, but...
2016-10-29 13:38:02 +03:00
Paul Sokolovsky e381efed4a unix/modtime: Use ticks_diff() implementation from extmod/utime_mphal.c. 2016-10-29 04:58:06 +03:00
Paul Sokolovsky 760ed4629f unix/Makefile: Remove references to deprecated pip-micropython. 2016-10-25 13:11:08 +03:00
Damien George 4ebdb1f2b2 py: Be more specific with MP_DECLARE_CONST_FUN_OBJ macros.
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.
2016-10-21 16:26:01 +11:00
Paul Sokolovsky 799ccdc789 esp8266, stmhal, unix: MAKE_FROZEN is consistently defined in mkenv.mk. 2016-10-16 10:49:36 +03:00