summaryrefslogtreecommitdiffstatshomepage
path: root/py/misc.h
Commit message (Collapse)AuthorAge
* py/repl: Check for an identifier char after the keyword.Alex March2016-02-17
| | | | | - As described in the #1850. - Add cmdline tests.
* py/misc.h: Include stdint.h only once (unconditionally at the top).Paul Sokolovsky2015-12-08
|
* py/misc.h: Include stdint.h, as large share of code now depends on it.Paul Sokolovsky2015-12-07
|
* py: Wrap all obj-ptr conversions in MP_OBJ_TO_PTR/MP_OBJ_FROM_PTR.Damien George2015-11-29
| | | | | | | | | This allows the mp_obj_t type to be configured to something other than a pointer-sized primitive type. This patch also includes additional changes to allow the code to compile when sizeof(mp_uint_t) != sizeof(void*), such as using size_t instead of mp_uint_t, and various casts.
* py: Improve allocation policy of qstr data.Damien George2015-07-14
| | | | | | | | | | | | | | | | | | | | Previous to this patch all interned strings lived in their own malloc'd chunk. On average this wastes N/2 bytes per interned string, where N is the number-of-bytes for a quanta of the memory allocator (16 bytes on 32 bit archs). With this patch interned strings are concatenated into the same malloc'd chunk when possible. Such chunks are enlarged inplace when possible, and shrunk to fit when a new chunk is needed. RAM savings with this patch are highly varied, but should always show an improvement (unless only 3 or 4 strings are interned). New version typically uses about 70% of previous memory for the qstr data, and can lead to savings of around 10% of total memory footprint of a running script. Costs about 120 bytes code size on Thumb2 archs (depends on how many calls to gc_realloc are made).
* extmod: Add ubinascii.unhexlifyDave Hylands2015-05-20
| | | | This also pulls out hex_digit from py/lexer.c and makes unichar_hex_digit
* py: Overhaul and simplify printf/pfenv mechanism.Damien George2015-04-16
| | | | | | | | | | | | | | | | | | | | | | Previous to this patch the printing mechanism was a bit of a tangled mess. This patch attempts to consolidate printing into one interface. All (non-debug) printing now uses the mp_print* family of functions, mainly mp_printf. All these functions take an mp_print_t structure as their first argument, and this structure defines the printing backend through the "print_strn" function of said structure. Printing from the uPy core can reach the platform-defined print code via two paths: either through mp_sys_stdout_obj (defined pert port) in conjunction with mp_stream_write; or through the mp_plat_print structure which uses the MP_PLAT_PRINT_STRN macro to define how string are printed on the platform. The former is only used when MICROPY_PY_IO is defined. With this new scheme printing is generally more efficient (less layers to go through, less arguments to pass), and, given an mp_print_t* structure, one can call mp_print_str for efficiency instead of mp_printf("%s", ...). Code size is also reduced by around 200 bytes on Thumb2 archs.
* py: Add MICROPY_MALLOC_USES_ALLOCATED_SIZE to allow simpler malloc API.Damien George2015-03-03
|
* py: Change vstr_null_terminate -> vstr_null_terminated_str, returns str.Damien George2015-01-29
|
* py: Change vstr so that it doesn't null terminate buffer by default.Damien George2015-01-28
| | | | | | | | | This cleans up vstr so that it's a pure "variable buffer", and the user can decide whether they need to add a terminating null byte. In most places where vstr is used, the vstr did not need to be null terminated and so this patch saves code size, a tiny bit of RAM, and makes vstr usage more efficient. When null termination is needed it must be done explicitly using vstr_null_terminate.
* py: Be more precise about unicode type and disabled unicode behaviour.Damien George2015-01-28
|
* py: Move mp_float_t related defines to misc.hDavid Steinberg2015-01-24
|
* py: Remove mp_obj_str_builder and use vstr instead.Damien George2015-01-21
| | | | | | | | | | | | With this patch str/bytes construction is streamlined. Always use a vstr to build a str/bytes object. If the size is known beforehand then use vstr_init_len to allocate only required memory. Otherwise use vstr_init and the vstr will grow as needed. Then use mp_obj_new_str_from_vstr to create a str/bytes object using the vstr memory. Saves code ROM: 68 bytes on stmhal, 108 bytes on bare-arm, and 336 bytes on unix x64.
* py: Add mp_obj_new_str_from_vstr, and use it where relevant.Damien George2015-01-21
| | | | | | | | This patch allows to reuse vstr memory when creating str/bytes object. This improves memory usage. Also saves code ROM: 128 bytes on stmhal, 92 bytes on bare-arm, and 88 bytes on unix x64.
* py: Add include guards to mpconfig,misc,qstr,obj,runtime,parsehelper.Damien George2014-12-29
|
* py: Add further checks for failed malloc in lexer init functions.Damien George2014-10-09
|
* Fix error: unknown type name 'size_t'bvernoux2014-09-28
|
* py: For malloc and vstr functions, use size_t exclusively for int type.Damien George2014-09-25
| | | | | | It seems most sensible to use size_t for measuring "number of bytes" in malloc and vstr functions (since that's what size_t is for). We don't use mp_uint_t because malloc and vstr are not Micro Python specific.
* py: Add generic helper to align a pointer.Paul Sokolovsky2014-07-12
|
* Rename machine_(u)int_t to mp_(u)int_t.Damien George2014-07-03
| | | | See discussion in issue #50.
* py: Make unichar_charlen() accept/return machine_uint_t.Paul Sokolovsky2014-06-28
|
* py: Small comments, name changes, use of machine_int_t.Damien George2014-06-28
|
* misc: Add count_lead_ones() function, useful for UTF-8 handling.Paul Sokolovsky2014-06-27
|
* py: Implement basic unicode functions.Chris Angelico2014-06-27
|
* Prefix ARRAY_SIZE with micropython prefix MP_Emmanuel Blot2014-06-19
|
* unicode: Add trivial implementation of unichar_charlen().Paul Sokolovsky2014-06-14
|
* unicode: String API is const byte*.Paul Sokolovsky2014-06-14
| | | | | We still have that char vs byte dichotomy, but majority of string operations now use byte.
* add methods isspace(), isalpha(), isdigit(), isupper() and islower() to strKim Bauters2014-05-31
|
* objstr: Implement .lower() and .upper().Paul Sokolovsky2014-05-10
|
* py: Improve handling of memory error in parser.Damien George2014-05-10
| | | | | | | | | | | Parser shouldn't raise exceptions, so needs to check when memory allocation fails. This patch does that for the initial set up of the parser state. Also, we now put the parser object on the stack. It's small enough to go there instead of on the heap. This partially addresses issue #558.
* py, unix: Add -v option, print bytecode dump if used.Paul Sokolovsky2014-05-05
| | | | | | | | | | This will work if MICROPY_DEBUG_PRINTERS is defined, which is only for unix/windows ports. This makes it convenient to user uPy normally, but easily get bytecode dump on the spot if needed, without constant recompiles back and forth. TODO: Add more useful debug output, adjust verbosity level on which specifically bytecode dump happens.
* Add license header to (almost) all files.Damien George2014-05-03
| | | | | | | 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/.
* Add ARRAY_SIZE macro, and use it where possible.Damien George2014-04-26
|
* py: Check explicitly for memory allocation failure in parser.Damien George2014-04-10
| | | | | | Previously, a failed malloc/realloc would throw an exception, which was not caught. I think it's better to keep the parser free from NLR (exception throwing), hence this patch.
* py: Add emergency exception object for when heap allocation fails.Damien George2014-04-10
|
* Improve GC finalisation code; add option to disable it.Damien George2014-04-05
|
* Merge pull request #425 from iabdalkader/delDamien George2014-04-05
|\ | | | | Implement del
| * Implement delmux2014-04-03
| |
* | py: Add m_malloc_fail function to handle memory allocation error.Damien George2014-04-04
|/ | | | A malloc/realloc fail now throws MemoryError.
* py: Wrap compile_scope_inline_asm in #if; remove comment from misc.h.Damien George2014-04-02
|
* Add vstr_ins and vstr_cut_out; improve stmhal readline.Damien George2014-03-15
|
* py: Take out bitfield entries from their own structure.Damien George2014-02-26
| | | | | Don't need to wrap bitfields in their own struct. Compiler does the correct thing without it.
* py: Rename strtonum to mp_strtonum.Damien George2014-02-22
| | | | | strtonum clashes with BSD function of same name, and our version is different so warrants a unique name. Addresses Issue #305.
* Make DEBUG_printf() a proper function, implementation is port-dependent.Paul Sokolovsky2014-02-16
| | | | | In particular, unix outputs to stderr, to allow to run testsuite against micropython built with debug output (by redirecting stderr to /dev/null).
* Implement fixed buffer vstrs; use them for import path.Damien George2014-02-06
|
* Search paths properly on import and execute __init__.py if it exists.Damien George2014-02-05
|
* Implement support for sys.path when loading modules.Paul Sokolovsky2014-02-05
| | | | | | | | sys.path is not initialized by rt_init(), that's left for platform-specific startup code. (For example, bare metal port may have some hardcoded defaults, and let user change sys.path directly; while port for OS with environment feature can take path from environment). If it's not explicitly initialized, modules will be imported only from a current directory.
* Add generic MIN()/MAX() functions.Paul Sokolovsky2014-02-05
|
* Implement octal and hex escapes in strings.Paul Sokolovsky2014-01-22
|
* Revamp qstrs: they now include length and hash.Damien George2014-01-21
| | | | | Can now have null bytes in strings. Can define ROM qstrs per port using qstrdefsport.h