Commit Graph

34 Commits

Author SHA1 Message Date
Damien George
efe23aca71 all: Remove third argument to MP_REGISTER_MODULE.
It's no longer needed because this macro is now processed after
preprocessing the source code via cpp (in the qstr extraction stage), which
means unused MP_REGISTER_MODULE's are filtered out by the preprocessor.

Signed-off-by: Damien George <damien@micropython.org>
2022-06-02 16:31:37 +10:00
Jim Mussared
4eab44a1ec extmod: Make extmod modules use MP_REGISTER_MODULE.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-05-18 20:49:12 +10:00
Jim Mussared
0e7bfc88c6 all: Use mp_obj_malloc everywhere it's applicable.
This replaces occurences of

    foo_t *foo = m_new_obj(foo_t);
    foo->base.type = &foo_type;

with

    foo_t *foo = mp_obj_malloc(foo_t, &foo_type);

Excludes any places where base is a sub-field or when new0/memset is used.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-05-03 22:28:14 +10:00
Daniël van de Giessen
e2513bfe8d extmod/moduzlib: Fix parsing zlib header dict size.
From RFC 1950 section 2.2: "CINFO is the base-2 logarithm of the LZ77
window size, minus eight (CINFO=7 indicates a 32K window size)"

Signed-off-by: Daniël van de Giessen <daniel@dvdgiessen.nl>
2022-03-08 23:16:14 +11:00
Damien George
38a204ed96 py: Introduce and use mp_raise_type_arg helper.
To reduce code size.

Signed-off-by: Damien George <damien@micropython.org>
2021-07-15 00:12:41 +10:00
Damien George
94dfaff18b extmod: Update for move of crypto-algorithms, re1.5, uzlib to lib.
Signed-off-by: Damien George <damien@micropython.org>
2021-07-12 16:37:07 +10:00
Jim Mussared
def76fe4d9 all: Use MP_ERROR_TEXT for all error messages. 2020-04-05 15:02:06 +10:00
Damien George
69661f3343 all: Reformat C and Python source code with tools/codeformat.py.
This is run with uncrustify 0.70.1, and black 19.10b0.
2020-02-28 10:33:03 +11:00
Damien George
97eca38c4f py: Add mp_raise_type helper macro and use it where appropriate.
This provides a more consistent C-level API to raise exceptions, ie moving
away from nlr_raise towards mp_raise_XXX.  It also reduces code size by a
small amount on some ports.
2020-02-13 11:03:37 +11:00
Damien George
bbeaafd9aa extmod: Add dynamic-runtime guards to btree/framebuf/uheapq/ure/uzlib.
So they can be built as dynamic native modules, as well as existing static
native modules.
2019-12-12 20:15:28 +11:00
Paul Sokolovsky
35687a87ec extmod/moduzlib: Update for uzlib 2.9.2. 2019-01-27 10:59:49 +11:00
Damien George
e8398a5856 extmod: Update to use new mp_get_stream helper.
With this patch objects are only checked that they have the stream protocol
at the start of their use as a stream, and afterwards the efficient
mp_get_stream() helper is used to extract the stream protocol C methods.
2018-06-18 12:35:56 +10:00
Damien George
a3dc1b1957 all: Remove inclusion of internal py header files.
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.
2017-10-04 12:37:50 +11:00
Javier Candeira
35a1fea90b all: Raise exceptions via mp_raise_XXX
- Changed: ValueError, TypeError, NotImplementedError
  - OSError invocations unchanged, because the corresponding utility
    function takes ints, not strings like the long form invocation.
  - OverflowError, IndexError and RuntimeError etc. not changed for now
    until we decide whether to add new utility functions.
2017-08-13 22:52:33 +10:00
Alexander Steffen
55f33240f3 all: Use the name MicroPython consistently in comments
There were several different spellings of MicroPython present in comments,
when there should be only one.
2017-07-31 18:35:40 +10:00
Paul Sokolovsky
91e93a9684 extmod/moduzlib: decompress: Remove stale "(void)n_args".
n_args is now actually used in this function.
2017-06-24 16:36:05 +03:00
Paul Sokolovsky
59a1201da9 all: Remove readall() method, which is equivalent to read() w/o args.
Its addition was due to an early exploration on how to add CPython-like
stream interface. It's clear that it's not needed and just takes up
bytes in all ports.
2016-11-14 00:24:22 +03:00
Damien George
75af908c0e extmod: Use mp_raise_OSError helper function. 2016-10-07 13:52:14 +11:00
Paul Sokolovsky
7b901d6fb7 extmod/moduzlib: DecompIO: Add support for gzip-formatted streams.
This uses extension introduced in CPython 3.5: if wbits (dictionary size
code) has value 16 + 8..15, it means that gzip-formatted stream expected.
2016-09-24 15:30:11 +03:00
Damien George
93c4a6a3f7 all: Remove 'name' member from mp_obj_module_t struct.
One can instead lookup __name__ in the modules dict to get the value.
2016-09-22 00:23:16 +10:00
Paul Sokolovsky
1bc5cb4312 extmod/moduzlib: Support wbits arg to DecompIO. 2016-09-04 14:44:12 +03:00
Paul Sokolovsky
f7c4611523 extmod/moduzlib: Use mperrno.h for error constants. 2016-09-03 00:34:57 +03:00
Paul Sokolovsky
a6864a13c7 extmod/moduzlib: Implement zlib stream decompressor class, DecompIO. 2016-09-03 00:19:35 +03:00
Paul Sokolovsky
ed4ce196ed extmod/moduzlib: Refactor to new stream-compatible uzlib 2.0 API. 2016-08-17 06:06:34 +03:00
Damien George
4b72b3a133 py: Change type signature of builtin funs that take variable or kw args.
With this patch the n_args parameter is changed type from mp_uint_t to
size_t.
2016-01-11 00:49:27 +00:00
Damien George
cbf7674025 py: Add MP_ROM_* macros and mp_rom_* types and use them. 2015-11-29 14:25:04 +00:00
Damien George
1ef26b35c1 py, extmod: Remove include of unnecessary system headers. 2015-03-14 23:11:25 +00:00
Paul Sokolovsky
e9995bdea2 moduzlib: Align out buffer to block size; shrink when decompression done. 2015-01-28 02:30:01 +02:00
Paul Sokolovsky
2324f3ef29 moduzlib: Implement raw DEFLATE decoding support. 2015-01-28 02:21:49 +02:00
Damien George
ff8dd3f486 py, unix: Allow to compile with -Wunused-parameter.
See issue #699.
2015-01-20 12:47:20 +00:00
Damien George
3765ea419a extmod: Prefix py/ for includes from py core directory. 2015-01-01 20:35:21 +00:00
Damien George
3b603f29ec Use MP_DEFINE_CONST_DICT macro to define module dicts.
This is just a clean-up of the code.  Generated code is exactly the
same.
2014-11-29 14:39:27 +00:00
Damien George
4b71c056ef moduzlib: Fix fn prototype and some code style; use it in stmhal port. 2014-10-12 23:35:38 +01:00
Paul Sokolovsky
426bb58b23 moduzlib: New zlib-like module, based on uzlib. 2014-10-13 00:07:43 +03:00