Commit Graph

75 Commits

Author SHA1 Message Date
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
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
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
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
e7db8171d8 unix: Implement garbage collection support. 2014-02-11 16:20:02 +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
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
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
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
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
4d5b28cd08 Add qstr_info() function and bindings for unix port. 2014-01-29 18:56:46 +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
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
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
fe2690da0a unix: Implement sys.argv. 2014-01-20 01:00:28 +02:00
Damien George
136b149e41 py: Add full traceback to exception printing. 2014-01-19 12:38:49 +00:00
Damien George
cbd2f7482c py: Add module/function/class name to exceptions.
Exceptions know source file, line and block name.

Also tidy up some debug printing functions and provide a global
flag to enable/disable them.
2014-01-19 11:48:48 +00:00
Damien George
8fce5b42a2 Merge pull request #194 from pfalcon/socket
Add lean ("raw") socket module.
2014-01-18 15:34:30 -08:00
Damien George
08335004cf Add source file name and line number to error messages.
Byte code has a map from byte-code offset to source-code line number,
used to give better error messages.
2014-01-18 23:24:36 +00:00
Paul Sokolovsky
fc92608237 Add lean ("raw") socket module. 2014-01-19 00:16:39 +02:00
Damien George
4899ff9470 Merge branch 'str-repr' of github.com:pfalcon/micropython into pfalcon-str-repr
Conflicts:
	tests/basics/tests/exception1.py
2014-01-15 22:39:03 +00:00
Damien George
9528cd66d7 Convert parse errors to exceptions.
Parser no longer prints an error, but instead returns an exception ID
and message.
2014-01-15 21:23:31 +00:00
Paul Sokolovsky
76d982ef34 type->print(): Distinguish str() and repr() variety by passing extra param. 2014-01-15 02:15:38 +02:00
Damien George
004cdcebfe py: Implement base class lookup, issubclass, isinstance. 2014-01-09 21:43:51 +00:00
Damien George
062478e66d Improved type/class/instance code; mp_obj_type_t now has load_attr, store_attr.
Creating of classes (types) and instances is much more like CPython now.
You can use "type('name', (), {...})" to create classes.
2014-01-09 20:57:50 +00:00
Paul Sokolovsky
e0e79ae6d6 unix: Add basic implementation of io.FileIO object.
Note: only read/write/close methods are defined so far, and class
is not exposed (use open() factory function, as usual).
2014-01-08 17:39:06 +02:00
Damien George
97209d38e1 Merge branch 'cplusplus' of https://github.com/ian-v/micropython into ian-v-cplusplus
Conflicts:
	py/objcomplex.c
2014-01-07 15:58:30 +00:00
Damien George
136f67523b Factor and simplify Makefile's and mpconfig. 2014-01-07 14:54:15 +00:00
ian-v
5fd8fd2c16 Revert MP_BOOL, etc. and use <stdbool.h> instead 2014-01-06 13:51:53 -08:00