Commit Graph

667 Commits

Author SHA1 Message Date
Paul Sokolovsky
ec314c951d unix/modos: getenv(): Handle non-existing envvar correctly. 2015-11-14 17:12:04 +02:00
Paul Sokolovsky
908f5159cf unix/modos: Add Windows workaround for mkdir(). 2015-11-14 02:35:38 +02:00
Paul Sokolovsky
27dafa5ed5 unix/modos: Add mkdir().
Dependency of upip.
2015-11-13 22:26:51 +02:00
Paul Sokolovsky
d8557834c0 unix/modos: Add getenv().
Dependency of upip.
2015-11-13 21:30:06 +02:00
Paul Sokolovsky
a01f6c9ae7 unix/main: Remove stray mp_printf() from previous commit. 2015-11-13 17:33:42 +02:00
Paul Sokolovsky
66fd3e4a7b unix: Use standard mphalport.h header.
This also unbreaks "make minimal".
2015-11-13 15:44:26 +02:00
Paul Sokolovsky
3a6b3d230c main.c: Switch stderr printing from ANSI C to native POSIX. 2015-11-13 15:29:42 +02:00
Paul Sokolovsky
94f9330d3e unix: Allow to override MICROPY_PY_MATH_SPECIAL_FUNCTIONS from command-line. 2015-11-13 15:24:57 +02:00
Paul Sokolovsky
6d1eabfeaa unix/mpconfigport: Move log2() definition to modmath.c.
It's safer to define it where it's used, defining it for all source files
may lead to hard to diagnose conflicts in corner cases.
2015-11-13 15:24:48 +02:00
Paul Sokolovsky
f882d53fcd unix/main: Use builtin unichar_isdigit() in preference if libc's.
Less dependencies.
2015-11-13 01:57:08 +02:00
Paul Sokolovsky
3c7e1b80ac unix/modjni: Add missing get_jclass_name() function. 2015-11-11 16:43:27 +02:00
Paul Sokolovsky
6e68a68d18 unix/gccollect: Fallback to setjmp-based register fetching automatically.
Now, if we build for an architecture which doesn't have dedicated support
for getting registers for GC scanning, fallback to setjmp-based method
automatically. It's still possible to force setjmp-based implementation
on archs with dedicated support (e.g. for testing, or for peculiar calling
conventions/optimizations).
2015-11-08 16:05:33 +02:00
Paul Sokolovsky
06f70973f7 unix/unix_mphal: Typo fix in comment. 2015-11-03 00:36:46 +03:00
Damien George
731f359292 all: Add py/mphal.h and use it in all ports.
py/mphal.h contains declarations for generic mp_hal_XXX functions, such
as stdio and delay/ticks, which ports should provide definitions for.  A
port will also provide mphalport.h with further HAL declarations.
2015-10-31 19:14:30 +03:00
Paul Sokolovsky
404dae80a9 unix, stmhal: Introduce mp_hal_delay_ms(), mp_hal_ticks_ms().
These MPHAL functions are intended to replace previously used HAL_Delay(),
HAL_GetTick() to provide better naming and MPHAL separation (they are
fully equivalent otherwise).

Also, refactor extmod/modlwip to use them.
2015-10-27 23:31:42 +03:00
Paul Sokolovsky
91f2168dd5 unix/modjni: Actually check argument type when doing method resolution.
This is required to properly select among overloaded methods. It however
relies on java.lang.Object-overloaded method to come last, which appears
to be the case for OpenJDK.
2015-10-23 00:33:54 +03:00
Paul Sokolovsky
9ebd4dabf2 unix/modjni: Don't pass Java object to a method which doesn't expect it.
For example, don't pass Integer to double method. This is still not
selective enough to choose the right overloaded method maong those
taking objects.
2015-10-22 01:35:17 +03:00
Paul Sokolovsky
8e6e9eaea5 unix: Use "Ctrl" as a name of the key, not "CTRL". 2015-10-20 12:30:36 +03:00
Paul Sokolovsky
2c040edef8 libffi: Skip building docs.
This requires makeinfo installed and wastes time (especially in CI).
2015-10-19 22:30:03 +03:00
Paul Sokolovsky
39a380b621 unix/modos: Android Bionic lacks statvfs(), has BSD statfs(). 2015-10-19 21:43:20 +03:00
Paul Sokolovsky
e0f5df579b all: Make netutils.h available to all ports by default.
Generally, ports should inherit INC from py.mk, append to it, not
overwrite it. TODO: Likely should do the same for other vars too.
2015-10-19 18:32:42 +03:00
Paul Sokolovsky
8ee153f234 unix/modtime: Implement ticks_ms(), ticks_us() and ticks_diff().
All of these functions return positive small int, thus range is 2 bits less
than word size (30 bit on 32-bit systems, 62 bit on 64-bit systems).
2015-10-19 17:48:27 +03:00
Paul Sokolovsky
fd379db286 unix/modtime: Implement sleep_ms(), sleep_us(). 2015-10-19 17:48:27 +03:00
Paul Sokolovsky
949c5c9180 unix/unix_mphal: Implement HAL_Delay() and HAL_GetTick(). 2015-10-19 00:31:37 +03:00
Paul Sokolovsky
2ca7b05552 unix/modos: Checking config macros requires mpconfig.h. 2015-10-18 03:05:47 +03:00
Paul Sokolovsky
f8e9ef5cd0 unix/modos: Guard sys/statvfs.h include with MICROPY_PY_OS_STATVFS check.
E.g. Windows lacks this header.
2015-10-18 02:54:20 +03:00
Paul Sokolovsky
c3000b6f69 unix/modos: Add statvfs() function.
Another function (like stat) which is problematic to deal with on ABI level
(FFI), as struct statvfs layout may differ unpredictably between OSes and
even different versions of a same OS. So, implement it in C, returning a
10-element tuple of f_bsize, f_frsize, f_blocks, f_bfree, f_bavail, f_files,
f_ffree, f_favail, f_flag, f_namemax. This is exactly the order described
in Python3 docs, https://docs.python.org/3/library/os.html#os.statvfs
(but note that os.statvfs() should make these values available as
attributes).
2015-10-18 01:21:23 +03:00
Paul Sokolovsky
6ec6f51326 unix: Build libffi in a directory which is gitgnored.
To avoid "-dirty" version previous and spurious "modified" output from
git status, etc.
2015-10-18 00:44:45 +03:00
Damien George
556c8a9a4f unix: Fix coverage build now that mp_plat_print uses write. 2015-10-15 00:23:03 +01:00
Damien George
4300c7dba2 py: Remove dependency on printf/fwrite in mp_plat_print.
See issue #1500.
2015-10-15 00:05:55 +01:00
Paul Sokolovsky
74d0df7324 unix: Allow to build against Android down to 1.5.
Bionic libc in Android 1.5 missed log2() and nan() functions.
2015-10-15 00:11:09 +03:00
Paul Sokolovsky
fe29cc192d unix/modjni: Add iteration support for Java List objects.
Using generic iteration-via-subscription support (TODO: factor it out for
reuse).
2015-10-14 00:36:03 +03:00
Paul Sokolovsky
41eb705477 unix/modjni: call_method: Check for Java exception after method return. 2015-10-14 00:25:10 +03:00
Paul Sokolovsky
21f43ba9b0 unix/modtermios: tcsetattr: If 0 passed for "when" param, treat as TCSANOW.
As we dn't export constants for TCSANOW, etc., zero makes a good "don't
care" param, and now it will work also under Android Bionic and any other
libc.
2015-10-13 00:37:55 +03:00
Damien George
3aa7dd23c9 unix: Add exit and paste-mode hints to shell startup banner.
Thanks to @nyov for the initial patch.
2015-10-12 00:19:00 +01:00
Damien George
0334058fa4 Rename "Micro Python" to "MicroPython" in REPL, help, readme's and misc. 2015-10-12 00:06:25 +01:00
Damien George
46a1102852 repl: Add paste mode to friendly REPL, entered via CTRL-E.
Use CTRL-E to enter paste mode.  Prompt starts with "===" and accepts
all characters verbatim, echoing them back.  Only control characters are
CTRL-C which cancels the input and returns to normal REPL, and CTRL-D
which ends the input and executes it.  The input is executed as though
it were a file.  The input is not added to the prompt history.
2015-10-11 23:30:22 +01:00
Paul Sokolovsky
1b586f3a73 py: Rename MP_BOOL() to mp_obj_new_bool() for consistency in naming. 2015-10-11 15:18:15 +03:00
Anmol Sarma
95b352064e unix/modsocket: Fix usage of pointers to locals outside scope 2015-10-10 17:29:26 +05:30
Paul Sokolovsky
7381b7ac71 unix/modjni: py2jvalue: Support bool and None values. 2015-10-10 01:20:48 +03:00
Paul Sokolovsky
02041bf2e0 unix/modjni: jvalue2py() is currently not used.
Not remove so far, may be needed later.
2015-10-09 00:27:27 +03:00
Paul Sokolovsky
216b6a494e unix/modjni: Allow to access fields of objects. 2015-10-08 16:57:02 +03:00
Paul Sokolovsky
fd38799049 unix/modjni: After Call*Method(), Java exception should always be checked.
OpenJDK seemed to return NULL in case of exception, but Dalvik returns
arbitrary value, so skip such "optimizations".
2015-10-07 07:40:29 +03:00
Paul Sokolovsky
aaa8867d4a modussl: SSL socket wrapper module based on axTLS. 2015-10-06 18:10:39 +03:00
Paul Sokolovsky
326ff54649 unix: Add support for building axtls dependency lib. 2015-10-04 02:39:01 +03:00
Paul Sokolovsky
1ea4b77a9a unix/modjni: jclass.__str__/__repr__: Return Java .toString() value. 2015-10-04 01:57:07 +03:00
Paul Sokolovsky
f22be4ebd9 unix/modjni: jobject.__str__/__repr__: Return Java .toString() value. 2015-10-03 08:58:46 -07:00
Paul Sokolovsky
9e0a3d46b6 unix/modjni: Convert Java's IndexOutOfBoundsException to Python's IndexError. 2015-10-02 00:22:09 -07:00
Damien George
58e0f4ac50 py: Allocate parse nodes in chunks to reduce fragmentation and RAM use.
With this patch parse nodes are allocated sequentially in chunks.  This
reduces fragmentation of the heap and prevents waste at the end of
individually allocated parse nodes.

Saves roughly 20% of RAM during parse stage.
2015-10-02 00:11:11 +01:00
Damien George
a81539db25 tests: Add further tests for mpz code. 2015-10-01 18:49:37 +01:00
Paul Sokolovsky
c4489a0543 unix/modjni: Propagate Java exceptions on list access. 2015-10-01 01:20:56 -07:00
Paul Sokolovsky
0eba162ab5 unix/modjni: Fix method argument matching. 2015-09-30 00:55:09 -07:00
Paul Sokolovsky
f3ca8623f7 unix/modjni: Implement len() for objects with java.util.List interface. 2015-09-29 10:06:07 -07:00
Paul Sokolovsky
77020281ae unix/modjni: call_method: Delete done local references in loop.
To avoid local ref table overflow.
2015-09-28 08:37:34 -07:00
Paul Sokolovsky
0d28a3edb9 unix/modjni: call_method: Better resource release. 2015-09-27 22:32:54 -07:00
Paul Sokolovsky
81d64ab939 unix/modjni: call_method(): If name doesn't match, cleanup via goto next_method. 2015-09-26 08:51:22 -07:00
Paul Sokolovsky
c0a79cc919 unix/modjni: Need to really use per-rettype Call*Method functions. 2015-09-26 08:49:12 -07:00
Paul Sokolovsky
7e18d3b6ff unix/modjni: new_jobject(): Handle null reference. 2015-09-24 15:29:57 -07:00
Paul Sokolovsky
e632b1fda7 unix/modjni: Factor out is_object_type(). 2015-09-23 07:11:56 -07:00
Vicente Olivert Riera
587914169c unix/modffi.c: cast first to intptr_t when casting from/to pointer
This fixes errors like these ones:

modffi.c: In function 'return_ffi_value':
modffi.c:143:29: error: cast to pointer from integer of different size
[-Werror=int-to-pointer-cast]
             const char *s = (const char *)val;
                             ^
modffi.c:162:20: error: cast to pointer from integer of different size
[-Werror=int-to-pointer-cast]
             return (mp_obj_t)val;
                    ^
modffi.c: In function 'ffifunc_call':
modffi.c:358:25: error: cast from pointer to integer of different size
[-Werror=pointer-to-int-cast]
             values[i] = (ffi_arg)a;
                         ^
modffi.c:373:25: error: cast from pointer to integer of different size
[-Werror=pointer-to-int-cast]
             values[i] = (ffi_arg)s;
                         ^
modffi.c:381:25: error: cast from pointer to integer of different size
[-Werror=pointer-to-int-cast]
             values[i] = (ffi_arg)bufinfo.buf;
                         ^
modffi.c:384:25: error: cast from pointer to integer of different size
[-Werror=pointer-to-int-cast]
             values[i] = (ffi_arg)p->func;
                         ^

These errors can be highlighted when building micropython from MIPS64
n32 because ffi_arg is 64-bit wide and the pointers on MIPS64 n32 are
32-bit wide, so it's trying to case an integer to a pointer (or
vice-versa) of a different size. We should cast first the pointer (or the
integer) to a pointer sized integer (intptr_t) to fix that problem.

Signed-off-by: Vicente Olivert Riera <Vincent.Riera@imgtec.com>
2015-09-22 18:54:31 -07:00
Paul Sokolovsky
ed22e9ba3e unix/modjni: Move type analysis logic to new_jobject(), for reuse. 2015-09-22 17:02:17 -07:00
Paul Sokolovsky
b2d880d749 unix/modjni: Support for subscripting of Java lists (r/o so far). 2015-09-21 12:02:54 -07:00
Paul Sokolovsky
6196aa45ed unix/modjni: jvalue2py: Handle boolean. 2015-09-20 00:36:51 +03:00
Alex March
c0035d1694 unix: Use MICROPY_HAL_H macro for header inclusion.
Follow the same format as other ports using the macro to include
the HAL header.
2015-09-19 14:03:57 +01:00
Paul Sokolovsky
1e9d8e110b unix/modjni: py2jvalue: Pass jobject's down to Java.
So far, no signature check is done (TODO).
2015-09-19 01:05:25 +03:00
Paul Sokolovsky
011c7f5718 unix/modjni: py2jvalue: Handle both int and long java types (with TODO for long). 2015-09-18 13:21:21 +03:00
Paul Sokolovsky
1cb5de2cd5 unix/modjni: jvalue2py: Handle class-containing jvalues. 2015-09-17 13:31:40 +03:00
Paul Sokolovsky
cb6cf5e257 unix/modjni: Add env() module function.
Useful to load native method libraries not loaded by VM (as happens on
Android).
2015-09-16 01:10:09 +03:00
Tom Soulanille
aeb62f9ae3 py/objslice: Make slice attributes (start/stop/step) readable.
Configurable with MICROPY_PY_BUILTINS_SLICE_ATTRS.  Disabled by default.
2015-09-15 21:59:20 +01:00
Paul Sokolovsky
b230a86d33 unix/modjni: Return any object type value as a jobject. 2015-09-15 14:07:39 +03:00
Paul Sokolovsky
5167332131 unix/modjni: Return Java null as Python None. 2015-09-14 00:15:35 +03:00
Paul Sokolovsky
7a4b10cc4c unix/modjni: Support static methods. 2015-09-14 00:12:47 +03:00
Paul Sokolovsky
26a9b4d48e unix/modjni: Factor out new_jobject(), jvalue2py() functions. 2015-09-13 01:27:47 +03:00
Damien George
3ca84026db unix: Enable REPL auto-indent. 2015-09-12 22:09:18 +01:00
Paul Sokolovsky
4e7bde8c9e unix/modjni: Factor out py2jvalue() function. 2015-09-12 00:20:06 +03:00
Paul Sokolovsky
e79c6b6312 unix/modjni: "jni" module to interface to JNI-compliant JavaVM.
This includes Android Dalvik VM for example.

Example usage:

import jni
System = jni.cls("java/lang/System")
System.out.println("Hello, Java!")
2015-09-11 21:38:57 +03:00
Damien George
25afc7da0d tests: Add tests to improve coverage of objstr.c. 2015-09-03 23:06:18 +01:00
Paul Sokolovsky
696eee9475 modffi: dlsym() doesn't set errno, so use ENOENT for OSError.
This may be a bit confusing, as ENOENT is often rendered as "No such
file or directory", but any other code would be only more confusing.
2015-08-31 00:20:08 +03:00
Paul Sokolovsky
a9058bf294 unix: Allow to build libffi from source and link against it.
Linking against local libffi (and other libs in future) is triggered by
"make MICROPY_STANDALONE=1". Before that, dependent libs should be built
with "make deplibs".
2015-08-30 15:26:25 +03:00
Paul Sokolovsky
18c22faf4d py: Treat -m32 flag as part of CC, LD, etc.
Indeed, this flag efectively selects architecture target, and must
consistently apply to all compiles and links, including 3rd-party
libraries, unlike CFLAGS, which have MicroPython-specific setting.
2015-08-29 21:18:10 +03:00
Paul Sokolovsky
aa65e1edb3 unix: Bump default heap size to 1MB (2MB on 64-bit systems). 2015-08-22 23:54:25 +03:00
Paul Sokolovsky
22ff397fb1 py: Add MICROPY_PY_BUILTINS_FILTER, disable for minimal ports.
Saves 320 bytes on x86.
2015-08-20 01:05:11 +03:00
blmorris
bdd78c31b6 py: Add stream_tell method, and use for unix and stmhal file tell. 2015-08-13 22:56:32 +01:00
blmorris
26664dd180 unix/mpconfigport.h: set MICROPY_PY_SYS_PLATFORM to "darwin" if compiled on OSX
This change allows micropython to return the same value as CPython for sys.platform
2015-08-05 21:18:33 +03:00
Tom Soulanille
7d588b0c7c lib/mp-readline: Add emacs-style control characters for cursor movement.
Disabled by default.  Adds 108 bytes to Thumb2 arch when enabled.
2015-07-26 15:22:13 +01:00
Paul Sokolovsky
c48740e20b unix: modsocket: Implement inet_pton() in preference of inet_aton().
inet_pton supports both ipv4 and ipv6 addresses. Interface is also extensible
for other address families, but underlying libc inet_pton() function isn't
really extensible (e.g., it doesn't return length of binary address, i.e. it's
really hardcoded to AF_INET and AF_INET6). But anyway, on Python side, we could
extend it to support other addresses.
2015-07-15 00:06:03 +03:00
Paul Sokolovsky
b178dccb9c unix: modsocket: Implement recvfrom().
Required to implement UDP servers.
2015-07-14 01:47:02 +03:00
Paul Sokolovsky
3b83aeb403 unix: modsocket: Implement sendto().
sendto() turns out to be mandatory function to work with UDP. It may seem
that connect(addr) + send() would achieve the same effect, but what connect()
appears to do is to set source address filter on a socket to its argument.
Then everything falls apart: socket sends to a broad-/multi-cast address,
but reply is sent from real peer address, which doesn't match filter set
by connect(), so local socket never sees a reply.
2015-07-12 13:53:35 +03:00
Paul Sokolovsky
115afdb07d unix: socket.getaddrinfo: Port is unsigned value.
Treating it as signed lead to buffer overflow for ports >= 32768.
2015-07-11 00:06:10 +03:00
Paul Sokolovsky
8eb802a55b unix: socket.getaddrinfo: Accept family & socktype arguments.
This usually allows to get just a single address entry.
2015-07-10 01:50:23 +03:00
Paul Sokolovsky
354d17523f modmachine: Implement physical memory access using /dev/mem (Linux, etc).
This requires root access. And on recent Linux kernels, with
CONFIG_STRICT_DEVMEM option enabled, only address ranges listed in
/proc/iomem can be accessed. The above compiled-time option can be
however overriden with boot-time option "iomem=relaxed".

This also removed separate read/write paths - there unlikely would
be a case when they're different.
2015-07-08 11:37:23 +03:00
Ari Suutari
63b9e598a3 unix: Add O_WRONLY | O_CREAT to open call when opening file for append ("a").
To comply with Python semantics.
2015-06-21 00:03:26 +03:00
Damien George
06593fb0f2 py: Use a wrapper to explicitly check self argument of builtin methods.
Previous to this patch a call such as list.append(1, 2) would lead to a
seg fault.  This is because list.append is a builtin method and the first
argument to such methods is always assumed to have the correct type.

Now, when a builtin method is extracted like this it is wrapped in a
checker object which checks the the type of the first argument before
calling the builtin function.

This feature is contrelled by MICROPY_BUILTIN_METHOD_CHECK_SELF_ARG and
is enabled by default.

See issue #1216.
2015-06-20 16:39:39 +01:00
Damien George
031278f661 unix: Allow to cat a script into stdin from the command line.
See issue #1306.
2015-06-04 23:42:45 +01:00
Damien George
181adc6a4e unix: Update .gitignore; now ignores coverage build. 2015-06-03 17:47:31 +01:00
Paul Sokolovsky
c36635c112 unix: Prepare upip frozen modules under build/. 2015-06-03 19:28:31 +03:00
Paul Sokolovsky
a546acda8c unix: Uncompress upip tarball to build directory. 2015-06-03 01:55:54 +03:00
Paul Sokolovsky
9456732b86 unix: Include upip as fronzen modules inside the standard interpreter.
MicroPython doesn't come with standard library included, so it is important
to be able to easily install needed package in a seamless manner. Bundling
package manager (upip) inside an executable solves this issue.

upip is bundled only with standard executable, not "minimal" or "fast"
builds.
2015-06-02 01:32:07 +03:00
stijn
100004eeaf unix: Print an extra newline to the output on ctrl-D
This assures the terminal prints it's prompt on a fresh line instead of
appending it to the uPy prompt after exit.
2015-05-30 13:38:17 +03:00
Paul Sokolovsky
6a664cb114 unix: minimal: Don't use readline support.
After switching to builtin readline support, "minimal" no longer builds, and
minimal doesn't really need readline support.
2015-05-30 13:13:43 +03:00
Paul Sokolovsky
51726b4d43 unix: Allow to override default sys.path value.
Using MICROPY_PY_SYS_PATH_DEFAULT macro define. A usecase is building a
distribution package, which should not have user home path by default in
sys.path. In such case, MICROPY_PY_SYS_PATH_DEFAULT can be defined on
make command-line (using CFLAGS_EXTRA).
2015-05-30 01:07:58 +03:00
Damien George
a16715ac62 tests: Add special tests to test mp_printf function to improve coverage. 2015-05-28 14:25:07 +00:00
Damien George
9ae3fc6523 unix: Add option to use uPy readline, and enable by default.
This gets uPy readline working with unix port, with tab completion and
history.  GNU readline is still supported, configure using
MICROPY_USE_READLINE variable.
2015-05-27 15:59:43 +01:00
Damien George
4a10214be2 unix: Factor out stdio and ctrl-C code to unix_mphal.c file. 2015-05-27 15:52:35 +01:00
Paul Sokolovsky
ebf8dc6b03 Revert "unix: Include stdio.h to allow easy debugging with printf()."
This reverts commit 8fbabab1a8. Turned to
cause problems on MacOSX.
2015-05-17 09:59:06 +03:00
Damien George
f601390ef8 unix: Add some extra coverage tests for vstr and attrtuple. 2015-05-12 23:34:10 +01:00
Paul Sokolovsky
8fbabab1a8 unix: Include stdio.h to allow easy debugging with printf(). 2015-05-10 17:13:33 +03:00
Paul Sokolovsky
717a958256 unix: Print unhandled exception to stderr, like CPython does. 2015-05-10 00:55:35 +03:00
Paul Sokolovsky
c3ae03ff18 unix: Fix thumb2 vs arm native emitter auto-detection.
Make thumb2 have priority over arm.
2015-05-08 22:35:34 +01:00
Damien George
d792d9e49e unix: Make extra-coverage function callable from Python scripts.
This allows the output of the extra-coverage tests to be checked using
the normal run-tests script.
2015-05-08 09:18:38 +01:00
Damien George
d3b32caea4 unix: Add special function to improve coverage.
The function and corresponding command-line option are only enabled for
the coverage build.  They are used to exercise uPy features that can't
be properly tested by Python scripts.
2015-05-08 00:19:56 +01:00
Paul Sokolovsky
5ab5ac5448 modbuiltins: Add NotImplemented builtin constant.
From https://docs.python.org/3/library/constants.html#NotImplemented :
"Special value which should be returned by the binary special methods
(e.g. __eq__(), __lt__(), __add__(), __rsub__(), etc.) to indicate
that the operation is not implemented with respect to the other type;
may be returned by the in-place binary special methods (e.g. __imul__(),
__iand__(), etc.) for the same purpose. Its truth value is true."

Some people however appear to abuse it to mean "no value" when None is
a legitimate value (don't do that).
2015-05-04 19:45:53 +03:00
Paul Sokolovsky
0116218fa8 modmachine: Add new module to access hardware, starting with physical memory.
Refactored from "stm" module, provides mem8, mem16, mem32 objects with
array subscript syntax.
2015-05-04 13:05:12 +03:00
Damien George
a9afcb159a unix/modffi.c: get_buffer is allowed to return NULL if len=0.
This is consistent with the logic in mp_get_buffer, and the code here is
an inlined version of that function.
2015-05-01 21:34:08 +01:00
Damien George
95f53461c2 py: Replace py-version.sh with makeversionhdr.py, written in Python.
Also rename py-version.h to mpversion.h for consistency with mpconfig.h.
2015-04-28 23:52:36 +01:00
Damien George
6bbbb1ab41 unix/modffi: Support passing float/double args. 2015-04-28 19:40:34 +01:00
Paul Sokolovsky
8b85d14b92 modsys: Add basic sys.exc_info() implementation.
The implementation is very basic and non-compliant and provided solely for
CPython compatibility. The function itself is bad Python2 heritage, its
usage is discouraged.
2015-04-25 03:49:23 +03:00
Damien George
7f9d1d6ab9 py: Overhaul and simplify printf/pfenv mechanism.
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.
2015-04-16 14:30:16 +00:00
Paul Sokolovsky
d35ac956d1 input.c: Fix line-endings after recent changes. 2015-04-10 23:01:58 +03:00
stijn
df1637c580 unix: Automatically fix incompatible readline build options. 2015-04-09 13:35:16 +00:00
Paul Sokolovsky
282ca09f8e py: Add MICROPY_PY_BUILTINS_REVERSED, disable for minimal ports. 2015-04-07 00:17:11 +03:00
Paul Sokolovsky
e2d44e30c7 py: Add MICROPY_PY_BUILTINS_ENUMERATE, disable for minimal ports. 2015-04-06 23:51:29 +03:00
Paul Sokolovsky
ac2f7a7f6a objstr: Add .splitlines() method.
splitlines() occurs ~179 times in CPython3 standard library, so was
deemed worthy to implement. The method has subtle semantic differences
from just .split("\n"). It is also defined as working for any end-of-line
combination, but this is currently not implemented - it works only with
LF line-endings (which should be OK for text strings on any platforms,
but not OK for bytes).
2015-04-04 00:09:48 +03:00
Paul Sokolovsky
dbc0191d5f unix: Add stackless config settings, for easy access. 2015-04-03 00:27:14 +03:00
stijn
28fa84b445 py: Add optional support for descriptors' __get__ and __set__ methods.
Disabled by default.  Enabled on unix and windows ports.
2015-03-26 23:55:14 +00:00
Damien George
4a8556ca58 unix: Remove -Wdouble-promotion from main build, and 2 from coverage.
The 2 removed from coverage build are: -Wredundant-decls and
-Wstrict-prototypes.
2015-03-22 22:41:45 +00:00
Paul Sokolovsky
6bf423df2c unix: Bump stack limit and adjust for 64-bitness.
Without that, "import http.client" failed due to max recursion.
2015-03-21 02:16:45 +02:00
stijn
3cc17c69ff py: Allow retrieving a function's __name__.
Disabled by default.  Enabled on unix and stmhal ports.
2015-03-20 23:13:32 +00:00
Paul Sokolovsky
8d51c9d376 unix: When using separate obj output dirs, make -B is no longer relevant. 2015-03-21 00:42:29 +02:00
Damien George
2e22c2b477 unix: Move compiler warnings from production build to coverage build. 2015-03-20 22:33:13 +00:00
Paul Sokolovsky
0ef01d0a75 py: Implement core of OrderedDict type.
Given that there's already support for "fixed table" maps, which are
essentially ordered maps, the implementation of OrderedDict just extends
"fixed table" maps by adding an "is ordered" flag and add/remove
operations, and reuses 95% of objdict code, just making methods tolerant
to both dict and OrderedDict.

Some things are missing so far, like CPython-compatible repr and comparison.

OrderedDict is Disabled by default; enabled on unix and stmhal ports.
2015-03-20 17:26:10 +00:00
Damien George
92496abe0f unix: Enable extra compiler warnings.
To address issue #699.
2015-03-19 00:25:33 +00:00
Damien George
42e0c59308 py: Add MICROPY_COMP_{DOUBLE,TRIPLE}_TUPLE_ASSIGN config options.
These allow to fine-tune the compiler to select whether it optimises
tuple assignments of the form a, b = c, d and a, b, c = d, e, f.
Sensible defaults are provided.
2015-03-14 13:11:35 +00:00
Paul Sokolovsky
1129de5ac0 unix: Support readline history saving to file, improves interactive usage. 2015-03-13 21:46:19 +00:00
Damien George
d891452a73 py: Add MICROPY_MALLOC_USES_ALLOCATED_SIZE to allow simpler malloc API. 2015-03-03 21:23:13 +00:00
Damien George
81e661f28b travis: Add automated coverage testing using coveralls. 2015-03-01 14:50:09 +00:00
Paul Sokolovsky
cefcbb22b2 objarray: Implement array slice assignment.
This is rarely used feature which takes enough code to implement, so is
controlled by MICROPY_PY_ARRAY_SLICE_ASSIGN config setting, default off.
But otherwise it may be useful, as allows to update arbitrary-sized data
buffers in-place.

Slice is yet to implement, and actually, slice assignment implemented in
such a way that RHS of assignment should be array of the exact same item
typecode as LHS. CPython has it more relaxed, where RHS can be any sequence
of compatible types (e.g. it's possible to assign list of int's to a
bytearray slice).

Overall, when all "slice write" features are implemented, it may cost ~1KB
of code.
2015-02-27 22:17:15 +02:00
Paul Sokolovsky
bbaf68f2cb modffi: Implement 'O' type handling for func arguments. 2015-02-25 23:38:22 +02:00
Damien George
5cbeacebdb py: Make math special functions configurable and disabled by default.
The implementation of these functions is very large (order 4k) and they
are rarely used, so we don't enable them by default.

They are however enabled in stmhal and unix, since we have the room.
2015-02-22 14:48:18 +00:00
Paul Sokolovsky
99bcaa2fb6 modffi: Add toplevel func() function to create a function by pointer. 2015-02-11 07:21:03 +08:00
Damien George
0bfc7638ba py: Protect mp_parse and mp_compile with nlr push/pop block.
To enable parsing constants more efficiently, mp_parse should be allowed
to raise an exception, and mp_compile can already raise a MemoryError.
So these functions need to be protected by an nlr push/pop block.

This patch adds that feature in all places.  This allows to simplify how
mp_parse and mp_compile are called: they now raise an exception if they
have an error and so explicit checking is not needed anymore.
2015-02-07 18:33:58 +00:00
Paul Sokolovsky
8775caf9f1 modffi: Add .addr() method to just get symbol address. 2015-02-06 00:19:43 +02:00
Paul Sokolovsky
98c4bc3fac py: Add MICROPY_PY_ALL_SPECIAL_METHODS and __iadd__ special method under it. 2015-01-31 00:35:56 +02:00
Damien George
598af3a7d6 unix: Add "coverage" target to do coverage testing using gcov. 2015-01-29 14:54:38 +00:00
Paul Sokolovsky
31c1f1300e modffi: 's' (string) return type: handle NULL properly (return None). 2015-01-25 01:36:14 +02:00
Paul Sokolovsky
2e526ff1a1 modffi: Support return values of mp_obj_t type. 2015-01-22 01:09:17 +02:00
Paul Sokolovsky
0ab3fc3805 modffi: Support open own executable using open(None). 2015-01-21 00:38:06 +02:00
Damien George
ff8dd3f486 py, unix: Allow to compile with -Wunused-parameter.
See issue #699.
2015-01-20 12:47:20 +00:00
Damien George
50912e7f5d py, unix, stmhal: Allow to compile with -Wshadow.
See issue #699.
2015-01-20 11:55:10 +00:00
Damien George
51ef28a9d6 unix: Update .gitignore for "fast" and "minimal" builds. 2015-01-16 18:05:31 +00:00