Numworks Epsilon  1.4.1
Graphing Calculator Operating System
objint.c File Reference
#include <stdlib.h>
#include <assert.h>
#include <string.h>
#include "py/parsenum.h"
#include "py/smallint.h"
#include "py/objint.h"
#include "py/objstr.h"
#include "py/runtime.h"
#include "py/binary.h"

Go to the source code of this file.

Typedefs

typedef mp_longint_impl_t fmt_int_t
 
typedef unsigned long long fmt_uint_t
 

Functions

STATIC mp_obj_t mp_obj_int_make_new (const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args)
 
void mp_obj_int_print (const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind)
 
size_t mp_int_format_size (size_t num_bits, int base, const char *prefix, char comma)
 
char * mp_obj_int_formatted (char **buf, size_t *buf_size, size_t *fmt_size, mp_const_obj_t self_in, int base, const char *prefix, char base_char, char comma)
 
int mp_obj_int_sign (mp_obj_t self_in)
 
mp_obj_t mp_obj_int_unary_op (mp_unary_op_t op, mp_obj_t o_in)
 
mp_obj_t mp_obj_int_binary_op (mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs_in)
 
mp_obj_t mp_obj_new_int_from_str_len (const char **str, size_t len, bool neg, unsigned int base)
 
mp_obj_t mp_obj_new_int_from_ll (long long val)
 
mp_obj_t mp_obj_new_int_from_ull (unsigned long long val)
 
mp_obj_t mp_obj_new_int_from_uint (mp_uint_t value)
 
mp_obj_t mp_obj_new_int (mp_int_t value)
 
mp_int_t mp_obj_int_get_truncated (mp_const_obj_t self_in)
 
mp_int_t mp_obj_int_get_checked (mp_const_obj_t self_in)
 
mp_obj_t mp_obj_int_binary_op_extra_cases (mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs_in)
 
STATIC mp_obj_t int_from_bytes (size_t n_args, const mp_obj_t *args)
 
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN (int_from_bytes_fun_obj, 3, 4, int_from_bytes)
 
STATIC MP_DEFINE_CONST_CLASSMETHOD_OBJ (int_from_bytes_obj, MP_ROM_PTR(&int_from_bytes_fun_obj))
 
STATIC mp_obj_t int_to_bytes (size_t n_args, const mp_obj_t *args)
 
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN (int_to_bytes_obj, 3, 4, int_to_bytes)
 
STATIC MP_DEFINE_CONST_DICT (int_locals_dict, int_locals_dict_table)
 

Variables

STATIC const uint8_t log_base2_floor []
 
STATIC const mp_rom_map_elem_t int_locals_dict_table []
 
const mp_obj_type_t mp_type_int
 

Typedef Documentation

◆ fmt_int_t

typedef mp_longint_impl_t fmt_int_t

Definition at line 170 of file objint.c.

◆ fmt_uint_t

typedef unsigned long long fmt_uint_t

Definition at line 171 of file objint.c.

Function Documentation

◆ int_from_bytes()

STATIC mp_obj_t int_from_bytes ( size_t  n_args,
const mp_obj_t args 
)

Definition at line 390 of file objint.c.

◆ int_to_bytes()

STATIC mp_obj_t int_to_bytes ( size_t  n_args,
const mp_obj_t args 
)

Definition at line 422 of file objint.c.

◆ MP_DEFINE_CONST_CLASSMETHOD_OBJ()

STATIC MP_DEFINE_CONST_CLASSMETHOD_OBJ ( int_from_bytes_obj  ,
MP_ROM_PTR int_from_bytes_fun_obj 
)

◆ MP_DEFINE_CONST_DICT()

STATIC MP_DEFINE_CONST_DICT ( int_locals_dict  ,
int_locals_dict_table   
)

◆ MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN() [1/2]

STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN ( int_from_bytes_fun_obj  ,
,
,
int_from_bytes   
)

◆ MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN() [2/2]

STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN ( int_to_bytes_obj  ,
,
,
int_to_bytes   
)

◆ mp_int_format_size()

size_t mp_int_format_size ( size_t  num_bits,
int  base,
const char *  prefix,
char  comma 
)

Definition at line 207 of file objint.c.

◆ mp_obj_int_binary_op()

mp_obj_t mp_obj_int_binary_op ( mp_binary_op_t  op,
mp_obj_t  lhs_in,
mp_obj_t  rhs_in 
)

Definition at line 321 of file objint.c.

◆ mp_obj_int_binary_op_extra_cases()

mp_obj_t mp_obj_int_binary_op_extra_cases ( mp_binary_op_t  op,
mp_obj_t  lhs_in,
mp_obj_t  rhs_in 
)

Definition at line 373 of file objint.c.

◆ mp_obj_int_formatted()

char* mp_obj_int_formatted ( char **  buf,
size_t buf_size,
size_t fmt_size,
mp_const_obj_t  self_in,
int  base,
const char *  prefix,
char  base_char,
char  comma 
)

Definition at line 222 of file objint.c.

◆ mp_obj_int_get_checked()

mp_int_t mp_obj_int_get_checked ( mp_const_obj_t  self_in)

Definition at line 365 of file objint.c.

◆ mp_obj_int_get_truncated()

mp_int_t mp_obj_int_get_truncated ( mp_const_obj_t  self_in)

Definition at line 361 of file objint.c.

◆ mp_obj_int_make_new()

STATIC mp_obj_t mp_obj_int_make_new ( const mp_obj_type_t type_in,
size_t  n_args,
size_t  n_kw,
const mp_obj_t args 
)

Definition at line 43 of file objint.c.

◆ mp_obj_int_print()

void mp_obj_int_print ( const mp_print_t print,
mp_obj_t  self_in,
mp_print_kind_t  kind 
)

Definition at line 177 of file objint.c.

◆ mp_obj_int_sign()

int mp_obj_int_sign ( mp_obj_t  self_in)

Definition at line 304 of file objint.c.

◆ mp_obj_int_unary_op()

mp_obj_t mp_obj_int_unary_op ( mp_unary_op_t  op,
mp_obj_t  o_in 
)

Definition at line 316 of file objint.c.

◆ mp_obj_new_int()

mp_obj_t mp_obj_new_int ( mp_int_t  value)

Definition at line 353 of file objint.c.

◆ mp_obj_new_int_from_ll()

mp_obj_t mp_obj_new_int_from_ll ( long long  val)

Definition at line 332 of file objint.c.

◆ mp_obj_new_int_from_str_len()

mp_obj_t mp_obj_new_int_from_str_len ( const char **  str,
size_t  len,
bool  neg,
unsigned int  base 
)

Definition at line 326 of file objint.c.

◆ mp_obj_new_int_from_uint()

mp_obj_t mp_obj_new_int_from_uint ( mp_uint_t  value)

Definition at line 343 of file objint.c.

◆ mp_obj_new_int_from_ull()

mp_obj_t mp_obj_new_int_from_ull ( unsigned long long  val)

Definition at line 338 of file objint.c.

Variable Documentation

◆ int_locals_dict_table

STATIC const mp_rom_map_elem_t int_locals_dict_table[]
Initial value:
= {
{ MP_ROM_QSTR(MP_QSTR_from_bytes), MP_ROM_PTR(&int_from_bytes_obj) },
{ MP_ROM_QSTR(MP_QSTR_to_bytes), MP_ROM_PTR(&int_to_bytes_obj) },
}
#define MP_ROM_QSTR(q)
Definition: obj.h:241
#define MP_ROM_PTR(p)
Definition: obj.h:242

Definition at line 452 of file objint.c.

◆ log_base2_floor

STATIC const uint8_t log_base2_floor[]
Initial value:
= {
0, 1, 1, 2,
2, 2, 2, 3,
3, 3, 3, 3,
3, 3, 3, 4,
}

Definition at line 194 of file objint.c.

◆ mp_type_int

const mp_obj_type_t mp_type_int
Initial value:
= {
.name = MP_QSTR_int,
.print = mp_obj_int_print,
.make_new = mp_obj_int_make_new,
.unary_op = mp_obj_int_unary_op,
.binary_op = mp_obj_int_binary_op,
.locals_dict = (mp_obj_dict_t*)&int_locals_dict,
}
mp_obj_t mp_obj_int_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs_in)
Definition: objint.c:321
STATIC mp_obj_t mp_obj_int_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args)
Definition: objint.c:43
mp_obj_t mp_obj_int_unary_op(mp_unary_op_t op, mp_obj_t o_in)
Definition: objint.c:316
const mp_obj_type_t mp_type_type
Definition: objtype.c:969
void mp_obj_int_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind)
Definition: objint.c:177
qstr name
Definition: obj.h:478

Definition at line 459 of file objint.c.