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.
This commit is contained in:
Paul Sokolovsky 2016-08-12 21:58:56 +03:00
parent 9e1b61dedd
commit 8c50f93a41
1 changed files with 10 additions and 0 deletions

View File

@ -141,6 +141,16 @@ NORETURN void mp_raise_TypeError(const char *msg);
NORETURN void mp_not_implemented(const char *msg);
NORETURN void mp_exc_recursion_depth(void);
#if MICROPY_BUILTIN_METHOD_CHECK_SELF_ARG
#undef mp_check_self
#define mp_check_self(pred)
#else
// A port may define to raise TypeError for example
#ifndef mp_check_self
#define mp_check_self(pred) assert(pred)
#endif
#endif
// helper functions for native/viper code
mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type);
mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type);