xbe
0a6894c24b
str.(r)partition: factor out duplicate code.
...
Switch str.rpartition to search from left to right. Factor the
duplicate code into one helper function.
2014-03-21 03:17:09 -07:00
xbe
4504ea8007
Implement str.rpartition and add tests for it.
2014-03-21 02:58:09 -07:00
xbe
613a8e3edf
Implement str.partition and add tests for it.
2014-03-21 02:57:18 -07:00
xbe
c55388823f
objstr.c: Replace size_t with machine_uint_t.
2014-03-17 02:43:50 -07:00
xbe
efe3422394
py: Clean up includes.
...
Remove unnecessary includes. Add includes that improve portability.
2014-03-17 02:43:40 -07:00
Damien George
536dde254b
py: In string.count, handle case of zero-length needle.
2014-03-13 22:07:55 +00:00
xbe
c5d70ba48b
Fix issues in str.count implementation.
...
See pull request #343 .
2014-03-13 00:33:07 -07:00
xbe
9e1e8cd642
Implement str.count and add tests for it.
...
Also modify mp_get_index to accept:
1. Indices that are or evaluate to a boolean.
2. Slice indices.
Add tests for these two cases.
2014-03-12 22:57:16 -07:00
Damien George
2da9830b92
py: Make objstr support buffer protocol (read only).
2014-03-09 19:58:18 +00: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
d5df6cd44a
Replace global "static" -> "STATIC", to allow "analysis builds". Part 1.
...
Some tools do not support local/static symbols (one example is GNU ld map file).
Exposing all functions will allow to do detailed size comparisons, etc.
Also, added bunch of statics where they were missing, and replaced few identity
functions with global mp_identity().
2014-02-12 18:21:11 +02:00
Paul Sokolovsky
4e2460852a
objstr: Mark few local symbols as static, cleanup codestyle.
...
Please don't submit patches with tab indentation!
2014-02-11 15:34: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
Paul Sokolovsky
ea2509d92c
Fix assert() usage.
2014-02-02 08:58:16 +02:00
Paul Sokolovsky
87e85b7dc7
Implement str/bytes rich comparisons.
2014-02-02 08:58:16 +02:00
Paul Sokolovsky
7364af2d8c
Factor out m_seq_get_fast_slice_indexes() fucntions as sequence helper.
...
Takes slice object and sequence length and computes subsequence indexes
for case of slice step=1.
2014-02-02 02:38:22 +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
Damien George
94f68300f9
py: Make str.replace do 2 passes over the string.
2014-01-31 23:45:12 +00:00
xbe
480c15afb5
Implement str.replace and add tests for it.
2014-01-30 22:17:30 -08:00
Paul Sokolovsky
0b7e29c025
Factor out quoted string print function for reuse (mp_str_print_quoted()).
2014-01-28 03:40:06 +02:00
Damien George
b829b5caec
Implement mp_parse_node_free; print properly repr(string).
2014-01-25 13:51:19 +00:00
Damien George
7c9c667633
py: Implement iterator support for object that has __getitem__.
...
Addresses Issue #203 .
2014-01-25 00:17:36 +00:00
Paul Sokolovsky
91fb1c9b13
Add basic implementation of bytes type, piggybacking on str.
...
This reuses as much str implementation as possible, from this we
can make them more separate as needed.
2014-01-24 22:56:26 +02:00
Damien George
1e708fed18
py: Implement bool unary op; tidy up unary op dispatch.
2014-01-23 18:27:51 +00:00
Paul Sokolovsky
1eacefe5bc
Implement simplest case of str.startswith().
2014-01-23 02:47:10 +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
4c316552c1
Implement str.split(None).
...
Note that splitting by explicit string is not implemented so far.
2014-01-21 05:01:21 +02:00
Paul Sokolovsky
7380a83780
str: Implement proper string (instead of byte string) indexing.
...
Also, support negative indexes.
2014-01-21 02:25:59 +02:00
Paul Sokolovsky
545591a696
Implement string multiplication.
2014-01-21 00:39:12 +02:00
Paul Sokolovsky
8965a5eb1e
objstr: More support for MP_OBJ_QSTR.
2014-01-20 23:34:17 +02:00
Paul Sokolovsky
bb33cc66fb
Properly print MP_OBJ_QSTR objects.
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
Paul Sokolovsky
f2b796e7c7
str.format: Don't assume that '}' immediately follows '{', skip insides.
...
That at least makes stuff like "{:x}".format(1) to produce not completely
broken output.
2014-01-16 03:46:01 +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
Paul Sokolovsky
76d982ef34
type->print(): Distinguish str() and repr() variety by passing extra param.
2014-01-15 02:15:38 +02:00
John R. Lenton
f5a0a7d2b3
Merge remote-tracking branch 'upstream/master' into containment
2014-01-13 23:09:04 +00:00
Damien George
f62d33aa1d
Consolidate rt_make_function_[0123] to rt_make_function_n.
2014-01-13 19:50:05 +00:00
Damien George
f88a72a88e
Merge pull request #168 from dhylands/add-strstr
...
Added public domain implementations of strchr and strstr.
2014-01-13 11:43:57 -08:00
Damien George
2300537c79
Cleanup built-ins, and fix some compiler warnings/errors.
2014-01-13 19:39:01 +00:00
Dave Hylands
c8effff937
Added public domain implementations of strchr and strstr.
2014-01-12 22:34:58 -08:00
John R. Lenton
13e64f0660
Merge remote-tracking branch 'upstream/master' into containment
2014-01-13 00:41:12 +00:00
John R. Lenton
e820491f7a
Implement a basic str.find; fixes #67
2014-01-12 21:53:52 +00:00
John R. Lenton
c1bef21920
Implemented support for in
and not in
operators.
2014-01-11 12:39:33 +00:00
Damien George
2d45429122
Use memcpy instead of strncpy; add usart.status to stm.
2014-01-09 22:04:45 +00:00
xbe
7b0f39f318
Implement str.strip
2014-01-08 14:23:45 -08: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
7a16fadbf8
Co-exist with C++ (issue #85 )
2014-01-06 09:52:29 -08:00
Paul Sokolovsky
860ffb0a43
Convert many object types structs to use C99 tagged initializer syntax.
2014-01-05 22:34:09 +02:00
xyb
8cfc9f07b9
Implements str iterator
2014-01-05 18:47:51 +08: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
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
Paul Sokolovsky
6ee1e383d6
str slice: Trim slice indexes to be in range.
2014-01-04 03:55:37 +02:00
Damien George
c8d1384fc0
Fix int -> machine_int_t; add print to slice test.
2014-01-04 01:06:10 +00:00
Paul Sokolovsky
f8b9d3c41a
str: Throw TypeError for invalid index type and clean up comments.
2014-01-04 02:35:49 +02:00
Paul Sokolovsky
e606cb6561
slice: Allow building with MICROPY_ENABLE_SLICE=0.
2014-01-04 02:35:49 +02:00
Paul Sokolovsky
decad08ef5
str: Handle non-positive slice indexes.
2014-01-04 02:35:48 +02:00
Paul Sokolovsky
31ba60f836
str: Initial implementation of string slicing.
...
Only step=1 and non-negative indexes are supported so far.
2014-01-04 02:35:48 +02:00
Damien George
fe8fb9165c
py: remove depedence on strcat and stpcpy.
...
This fixes Issue #29 , and means the core is no longer dependent on
string functions, except strlen.
2014-01-02 16:36:09 +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