summaryrefslogtreecommitdiff
path: root/py/binary.c
AgeCommit message (Collapse)Author
2019-09-02py/binary: Change mp_uint_t to size_t for index, size, align args.Damien George
Reduces code size for nan-box builds, otherwise changes nothing.
2019-09-02py/modstruct: Fix struct.pack_into with unaligned offset of native type.Damien George
Following the same fix for unpack.
2019-09-02py/modstruct: Fix struct.unpack with unaligned offset of native type.Tom McDermott
With this patch alignment is done relative to the start of the buffer that is being unpacked, not the raw pointer value, as per CPython. Fixes issue #3314.
2019-05-17various: Update early copyright years to match actual edit history.Damien George
2019-05-17various: Add and update my copyright line based on git history.Paul Sokolovsky
For modules I initially created or made substantial contributions to.
2019-02-12py: Downcase all MP_OBJ_IS_xxx macros to make a more consistent C API.Damien George
These macros could in principle be (inline) functions so it makes sense to have them lower case, to match the other C API functions. The remaining macros that are upper case are: - MP_OBJ_TO_PTR, MP_OBJ_FROM_PTR - MP_OBJ_NEW_SMALL_INT, MP_OBJ_SMALL_INT_VALUE - MP_OBJ_NEW_QSTR, MP_OBJ_QSTR_VALUE - MP_OBJ_FUN_MAKE_SIG - MP_DECLARE_CONST_xxx - MP_DEFINE_CONST_xxx These must remain macros because they are used when defining const data (at least, MP_OBJ_NEW_SMALL_INT is so it makes sense to have MP_OBJ_SMALL_INT_VALUE also a macro). For those macros that have been made lower case, compatibility macros are provided for the old names so that users do not need to change their code immediately.
2017-11-16py/objstr: Remove "make_qstr_if_not_already" arg from mp_obj_new_str.Damien George
This patch simplifies the str creation API to favour the common case of creating a str object that is not forced to be interned. To force interning of a new str the new mp_obj_new_str_via_qstr function is added, and should only be used if warranted. Apart from simplifying the mp_obj_new_str function (and making it have the same signature as mp_obj_new_bytes), this patch also reduces code size by a bit (-16 bytes for bare-arm and roughly -40 bytes on the bare-metal archs).
2017-08-15py/binary.c: Fix bug when packing big-endian 'Q' values.Bas van Sisseren
Without bugfix: struct.pack('>Q', 16) b'\x00\x00\x00\x10\x00\x00\x00\x00' With bugfix: struct.pack('>Q', 16) b'\x00\x00\x00\x00\x00\x00\x00\x10'
2017-07-31all: Use the name MicroPython consistently in commentsAlexander Steffen
There were several different spellings of MicroPython present in comments, when there should be only one.
2017-07-04py/binary: Add missing "break" statements.Damien George
2017-05-09py/binary: Handle storing big-ints to all arrays types.Damien George
Prior to this patch only 'q' and 'Q' type arrays could store big-int values. With this patch any big int that is stored to an array is handled by the big-int implementation, regardless of the typecode of the array. This allows arrays to work with all type sizes on all architectures.
2017-01-17py/binary: mp_binary_get_size: Raise error on unsupported typecodes.Paul Sokolovsky
Previouly, we had errors checked in callers, which led to duplicate code or missing checks in some places.
2016-12-12py/binary: Do zero extension when storing a value larger than word size.Damien George
2015-11-29py: Wrap all obj-ptr conversions in MP_OBJ_TO_PTR/MP_OBJ_FROM_PTR.Damien George
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.
2015-11-27py/binary: Make use of MP_ALIGN.Damien George
2015-10-12py/objarray: Allow to create array of void pointers, as extension to CPython.Paul Sokolovsky
Using 'P' format specifier (matches struct module). This is another shortcut for FFI, just as previously introduced "array of objects" ('O').
2015-09-01py/binary: Add support for array('q') and array('Q').Damien George
2015-05-17py/binary: Make return type of mp_binary_get_size size_t instead of int.Kaspar Schleiser
Fixes sign-compare warning.
2015-04-25py: Fix handling of negative numbers in struct.pack of q/Q.Damien George
2015-04-25py: Support conversion of bignum to bytes.Damien George
This gets int.to_bytes working for bignum, and also struct.pack with 'q' and 'Q' args on 32-bit machines. Addresses issue #1155.
2015-03-05objarray: Support array('O'), array of objects, as extension to CPython.Paul Sokolovsky
Might be useful at least for memoryview hacks.
2015-01-27py: Add support for floats in mp_binary_{get,set}_val()David Steinberg
- This then provides support for floats in the struct package
2015-01-24binary: Rework array accessors. They work with native, not stdint types.Paul Sokolovsky
2015-01-16py, unix: Allow to compile with -Wsign-compare.Damien George
See issue #699.
2015-01-01py: Move to guarded includes, everywhere in py/ core.Damien George
Addresses issue #1022.
2014-12-05py: Rename mp_obj_int_get to mp_obj_int_get_truncated; fix struct.pack.Damien George
mp_obj_int_get_truncated is used as a "fast path" int accessor that doesn't check for overflow and returns the int truncated to the machine word size, ie mp_int_t. Use mp_obj_int_get_truncated to fix struct.pack when packing maximum word sized values. Addresses issues #779 and #998.
2014-11-21py: Add support for float/double arrays in array module.Damien George
Addresses issue #981.
2014-10-06py: Make mp_binary_set_val work on big endian machine.Damien George
2014-10-03py: Convert [u]int to mp_[u]int_t where appropriate.Damien George
Addressing issue #50.
2014-09-10py: Enable struct/binary-helper to parse q and Q sized ints.Damien George
Addresses issue #848.
2014-09-06modstruct: Implement 'O', 'P', 's' types for packed structs.Paul Sokolovsky
This is required to deal with, well, packed C structs containing pointers.
2014-08-30py: Change uint to mp_uint_t in runtime.h, stackctrl.h, binary.h.Damien George
Part of code cleanup, working towards resolving issue #50.
2014-08-10py: binary.c: Properly implement alignment for native unpacked structs.Paul Sokolovsky
2014-07-05binary: Factor out mp_binary_set_int().Paul Sokolovsky
2014-07-03Rename machine_(u)int_t to mp_(u)int_t.Damien George
See discussion in issue #50.
2014-06-26binary: machine_uint_t vs uint dichotomy starts doing real damage.Paul Sokolovsky
2014-06-25modstruct: Fix alignment handling issues.Paul Sokolovsky
Also, factor out mp_binary_get_int() function.
2014-06-21py: Include mpconfig.h before all other includes.Paul Sokolovsky
It defines types used by all other headers. Fixes #691.
2014-06-02modstruct: Add one more extension to typecodes - 'S', a pointer to C string.Paul Sokolovsky
Also, add comment with description of extension to CPython's typecodes.
2014-06-01Rename bultins config variables to MICROPY_PY_BUILTINS_*.Damien George
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.
2014-05-03Add license header to (almost) all files.Damien George
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/.
2014-04-20modstruct: Add 'O' typecode for passing mp_obj_t.Paul Sokolovsky
Useful as callback data, etc.
2014-04-20modstruct: Use proper int accessor which checks input value type.Paul Sokolovsky
2014-04-19modstruct: Initial implementation of struct.pack().Paul Sokolovsky
2014-04-19modstruct: Fix .calcsize() to account for struct type/alignment.Paul Sokolovsky
2014-04-19modstruct: Support 'q' & 'Q' type codes.Paul Sokolovsky
2014-04-18py: Add mp_binary_set_val_array_from_int, to store an int directly.Damien George
2014-04-11modstruct: Basic implementation of native struct alignment and types.Paul Sokolovsky
2014-04-11binary: Rename array accessors for clarity.Paul Sokolovsky
2014-04-11modstruct: Refactor to support both LE and BE packed structs.Paul Sokolovsky