Numworks Epsilon  1.4.1
Graphing Calculator Operating System
objexcept.c File Reference
#include <string.h>
#include <stdarg.h>
#include <assert.h>
#include <stdio.h>
#include "py/objlist.h"
#include "py/objstr.h"
#include "py/objtuple.h"
#include "py/objtype.h"
#include "py/runtime.h"
#include "py/gc.h"
#include "py/mperrno.h"

Go to the source code of this file.

Classes

struct  _exc_printer_t
 

Macros

#define TRACEBACK_ENTRY_LEN   (3)
 
#define EMG_TRACEBACK_ALLOC   (2 * TRACEBACK_ENTRY_LEN)
 
#define MP_DEFINE_EXCEPTION(exc_name, base_name)
 
#define GET_NATIVE_EXCEPTION(self, self_in)
 

Functions

STATIC void mp_obj_exception_print (const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind)
 
mp_obj_t mp_obj_exception_make_new (const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args)
 
mp_obj_t mp_obj_exception_get_value (mp_obj_t self_in)
 
STATIC void exception_attr (mp_obj_t self_in, qstr attr, mp_obj_t *dest)
 
STATIC mp_obj_t exc___init__ (size_t n_args, const mp_obj_t *args)
 
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN (exc___init___obj, 1, MP_OBJ_FUN_ARGS_MAX, exc___init__)
 
STATIC MP_DEFINE_CONST_DICT (exc_locals_dict, exc_locals_dict_table)
 
mp_obj_t mp_obj_new_exception (const mp_obj_type_t *exc_type)
 
mp_obj_t mp_obj_new_exception_arg1 (const mp_obj_type_t *exc_type, mp_obj_t arg)
 
mp_obj_t mp_obj_new_exception_args (const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args)
 
mp_obj_t mp_obj_new_exception_msg (const mp_obj_type_t *exc_type, const char *msg)
 
STATIC void exc_add_strn (void *data, const char *str, size_t len)
 
mp_obj_t mp_obj_new_exception_msg_varg (const mp_obj_type_t *exc_type, const char *fmt,...)
 
bool mp_obj_is_exception_type (mp_obj_t self_in)
 
bool mp_obj_is_exception_instance (mp_obj_t self_in)
 
bool mp_obj_exception_match (mp_obj_t exc, mp_const_obj_t exc_type)
 
void mp_obj_exception_clear_traceback (mp_obj_t self_in)
 
void mp_obj_exception_add_traceback (mp_obj_t self_in, qstr file, size_t line, qstr block)
 
void mp_obj_exception_get_traceback (mp_obj_t self_in, size_t *n, size_t **values)
 

Variables

const mp_obj_exception_t mp_const_MemoryError_obj = {{&mp_type_MemoryError}, 0, 0, NULL, (mp_obj_tuple_t*)&mp_const_empty_tuple_obj}
 
const mp_obj_exception_t mp_const_GeneratorExit_obj = {{&mp_type_GeneratorExit}, 0, 0, NULL, (mp_obj_tuple_t*)&mp_const_empty_tuple_obj}
 
STATIC const mp_rom_map_elem_t exc_locals_dict_table []
 
const mp_obj_type_t mp_type_BaseException
 

Macro Definition Documentation

◆ EMG_TRACEBACK_ALLOC

#define EMG_TRACEBACK_ALLOC   (2 * TRACEBACK_ENTRY_LEN)

Definition at line 44 of file objexcept.c.

◆ GET_NATIVE_EXCEPTION

#define GET_NATIVE_EXCEPTION (   self,
  self_in 
)
Value:
/* make sure self_in is an exception instance */ \
assert(mp_obj_is_exception_instance(self_in)); \
mp_obj_exception_t *self; \
self = MP_OBJ_TO_PTR(self_in); \
} else { \
self = MP_OBJ_TO_PTR(((mp_obj_instance_t*)MP_OBJ_TO_PTR(self_in))->subobj[0]); \
}
#define mp_obj_is_native_exception_instance(o)
Definition: obj.h:712
bool mp_obj_is_exception_instance(mp_obj_t self_in)
Definition: objexcept.c:451
#define MP_OBJ_TO_PTR(o)
Definition: obj.h:228

Definition at line 468 of file objexcept.c.

◆ MP_DEFINE_EXCEPTION

#define MP_DEFINE_EXCEPTION (   exc_name,
  base_name 
)
Value:
const mp_obj_type_t mp_type_ ## exc_name = { \
{ &mp_type_type }, \
.name = MP_QSTR_ ## exc_name, \
.attr = exception_attr, \
.parent = &mp_type_ ## base_name, \
};
mp_obj_t mp_obj_exception_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args)
Definition: objexcept.c:133
const mp_obj_type_t mp_type_type
Definition: objtype.c:969
qstr name
Definition: obj.h:478
STATIC void mp_obj_exception_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind)
Definition: objexcept.c:99
STATIC void exception_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest)
Definition: objexcept.c:192

Definition at line 238 of file objexcept.c.

◆ TRACEBACK_ENTRY_LEN

#define TRACEBACK_ENTRY_LEN   (3)

Definition at line 41 of file objexcept.c.

Function Documentation

◆ exc___init__()

STATIC mp_obj_t exc___init__ ( size_t  n_args,
const mp_obj_t args 
)

Definition at line 215 of file objexcept.c.

◆ exc_add_strn()

STATIC void exc_add_strn ( void *  data,
const char *  str,
size_t  len 
)

Definition at line 358 of file objexcept.c.

◆ exception_attr()

STATIC void exception_attr ( mp_obj_t  self_in,
qstr  attr,
mp_obj_t dest 
)

Definition at line 192 of file objexcept.c.

◆ MP_DEFINE_CONST_DICT()

STATIC MP_DEFINE_CONST_DICT ( exc_locals_dict  ,
exc_locals_dict_table   
)

◆ MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN()

STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN ( exc___init___obj  ,
,
MP_OBJ_FUN_ARGS_MAX  ,
exc___init__   
)

◆ mp_obj_exception_add_traceback()

void mp_obj_exception_add_traceback ( mp_obj_t  self_in,
qstr  file,
size_t  line,
qstr  block 
)

Definition at line 485 of file objexcept.c.

◆ mp_obj_exception_clear_traceback()

void mp_obj_exception_clear_traceback ( mp_obj_t  self_in)

Definition at line 478 of file objexcept.c.

◆ mp_obj_exception_get_traceback()

void mp_obj_exception_get_traceback ( mp_obj_t  self_in,
size_t n,
size_t **  values 
)

Definition at line 537 of file objexcept.c.

◆ mp_obj_exception_get_value()

mp_obj_t mp_obj_exception_get_value ( mp_obj_t  self_in)

Definition at line 183 of file objexcept.c.

◆ mp_obj_exception_make_new()

mp_obj_t mp_obj_exception_make_new ( const mp_obj_type_t type,
size_t  n_args,
size_t  n_kw,
const mp_obj_t args 
)

Definition at line 133 of file objexcept.c.

◆ mp_obj_exception_match()

bool mp_obj_exception_match ( mp_obj_t  exc,
mp_const_obj_t  exc_type 
)

Definition at line 458 of file objexcept.c.

◆ mp_obj_exception_print()

STATIC void mp_obj_exception_print ( const mp_print_t print,
mp_obj_t  o_in,
mp_print_kind_t  kind 
)

Definition at line 99 of file objexcept.c.

◆ mp_obj_is_exception_instance()

bool mp_obj_is_exception_instance ( mp_obj_t  self_in)

Definition at line 451 of file objexcept.c.

◆ mp_obj_is_exception_type()

bool mp_obj_is_exception_type ( mp_obj_t  self_in)

Definition at line 439 of file objexcept.c.

◆ mp_obj_new_exception()

mp_obj_t mp_obj_new_exception ( const mp_obj_type_t exc_type)

Definition at line 329 of file objexcept.c.

◆ mp_obj_new_exception_arg1()

mp_obj_t mp_obj_new_exception_arg1 ( const mp_obj_type_t exc_type,
mp_obj_t  arg 
)

Definition at line 334 of file objexcept.c.

◆ mp_obj_new_exception_args()

mp_obj_t mp_obj_new_exception_args ( const mp_obj_type_t exc_type,
size_t  n_args,
const mp_obj_t args 
)

Definition at line 338 of file objexcept.c.

◆ mp_obj_new_exception_msg()

mp_obj_t mp_obj_new_exception_msg ( const mp_obj_type_t exc_type,
const char *  msg 
)

Definition at line 343 of file objexcept.c.

◆ mp_obj_new_exception_msg_varg()

mp_obj_t mp_obj_new_exception_msg_varg ( const mp_obj_type_t exc_type,
const char *  fmt,
  ... 
)

Definition at line 380 of file objexcept.c.

Variable Documentation

◆ exc_locals_dict_table

STATIC const mp_rom_map_elem_t exc_locals_dict_table[]
Initial value:
= {
{ MP_ROM_QSTR(MP_QSTR___init__), MP_ROM_PTR(&exc___init___obj) },
}
#define MP_ROM_QSTR(q)
Definition: obj.h:241
#define MP_ROM_PTR(p)
Definition: obj.h:242

Definition at line 223 of file objexcept.c.

◆ mp_const_GeneratorExit_obj

const mp_obj_exception_t mp_const_GeneratorExit_obj = {{&mp_type_GeneratorExit}, 0, 0, NULL, (mp_obj_tuple_t*)&mp_const_empty_tuple_obj}

Definition at line 97 of file objexcept.c.

◆ mp_const_MemoryError_obj

const mp_obj_exception_t mp_const_MemoryError_obj = {{&mp_type_MemoryError}, 0, 0, NULL, (mp_obj_tuple_t*)&mp_const_empty_tuple_obj}

Definition at line 47 of file objexcept.c.

◆ mp_type_BaseException

const mp_obj_type_t mp_type_BaseException
Initial value:
= {
.name = MP_QSTR_BaseException,
.attr = exception_attr,
.locals_dict = (mp_obj_dict_t*)&exc_locals_dict,
}
mp_obj_t mp_obj_exception_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args)
Definition: objexcept.c:133
const mp_obj_type_t mp_type_type
Definition: objtype.c:969
qstr name
Definition: obj.h:478
STATIC void mp_obj_exception_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind)
Definition: objexcept.c:99
STATIC void exception_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest)
Definition: objexcept.c:192

Definition at line 229 of file objexcept.c.