Damien George
11de8399fe
py: Small changes to objstr.c, including a bug fix.
Some small fixed:
- Combine 'x' and 'X' cases in str format code.
- Remove trailing spaces from some lines.
- Make exception messages consistently begin with lower case (then
needed to change those in objarray and objtuple so the same
constant string data could be used).
- Fix bug with exception message having %c instead of %%c.
11 years ago
Paul Sokolovsky
75ce9256b2
objstr: Implement "%(key)s" % {} formatting for strings and dicts.
Also, make sure that args to "*" format specifiers are bounds-checked
properly and don't lead for segfaults in case of mismatch.
11 years ago
Chris Angelico
9ab8ab2117
Replace assert(0) with a self-documenting TODO string
11 years ago
Chris Angelico
4867413e69
Simplify detection of quote characters in mp_str_print_quoted.
Once a double quote has been found, the subsequent discovery of a single quote
won't change behaviour at all, so don't bother looking for one.
11 years ago
Damien George
fcc9cf63f1
py, str: Replace enum with actual function pointer.
This way, it's slightly more efficient, uses less ROM (60 bytes less
for stmhal), and doesn't require to raise exception if bad operation
given.
11 years ago
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.
11 years ago
Paul Sokolovsky
ae9c82d5f3
objstr: str_uni_istype(): Spurious whitespace on empty lines.
11 years ago
Paul Sokolovsky
f69b9d379c
objstr: str_uni_istype(): Codestyle.
11 years ago
Kim Bauters
a3f4b83018
add methods isspace(), isalpha(), isdigit(), isupper() and islower() to str
11 years ago
Paul Sokolovsky
8827682b35
objstr: *strip(): If nothing is stripped, don't create dup string.
11 years ago
Paul Sokolovsky
bcdffe53c6
objstr: *strip(): Fix handling of one-char subject strings.
11 years ago
Damien George
f600a6a085
py: Slightly improve efficiency of mp_obj_new_str; rename str_new.
Reorder interning logic in mp_obj_new_str, to be more efficient.
str_new is globally accessible, so should be prefixed with mp_obj_.
11 years ago
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!).
11 years ago
Paul Sokolovsky
5fd5af98d0
objlist: Implement support for arbitrary (3-arg) slices.
11 years ago
Paul Sokolovsky
de4b9329f9
py: Refactor slice helpers, preparing to support arbitrary slicing.
11 years ago
Paul Sokolovsky
69d081a7cf
py: Handle case of slice start > stop in common sequence function.
11 years ago
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.
11 years ago
Damien George
ee3fd46f13
Rename configuration variables controling Python features.
Now of the form MICROPY_PY_*. See issue #35 .
11 years ago
Paul Sokolovsky
d098c6bf85
objstr: Implement .endswith().
11 years ago
Damien George
6ac5dced24
py: Rename MP_OBJ_NOT_SUPPORTED to MP_OBJ_NULL.
See issue #608 for justification.
11 years ago
Paul Sokolovsky
c18ef2a9dd
objstr: startswith(): Accept optional "start" arg.
11 years ago
Paul Sokolovsky
70328e419a
py: Implement more complete bytes comparison handling.
11 years ago
Paul Sokolovsky
a47b64ae2d
objstringio: Implement io.BytesIO.
Done in generalized manner, allowing any stream class to be specified as
working with bytes.
11 years ago
Paul Sokolovsky
2a27365854
objstr.c: Partial implementation of .rsplit().
sep=None is TODO.
11 years ago
Paul Sokolovsky
da9f0924ef
py, unix: Add copyright for modules I worked closely on.
11 years ago
Paul Sokolovsky
5ebd5f0f19
objstr: Slice indexing: support bytes properly.
11 years ago
Paul Sokolovsky
bfb8819c0c
objstr: Make .split() support bytes.
11 years ago
Paul Sokolovsky
5e5d69b35e
objstr: Make .join() support bytes.
11 years ago
Paul Sokolovsky
eea0118654
py: Give up and make mp_obj_str_get_data() deal with bytes too.
This is not fully correct re: error handling, because we should check that
that types are used consistently (only str's or only bytes), but magically
makes lot of functions support bytes.
11 years ago
Paul Sokolovsky
b2d4fc06fc
objstr: Make *strip() accept bytes.
11 years ago
Paul Sokolovsky
69f3eb2c96
objstr: Make .[r]partition() work with bytes.
11 years ago
Paul Sokolovsky
d915a52eb6
py: Fix prefix on few sequence helpers, was incorrectly "mp_".
11 years ago
Paul Sokolovsky
6913521911
objstr: Implement .lower() and .upper().
11 years ago
Damien George
d0a5bf34f7
py: Tidy up returning NULL which should be MP_OBJ_NOT_SUPPORTED.
11 years ago
Paul Sokolovsky
7b0f9a7d9b
bytes: Implement comparison and other binary operations.
Should support everything supported by strings.
11 years ago
Paul Sokolovsky
b473d0ae86
py: bytes(), str(): Add NotImplementedError for kwargs.
Addresses #567 .
11 years ago
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/.
11 years ago
Paul Sokolovsky
f54bcbf099
py, unix: Make "mpconfig.h" be first included, as other headers depend on it.
Specifically, nlr.h does.
11 years ago
Paul Sokolovsky
e908591baa
py: Abstract no-return attribute for functions a bit.
11 years ago
Paul Sokolovsky
e14d096cb7
objstr: Optimize .rstrip() by scanning string from end.
11 years ago
Paul Sokolovsky
881078403e
objstr: Implement .lstrip() & .rstrip().
Share code with .strip(). TODO: optimize .rstrip().
11 years ago
Paul Sokolovsky
504e23388c
objstr: Init hash in mp_obj_str_builder_start() to 0.
11 years ago
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.
11 years ago
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.
11 years ago
Damien George
729f7b42d6
py: Merge BINARY_OP_SUBSCR and store_subscr (w/ delete) into subscr.
mp_obj_t->subscr now does load/store/delete.
11 years ago
Damien George
ee01411036
py: Add len(bytes).
11 years ago
Damien George
897fe0c0d0
py: Add builtin functions bin and oct, and some tests for them.
11 years ago
Damien George
3bb8bd899b
Make USE_COMPUTED_GOTO a config option in mpconfig.h.
Disabled by default. Enabled in unix port.
11 years ago
Paul Sokolovsky
58676fc2c7
objstr: Allow to define statically allocated str objects.
Similar to tuples, lists, dicts. Statically allocated strings don't have hash
computed.
11 years ago
Paul Sokolovsky
59e269cfec
qstr, objstr: Make sure that valid hash != 0, treat 0 as "not computed".
This feature was proposed with initial hashing RFC, and is prerequisite for
seamless static str object definition.
11 years ago