Commit Graph

188 Commits

Author SHA1 Message Date
Damien George c49ddb9315 py: Fix configurability of builtin slice. 2014-06-01 13:49:35 +01:00
Damien George fb510b3bf9 Rename bultins config variables to MICROPY_PY_BUILTINS_*.
This renames:
MICROPY_PY_FROZENSET -> MICROPY_PY_BUILTINS_FROZENSET
MICROPY_PY_PROPERTY -> MICROPY_PY_BUILTINS_PROPERTY
MICROPY_PY_SLICE -> MICROPY_PY_BUILTINS_SLICE
MICROPY_ENABLE_FLOAT -> MICROPY_PY_BUILTINS_FLOAT

See issue #35 for discussion.
2014-06-01 13:32:54 +01:00
Damien George d1e355ea8e py: Fix check of small-int overflow when parsing ints.
Also unifies use of SMALL_INT_FITS macro across parser and runtime.
2014-05-28 14:51:12 +01:00
Damien George 503d611033 py: Implement long int parsing in int(...).
Addresses issue #627.
2014-05-28 14:07:21 +01:00
Damien George 2617eebf2f Change const byte* to const char* where sensible.
This removes need for some casts (at least, more than it adds need
for new casts!).
2014-05-25 22:27:57 +01:00
Paul Sokolovsky 5fd5af98d0 objlist: Implement support for arbitrary (3-arg) slices. 2014-05-25 22:12:56 +03:00
Paul Sokolovsky de4b9329f9 py: Refactor slice helpers, preparing to support arbitrary slicing. 2014-05-25 21:21:57 +03:00
Paul Sokolovsky 2705f4c782 objlist: Implement growing slice assignment.
This means that complete slice operations are supported for lists (but not
for bytearray's and array.array's).
2014-05-25 02:36:12 +03:00
Paul Sokolovsky afaaf535e6 objslice: Support arbitrary objects start, stop, and step.
Older int-only encoding is not expressive enough to support arbitrary slice
assignment operations.
2014-05-25 01:42:24 +03:00
Damien George 7a4ddd2428 Add SystemExit exception and use it in unix/ and stmhal/ ports.
Addresses issue #598.
2014-05-24 23:32:19 +01:00
Damien George 6ac5dced24 py: Rename MP_OBJ_NOT_SUPPORTED to MP_OBJ_NULL.
See issue #608 for justification.
2014-05-21 19:42:43 +01:00
Paul Sokolovsky ab7bf28489 py: More const usage. 2014-05-17 11:20:10 +03:00
Paul Sokolovsky a47b64ae2d objstringio: Implement io.BytesIO.
Done in generalized manner, allowing any stream class to be specified as
working with bytes.
2014-05-15 07:28:19 +03:00
Damien George 2323ef9182 py: Rename globally-accessible tuple functions, prefix with mp_obj_.
Likely there are other functions that should be renamed, but this is a
start.
2014-05-11 18:00:45 +01:00
Paul Sokolovsky ea9708092e objtuple: Go out of the way to support comparison of subclasses.
Two things are handled here: allow to compare native subtypes of tuple,
e.g. namedtuple (TODO: should compare type too, currently compared
duck-typedly by content). Secondly, allow user sunclasses of tuples
(and its subtypes) be compared either. "Magic" I did previously in
objtype.c covers only one argument (lhs is many), so we're in trouble
when lhs is native type - there's no other option besides handling
rhs in special manner. Fortunately, this patch outlines approach with
fast path for native types.
2014-05-11 03:33:19 +03:00
Paul Sokolovsky 7aca1cae34 py: Start making good use of mp_const_obj_t. 2014-05-11 02:26:42 +03:00
Paul Sokolovsky 94d8246272 objlist: Implement non-growing slice assignment.
Slice value to assign can be only a list so far too.
2014-05-10 22:24:31 +03:00
Paul Sokolovsky d915a52eb6 py: Fix prefix on few sequence helpers, was incorrectly "mp_". 2014-05-10 21:36:33 +03:00
Paul Sokolovsky b181b581aa objset: Give up and implement frozenset.
Tired of patching CPython stdlib for it.
2014-05-10 16:56:20 +03:00
Damien George d0a5bf34f7 py: Tidy up returning NULL which should be MP_OBJ_NOT_SUPPORTED. 2014-05-10 13:55:11 +01:00
Damien George a32c1e41cc py: Improve native emitter; now supports more opcodes. 2014-05-07 18:30:52 +01:00
Damien George 04b9147e15 Add license header to (almost) all files.
Blanket wide to all .c and .h files.  Some files originating from ST are
difficult to deal with (license wise) so it was left out of those.

Also merged modpyb.h, modos.h, modstm.h and modtime.h in stmhal/.
2014-05-03 23:27:38 +01:00
Paul Sokolovsky 418aca976c objclosure, objcell: Print detailed representation if was requested.
Well, it is bound to "detailed error reporting", but that's closest what we
have now without creating new entities.
2014-05-03 14:16:11 +03:00
Paul Sokolovsky d8351ca8a0 objtype: .print() Exception instances in adhoc way.
This is ugly, just as expected.
2014-05-02 02:00:47 +03:00
Paul Sokolovsky c3103b55c1 objgenerator: .print(): Output real underlying function name. 2014-05-01 23:22:11 +03:00
Paul Sokolovsky a224067846 py: Clear allocated, but unused memory in containers.
Also, clear up freed slots in containers.

As a follow up to 32bef315be.
2014-04-28 00:33:21 +03:00
Damien George 2827d62e8b py: Implement keyword-only args.
Implements 'def f(*, a)' and 'def f(*a, b)', but not default
keyword-only args, eg 'def f(*, a=1)'.

Partially addresses issue #524.
2014-04-27 15:50:52 +01:00
Paul Sokolovsky cb9dc086a3 modio: Implement io.StringIO class. 2014-04-26 20:26:14 +03:00
Paul Sokolovsky dec31bb872 objexcept: Add mp_obj_new_exception_arg1() convenience function. 2014-04-22 00:02:51 +03:00
Damien George 3558f62fb5 py: Making closures now passes pointer to stack, not a tuple for vars.
Closed over variables are now passed on the stack, instead of creating a
tuple and passing that.  This way memory for the closed over variables
can be allocated within the closure object itself.  See issue #510 for
background.
2014-04-20 17:50:40 +01:00
Paul Sokolovsky 4602b9a79f obj.h: Typo fix in comment. 2014-04-19 03:21:06 +03:00
Damien George b11b85adaa py: Allow to pass buffer protocol flags to get_buffer helper funcs. 2014-04-18 22:59:24 +01:00
Damien George 57a4b4f178 py: Add typecode to buffer protocol.
When querying an object that supports the buffer protocol, that object
must now return a typecode (as per binary.[ch]).  This does not have to
be honoured by the caller, but can be useful for determining element
size.
2014-04-18 22:29:21 +01:00
Damien George ea8d06c39d py: Add MP_OBJ_STOP_ITERATION and make good use of it.
Also make consistent use of MP_OBJ_NOT_SUPPORTED and MP_OBJ_NULL.
This helps a lot in debugging and understanding of function API.
2014-04-17 23:19:36 +01:00
Damien George 729f7b42d6 py: Merge BINARY_OP_SUBSCR and store_subscr (w/ delete) into subscr.
mp_obj_t->subscr now does load/store/delete.
2014-04-17 22:10:53 +01:00
Damien George de7c425139 py: Simplify objfun/objgenerator connection, no need to call bc_get. 2014-04-17 19:16:11 +01:00
Damien George 71d3112f7e py: Make built-in 'range' a class.
Addresses issue #487.
2014-04-17 18:18:55 +01:00
Damien George 777b0f32f4 py: Add property object, with basic functionality.
Enabled by MICROPY_ENABLE_PROPERTY.
2014-04-13 18:59:45 +01:00
Paul Sokolovsky 18bef25a0c objlist: Add support for statically allocated lists.
Similar to similar support for lists.
2014-04-13 07:02:56 +03:00
Damien George 2813cb6043 py: Add 'static' to inline function MP_BOOL; remove category_t.
Small fixes to get it compiling with ARMCC.  I have no idea why
category_t was in the enum definition for qstrs...
2014-04-12 17:53:05 +01:00
Damien George db049c2e00 py: Change inline to static inline for 2 functions. 2014-04-12 00:08:40 +01:00
Damien George 1184094839 py: Revert some inline functions back to macros, since they bloat stmhal. 2014-04-11 22:30:09 +01:00
Damien George a5c82a8187 py: Convert some macros to inline functions (in obj.h).
Also convert mp_obj_is_integer to an inline function.

Overall this decreased code size (at least on 32-bit x86 machine).
2014-04-11 11:16:53 +00:00
Damien George ae491055fa py: Fix float/complex binop returning NULL; implement complex power. 2014-04-10 20:08:11 +01:00
Damien George b5fbd0ba87 py: Add mp_obj_is_integer; make mp_get_index check for long int.
mp_obj_is_integer should be used to check if an object is of integral
type.  It returns true for bool, small int and long int.
2014-04-09 19:55:33 +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
Damien George f4c9b33abf py: Remove DELETE_SUBSCR opcode, combine with STORE_SUBSCR.
This makes the runtime and object APIs more consistent.  mp_store_subscr
functionality now moved into objects (ie list and dict store_item).
2014-04-08 21:32:29 +01:00
Damien George 4671392d90 Merge branch 'master' of github.com:micropython/micropython 2014-04-08 21:13:04 +01:00
Damien George 1d24ea5207 py: Finish implementation of all del opcodes.
At this point, all opcodes are now implemented!

Some del opcodes have been combined with store opcodes, with the value
to store being MP_OBJ_NULL.
2014-04-08 21:11:49 +01:00
Paul Sokolovsky 4dcb605ac4 py: Make bytearray a proper type. 2014-04-08 22:11:40 +03:00