Wykres commitów

581 Commity (698a6a9d7d8d9f4bf90287ddf60ebf5325167ec8)

Autor SHA1 Wiadomość Data
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