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.
11 years ago
Damien George
e09ffa1400
Search paths properly on import and execute __init__.py if it exists.
11 years ago
Paul Sokolovsky
9110896063
Remove older import helpers, no longer used.
11 years ago
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.
11 years ago
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.
11 years ago
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).
11 years ago
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.
11 years ago
Damien George
4d5b28cd08
Add qstr_info() function and bindings for unix port.
11 years ago
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))).
11 years ago
Damien George
b829b5caec
Implement mp_parse_node_free; print properly repr(string).
11 years ago
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.
11 years ago
Paul Sokolovsky
2b2cb7b7f4
unix main: Free input line.
Also, readline uses system malloc, so for symmetry, use the same for
non-readline case.
11 years ago
Damien George
5fa93b6755
Second stage of qstr revamp: uPy str object can be qstr or not.
11 years ago
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
11 years ago
Paul Sokolovsky
51ee44a718
unix file: Refactor and add sys.stdout/stdin/stderr.
11 years ago
Paul Sokolovsky
fe2690da0a
unix: Implement sys.argv.
11 years ago
Damien George
136b149e41
py: Add full traceback to exception printing.
11 years ago
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.
11 years ago
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.
11 years ago
Paul Sokolovsky
fc92608237
Add lean ("raw") socket module.
11 years ago
Damien George
9528cd66d7
Convert parse errors to exceptions.
Parser no longer prints an error, but instead returns an exception ID
and message.
11 years ago
Paul Sokolovsky
76d982ef34
type->print(): Distinguish str() and repr() variety by passing extra param.
11 years ago
Damien George
004cdcebfe
py: Implement base class lookup, issubclass, isinstance.
11 years ago
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.
11 years ago
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).
11 years ago
John R. Lenton
9c83ec0eda
Merge remote-tracking branch 'upstream/master' into dict_feats
11 years ago
Damien George
136f67523b
Factor and simplify Makefile's and mpconfig.
11 years ago
ian-v
5fd8fd2c16
Revert MP_BOOL, etc. and use <stdbool.h> instead
11 years ago
ian-v
7a16fadbf8
Co-exist with C++ (issue #85 )
11 years ago
Paul Sokolovsky
860ffb0a43
Convert many object types structs to use C99 tagged initializer syntax.
11 years ago
Damien George
71c5181a8d
Convert Python types to proper Python type hierarchy.
Now much more inline with how CPython does types.
11 years ago
Paul Sokolovsky
d674bd5989
Convert USE_READLINE config option to be consistent with others.
11 years ago
Damien George
eb7bfcb286
Split qstr into pools, and put initial pool in ROM.
Qstr's are now split into a linked-list of qstr pools. This has 2
benefits: the first pool can be in ROM (huge benefit, since we no longer
use RAM for the core qstrs), and subsequent pools use m_new for the next
pool instead of m_renew (thus avoiding a huge single table for all the
qstrs).
Still would be better to use a hash table, but this scheme takes us part
of the way (eventually convert the pools to hash tables).
Also fixed bug with import.
Also improved the way the module code is referenced (not magic number 1
anymore).
11 years ago
Damien George
1fb031744f
Change mp_compile so that it returns a function object for the module.
11 years ago
Damien George
66028ab6dc
Basic implementation of import.
import works for simple cases. Still work to do on finding the right
script, and setting globals/locals correctly when running an imported
function.
11 years ago
Edd Barrett
8146aea8ef
malloc.h is obsolete.
11 years ago
Paul Sokolovsky
fa027672da
Make GNU Readline usage optional (USE_READLINE define). Still enabled.
Readline is GPL, so linking with it casts the binary GPL.
11 years ago
Paul Sokolovsky
903b24f041
Add readline history support.
11 years ago
Damien
732407f1bf
Change memory allocation API to require size for free and realloc.
11 years ago
Damien
b86e3f9293
py: implement some basic exception matching.
11 years ago
Damien
d99b05282d
Change object representation from 1 big union to individual structs.
A big change. Micro Python objects are allocated as individual structs
with the first element being a pointer to the type information (which
is itself an object). This scheme follows CPython. Much more flexible,
not necessarily slower, uses same heap memory, and can allocate objects
statically.
Also change name prefix, from py_ to mp_ (mp for Micro Python).
11 years ago
Damien
0f08267fa4
unix: include obj.h, and build additional py files.
11 years ago
Damien
087d218d95
Unix: add machine-specific sqrt support.
11 years ago
Damien
014e19fc4d
Fix compiler warnings in unix/main.c.
11 years ago
Damien
a53f694dc3
Test code for user objects.
11 years ago
Damien
8b3a7c2237
Fix func decls with no arguments: () -> (void).
11 years ago
Damien
92c06561a3
Improve REPL compount statement detection.
11 years ago
Damien
fa2162bc77
Integrate new lexer stream with stm framework.
11 years ago
Damien
a5185f4bc8
Abstract out back-end stream functionality from lexer.
11 years ago
Damien
5ac1b2efbd
Implement REPL.
11 years ago