Numworks Epsilon  1.4.1
Graphing Calculator Operating System
objdict.c File Reference
#include <string.h>
#include <assert.h>
#include "py/runtime.h"
#include "py/builtin.h"
#include "py/objtype.h"

Go to the source code of this file.

Classes

struct  _mp_obj_dict_it_t
 
struct  _mp_obj_dict_view_it_t
 
struct  _mp_obj_dict_view_t
 

Macros

#define MP_OBJ_IS_DICT_TYPE(o)   (MP_OBJ_IS_OBJ(o) && ((mp_obj_base_t*)MP_OBJ_TO_PTR(o))->type->make_new == dict_make_new)
 

Typedefs

typedef struct _mp_obj_dict_it_t mp_obj_dict_it_t
 
typedef enum _mp_dict_view_kind_t mp_dict_view_kind_t
 
typedef struct _mp_obj_dict_view_it_t mp_obj_dict_view_it_t
 
typedef struct _mp_obj_dict_view_t mp_obj_dict_view_t
 

Enumerations

enum  _mp_dict_view_kind_t { MP_DICT_VIEW_ITEMS, MP_DICT_VIEW_KEYS, MP_DICT_VIEW_VALUES }
 

Functions

STATIC mp_obj_t dict_update (size_t n_args, const mp_obj_t *args, mp_map_t *kwargs)
 
STATIC mp_map_elem_tdict_iter_next (mp_obj_dict_t *dict, size_t *cur)
 
STATIC void dict_print (const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind)
 
STATIC mp_obj_t dict_make_new (const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args)
 
STATIC mp_obj_t dict_unary_op (mp_unary_op_t op, mp_obj_t self_in)
 
STATIC mp_obj_t dict_binary_op (mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs_in)
 
mp_obj_t mp_obj_dict_get (mp_obj_t self_in, mp_obj_t index)
 
STATIC mp_obj_t dict_subscr (mp_obj_t self_in, mp_obj_t index, mp_obj_t value)
 
STATIC mp_obj_t dict_it_iternext (mp_obj_t self_in)
 
STATIC mp_obj_t dict_getiter (mp_obj_t self_in, mp_obj_iter_buf_t *iter_buf)
 
STATIC mp_obj_t dict_clear (mp_obj_t self_in)
 
STATIC MP_DEFINE_CONST_FUN_OBJ_1 (dict_clear_obj, dict_clear)
 
STATIC mp_obj_t dict_copy (mp_obj_t self_in)
 
STATIC MP_DEFINE_CONST_FUN_OBJ_1 (dict_copy_obj, dict_copy)
 
STATIC mp_obj_t dict_fromkeys (size_t n_args, const mp_obj_t *args)
 
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN (dict_fromkeys_fun_obj, 2, 3, dict_fromkeys)
 
STATIC MP_DEFINE_CONST_CLASSMETHOD_OBJ (dict_fromkeys_obj, MP_ROM_PTR(&dict_fromkeys_fun_obj))
 
STATIC mp_obj_t dict_get_helper (size_t n_args, const mp_obj_t *args, mp_map_lookup_kind_t lookup_kind)
 
STATIC mp_obj_t dict_get (size_t n_args, const mp_obj_t *args)
 
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN (dict_get_obj, 2, 3, dict_get)
 
STATIC mp_obj_t dict_pop (size_t n_args, const mp_obj_t *args)
 
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN (dict_pop_obj, 2, 3, dict_pop)
 
STATIC mp_obj_t dict_setdefault (size_t n_args, const mp_obj_t *args)
 
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN (dict_setdefault_obj, 2, 3, dict_setdefault)
 
STATIC mp_obj_t dict_popitem (mp_obj_t self_in)
 
STATIC MP_DEFINE_CONST_FUN_OBJ_1 (dict_popitem_obj, dict_popitem)
 
STATIC MP_DEFINE_CONST_FUN_OBJ_KW (dict_update_obj, 1, dict_update)
 
STATIC mp_obj_t dict_view_it_iternext (mp_obj_t self_in)
 
STATIC mp_obj_t dict_view_getiter (mp_obj_t view_in, mp_obj_iter_buf_t *iter_buf)
 
STATIC void dict_view_print (const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind)
 
STATIC mp_obj_t dict_view_binary_op (mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs_in)
 
STATIC mp_obj_t mp_obj_new_dict_view (mp_obj_t dict, mp_dict_view_kind_t kind)
 
STATIC mp_obj_t dict_view (mp_obj_t self_in, mp_dict_view_kind_t kind)
 
STATIC mp_obj_t dict_items (mp_obj_t self_in)
 
STATIC MP_DEFINE_CONST_FUN_OBJ_1 (dict_items_obj, dict_items)
 
STATIC mp_obj_t dict_keys (mp_obj_t self_in)
 
STATIC MP_DEFINE_CONST_FUN_OBJ_1 (dict_keys_obj, dict_keys)
 
STATIC mp_obj_t dict_values (mp_obj_t self_in)
 
STATIC MP_DEFINE_CONST_FUN_OBJ_1 (dict_values_obj, dict_values)
 
STATIC MP_DEFINE_CONST_DICT (dict_locals_dict, dict_locals_dict_table)
 
void mp_obj_dict_init (mp_obj_dict_t *dict, size_t n_args)
 
mp_obj_t mp_obj_new_dict (size_t n_args)
 
size_t mp_obj_dict_len (mp_obj_t self_in)
 
mp_obj_t mp_obj_dict_store (mp_obj_t self_in, mp_obj_t key, mp_obj_t value)
 
mp_obj_t mp_obj_dict_delete (mp_obj_t self_in, mp_obj_t key)
 
mp_map_tmp_obj_dict_get_map (mp_obj_t self_in)
 

Variables

STATIC const mp_obj_type_t dict_view_type
 
STATIC const mp_obj_type_t dict_view_it_type
 
STATIC const char *const mp_dict_view_names [] = {"dict_items", "dict_keys", "dict_values"}
 
STATIC const mp_rom_map_elem_t dict_locals_dict_table []
 
const mp_obj_type_t mp_type_dict
 

Macro Definition Documentation

◆ MP_OBJ_IS_DICT_TYPE

#define MP_OBJ_IS_DICT_TYPE (   o)    (MP_OBJ_IS_OBJ(o) && ((mp_obj_base_t*)MP_OBJ_TO_PTR(o))->type->make_new == dict_make_new)

Definition at line 34 of file objdict.c.

Typedef Documentation

◆ mp_dict_view_kind_t

◆ mp_obj_dict_it_t

◆ mp_obj_dict_view_it_t

◆ mp_obj_dict_view_t

Enumeration Type Documentation

◆ _mp_dict_view_kind_t

Enumerator
MP_DICT_VIEW_ITEMS 
MP_DICT_VIEW_KEYS 
MP_DICT_VIEW_VALUES 

Definition at line 400 of file objdict.c.

Function Documentation

◆ dict_binary_op()

STATIC mp_obj_t dict_binary_op ( mp_binary_op_t  op,
mp_obj_t  lhs_in,
mp_obj_t  rhs_in 
)

Definition at line 115 of file objdict.c.

◆ dict_clear()

STATIC mp_obj_t dict_clear ( mp_obj_t  self_in)

Definition at line 229 of file objdict.c.

◆ dict_copy()

STATIC mp_obj_t dict_copy ( mp_obj_t  self_in)

Definition at line 239 of file objdict.c.

◆ dict_fromkeys()

STATIC mp_obj_t dict_fromkeys ( size_t  n_args,
const mp_obj_t args 
)

Definition at line 255 of file objdict.c.

◆ dict_get()

STATIC mp_obj_t dict_get ( size_t  n_args,
const mp_obj_t args 
)

Definition at line 311 of file objdict.c.

◆ dict_get_helper()

STATIC mp_obj_t dict_get_helper ( size_t  n_args,
const mp_obj_t args,
mp_map_lookup_kind_t  lookup_kind 
)

Definition at line 284 of file objdict.c.

◆ dict_getiter()

STATIC mp_obj_t dict_getiter ( mp_obj_t  self_in,
mp_obj_iter_buf_t iter_buf 
)

Definition at line 216 of file objdict.c.

◆ dict_it_iternext()

STATIC mp_obj_t dict_it_iternext ( mp_obj_t  self_in)

Definition at line 205 of file objdict.c.

◆ dict_items()

STATIC mp_obj_t dict_items ( mp_obj_t  self_in)

Definition at line 515 of file objdict.c.

◆ dict_iter_next()

STATIC mp_map_elem_t* dict_iter_next ( mp_obj_dict_t dict,
size_t cur 
)

Definition at line 41 of file objdict.c.

◆ dict_keys()

STATIC mp_obj_t dict_keys ( mp_obj_t  self_in)

Definition at line 520 of file objdict.c.

◆ dict_make_new()

STATIC mp_obj_t dict_make_new ( const mp_obj_type_t type,
size_t  n_args,
size_t  n_kw,
const mp_obj_t args 
)

Definition at line 82 of file objdict.c.

◆ dict_pop()

STATIC mp_obj_t dict_pop ( size_t  n_args,
const mp_obj_t args 
)

Definition at line 316 of file objdict.c.

◆ dict_popitem()

STATIC mp_obj_t dict_popitem ( mp_obj_t  self_in)

Definition at line 326 of file objdict.c.

◆ dict_print()

STATIC void dict_print ( const mp_print_t print,
mp_obj_t  self_in,
mp_print_kind_t  kind 
)

Definition at line 55 of file objdict.c.

◆ dict_setdefault()

STATIC mp_obj_t dict_setdefault ( size_t  n_args,
const mp_obj_t args 
)

Definition at line 321 of file objdict.c.

◆ dict_subscr()

STATIC mp_obj_t dict_subscr ( mp_obj_t  self_in,
mp_obj_t  index,
mp_obj_t  value 
)

Definition at line 174 of file objdict.c.

◆ dict_unary_op()

STATIC mp_obj_t dict_unary_op ( mp_unary_op_t  op,
mp_obj_t  self_in 
)

Definition at line 100 of file objdict.c.

◆ dict_update()

STATIC mp_obj_t dict_update ( size_t  n_args,
const mp_obj_t args,
mp_map_t kwargs 
)

Definition at line 344 of file objdict.c.

◆ dict_values()

STATIC mp_obj_t dict_values ( mp_obj_t  self_in)

Definition at line 525 of file objdict.c.

◆ dict_view()

STATIC mp_obj_t dict_view ( mp_obj_t  self_in,
mp_dict_view_kind_t  kind 
)

Definition at line 510 of file objdict.c.

◆ dict_view_binary_op()

STATIC mp_obj_t dict_view_binary_op ( mp_binary_op_t  op,
mp_obj_t  lhs_in,
mp_obj_t  rhs_in 
)

Definition at line 482 of file objdict.c.

◆ dict_view_getiter()

STATIC mp_obj_t dict_view_getiter ( mp_obj_t  view_in,
mp_obj_iter_buf_t iter_buf 
)

Definition at line 450 of file objdict.c.

◆ dict_view_it_iternext()

STATIC mp_obj_t dict_view_it_iternext ( mp_obj_t  self_in)

Definition at line 421 of file objdict.c.

◆ dict_view_print()

STATIC void dict_view_print ( const mp_print_t print,
mp_obj_t  self_in,
mp_print_kind_t  kind 
)

Definition at line 462 of file objdict.c.

◆ MP_DEFINE_CONST_CLASSMETHOD_OBJ()

STATIC MP_DEFINE_CONST_CLASSMETHOD_OBJ ( dict_fromkeys_obj  ,
MP_ROM_PTR dict_fromkeys_fun_obj 
)

◆ MP_DEFINE_CONST_DICT()

STATIC MP_DEFINE_CONST_DICT ( dict_locals_dict  ,
dict_locals_dict_table   
)

◆ MP_DEFINE_CONST_FUN_OBJ_1() [1/6]

STATIC MP_DEFINE_CONST_FUN_OBJ_1 ( dict_clear_obj  ,
dict_clear   
)

◆ MP_DEFINE_CONST_FUN_OBJ_1() [2/6]

STATIC MP_DEFINE_CONST_FUN_OBJ_1 ( dict_copy_obj  ,
dict_copy   
)

◆ MP_DEFINE_CONST_FUN_OBJ_1() [3/6]

STATIC MP_DEFINE_CONST_FUN_OBJ_1 ( dict_popitem_obj  ,
dict_popitem   
)

◆ MP_DEFINE_CONST_FUN_OBJ_1() [4/6]

STATIC MP_DEFINE_CONST_FUN_OBJ_1 ( dict_items_obj  ,
dict_items   
)

◆ MP_DEFINE_CONST_FUN_OBJ_1() [5/6]

STATIC MP_DEFINE_CONST_FUN_OBJ_1 ( dict_keys_obj  ,
dict_keys   
)

◆ MP_DEFINE_CONST_FUN_OBJ_1() [6/6]

STATIC MP_DEFINE_CONST_FUN_OBJ_1 ( dict_values_obj  ,
dict_values   
)

◆ MP_DEFINE_CONST_FUN_OBJ_KW()

STATIC MP_DEFINE_CONST_FUN_OBJ_KW ( dict_update_obj  ,
,
dict_update   
)

◆ MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN() [1/4]

STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN ( dict_fromkeys_fun_obj  ,
,
,
dict_fromkeys   
)

◆ MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN() [2/4]

STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN ( dict_get_obj  ,
,
,
dict_get   
)

◆ MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN() [3/4]

STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN ( dict_pop_obj  ,
,
,
dict_pop   
)

◆ MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN() [4/4]

STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN ( dict_setdefault_obj  ,
,
,
dict_setdefault   
)

◆ mp_obj_dict_delete()

mp_obj_t mp_obj_dict_delete ( mp_obj_t  self_in,
mp_obj_t  key 
)

Definition at line 602 of file objdict.c.

◆ mp_obj_dict_get()

mp_obj_t mp_obj_dict_get ( mp_obj_t  self_in,
mp_obj_t  index 
)

Definition at line 164 of file objdict.c.

◆ mp_obj_dict_get_map()

mp_map_t* mp_obj_dict_get_map ( mp_obj_t  self_in)

Definition at line 608 of file objdict.c.

◆ mp_obj_dict_init()

void mp_obj_dict_init ( mp_obj_dict_t dict,
size_t  n_args 
)

Definition at line 579 of file objdict.c.

◆ mp_obj_dict_len()

size_t mp_obj_dict_len ( mp_obj_t  self_in)

Definition at line 590 of file objdict.c.

◆ mp_obj_dict_store()

mp_obj_t mp_obj_dict_store ( mp_obj_t  self_in,
mp_obj_t  key,
mp_obj_t  value 
)

Definition at line 595 of file objdict.c.

◆ mp_obj_new_dict()

mp_obj_t mp_obj_new_dict ( size_t  n_args)

Definition at line 584 of file objdict.c.

◆ mp_obj_new_dict_view()

STATIC mp_obj_t mp_obj_new_dict_view ( mp_obj_t  dict,
mp_dict_view_kind_t  kind 
)

Definition at line 502 of file objdict.c.

Variable Documentation

◆ dict_locals_dict_table

STATIC const mp_rom_map_elem_t dict_locals_dict_table[]
Initial value:
= {
{ MP_ROM_QSTR(MP_QSTR_clear), MP_ROM_PTR(&dict_clear_obj) },
{ MP_ROM_QSTR(MP_QSTR_copy), MP_ROM_PTR(&dict_copy_obj) },
{ MP_ROM_QSTR(MP_QSTR_fromkeys), MP_ROM_PTR(&dict_fromkeys_obj) },
{ MP_ROM_QSTR(MP_QSTR_get), MP_ROM_PTR(&dict_get_obj) },
{ MP_ROM_QSTR(MP_QSTR_items), MP_ROM_PTR(&dict_items_obj) },
{ MP_ROM_QSTR(MP_QSTR_keys), MP_ROM_PTR(&dict_keys_obj) },
{ MP_ROM_QSTR(MP_QSTR_pop), MP_ROM_PTR(&dict_pop_obj) },
{ MP_ROM_QSTR(MP_QSTR_popitem), MP_ROM_PTR(&dict_popitem_obj) },
{ MP_ROM_QSTR(MP_QSTR_setdefault), MP_ROM_PTR(&dict_setdefault_obj) },
{ MP_ROM_QSTR(MP_QSTR_update), MP_ROM_PTR(&dict_update_obj) },
{ MP_ROM_QSTR(MP_QSTR_values), MP_ROM_PTR(&dict_values_obj) },
{ MP_ROM_QSTR(MP_QSTR___getitem__), MP_ROM_PTR(&mp_op_getitem_obj) },
{ MP_ROM_QSTR(MP_QSTR___setitem__), MP_ROM_PTR(&mp_op_setitem_obj) },
{ MP_ROM_QSTR(MP_QSTR___delitem__), MP_ROM_PTR(&mp_op_delitem_obj) },
}
#define MP_ROM_QSTR(q)
Definition: obj.h:241
#define MP_ROM_PTR(p)
Definition: obj.h:242

Definition at line 533 of file objdict.c.

◆ dict_view_it_type

STATIC const mp_obj_type_t dict_view_it_type
Initial value:
= {
.name = MP_QSTR_iterator,
.getiter = mp_identity_getiter,
.iternext = dict_view_it_iternext,
}
STATIC mp_obj_t dict_view_it_iternext(mp_obj_t self_in)
Definition: objdict.c:421
const mp_obj_type_t mp_type_type
Definition: objtype.c:969
mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf)
Definition: obj.c:507
qstr name
Definition: obj.h:478

Definition at line 398 of file objdict.c.

◆ dict_view_type

STATIC const mp_obj_type_t dict_view_type
Initial value:
= {
.name = MP_QSTR_dict_view,
.print = dict_view_print,
.binary_op = dict_view_binary_op,
.getiter = dict_view_getiter,
}
STATIC mp_obj_t dict_view_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs_in)
Definition: objdict.c:482
STATIC mp_obj_t dict_view_getiter(mp_obj_t view_in, mp_obj_iter_buf_t *iter_buf)
Definition: objdict.c:450
const mp_obj_type_t mp_type_type
Definition: objtype.c:969
qstr name
Definition: obj.h:478
STATIC void dict_view_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind)
Definition: objdict.c:462

Definition at line 397 of file objdict.c.

◆ mp_dict_view_names

STATIC const char* const mp_dict_view_names[] = {"dict_items", "dict_keys", "dict_values"}

Definition at line 406 of file objdict.c.

◆ mp_type_dict

const mp_obj_type_t mp_type_dict
Initial value:
= {
.name = MP_QSTR_dict,
.print = dict_print,
.make_new = dict_make_new,
.unary_op = dict_unary_op,
.binary_op = dict_binary_op,
.subscr = dict_subscr,
.getiter = dict_getiter,
.locals_dict = (mp_obj_dict_t*)&dict_locals_dict,
}
STATIC void dict_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind)
Definition: objdict.c:55
STATIC mp_obj_t dict_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs_in)
Definition: objdict.c:115
STATIC mp_obj_t dict_getiter(mp_obj_t self_in, mp_obj_iter_buf_t *iter_buf)
Definition: objdict.c:216
STATIC mp_obj_t dict_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args)
Definition: objdict.c:82
const mp_obj_type_t mp_type_type
Definition: objtype.c:969
qstr name
Definition: obj.h:478
STATIC mp_obj_t dict_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value)
Definition: objdict.c:174
STATIC mp_obj_t dict_unary_op(mp_unary_op_t op, mp_obj_t self_in)
Definition: objdict.c:100

Definition at line 552 of file objdict.c.