summaryrefslogtreecommitdiffstatshomepage
path: root/py/mpprint.c
Commit message (Collapse)AuthorAge
* py/mpprint: Fail an assertion with unsupported format specifiers.Delio Brignoli2016-09-01
| | | | | | Arguments of an unknown type cannot be skipped and continuing to parse a format string after encountering an unknown format specifier leads to undefined behaviour. This patch helps to find use of unsupported formats.
* py/mpprint: Fix sign extension when printf'ing %u, %x and %X.Damien George2016-02-01
|
* py: Change mp_obj_int_is_positive to more general mp_obj_int_sign.Damien George2016-01-07
| | | | This function returns the sign (-1, 0 or 1) of the integer object.
* py/mpprint: Fix printing of 64bit integers for 64bit windows buildsstijn2015-12-19
| | | | | | | | | | | | | | | | This makes all tests pass again for 64bit windows builds which would previously fail for anything printing ranges (builtin_range/unpack1) because they were printed as range( ld, ld ). This is done by reusing the mp_vprintf implementation for MICROPY_OBJ_REPR_D for 64bit windows builds (both msvc and mingw-w64) since the format specifier used for 64bit integers is also %lld, or %llu for the unsigned version. Note these specifiers used to be fetched from inttypes.h, which is the C99 way of working with printf/scanf in a portable way, but mingw-w64 wants to be backwards compatible with older MS C runtimes and uses the non-portable %I64i instead of %lld in inttypes.h, so remove the use of said header again in mpconfig.h and define the specifiers manually.
* py/mpprint: Implement %llu and %lld format specifiers for mp_printf.Damien George2015-12-17
| | | | Only enabled for MICROPY_OBJ_REPR_D.
* py/mpprint: Printing of doubles is now supported (by uPy own routine).fabien.lementec2015-12-02
|
* py: Change qstr_* functions to use size_t as the type for str len arg.Damien George2015-11-29
|
* py: Change mp_print_strn_t func type to use size_t for the str length.Damien George2015-11-29
|
* all: Add py/mphal.h and use it in all ports.Damien George2015-10-31
| | | | | | py/mphal.h contains declarations for generic mp_hal_XXX functions, such as stdio and delay/ticks, which ports should provide definitions for. A port will also provide mphalport.h with further HAL declarations.
* py: Remove unnecessary extra handling of padding of nan/inf.Damien George2015-05-28
| | | | | | | C's printf will pad nan/inf differently to CPython. Our implementation originally conformed to C, now it conforms to CPython's way. Tests for this are also added in this patch.
* py: Reduce size of mp_printf by eliminating unnecessary code.Damien George2015-05-28
| | | | Saves around 120 bytes on Thumb2 archs.
* py: Implement mp_format_float for doubles and use where appropriatestijn2015-05-17
| | | | | | | This allows using (almost) the same code for printing floats everywhere, removes the dependency on sprintf and uses just snprintf and applies an msvc-specific fix for snprintf in a single place so nan/inf are now printed correctly.
* py: Add %q format support to mp_[v]printf, and use it.Damien George2015-04-16
|
* 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.