Skip to content
Snippets Groups Projects
  1. May 06, 2019
    • Jun Wu's avatar
      py: remove "if (0)" and "if (false)" branches. · 089c9b71
      Jun Wu authored
      Prior to this commit, building the unix port with `DEBUG=1` and
      `-finstrument-functions` the compilation would fail with an error like
      "control reaches end of non-void function".  This change fixes this by
      removing the problematic "if (0)" branches.  Not all branches affect
      compilation, but they are all removed for consistency.
      089c9b71
  2. Feb 12, 2019
    • Damien George's avatar
      py: Downcase all MP_OBJ_IS_xxx macros to make a more consistent C API. · eee1e884
      Damien George authored
      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.
      eee1e884
  3. Sep 20, 2018
  4. Apr 04, 2018
  5. Nov 24, 2017
    • Damien George's avatar
      py/runtime: Add MP_BINARY_OP_CONTAINS as reverse of MP_BINARY_OP_IN. · 5e34a113
      Damien George authored
      Before this patch MP_BINARY_OP_IN had two meanings: coming from bytecode it
      meant that the args needed to be swapped, but coming from within the
      runtime meant that the args were already in the correct order.  This lead
      to some confusion in the code and comments stating how args were reversed.
      It also lead to 2 bugs: 1) containment for a subclass of a native type
      didn't work; 2) the expression "{True} in True" would illegally succeed and
      return True.  In both of these cases it was because the args to
      MP_BINARY_OP_IN ended up being reversed twice.
      
      To fix these things this patch introduces MP_BINARY_OP_CONTAINS which
      corresponds exactly to the __contains__ special method, and this is the
      operator that built-in types should implement.  MP_BINARY_OP_IN is now only
      emitted by the compiler and is converted to MP_BINARY_OP_CONTAINS by
      swapping the arguments.
      5e34a113
  6. Oct 04, 2017
    • Damien George's avatar
      all: Remove inclusion of internal py header files. · a3dc1b19
      Damien George authored
      Header files that are considered internal to the py core and should not
      normally be included directly are:
          py/nlr.h - internal nlr configuration and declarations
          py/bc0.h - contains bytecode macro definitions
          py/runtime0.h - contains basic runtime enums
      
      Instead, the top-level header files to include are one of:
          py/obj.h - includes runtime0.h and defines everything to use the
              mp_obj_t type
          py/runtime.h - includes mpstate.h and hence nlr.h, obj.h, runtime0.h,
              and defines everything to use the general runtime support functions
      
      Additional, specific headers (eg py/objlist.h) can be included if needed.
      a3dc1b19
  7. Sep 17, 2017
    • Paul Sokolovsky's avatar
      py/modbuiltins: Implement abs() by dispatching to MP_UNARY_OP_ABS. · 9dce823c
      Paul Sokolovsky authored
      This allows user classes to implement __abs__ special method, and saves
      code size (104 bytes for x86_64), even though during refactor, an issue
      was fixed and few optimizations were made:
      
      * abs() of minimum (negative) small int value is calculated properly.
      * objint_longlong and objint_mpz avoid allocating new object is the
        argument is already non-negative.
      9dce823c
  8. Sep 07, 2017
  9. Aug 29, 2017
  10. Jul 31, 2017
  11. Jul 25, 2017
  12. Apr 21, 2017
  13. Apr 04, 2017
  14. Mar 28, 2017
  15. Feb 16, 2017
  16. Feb 02, 2017
  17. Jan 21, 2017
  18. Jan 19, 2017
  19. Dec 21, 2016
  20. Oct 17, 2016
  21. Oct 11, 2016
  22. May 08, 2016
  23. Mar 10, 2016
  24. Jan 07, 2016
  25. Nov 29, 2015
    • Damien George's avatar
      py: Wrap all obj-ptr conversions in MP_OBJ_TO_PTR/MP_OBJ_FROM_PTR. · 999cedb9
      Damien George authored
      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.
      999cedb9
  26. Oct 20, 2015
  27. Oct 11, 2015
  28. Oct 01, 2015
  29. Sep 15, 2015
  30. Jun 13, 2015
  31. May 12, 2015
    • Damien George's avatar
      py: Convert hash API to use MP_UNARY_OP_HASH instead of ad-hoc function. · c2a4e4ef
      Damien George authored
      Hashing is now done using mp_unary_op function with MP_UNARY_OP_HASH as
      the operator argument.  Hashing for int, str and bytes still go via
      fast-path in mp_unary_op since they are the most common objects which
      need to be hashed.
      
      This lead to quite a bit of code cleanup, and should be more efficient
      if anything.  It saves 176 bytes code space on Thumb2, and 360 bytes on
      x86.
      
      The only loss is that the error message "unhashable type" is now the
      more generic "unsupported type for __hash__".
      c2a4e4ef
  32. Apr 25, 2015
  33. Apr 22, 2015
  34. Mar 14, 2015
  35. Jan 24, 2015
  36. Jan 07, 2015
  37. Jan 02, 2015
Loading