Paul Sokolovsky
ee4aaf7cdd
Implement tuple addition.
2014-02-08 23:17:51 +02:00
Paul Sokolovsky
1a996c48ac
Refactor list comparison code to mp_seq_cmp_objs().
2014-02-08 22:56:36 +02:00
Damien George
7d0bfbedd2
py: Add some qstrs to the global table.
2014-02-08 19:01:47 +00:00
Paul Sokolovsky
e5a15cb7a5
mp_obj_new_list(n, items): Copy items only if not-NULL.
...
Similar to mp_obj_new_tuple().
2014-02-04 19:36:00 +02:00
Paul Sokolovsky
ea2509d92c
Fix assert() usage.
2014-02-02 08:58:16 +02:00
Paul Sokolovsky
13cfabd1b2
Implement slicing for lists.
2014-02-02 03:32:55 +02:00
Damien George
9aa2a527b5
py: Tidy up BINARY_OPs; negation done by special NOT bytecode.
...
IS_NOT and NOT_IN are now compiled to IS + NOT and IN + NOT, with a new
special NOT bytecode.
2014-02-01 23:04:09 +00:00
Paul Sokolovsky
c1d9bbc345
Implement __bool__ and __len__ via unary_op virtual method for all types.
...
__bool__() and __len__() are just the same as __neg__() or __invert__(),
and require efficient dispatching implementation (not requiring search/lookup).
type->unary_op() is just the right choice for this short of adding
standalone virtual method(s) to already big mp_obj_type_t structure.
2014-01-30 04:37:19 +02:00
Damien George
c7aa9fcae5
Merge branch 'master' of github.com:micropython/micropython
2014-01-27 23:16:20 +00:00
Damien George
4e8dc8c41b
py: Add unary op not for NoneType, bool, tuple, list, dict; fix for int.
2014-01-27 23:15:32 +00:00
Paul Sokolovsky
ddf1aa9223
list.pop(): Don't allow ->alloc drop to zero, which causes unexpected behavior.
2014-01-27 01:07:58 +02: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
439542f70c
sequence.c: Start to refactor sequence operations for reuse among types.
2014-01-21 00:39:12 +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
Damien George
ebde0b8a09
Tiny optimisation in objlist.c; a new test for inheritance.
2014-01-19 00:47:40 +00:00
Damien George
20006dbba9
Make VM stack grow upwards, and so no reversed args arrays.
...
Change state layout in VM so the stack starts at state[0] and grows
upwards. Locals are at the top end of the state and number downwards.
This cleans up a lot of the interface connecting the VM to C: now all
functions that take an array of Micro Python objects are in order (ie no
longer in reverse).
Also clean up C API with keyword arguments (call_n and call_n_kw
replaced with single call method that takes keyword arguments). And now
make_new takes keyword arguments.
emitnative.c has not yet been changed to comply with the new order of
stack layout.
2014-01-18 14:10:48 +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
0f59203e37
Tidy up.
2014-01-14 23:18:35 +00:00
John R. Lenton
88cb1e60e0
Made sorted() raise an exception instead of aborting when given no arguments; moved around some things in objfun.c as a consequence
2014-01-13 19:55:18 +00:00
John R. Lenton
5c76839559
sorted
2014-01-13 05:12:50 +00:00
Paul Sokolovsky
1945e60aeb
list: Implement comparison operators.
2014-01-12 03:34:04 +02:00
Paul Sokolovsky
c698d266d1
list: Add extend() methods and += operator.
2014-01-12 00:54:10 +02:00
John R. Lenton
b8698fca75
unified the bops
2014-01-11 00:58:59 +00:00
Paul Sokolovsky
074d3b5f86
list: Implement list multiplication.
2014-01-11 00:49:19 +02:00
Damien George
38a2da68c2
py: Stuff qstr in object pointer; keys for mp_map_t are now always mp_obj_t.
2014-01-08 17:33:12 +00:00
Damien George
dfc0bac086
py: Small big fix to type declarations.
2014-01-07 23:18:54 +00:00
John R. Lenton
3391e19068
A bit of stylistic cleanup (chose the wrong side during conflict resolution).
2014-01-07 18:06:34 +00:00
John R. Lenton
270112f731
Merge remote-tracking branch 'upstream/master' into listsort. Lots of conflict fun.
...
Conflicts:
py/obj.h
py/objbool.c
py/objboundmeth.c
py/objcell.c
py/objclass.c
py/objclosure.c
py/objcomplex.c
py/objdict.c
py/objexcept.c
py/objfun.c
py/objgenerator.c
py/objinstance.c
py/objmodule.c
py/objrange.c
py/objset.c
py/objslice.c
2014-01-07 18:01:08 +00:00
John R. Lenton
c06763a020
This implements a better (more python-conformant) list.sort.
...
It's not really about that, though; it's about me figuring out a sane
way forward for keyword-argument functions (and function
metadata). But it's useful as is, and shouldn't break any existing
code, so here you have it; I'm going to park it in my mind for a bit
while sorting out the rest of the dict branch.
2014-01-07 17:29:16 +00: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
ian-v
a5a01df81d
Make list and str method tables static
2014-01-06 14:14:11 -08:00
ian-v
5fd8fd2c16
Revert MP_BOOL, etc. and use <stdbool.h> instead
2014-01-06 13:51:53 -08:00
ian-v
7a16fadbf8
Co-exist with C++ (issue #85 )
2014-01-06 09:52:29 -08:00
John R. Lenton
a10dba7509
Merge remote-tracking branch 'upstream/master' into list_reverse
2014-01-06 00:08:21 +00:00
Damien George
8137b004b0
Merge branch 'list_remove' of git://github.com/chipaca/micropython into chipaca-list_remove
2014-01-05 23:58:49 +00:00
Damien George
aa35fc60d7
Merge pull request #92 from chipaca/list_insert
...
List insert. Fixes issue #61 .
2014-01-05 15:59:00 -08:00
Damien George
17f4497d6d
Merge pull request #91 from chipaca/list_index
...
Fix off-by-one in non-default values of index's 2nd and 3rd arguments.
2014-01-05 15:55:55 -08:00
John R. Lenton
ba3f87c947
Merge remote-tracking branch 'upstream/master' into list_reverse
2014-01-05 22:29:03 +00:00
John R. Lenton
d52a0318ce
Merge remote-tracking branch 'upstream/master' into list_remove
2014-01-05 22:27:11 +00:00
John R. Lenton
8428b8f3c9
Merge remote-tracking branch 'upstream/master' into list_insert
2014-01-05 22:11:01 +00:00
John R. Lenton
c553162ebc
Fix off-by-one in non-default values of index's 2nd and 3rd arguments.
2014-01-05 21:57:27 +00:00
Paul Sokolovsky
860ffb0a43
Convert many object types structs to use C99 tagged initializer syntax.
2014-01-05 22:34:09 +02:00
Damien George
f0691f4ed5
Fix qstr in objlist.c; add more tests for list.index.
...
list.index fails on an edge case.
2014-01-05 13:44:06 +00:00
John R. Lenton
7e73a8fd09
Merge remote-tracking branch 'upstream/master' into list_index
2014-01-05 01:57:54 +00:00
Damien George
71c5181a8d
Convert Python types to proper Python type hierarchy.
...
Now much more inline with how CPython does types.
2014-01-04 20:21:15 +00:00
Damien George
4d4bc9533e
Merge pull request #70 from chipaca/list_count
...
Implements list.count. Fixes isue #55 .
2014-01-04 10:09:40 -08:00
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).
2014-01-04 15:57:35 +00:00
John R. Lenton
6e1e98f864
Implements list.reverse; fixes issue #66
2014-01-04 02:10:29 +00:00
John R. Lenton
49fb6e53b3
Implements list.remove (in terms of list.index and list.pop).
...
Fixes issue #63 .
2014-01-04 01:56:53 +00:00
John R. Lenton
45a8744617
Implements list.insert. Fixes issue #61 .
2014-01-04 01:15:01 +00:00
John R. Lenton
5d4a821339
Implements list.index. Fixes issue #57 .
2014-01-04 00:26:30 +00:00
John R. Lenton
e241e8c169
Implemented list.count
2014-01-03 23:57:28 +00:00
John R. Lenton
26c211648b
Implemented list.copy. Fixes issue #54 .
2014-01-03 23:42:17 +00:00
John R. Lenton
069ded9514
Added list.clear. Fixes issue #53 .
2014-01-03 23:22:53 +00:00
John R. Lenton
25f417c08c
Worked on list.pop:
...
* Fixes issue #51
* Adds a specific error message for when you try to pop an empty list.
* Releases some memory if the list has shurnk a lot.
2014-01-03 22:53:18 +00:00
John R. Lenton
9bc56d933f
Changed to use memcpy.
2014-01-03 10:13:38 +00:00
John R. Lenton
aeb16c36b0
Add a bit of whitespace.
2014-01-03 02:36:35 +00:00
John R. Lenton
81ad89c46e
untabified
2014-01-03 02:32:40 +00:00
John R. Lenton
4cb80582c4
Add list addition ( fixes : #39 )
2014-01-03 02:27:08 +00:00
Damien
732407f1bf
Change memory allocation API to require size for free and realloc.
2013-12-29 19:33:23 +00:00
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).
2013-12-21 18:17:45 +00:00