Paul Sokolovsky
9a092831f7
unix: Enable modffi by default.
...
ffi is needed to use micropython-lib, so let's have it enabled by default,
then folks who have troubles with libffi can disable it, instead of everyone
doing manual actions again and again.
2014-04-13 00:01:40 +03:00
xbe
a36a55d2cf
unix: Update comment in gccollect.c
2014-04-11 06:42:17 -07:00
Paul Sokolovsky
263853ef84
modffi: Update for latest binary API refactors.
2014-04-11 05:17:41 +03:00
Damien George
f22626ee4f
unix: Add option to only compile, and not execute code.
2014-04-10 11:30:35 +01:00
Paul Sokolovsky
3aa8ee7c9e
py: Add mp_get_buffer(), mp_get_buffer_raise() convenience functions to API.
2014-04-09 01:07:37 +03:00
Paul Sokolovsky
f898a95cba
unix modffi: Support any object implementing buffer protocol as a native arg.
2014-04-08 19:08:34 +03:00
Damien George
72cfc6ef0a
unix: Oops, remove nlr_jump test in main.
2014-04-08 15:10:21 +01:00
Damien George
26cf55ae05
Add a check for NULL nlr_top in nlr_jump.
...
If no nlr_buf has been pushed, and an nlr_jump is called, then control
is transferred to nlr_jump_fail (which should bail out with a fatal
error).
2014-04-08 14:08:14 +00:00
Damien George
97790455fe
Improve REPL detecting when input needs to continue.
...
Full CPython compatibility with this requires actually parsing the
input so far collected, and if it fails parsing due to lack of tokens,
then continue collecting input. It's not worth doing it this way. Not
having compatibility at this level does not hurt the goals of Micro
Python.
2014-04-08 11:04:29 +00:00
Paul Sokolovsky
72d70cb045
unix, stmhal: Consistently use "FileIO" as class name for file objects.
...
They correspond to io.FileIO in io module hierarchy (with small caveat
that io.FileIO is raw file and works with bytes, not strings).
2014-04-08 04:08:16 +03:00
Paul Sokolovsky
b8cf948550
unix, windows: There's no "help" builtin.
2014-04-08 04:07:02 +03:00
Damien George
6827f9fc55
Add uPy welcome message to UNIX and Windows ports; update Teensy port.
...
Partly addresses issue #154 .
2014-04-07 13:27:50 +01:00
Damien George
65cad12d38
py: Add option to compiler to specify default code emitter.
...
Also add command line option to unix port to select emitter.
2014-04-06 11:48:15 +01:00
Damien George
27e735fd18
py: Replace stream_p with *stream_p in mp_obj_type_t.
...
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/.
2014-04-05 23:02:23 +01:00
Damien George
7efc5b3f34
py: Make globals and locals proper dictionary objects.
...
Finishes addressing issue #424 .
In the end this was a very neat refactor that now makes things a lot
more consistent across the py code base. It allowed some
simplifications in certain places, now that everything is a dict object.
Also converted builtins tables to dictionaries. This will be useful
when we need to turn builtins into a proper module.
2014-04-05 22:36:42 +01:00
Damien George
12bab72d93
Improve GC finalisation code; add option to disable it.
2014-04-05 20:35:48 +01:00
Damien George
ea13f407a3
py: Change nlr_jump to nlr_raise, to aid in debugging.
...
This does not affect code size or performance when debugging turned off.
To address issue #420 .
2014-04-05 18:32:08 +01:00
Paul Sokolovsky
c39368427c
unix: Rename module sources per latest naming conventions (mod*.c).
2014-04-04 20:34:10 +03:00
Paul Sokolovsky
cd31d826bf
unix: Use STATIC modifier to enable code size analysis via map file.
2014-04-04 20:34:02 +03:00
Paul Sokolovsky
70193b2b4c
unix: Routines related to terminal reading should use system malloc.
...
Otherwise we have mixup between system and GC alloc.
2014-04-04 17:50:02 +03:00
Damien George
bd17e1b3ae
unix: Allocate more heap memory by default on 64 bit machines.
...
Pointers are 2x bigger on 64 bit machines, so we should allocate twice
the memory to have a comparable heap size.
2014-04-04 14:29:00 +01:00
Damien George
4b34c76fd6
Changes to get unix/ port compiling on Cygwin.
2014-04-03 23:51:16 +01:00
Paul Sokolovsky
c61ce96590
unix file: Implement context manager protocol (for "with" statement).
2014-04-03 22:09:05 +03:00
Paul Sokolovsky
78e8e30c87
unix: Enable GC.
...
GC support for "unix" port was implemented some time ago, but still not
enabled.
2014-04-02 20:57:19 +03:00
Paul Sokolovsky
d440dc0513
unix: Use argv[0] for command name in usage.
2014-04-02 20:31:18 +03:00
Paul Sokolovsky
a55a5469c3
unix: Support #if-able impl-specific cmdline options.
...
For example, we still build w/o GC enabled, so cannot really set heap size.
2014-04-02 20:29:18 +03:00
Paul Sokolovsky
d4e7e06d7f
unix: Properly recognize and report when script on cmdline not found.
...
Previosuly just silently exited.
2014-04-02 20:25:01 +03:00
Damien George
15d18069c5
py: Remove old "run time" functions that were 1 liners.
2014-03-31 16:28:13 +01:00
Damien George
df6567e634
Merge map.h into obj.h.
...
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.
2014-03-30 13:54:02 +01:00
Damien George
d17926db71
Rename rt_* to mp_*.
...
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.
2014-03-30 13:35:08 +01:00
Damien George
918638ec6e
unix: Fix ffi.c to compile with latest changes to API.
2014-03-29 13:48:32 +00:00
Damien George
3e1a5c10c5
py: Rename old const type objects to mp_type_* for consistency.
2014-03-29 13:43:38 +00:00
Damien George
9b196cddab
Remove mp_obj_type_t.methods entry and use .locals_dict instead.
...
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.
2014-03-26 21:47:19 +00:00
Damien George
c12b2213c1
Change mp_method_t.name from const char * to qstr.
...
Addresses issue #377 .
2014-03-26 20:15:40 +00:00
xbe
c93a22197b
unix: Clean up includes.
...
Remove unnecessary includes. Add includes that improve portability.
2014-03-16 12:14:15 -07:00
Damien George
5e34909a12
unix: Make usage info reflect actual usage of -X option.
2014-03-08 19:04:47 +00:00
Damien George
0c36da0b59
Implement ROMable modules. Add math module.
...
mp_module_obj_t can now be put in ROM.
Configuration of float type is now similar to longint: can now choose
none, float or double as the implementation.
math module has basic math functions. For STM port, these are not yet
implemented (they are just stub functions).
2014-03-08 15:24:39 +00:00
Damien George
635927bbce
unix: Add to usage print-out telling about -X option.
2014-03-04 08:39:47 +00:00
Paul Sokolovsky
a374d9c860
unix: Allow to set heap size using "-X heapsize=N" option.
2014-03-04 10:56:52 +08:00
Paul Sokolovsky
61f9b1c621
unix: Add GC support for ARM architecture.
2014-03-03 11:35:45 +08:00
Paul Sokolovsky
793838a919
MICROPY_USE_READLINE: Selects link lib, so should be defined in mpconfigport.mk
...
This change allows to build unix version without libreadline installed.
2014-02-28 11:09:29 +02:00
Damien George
ce1162ab15
GC: Fix printf formats for debugging; add gc_dump_alloc_table.
2014-02-26 22:55:59 +00:00
Damien George
438c88dd2f
Add arbitrary precision integer support.
...
Some functionality is still missing (eg and, or, bit shift), and some
things are buggy (eg subtract).
2014-02-22 19:25:23 +00:00
Paul Sokolovsky
44739e280e
Make DEBUG_printf() a proper function, implementation is port-dependent.
...
In particular, unix outputs to stderr, to allow to run testsuite against
micropython built with debug output (by redirecting stderr to /dev/null).
2014-02-16 18:20:49 +02:00
Damien George
c5966128c7
Implement proper exception type hierarchy.
...
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.
2014-02-15 16:10:44 +00:00
Damien George
a71c83a1d1
Change mp_obj_type_t.name from const char * to qstr.
...
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.
2014-02-15 11:34:50 +00:00
Damien George
9307ef46ca
Merge pull request #291 from GordonMcGregor/osx_build
...
OS X compatible -map syntax for LDFLAGS
2014-02-14 23:08:29 +00:00
Damien George
7ef098000a
Merge pull request #288 from pfalcon/port-builtins
...
Allow ports to define statically builtin functions.
2014-02-14 23:05:50 +00:00
Gordon McGregor
3890ec48e7
OS X compatible -map syntax for LDFLAGS
2014-02-14 16:38:05 -06:00
Paul Sokolovsky
8bc3516389
ffi: Implement ffivar.get()/set() methods.
...
Done by introducing another factored out helper API in binary.c. This API
can be reused also by array and struct modules.
2014-02-14 20:38:35 +02:00
Paul Sokolovsky
910843e86d
Allow ports to define statically builtin functions.
...
Convert unix open() to such.
2014-02-14 12:13:34 +02:00
Paul Sokolovsky
5be1b2873b
unix Makefile: Split off optimization options to COPT variable.
...
To allow easily try different optimization and configuration options
without patching any files.
2014-02-12 20:20:39 +02:00
Damien George
323f39a2b3
Merge pull request #278 from pfalcon/unix-gc
...
Enable GC for Unix port
2014-02-11 21:42:09 +00:00
Paul Sokolovsky
723a6ed371
More GC debugging improvements.
2014-02-11 18:09:50 +02:00
Paul Sokolovsky
e7db8171d8
unix: Implement garbage collection support.
2014-02-11 16:20:02 +02:00
Paul Sokolovsky
287d9620fc
Enable link map file generation.
2014-02-11 14:42:20 +02:00
Paul Sokolovsky
a075741c90
Rename str_join -> strjoin to make it not clash with objstr's one.
2014-02-11 14:39:10 +02:00
Damien George
d46ca25757
Fix some int casting that failed on 64 bit architecture.
2014-02-10 21:46:47 +00:00
Paul Sokolovsky
2e24ee8d80
socket: Tighten up int-to-str conversion.
2014-02-10 18:39:10 +02:00
Paul Sokolovsky
8c25201d9d
socket: Make sure that symbol definitions are const.
2014-02-10 18:39:06 +02:00
Paul Sokolovsky
f766264582
unix: Implement time.sleep().
2014-02-09 12:52:04 +02:00
Paul Sokolovsky
557c9d5264
unix microsocket: Add dummy makefile() method.
...
Unlike CPython socket, microsocket object already implements stream protocol
(read/write methods), so makefile() just returns object itself. TODO: this
doesn't take care of arguments CPython's makefile() may accept.
2014-02-08 22:00:20 +02:00
Paul Sokolovsky
21c51f0bde
ffi: Fix mp_obj_str_get_data() return type.
2014-02-08 22:00:15 +02:00
Paul Sokolovsky
1e19b24ea0
io.File, socket types: Add fileno() method.
...
Implementation is duplicated, but tolerate this for now, because there's
no clear idea how to de-dup it.
2014-02-08 21:20:32 +02:00
Paul Sokolovsky
9945f33886
Rename "rawsocket" module to "microsocket".
...
It's no longer intended to provide just "raw" socket interface, may include
some convenience methods for compatibility with CPython socket - but anyway
just minimal set required to deal with socket client and servers, not wider
network functionality.
2014-02-08 21:20:32 +02:00
Damien George
698ec21e46
Make mp_obj_str_get_data return char* instead of byte*.
...
Can't decide which is better for string type, char or byte pointer.
Changing to char removes a few casts. Really need to do proper unicode.
2014-02-08 18:17:23 +00:00
Damien George
354d15a964
Implement fixed buffer vstrs; use them for import path.
2014-02-06 21:11:19 +00:00
Damien George
e09ffa1400
Search paths properly on import and execute __init__.py if it exists.
2014-02-05 23:57:48 +00:00
Paul Sokolovsky
9110896063
Remove older import helpers, no longer used.
2014-02-05 02:03:23 +02:00
Paul Sokolovsky
630d85120f
unix: Be sure to add current/base dir of a script to sys.path.
...
This mirrors CPython behavior and makes possible to run scripts which
import other modules not from script's directory.
2014-02-05 01:53:44 +02:00
Paul Sokolovsky
625d08a93e
unix: Initialize sys.path from MICROPYPATH environment variable.
...
If it's not available, "~/.micropython/lib:/usr/lib/micropython" is used
as a fallback.
2014-02-05 01:40:41 +02:00
Paul Sokolovsky
0c59db1973
Use qstr id to create sys module.
2014-02-04 19:36:00 +02:00
Paul Sokolovsky
6964422cf4
unix time.clock(): Actually return float value.
2014-02-02 08:58:16 +02:00
Paul Sokolovsky
a9459bc723
unix: Add basic time module (with time() and clock() functions).
...
Both return int so far (single-precision float doesn't have enough
bits to represent int32 precisely).
2014-02-02 01:34:11 +02:00
Damien George
a908202d60
unix: libffi include path now found using pkg-config.
...
Hopefully this works for other people as well :)
2014-02-01 18:48:19 +00:00
Paul Sokolovsky
ed1239fce6
Add mpconfigport.mk file to configure which modules to include into build.
...
Proof of concept, controls "ffi" module as one which requires external
dependencies.
2014-02-01 20:09:45 +02:00
Damien George
62ad189a65
py: Add compile option to enable/disable source line numbers.
2014-01-29 21:51:51 +00:00
Damien George
4d5b28cd08
Add qstr_info() function and bindings for unix port.
2014-01-29 18:56:46 +00:00
Damien George
8bf91f2a87
unix: Fix compile warnings for ffi module on 64-bit machine.
2014-01-28 23:08:11 +00:00
Paul Sokolovsky
60a9fac8d4
unix: Initial implementation of FFI module.
...
Foreign Function Interface module allows to load native dynamic libraries,
call functions and access variables in them. This makes possible to write
interface modules in pure Python.
This module provides thin wrapper around libffi. ctypes compatibility might
be possible to implement on top of this module (though ctypes allow to call
functions without prototypes, which is not supported by libffi (i.e.
implementation would be inefficient))).
2014-01-29 00:24:00 +02:00
Damien George
56bb636014
Change -Og to -O0 in unix-cpy/Makefile; cast to small int in socket.c.
2014-01-26 17:52:23 +00:00
Damien George
554a75b689
Merge pull request #226 from pfalcon/make-debug
...
unix Makefile: -Og doesn't work (at least) with gcc 4.6 below.
2014-01-26 09:53:31 -08:00
Paul Sokolovsky
a88c30c64a
unix socket: Add setsockopt() method.
2014-01-26 02:03:07 +02:00
Paul Sokolovsky
5d362d3209
unix socket: Add few more socket constants.
2014-01-26 02:03:07 +02:00
Paul Sokolovsky
db0b282d45
unix socket: Store module constants in data structure.
...
-147 bytes on x86.
2014-01-26 02:03:07 +02:00
Paul Sokolovsky
e2febe90e3
unix Makefile: -Og doesn't work (at least) with gcc 4.6 below.
...
Also, don't try to force debug info format, use native.
2014-01-25 19:49:38 +02:00
Damien George
b829b5caec
Implement mp_parse_node_free; print properly repr(string).
2014-01-25 13:51:19 +00:00
Paul Sokolovsky
aee2ba70de
Add parse_node_free_struct() and use it to free parse tree after compilation.
...
TODO: Check lexer/parse/compile error path for leaks too.
2014-01-25 02:11:59 +02:00
Dave Hylands
c89c681a9f
Rework makefiles. Add proper dependency checking.
2014-01-24 08:46:48 -08:00
Paul Sokolovsky
2b2cb7b7f4
unix main: Free input line.
...
Also, readline uses system malloc, so for symmetry, use the same for
non-readline case.
2014-01-24 16:29:49 +02:00
Damien George
5fa93b6755
Second stage of qstr revamp: uPy str object can be qstr or not.
2014-01-22 14:35:10 +00:00
Damien George
12eaccacda
Merge branch 'master' of github.com:micropython/micropython
...
Conflicts:
py/objstr.c
py/py.mk
py/stream.c
unix/main.c
unix/socket.c
2014-01-21 21:54:15 +00:00
Damien George
55baff4c9b
Revamp qstrs: they now include length and hash.
...
Can now have null bytes in strings. Can define ROM qstrs per port using
qstrdefsport.h
2014-01-21 21:40:13 +00:00
Paul Sokolovsky
51ee44a718
unix file: Refactor and add sys.stdout/stdin/stderr.
2014-01-20 23:50:55 +02:00
Paul Sokolovsky
f0cfb8cb45
Don't preimport socket module.
2014-01-20 20:37:01 +02:00
Paul Sokolovsky
fc35aa6828
unix socket: Add send() and recv() methods.
...
CPython _socket actually have only those and doesn't provide stream
interface (higher-level CPython "socket" what adds this).
+516 bytes x86.
2014-01-20 20:37:01 +02:00
Paul Sokolovsky
decd597273
unix io.FileIO: Add iteration support.
...
A file cannot be iterated concurrently, so we make io.FileIO its own
iterator.
2014-01-20 18:42:08 +02:00
Damien George
7d08935458
Rename unix binary to 'micropython'.
2014-01-20 00:02:39 +00:00
Paul Sokolovsky
fe2690da0a
unix: Implement sys.argv.
2014-01-20 01:00:28 +02:00
Damien George
a11ceca807
Change int to uint for n_args in function with variable arguments.
2014-01-19 16:02:09 +00:00