Skip to content

Commit 8c50f93

Browse files
committed
py/runtime.h: Define mp_check_self(pred) helper macro.
Indended to replace raw asserts in bunch of files. Expands to empty if MICROPY_BUILTIN_METHOD_CHECK_SELF_ARG is defined, otehrwise by default still to assert, though a particular port may define it to something else.
1 parent 9e1b61d commit 8c50f93

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

py/runtime.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,16 @@ NORETURN void mp_raise_TypeError(const char *msg);
141141
NORETURN void mp_not_implemented(const char *msg);
142142
NORETURN void mp_exc_recursion_depth(void);
143143

144+
#if MICROPY_BUILTIN_METHOD_CHECK_SELF_ARG
145+
#undef mp_check_self
146+
#define mp_check_self(pred)
147+
#else
148+
// A port may define to raise TypeError for example
149+
#ifndef mp_check_self
150+
#define mp_check_self(pred) assert(pred)
151+
#endif
152+
#endif
153+
144154
// helper functions for native/viper code
145155
mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type);
146156
mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy