summaryrefslogtreecommitdiffstatshomepage
path: root/extmod/modure.c
Commit message (Collapse)AuthorAge
* all: Rename *umodule*.c to remove the "u" prefix.Jim Mussared2023-06-08
| | | | | | | | | | | Updates any includes, and references from Makefiles/CMake. This essentially reverts what was done long ago in commit 136b5cbd7669e8318f8455fc2706da97a5b7994c This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
* all: Rename UMODULE to MODULE in preprocessor/Makefile vars.Jim Mussared2023-06-08
| | | | | | This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
* all: Rename mod_umodule*, ^umodule* to remove the "u" prefix.Jim Mussared2023-06-08
| | | | | | This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
* all: Rename mp_umodule*, mp_module_umodule* to remove the "u" prefix.Jim Mussared2023-06-08
| | | | | | This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
* all: Rename MP_QSTR_umodule to MP_QSTR_module everywhere.Jim Mussared2023-06-08
| | | | | | | | | This renames the builtin-modules, such that help('modules') and printing the module object will show "module" rather than "umodule". This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
* py/obj: Convert make_new into a mp_obj_type_t slot.Jim Mussared2022-09-19
| | | | | | | | | | | Instead of being an explicit field, it's now a slot like all the other methods. This is a marginal code size improvement because most types have a make_new (100/138 on PYBV11), however it improves consistency in how types are declared, removing the special case for make_new. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
* py/obj: Add "full" and "empty" non-variable-length mp_obj_type_t.Jim Mussared2022-09-19
| | | | | | | This will always have the maximum/minimum size of a mp_obj_type_t representation and can be used as a member in other structs. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
* all: Remove unnecessary locals_dict cast.Jim Mussared2022-09-19
| | | | Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
* all: Make all mp_obj_type_t defs use MP_DEFINE_CONST_OBJ_TYPE.Jim Mussared2022-09-19
| | | | | | In preparation for upcoming rework of mp_obj_type_t layout. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
* extmod/modure: Convert byte offsets to unicode indices when necessary.Jeff Epler2022-09-06
| | | | | | | | And add a test. Fixes issue #9202. Signed-off-by: Jeff Epler <jepler@gmail.com>
* py/objstr: Optimise mp_obj_new_str_from_vstr for known-safe strings.Jim Mussared2022-08-26
| | | | | | | The new `mp_obj_new_str_from_utf8_vstr` can be used when you know you already have a unicode-safe string. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
* py/objstr: Split mp_obj_str_from_vstr into bytes/str versions.Jim Mussared2022-08-26
| | | | | | | | | | | | | | Previously the desired output type was specified. Now make the type part of the function name. Because this function is used in a few places this saves code size due to smaller call-site. This makes `mp_obj_new_str_type_from_vstr` a private function of objstr.c (which is almost the only place where the output type isn't a compile-time constant). This saves ~140 bytes on PYBV11. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
* all: Remove third argument to MP_REGISTER_MODULE.Damien George2022-06-02
| | | | | | | | 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>
* extmod: Make extmod modules use MP_REGISTER_MODULE.Jim Mussared2022-05-18
| | | | Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
* all: Use mp_obj_malloc everywhere it's applicable.Jim Mussared2022-05-03
| | | | | | | | | | | | | | | 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>
* extmod/modure: Set subject begin_line so ^ doesn't match interior.Damien George2022-03-16
| | | | | | Fixes issue #8402. Signed-off-by: Damien George <damien@micropython.org>
* extmod/modure: Redirect regex debug printing to mp_printf.Damien George2021-12-09
| | | | Signed-off-by: Damien George <damien@micropython.org>
* py: Introduce and use mp_raise_type_arg helper.Damien George2021-07-15
| | | | | | To reduce code size. Signed-off-by: Damien George <damien@micropython.org>
* extmod: Update for move of crypto-algorithms, re1.5, uzlib to lib.Damien George2021-07-12
| | | | Signed-off-by: Damien George <damien@micropython.org>
* extmod/modure: Allow \\ in re.sub replacements.Andrew Leech2020-09-30
|
* extmod/ure: Use single function for match/search/sub.stijn2020-06-08
| | | | | Saves about 500 bytes on unix x64 and enables CPython-conform usage of passing a re object to these functions.
* all: Format code to add space after C++-style comment start.stijn2020-04-23
| | | | | | Note: the uncrustify configuration is explicitly set to 'add' instead of 'force' in order not to alter the comments which use extra spaces after // as a means of indenting text for clarity.
* all: Clean up error strings to use lowercase and change cannot to can't.Damien George2020-04-13
| | | | | | | Now that error string compression is supported it's more important to have consistent error string formatting (eg all lowercase English words, consistent contractions). This commit cleans up some of the strings to make them more consistent.
* all: Use MP_ERROR_TEXT for all error messages.Jim Mussared2020-04-05
|
* all: Reformat C and Python source code with tools/codeformat.py.Damien George2020-02-28
| | | | This is run with uncrustify 0.70.1, and black 19.10b0.
* extmod: Add dynamic-runtime guards to btree/framebuf/uheapq/ure/uzlib.Damien George2019-12-12
| | | | | So they can be built as dynamic native modules, as well as existing static native modules.
* extmod/modure: Make regex dump-code debugging feature optional.Damien George2019-08-19
| | | | | | | Enabled via MICROPY_PY_URE_DEBUG, disabled by default (but enabled on unix coverage build). This is a rarely used feature that costs a lot of code (500-800 bytes flash). Debugging of regular expressions can be done offline with other tools.
* extmod/modure: Add ure.sub() function and method, and tests.Damien George2018-07-02
| | | | | | | This feature is controlled at compile time by MICROPY_PY_URE_SUB, disabled by default. Thanks to @dmazzella for the original patch for this feature; see #3770.
* extmod/modure: Add match.span(), start() and end() methods, and tests.Damien George2018-07-02
| | | | | | | This feature is controlled at compile time by MICROPY_PY_URE_MATCH_SPAN_START_END, disabled by default. Thanks to @dmazzella for the original patch for this feature; see #3770.
* extmod/modure: Add match.groups() method, and tests.Damien George2018-07-02
| | | | | | | This feature is controlled at compile time by MICROPY_PY_URE_MATCH_GROUPS, disabled by default. Thanks to @dmazzella for the original patch for this feature; see #3770.
* extmod/modure: Add cast to workaround bug in MSVC.Damien George2017-12-13
|
* extmod/modure: Convert alloca() to use new scoped allocation API.Damien George2017-12-11
|
* all: Remove inclusion of internal py header files.Damien George2017-10-04
| | | | | | | | | | | | | | | | 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.
* extmod/modure: Add stack overflow checking when executing a regex.Paul Sokolovsky2017-10-03
|
* all: Raise exceptions via mp_raise_XXXJavier Candeira2017-08-13
| | | | | | | | - 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.
* all: Use the name MicroPython consistently in commentsAlexander Steffen2017-07-31
| | | | | There were several different spellings of MicroPython present in comments, when there should be only one.
* extmod/modure: If input string is bytes, return bytes results too.Paul Sokolovsky2017-07-01
| | | | | | This applies to match.group() and split(). For ARM Thumb2, this increased code size by 12 bytes.
* extmod: Update for changes to mp_obj_str_get_data.Damien George2017-03-29
|
* all: Remove 'name' member from mp_obj_module_t struct.Damien George2016-09-22
| | | | One can instead lookup __name__ in the modules dict to get the value.
* extmod/modure: re_exec() renamed to ure_exec() due to collison in 4.3BSD.Tom Sparks2016-04-08
| | | | Addresses issue #1972.
* py: Change type signature of builtin funs that take variable or kw args.Damien George2016-01-11
| | | | | With this patch the n_args parameter is changed type from mp_uint_t to size_t.
* 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: Add MP_ROM_* macros and mp_rom_* types and use them.Damien George2015-11-29
|
* extmod/modure: Use correct integer type for n_args argument.Damien George2015-11-23
|
* extmod/modure: Make sure that errors in regexps are caught early.Paul Sokolovsky2015-11-01
|
* py: Add mp_obj_get_int_truncated and use it where appropriate.Damien George2015-05-12
| | | | | | mp_obj_get_int_truncated will raise a TypeError if the argument is not an integral type. Use mp_obj_int_get_truncated only when you know the argument is a small or big int.
* 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.
* extmod/ure: Fix msvc warning resulting from memset on const char ** pointerstijn2015-03-17
|
* extmod/ure: Correctly return None when a group has no match.Damien George2015-03-04
| | | | See issue #1122.
* extmod/modure: Make num_matches store actual number of matches.Damien George2015-02-18
|