xbe
8562de6c48
py/objstr.c: Remove done TODOs.
11 years ago
Paul Sokolovsky
1ecea7c753
py: Make 'bytes' be a proper type, support standard constructor args.
11 years ago
Paul Sokolovsky
be020c27a8
py: Make 'str' be a proper type, support standard constructor args.
11 years ago
Paul Sokolovsky
5972b4c05f
objstr: Switch from in-object string data to ptr to separate memory area.
This is pre-requisite for having efficient implementation of str<->bytes
conversion, and having that efficient is required with unfortunare
str vs bytes dichotomy in Python3.
11 years ago
Damien George
b035db355a
py: Make str.[r]partition more efficient.
11 years ago
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.
11 years ago
xbe
4504ea8007
Implement str.rpartition and add tests for it.
11 years ago
xbe
613a8e3edf
Implement str.partition and add tests for it.
11 years ago
xbe
c55388823f
objstr.c: Replace size_t with machine_uint_t.
11 years ago
xbe
efe3422394
py: Clean up includes.
Remove unnecessary includes. Add includes that improve portability.
11 years ago
Damien George
536dde254b
py: In string.count, handle case of zero-length needle.
11 years ago
xbe
c5d70ba48b
Fix issues in str.count implementation.
See pull request #343 .
11 years ago
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.
11 years ago
Damien George
2da9830b92
py: Make objstr support buffer protocol (read only).
11 years ago
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.
11 years ago
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.
11 years ago
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().
11 years ago
Paul Sokolovsky
4e2460852a
objstr: Mark few local symbols as static, cleanup codestyle.
Please don't submit patches with tab indentation!
11 years ago
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.
11 years ago
Paul Sokolovsky
ea2509d92c
Fix assert() usage.
11 years ago
Paul Sokolovsky
87e85b7dc7
Implement str/bytes rich comparisons.
11 years ago
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.
11 years ago
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.
11 years ago
Damien George
94f68300f9
py: Make str.replace do 2 passes over the string.
11 years ago
xbe
480c15afb5
Implement str.replace and add tests for it.
11 years ago
Paul Sokolovsky
0b7e29c025
Factor out quoted string print function for reuse (mp_str_print_quoted()).
11 years ago
Damien George
b829b5caec
Implement mp_parse_node_free; print properly repr(string).
11 years ago
Damien George
7c9c667633
py: Implement iterator support for object that has __getitem__.
Addresses Issue #203 .
11 years ago
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.
11 years ago
Damien George
1e708fed18
py: Implement bool unary op; tidy up unary op dispatch.
11 years ago
Paul Sokolovsky
1eacefe5bc
Implement simplest case of str.startswith().
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
4c316552c1
Implement str.split(None).
Note that splitting by explicit string is not implemented so far.
11 years ago
Paul Sokolovsky
7380a83780
str: Implement proper string (instead of byte string) indexing.
Also, support negative indexes.
11 years ago
Paul Sokolovsky
545591a696
Implement string multiplication.
11 years ago
Paul Sokolovsky
8965a5eb1e
objstr: More support for MP_OBJ_QSTR.
11 years ago
Paul Sokolovsky
bb33cc66fb
Properly print MP_OBJ_QSTR objects.
11 years ago
Damien George
a11ceca807
Change int to uint for n_args in function with variable arguments.
11 years ago
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.
11 years ago
Paul Sokolovsky
76d982ef34
type->print(): Distinguish str() and repr() variety by passing extra param.
11 years ago
Damien George
f62d33aa1d
Consolidate rt_make_function_[0123] to rt_make_function_n.
11 years ago
Damien George
2300537c79
Cleanup built-ins, and fix some compiler warnings/errors.
11 years ago
Dave Hylands
c8effff937
Added public domain implementations of strchr and strstr.
11 years ago
John R. Lenton
e820491f7a
Implement a basic str.find; fixes #67
11 years ago
John R. Lenton
c1bef21920
Implemented support for `in` and `not in` operators.
11 years ago
Damien George
2d45429122
Use memcpy instead of strncpy; add usart.status to stm.
11 years ago
xbe
7b0f39f318
Implement str.strip
11 years ago
John R. Lenton
9c83ec0eda
Merge remote-tracking branch 'upstream/master' into dict_feats
11 years ago
John R. Lenton
3391e19068
A bit of stylistic cleanup (chose the wrong side during conflict resolution).
11 years ago