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

Go to the source code of this file.

Classes

struct  class_lookup_data
 
struct  _mp_obj_super_t
 

Macros

#define DEBUG_PRINT   (0)
 
#define DEBUG_printf(...)   (void)0
 

Typedefs

typedef struct _mp_obj_super_t mp_obj_super_t
 

Functions

STATIC mp_obj_t static_class_method_make_new (const mp_obj_type_t *self_in, size_t n_args, size_t n_kw, const mp_obj_t *args)
 
STATIC mp_obj_t mp_obj_new_instance (const mp_obj_type_t *class, size_t subobjs)
 
STATIC int instance_count_native_bases (const mp_obj_type_t *type, const mp_obj_type_t **last_native_base)
 
STATIC void mp_obj_class_lookup (struct class_lookup_data *lookup, const mp_obj_type_t *type)
 
STATIC void instance_print (const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind)
 
mp_obj_t mp_obj_instance_make_new (const mp_obj_type_t *self, size_t n_args, size_t n_kw, const mp_obj_t *args)
 
STATIC mp_obj_t instance_unary_op (mp_unary_op_t op, mp_obj_t self_in)
 
STATIC mp_obj_t instance_binary_op (mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs_in)
 
STATIC void mp_obj_instance_load_attr (mp_obj_t self_in, qstr attr, mp_obj_t *dest)
 
STATIC bool mp_obj_instance_store_attr (mp_obj_t self_in, qstr attr, mp_obj_t value)
 
void mp_obj_instance_attr (mp_obj_t self_in, qstr attr, mp_obj_t *dest)
 
STATIC mp_obj_t instance_subscr (mp_obj_t self_in, mp_obj_t index, mp_obj_t value)
 
STATIC mp_obj_t mp_obj_instance_get_call (mp_obj_t self_in, mp_obj_t *member)
 
bool mp_obj_instance_is_callable (mp_obj_t self_in)
 
mp_obj_t mp_obj_instance_call (mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args)
 
STATIC mp_obj_t instance_getiter (mp_obj_t self_in, mp_obj_iter_buf_t *iter_buf)
 
STATIC mp_int_t instance_get_buffer (mp_obj_t self_in, mp_buffer_info_t *bufinfo, mp_uint_t flags)
 
STATIC void type_print (const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind)
 
STATIC mp_obj_t type_make_new (const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args)
 
STATIC mp_obj_t type_call (mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args)
 
STATIC void type_attr (mp_obj_t self_in, qstr attr, mp_obj_t *dest)
 
mp_obj_t mp_obj_new_type (qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict)
 
STATIC void super_print (const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind)
 
STATIC mp_obj_t super_make_new (const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args)
 
STATIC void super_attr (mp_obj_t self_in, qstr attr, mp_obj_t *dest)
 
void mp_load_super_method (qstr attr, mp_obj_t *dest)
 
bool mp_obj_is_subclass_fast (mp_const_obj_t object, mp_const_obj_t classinfo)
 
STATIC mp_obj_t mp_obj_is_subclass (mp_obj_t object, mp_obj_t classinfo)
 
STATIC mp_obj_t mp_builtin_issubclass (mp_obj_t object, mp_obj_t classinfo)
 
 MP_DEFINE_CONST_FUN_OBJ_2 (mp_builtin_issubclass_obj, mp_builtin_issubclass)
 
STATIC mp_obj_t mp_builtin_isinstance (mp_obj_t object, mp_obj_t classinfo)
 
 MP_DEFINE_CONST_FUN_OBJ_2 (mp_builtin_isinstance_obj, mp_builtin_isinstance)
 
mp_obj_t mp_instance_cast_to_native_base (mp_const_obj_t self_in, mp_const_obj_t native_type)
 

Variables

const byte mp_unary_op_method_name [MP_UNARY_OP_NUM_RUNTIME]
 
const byte mp_binary_op_method_name [MP_BINARY_OP_NUM_RUNTIME]
 
const mp_obj_type_t mp_type_type
 
const mp_obj_type_t mp_type_super
 
const mp_obj_type_t mp_type_staticmethod
 
const mp_obj_type_t mp_type_classmethod
 

Macro Definition Documentation

◆ DEBUG_PRINT

#define DEBUG_PRINT   (0)

Definition at line 40 of file objtype.c.

◆ DEBUG_printf

#define DEBUG_printf (   ...)    (void)0

Definition at line 41 of file objtype.c.

Typedef Documentation

◆ mp_obj_super_t

Function Documentation

◆ instance_binary_op()

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

Definition at line 476 of file objtype.c.

◆ instance_count_native_bases()

STATIC int instance_count_native_bases ( const mp_obj_type_t type,
const mp_obj_type_t **  last_native_base 
)

Definition at line 57 of file objtype.c.

◆ instance_get_buffer()

STATIC mp_int_t instance_get_buffer ( mp_obj_t  self_in,
mp_buffer_info_t bufinfo,
mp_uint_t  flags 
)

Definition at line 849 of file objtype.c.

◆ instance_getiter()

STATIC mp_obj_t instance_getiter ( mp_obj_t  self_in,
mp_obj_iter_buf_t iter_buf 
)

Definition at line 828 of file objtype.c.

◆ instance_print()

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

Definition at line 205 of file objtype.c.

◆ instance_subscr()

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

Definition at line 749 of file objtype.c.

◆ instance_unary_op()

STATIC mp_obj_t instance_unary_op ( mp_unary_op_t  op,
mp_obj_t  self_in 
)

Definition at line 352 of file objtype.c.

◆ mp_builtin_isinstance()

STATIC mp_obj_t mp_builtin_isinstance ( mp_obj_t  object,
mp_obj_t  classinfo 
)

Definition at line 1213 of file objtype.c.

◆ mp_builtin_issubclass()

STATIC mp_obj_t mp_builtin_issubclass ( mp_obj_t  object,
mp_obj_t  classinfo 
)

Definition at line 1204 of file objtype.c.

◆ MP_DEFINE_CONST_FUN_OBJ_2() [1/2]

MP_DEFINE_CONST_FUN_OBJ_2 ( mp_builtin_issubclass_obj  ,
mp_builtin_issubclass   
)

◆ MP_DEFINE_CONST_FUN_OBJ_2() [2/2]

MP_DEFINE_CONST_FUN_OBJ_2 ( mp_builtin_isinstance_obj  ,
mp_builtin_isinstance   
)

◆ mp_instance_cast_to_native_base()

mp_obj_t mp_instance_cast_to_native_base ( mp_const_obj_t  self_in,
mp_const_obj_t  native_type 
)

Definition at line 1219 of file objtype.c.

◆ mp_load_super_method()

void mp_load_super_method ( qstr  attr,
mp_obj_t dest 
)

Definition at line 1133 of file objtype.c.

◆ mp_obj_class_lookup()

STATIC void mp_obj_class_lookup ( struct class_lookup_data lookup,
const mp_obj_type_t type 
)

Definition at line 110 of file objtype.c.

◆ mp_obj_instance_attr()

void mp_obj_instance_attr ( mp_obj_t  self_in,
qstr  attr,
mp_obj_t dest 
)

Definition at line 739 of file objtype.c.

◆ mp_obj_instance_call()

mp_obj_t mp_obj_instance_call ( mp_obj_t  self_in,
size_t  n_args,
size_t  n_kw,
const mp_obj_t args 
)

Definition at line 809 of file objtype.c.

◆ mp_obj_instance_get_call()

STATIC mp_obj_t mp_obj_instance_get_call ( mp_obj_t  self_in,
mp_obj_t member 
)

Definition at line 791 of file objtype.c.

◆ mp_obj_instance_is_callable()

bool mp_obj_instance_is_callable ( mp_obj_t  self_in)

Definition at line 804 of file objtype.c.

◆ mp_obj_instance_load_attr()

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

Definition at line 528 of file objtype.c.

◆ mp_obj_instance_make_new()

mp_obj_t mp_obj_instance_make_new ( const mp_obj_type_t self,
size_t  n_args,
size_t  n_kw,
const mp_obj_t args 
)

Definition at line 247 of file objtype.c.

◆ mp_obj_instance_store_attr()

STATIC bool mp_obj_instance_store_attr ( mp_obj_t  self_in,
qstr  attr,
mp_obj_t  value 
)

Definition at line 624 of file objtype.c.

◆ mp_obj_is_subclass()

STATIC mp_obj_t mp_obj_is_subclass ( mp_obj_t  object,
mp_obj_t  classinfo 
)

Definition at line 1183 of file objtype.c.

◆ mp_obj_is_subclass_fast()

bool mp_obj_is_subclass_fast ( mp_const_obj_t  object,
mp_const_obj_t  classinfo 
)

Definition at line 1143 of file objtype.c.

◆ mp_obj_new_instance()

STATIC mp_obj_t mp_obj_new_instance ( const mp_obj_type_t class,
size_t  subobjs 
)

Definition at line 49 of file objtype.c.

◆ mp_obj_new_type()

mp_obj_t mp_obj_new_type ( qstr  name,
mp_obj_t  bases_tuple,
mp_obj_t  locals_dict 
)

Definition at line 979 of file objtype.c.

◆ static_class_method_make_new()

STATIC mp_obj_t static_class_method_make_new ( const mp_obj_type_t self_in,
size_t  n_args,
size_t  n_kw,
const mp_obj_t args 
)

Definition at line 1231 of file objtype.c.

◆ super_attr()

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

Definition at line 1081 of file objtype.c.

◆ super_make_new()

STATIC mp_obj_t super_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 1071 of file objtype.c.

◆ super_print()

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

Definition at line 1061 of file objtype.c.

◆ type_attr()

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

Definition at line 921 of file objtype.c.

◆ type_call()

STATIC mp_obj_t type_call ( mp_obj_t  self_in,
size_t  n_args,
size_t  n_kw,
const mp_obj_t args 
)

Definition at line 900 of file objtype.c.

◆ type_make_new()

STATIC mp_obj_t type_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 880 of file objtype.c.

◆ type_print()

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

Definition at line 874 of file objtype.c.

Variable Documentation

◆ mp_binary_op_method_name

const byte mp_binary_op_method_name[MP_BINARY_OP_NUM_RUNTIME]

Definition at line 416 of file objtype.c.

◆ mp_type_classmethod

const mp_obj_type_t mp_type_classmethod
Initial value:
= {
.name = MP_QSTR_classmethod,
}
STATIC mp_obj_t static_class_method_make_new(const mp_obj_type_t *self_in, size_t n_args, size_t n_kw, const mp_obj_t *args)
Definition: objtype.c:1231
const mp_obj_type_t mp_type_type
Definition: objtype.c:969
qstr name
Definition: obj.h:478

Definition at line 1247 of file objtype.c.

◆ mp_type_staticmethod

const mp_obj_type_t mp_type_staticmethod
Initial value:
= {
.name = MP_QSTR_staticmethod,
}
STATIC mp_obj_t static_class_method_make_new(const mp_obj_type_t *self_in, size_t n_args, size_t n_kw, const mp_obj_t *args)
Definition: objtype.c:1231
const mp_obj_type_t mp_type_type
Definition: objtype.c:969
qstr name
Definition: obj.h:478

Definition at line 1241 of file objtype.c.

◆ mp_type_super

const mp_obj_type_t mp_type_super
Initial value:
= {
.name = MP_QSTR_super,
.print = super_print,
.make_new = super_make_new,
.attr = super_attr,
}
const mp_obj_type_t mp_type_type
Definition: objtype.c:969
STATIC void super_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest)
Definition: objtype.c:1081
STATIC mp_obj_t super_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args)
Definition: objtype.c:1071
STATIC void super_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind)
Definition: objtype.c:1061
qstr name
Definition: obj.h:478

Definition at line 1125 of file objtype.c.

◆ mp_type_type

const mp_obj_type_t mp_type_type
Initial value:
= {
.name = MP_QSTR_type,
.print = type_print,
.make_new = type_make_new,
.call = type_call,
.unary_op = mp_generic_unary_op,
.attr = type_attr,
}
STATIC mp_obj_t type_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args)
Definition: objtype.c:900
STATIC mp_obj_t type_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args)
Definition: objtype.c:880
mp_obj_t mp_generic_unary_op(mp_unary_op_t op, mp_obj_t o_in)
Definition: obj.c:530
STATIC void type_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind)
Definition: objtype.c:874
const mp_obj_type_t mp_type_type
Definition: objtype.c:969
STATIC void type_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest)
Definition: objtype.c:921
qstr name
Definition: obj.h:478

Definition at line 969 of file objtype.c.

◆ mp_unary_op_method_name

const byte mp_unary_op_method_name[MP_UNARY_OP_NUM_RUNTIME]
Initial value:
= {
[MP_UNARY_OP_BOOL] = MP_QSTR___bool__,
[MP_UNARY_OP_LEN] = MP_QSTR___len__,
[MP_UNARY_OP_HASH] = MP_QSTR___hash__,
}

Definition at line 337 of file objtype.c.