Numworks Epsilon  1.4.1
Graphing Calculator Operating System
obj.c
Go to the documentation of this file.
1 /*
2  * This file is part of the MicroPython project, http://micropython.org/
3  *
4  * The MIT License (MIT)
5  *
6  * Copyright (c) 2013, 2014 Damien P. George
7  *
8  * Permission is hereby granted, free of charge, to any person obtaining a copy
9  * of this software and associated documentation files (the "Software"), to deal
10  * in the Software without restriction, including without limitation the rights
11  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12  * copies of the Software, and to permit persons to whom the Software is
13  * furnished to do so, subject to the following conditions:
14  *
15  * The above copyright notice and this permission notice shall be included in
16  * all copies or substantial portions of the Software.
17  *
18  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24  * THE SOFTWARE.
25  */
26 
27 #include <stdint.h>
28 #include <stdio.h>
29 #include <stdarg.h>
30 #include <assert.h>
31 
32 #include "py/obj.h"
33 #include "py/objtype.h"
34 #include "py/objint.h"
35 #include "py/objstr.h"
36 #include "py/runtime.h"
37 #include "py/stackctrl.h"
38 #include "py/stream.h" // for mp_obj_print
39 
41  if (MP_OBJ_IS_SMALL_INT(o_in)) {
42  return (mp_obj_type_t*)&mp_type_int;
43  } else if (MP_OBJ_IS_QSTR(o_in)) {
44  return (mp_obj_type_t*)&mp_type_str;
45  #if MICROPY_PY_BUILTINS_FLOAT
46  } else if (mp_obj_is_float(o_in)) {
47  return (mp_obj_type_t*)&mp_type_float;
48  #endif
49  } else {
50  const mp_obj_base_t *o = MP_OBJ_TO_PTR(o_in);
51  return (mp_obj_type_t*)o->type;
52  }
53 }
54 
56  return qstr_str(mp_obj_get_type(o_in)->name);
57 }
58 
59 void mp_obj_print_helper(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) {
60  // There can be data structures nested too deep, or just recursive
62 #ifndef NDEBUG
63  if (o_in == MP_OBJ_NULL) {
64  mp_print_str(print, "(nil)");
65  return;
66  }
67 #endif
68  mp_obj_type_t *type = mp_obj_get_type(o_in);
69  if (type->print != NULL) {
70  type->print((mp_print_t*)print, o_in, kind);
71  } else {
72  mp_printf(print, "<%q>", type->name);
73  }
74 }
75 
78 }
79 
80 // helper function to print an exception with traceback
81 void mp_obj_print_exception(const mp_print_t *print, mp_obj_t exc) {
83  size_t n, *values;
84  mp_obj_exception_get_traceback(exc, &n, &values);
85  if (n > 0) {
86  assert(n % 3 == 0);
87  mp_print_str(print, "Traceback (most recent call last):\n");
88  for (int i = n - 3; i >= 0; i -= 3) {
89 #if MICROPY_ENABLE_SOURCE_LINE
90  mp_printf(print, " File \"%q\", line %d", values[i], (int)values[i + 1]);
91 #else
92  mp_printf(print, " File \"%q\"", values[i]);
93 #endif
94  // the block name can be NULL if it's unknown
95  qstr block = values[i + 2];
96  if (block == MP_QSTR_NULL) {
97  mp_print_str(print, "\n");
98  } else {
99  mp_printf(print, ", in %q\n", block);
100  }
101  }
102  }
103  }
104  mp_obj_print_helper(print, exc, PRINT_EXC);
105  mp_print_str(print, "\n");
106 }
107 
109  if (arg == mp_const_false) {
110  return 0;
111  } else if (arg == mp_const_true) {
112  return 1;
113  } else if (arg == mp_const_none) {
114  return 0;
115  } else if (MP_OBJ_IS_SMALL_INT(arg)) {
116  if (MP_OBJ_SMALL_INT_VALUE(arg) == 0) {
117  return 0;
118  } else {
119  return 1;
120  }
121  } else {
122  mp_obj_type_t *type = mp_obj_get_type(arg);
123  if (type->unary_op != NULL) {
124  mp_obj_t result = type->unary_op(MP_UNARY_OP_BOOL, arg);
125  if (result != MP_OBJ_NULL) {
126  return result == mp_const_true;
127  }
128  }
129 
130  mp_obj_t len = mp_obj_len_maybe(arg);
131  if (len != MP_OBJ_NULL) {
132  // obj has a length, truth determined if len != 0
133  return len != MP_OBJ_NEW_SMALL_INT(0);
134  } else {
135  // any other obj is true per Python semantics
136  return 1;
137  }
138  }
139 }
140 
142  mp_call_fun_t call = mp_obj_get_type(o_in)->call;
143  if (call != mp_obj_instance_call) {
144  return call != NULL;
145  }
146  return mp_obj_instance_is_callable(o_in);
147 }
148 
149 // This function implements the '==' operator (and so the inverse of '!=').
150 //
151 // From the Python language reference:
152 // (https://docs.python.org/3/reference/expressions.html#not-in)
153 // "The objects need not have the same type. If both are numbers, they are converted
154 // to a common type. Otherwise, the == and != operators always consider objects of
155 // different types to be unequal."
156 //
157 // This means that False==0 and True==1 are true expressions.
158 //
159 // Furthermore, from the v3.4.2 code for object.c: "Practical amendments: If rich
160 // comparison returns NotImplemented, == and != are decided by comparing the object
161 // pointer."
163  // Float (and complex) NaN is never equal to anything, not even itself,
164  // so we must have a special check here to cover those cases.
165  if (o1 == o2
167  && !mp_obj_is_float(o1)
168  #endif
171  #endif
172  ) {
173  return true;
174  }
175  if (o1 == mp_const_none || o2 == mp_const_none) {
176  return false;
177  }
178 
179  // fast path for small ints
180  if (MP_OBJ_IS_SMALL_INT(o1)) {
181  if (MP_OBJ_IS_SMALL_INT(o2)) {
182  // both SMALL_INT, and not equal if we get here
183  return false;
184  } else {
185  mp_obj_t temp = o2; o2 = o1; o1 = temp;
186  // o2 is now the SMALL_INT, o1 is not
187  // fall through to generic op
188  }
189  }
190 
191  // fast path for strings
192  if (MP_OBJ_IS_STR(o1)) {
193  if (MP_OBJ_IS_STR(o2)) {
194  // both strings, use special function
195  return mp_obj_str_equal(o1, o2);
196  } else {
197  // a string is never equal to anything else
198  goto str_cmp_err;
199  }
200  } else if (MP_OBJ_IS_STR(o2)) {
201  // o1 is not a string (else caught above), so the objects are not equal
202  str_cmp_err:
203  #if MICROPY_PY_STR_BYTES_CMP_WARN
205  mp_warning("Comparison between bytes and str");
206  }
207  #endif
208  return false;
209  }
210 
211  // generic type, call binary_op(MP_BINARY_OP_EQUAL)
212  mp_obj_type_t *type = mp_obj_get_type(o1);
213  if (type->binary_op != NULL) {
214  mp_obj_t r = type->binary_op(MP_BINARY_OP_EQUAL, o1, o2);
215  if (r != MP_OBJ_NULL) {
216  return r == mp_const_true ? true : false;
217  }
218  }
219 
220  // equality not implemented, and objects are not the same object, so
221  // they are defined as not equal
222  return false;
223 }
224 
226  // This function essentially performs implicit type conversion to int
227  // Note that Python does NOT provide implicit type conversion from
228  // float to int in the core expression language, try some_list[1.0].
229  if (arg == mp_const_false) {
230  return 0;
231  } else if (arg == mp_const_true) {
232  return 1;
233  } else if (MP_OBJ_IS_SMALL_INT(arg)) {
234  return MP_OBJ_SMALL_INT_VALUE(arg);
235  } else if (MP_OBJ_IS_TYPE(arg, &mp_type_int)) {
236  return mp_obj_int_get_checked(arg);
237  } else {
239  mp_raise_TypeError("can't convert to int");
240  } else {
242  "can't convert %s to int", mp_obj_get_type_str(arg)));
243  }
244  }
245 }
246 
248  if (MP_OBJ_IS_INT(arg)) {
249  return mp_obj_int_get_truncated(arg);
250  } else {
251  return mp_obj_get_int(arg);
252  }
253 }
254 
255 // returns false if arg is not of integral type
256 // returns true and sets *value if it is of integral type
257 // can throw OverflowError if arg is of integral type, but doesn't fit in a mp_int_t
259  if (arg == mp_const_false) {
260  *value = 0;
261  } else if (arg == mp_const_true) {
262  *value = 1;
263  } else if (MP_OBJ_IS_SMALL_INT(arg)) {
264  *value = MP_OBJ_SMALL_INT_VALUE(arg);
265  } else if (MP_OBJ_IS_TYPE(arg, &mp_type_int)) {
266  *value = mp_obj_int_get_checked(arg);
267  } else {
268  return false;
269  }
270  return true;
271 }
272 
273 #if MICROPY_PY_BUILTINS_FLOAT
274 bool mp_obj_get_float_maybe(mp_obj_t arg, mp_float_t *value) {
275  mp_float_t val;
276 
277  if (arg == mp_const_false) {
278  val = 0;
279  } else if (arg == mp_const_true) {
280  val = 1;
281  } else if (MP_OBJ_IS_SMALL_INT(arg)) {
282  val = MP_OBJ_SMALL_INT_VALUE(arg);
283  #if MICROPY_LONGINT_IMPL != MICROPY_LONGINT_IMPL_NONE
284  } else if (MP_OBJ_IS_TYPE(arg, &mp_type_int)) {
285  val = mp_obj_int_as_float_impl(arg);
286  #endif
287  } else if (mp_obj_is_float(arg)) {
288  val = mp_obj_float_get(arg);
289  } else {
290  return false;
291  }
292 
293  *value = val;
294  return true;
295 }
296 
297 mp_float_t mp_obj_get_float(mp_obj_t arg) {
298  mp_float_t val;
299 
300  if (!mp_obj_get_float_maybe(arg, &val)) {
302  mp_raise_TypeError("can't convert to float");
303  } else {
305  "can't convert %s to float", mp_obj_get_type_str(arg)));
306  }
307  }
308 
309  return val;
310 }
311 
312 #if MICROPY_PY_BUILTINS_COMPLEX
313 void mp_obj_get_complex(mp_obj_t arg, mp_float_t *real, mp_float_t *imag) {
314  if (arg == mp_const_false) {
315  *real = 0;
316  *imag = 0;
317  } else if (arg == mp_const_true) {
318  *real = 1;
319  *imag = 0;
320  } else if (MP_OBJ_IS_SMALL_INT(arg)) {
321  *real = MP_OBJ_SMALL_INT_VALUE(arg);
322  *imag = 0;
323  #if MICROPY_LONGINT_IMPL != MICROPY_LONGINT_IMPL_NONE
324  } else if (MP_OBJ_IS_TYPE(arg, &mp_type_int)) {
325  *real = mp_obj_int_as_float_impl(arg);
326  *imag = 0;
327  #endif
328  } else if (mp_obj_is_float(arg)) {
329  *real = mp_obj_float_get(arg);
330  *imag = 0;
331  } else if (MP_OBJ_IS_TYPE(arg, &mp_type_complex)) {
332  mp_obj_complex_get(arg, real, imag);
333  } else {
335  mp_raise_TypeError("can't convert to complex");
336  } else {
338  "can't convert %s to complex", mp_obj_get_type_str(arg)));
339  }
340  }
341 }
342 #endif
343 #endif
344 
345 // note: returned value in *items may point to the interior of a GC block
346 void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items) {
347  if (MP_OBJ_IS_TYPE(o, &mp_type_tuple)) {
348  mp_obj_tuple_get(o, len, items);
349  } else if (MP_OBJ_IS_TYPE(o, &mp_type_list)) {
350  mp_obj_list_get(o, len, items);
351  } else {
353  mp_raise_TypeError("expected tuple/list");
354  } else {
356  "object '%s' is not a tuple or list", mp_obj_get_type_str(o)));
357  }
358  }
359 }
360 
361 // note: returned value in *items may point to the interior of a GC block
362 void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items) {
363  size_t seq_len;
364  mp_obj_get_array(o, &seq_len, items);
365  if (seq_len != len) {
367  mp_raise_ValueError("tuple/list has wrong length");
368  } else {
370  "requested length %d but object has length %d", (int)len, (int)seq_len));
371  }
372  }
373 }
374 
375 // is_slice determines whether the index is a slice index
376 size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, bool is_slice) {
377  mp_int_t i;
378  if (MP_OBJ_IS_SMALL_INT(index)) {
379  i = MP_OBJ_SMALL_INT_VALUE(index);
380  } else if (!mp_obj_get_int_maybe(index, &i)) {
382  mp_raise_TypeError("indices must be integers");
383  } else {
385  "%q indices must be integers, not %s",
386  type->name, mp_obj_get_type_str(index)));
387  }
388  }
389 
390  if (i < 0) {
391  i += len;
392  }
393  if (is_slice) {
394  if (i < 0) {
395  i = 0;
396  } else if ((mp_uint_t)i > len) {
397  i = len;
398  }
399  } else {
400  if (i < 0 || (mp_uint_t)i >= len) {
402  mp_raise_msg(&mp_type_IndexError, "index out of range");
403  } else {
405  "%q index out of range", type->name));
406  }
407  }
408  }
409 
410  // By this point 0 <= i <= len and so fits in a size_t
411  return (size_t)i;
412 }
413 
415  mp_int_t id = (mp_int_t)o_in;
416  if (!MP_OBJ_IS_OBJ(o_in)) {
417  return mp_obj_new_int(id);
418  } else if (id >= 0) {
419  // Many OSes and CPUs have affinity for putting "user" memories
420  // into low half of address space, and "system" into upper half.
421  // We're going to take advantage of that and return small int
422  // (signed) for such "user" addresses.
423  return MP_OBJ_NEW_SMALL_INT(id);
424  } else {
425  // If that didn't work, well, let's return long int, just as
426  // a (big) positive value, so it will never clash with the range
427  // of small int returned in previous case.
429  }
430 }
431 
432 // will raise a TypeError if object has no length
434  mp_obj_t len = mp_obj_len_maybe(o_in);
435  if (len == MP_OBJ_NULL) {
437  mp_raise_TypeError("object has no len");
438  } else {
440  "object of type '%s' has no len()", mp_obj_get_type_str(o_in)));
441  }
442  } else {
443  return len;
444  }
445 }
446 
447 // may return MP_OBJ_NULL
449  if (
451  // It's simple - unicode is slow, non-unicode is fast
452  MP_OBJ_IS_STR(o_in) ||
453 #endif
454  MP_OBJ_IS_TYPE(o_in, &mp_type_bytes)) {
455  GET_STR_LEN(o_in, l);
456  return MP_OBJ_NEW_SMALL_INT(l);
457  } else {
458  mp_obj_type_t *type = mp_obj_get_type(o_in);
459  if (type->unary_op != NULL) {
460  return type->unary_op(MP_UNARY_OP_LEN, o_in);
461  } else {
462  return MP_OBJ_NULL;
463  }
464  }
465 }
466 
468  mp_obj_type_t *type = mp_obj_get_type(base);
469  if (type->subscr != NULL) {
470  mp_obj_t ret = type->subscr(base, index, value);
471  if (ret != MP_OBJ_NULL) {
472  return ret;
473  }
474  // TODO: call base classes here?
475  }
476  if (value == MP_OBJ_NULL) {
478  mp_raise_TypeError("object does not support item deletion");
479  } else {
481  "'%s' object does not support item deletion", mp_obj_get_type_str(base)));
482  }
483  } else if (value == MP_OBJ_SENTINEL) {
485  mp_raise_TypeError("object is not subscriptable");
486  } else {
488  "'%s' object is not subscriptable", mp_obj_get_type_str(base)));
489  }
490  } else {
492  mp_raise_TypeError("object does not support item assignment");
493  } else {
495  "'%s' object does not support item assignment", mp_obj_get_type_str(base)));
496  }
497  }
498 }
499 
500 // Return input argument. Useful as .getiter for objects which are
501 // their own iterators, etc.
503  return self;
504 }
505 MP_DEFINE_CONST_FUN_OBJ_1(mp_identity_obj, mp_identity);
506 
508  (void)iter_buf;
509  return self;
510 }
511 
512 bool mp_get_buffer(mp_obj_t obj, mp_buffer_info_t *bufinfo, mp_uint_t flags) {
513  mp_obj_type_t *type = mp_obj_get_type(obj);
514  if (type->buffer_p.get_buffer == NULL) {
515  return false;
516  }
517  int ret = type->buffer_p.get_buffer(obj, bufinfo, flags);
518  if (ret != 0) {
519  return false;
520  }
521  return true;
522 }
523 
525  if (!mp_get_buffer(obj, bufinfo, flags)) {
526  mp_raise_TypeError("object with buffer protocol required");
527  }
528 }
529 
531  switch (op) {
532  case MP_UNARY_OP_HASH: return MP_OBJ_NEW_SMALL_INT((mp_uint_t)o_in);
533  default: return MP_OBJ_NULL; // op not supported
534  }
535 }
intptr_t mp_int_t
Definition: mpconfigport.h:73
uintptr_t mp_uint_t
Definition: mpconfigport.h:74
bool mp_obj_is_exception_instance(mp_obj_t self_in)
Definition: objexcept.c:451
NORETURN void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg)
Definition: runtime.c:1448
const char * qstr_str(qstr q)
Definition: qstr.c:278
const mp_obj_type_t mp_type_float
#define assert(e)
Definition: assert.h:9
#define MICROPY_ERROR_REPORTING_TERSE
Definition: mpconfig.h:521
#define mp_const_none
Definition: obj.h:614
mp_subscr_fun_t subscr
Definition: obj.h:512
const mp_obj_type_t mp_type_TypeError
MP_DEFINE_CONST_FUN_OBJ_1(mp_identity_obj, mp_identity)
mp_unary_op_fun_t unary_op
Definition: obj.h:491
#define MP_OBJ_IS_TYPE(o, t)
Definition: obj.h:254
mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt,...)
Definition: objexcept.c:380
mp_obj_t mp_generic_unary_op(mp_unary_op_t op, mp_obj_t o_in)
Definition: obj.c:530
bool mp_obj_instance_is_callable(mp_obj_t self_in)
Definition: objtype.c:804
bool mp_get_buffer(mp_obj_t obj, mp_buffer_info_t *bufinfo, mp_uint_t flags)
Definition: obj.c:512
void mp_obj_print(mp_obj_t o_in, mp_print_kind_t kind)
Definition: obj.c:76
#define MP_OBJ_SENTINEL
Definition: obj.h:75
mp_obj_type_t * mp_obj_get_type(mp_const_obj_t o_in)
Definition: obj.c:40
int mp_print_str(const mp_print_t *print, const char *str)
Definition: mpprint.c:53
mp_binary_op_fun_t binary_op
Definition: obj.h:492
bool mp_obj_equal(mp_obj_t o1, mp_obj_t o2)
Definition: obj.c:162
mp_int_t(* get_buffer)(mp_obj_t obj, mp_buffer_info_t *bufinfo, mp_uint_t flags)
Definition: obj.h:458
#define mp_const_true
Definition: obj.h:616
const mp_obj_type_t mp_type_bytes
Definition: objstr.c:1964
mp_call_fun_t call
Definition: obj.h:487
mp_unary_op_t
Definition: runtime0.h:45
mp_int_t mp_obj_get_int(mp_const_obj_t arg)
Definition: obj.c:225
#define MICROPY_PY_BUILTINS_COMPLEX
Definition: mpconfig.h:565
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: objtype.c:809
#define MP_OBJ_SMALL_INT_VALUE(o)
Definition: obj.h:86
mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in)
Definition: objint.c:361
#define mp_obj_is_float(o)
Definition: obj.h:745
void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items)
Definition: obj.c:346
size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, bool is_slice)
Definition: obj.c:376
const mp_obj_type_t mp_type_complex
mp_obj_t mp_obj_len_maybe(mp_obj_t o_in)
Definition: obj.c:448
mp_print_kind_t
Definition: obj.h:412
#define MP_OBJ_NEW_SMALL_INT(small_int)
Definition: obj.h:87
void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items)
Definition: obj.c:362
#define MICROPY_ERROR_REPORTING
Definition: mpconfigport.h:32
mp_obj_t mp_obj_id(mp_obj_t o_in)
Definition: obj.c:414
mp_obj_t(* mp_call_fun_t)(mp_obj_t fun, size_t n_args, size_t n_kw, const mp_obj_t *args)
Definition: obj.h:432
uint64_t mp_const_obj_t
Definition: obj.h:40
#define NULL
Definition: stddef.h:4
#define MP_OBJ_NULL
Definition: obj.h:73
#define MP_PYTHON_PRINTER
Definition: mpprint.h:45
void mp_obj_exception_get_traceback(mp_obj_t self_in, size_t *n, size_t **values)
Definition: objexcept.c:537
mp_print_fun_t print
Definition: obj.h:481
void mp_obj_print_helper(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind)
Definition: obj.c:59
size_t qstr
Definition: qstr.h:48
void mp_obj_list_get(mp_obj_t self_in, size_t *len, mp_obj_t **items)
Definition: objlist.c:480
#define GET_STR_LEN(str_obj_in, str_len)
Definition: objstr.h:48
const mp_obj_type_t mp_type_str
Definition: objstr.c:1950
void mp_obj_tuple_get(mp_obj_t self_in, size_t *len, mp_obj_t **items)
Definition: objtuple.c:250
mp_obj_t mp_identity(mp_obj_t self)
Definition: obj.c:502
bool mp_obj_is_callable(mp_obj_t o_in)
Definition: obj.c:141
mp_obj_t mp_obj_new_int_from_uint(mp_uint_t value)
Definition: objint.c:343
const mp_obj_type_t mp_type_ValueError
#define MP_OBJ_IS_INT(o)
Definition: obj.h:255
mp_obj_t mp_obj_new_int(mp_int_t value)
Definition: objint.c:353
bool mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value)
Definition: obj.c:258
mp_buffer_p_t buffer_p
Definition: obj.h:524
const mp_obj_type_t mp_type_IndexError
NORETURN void mp_raise_ValueError(const char *msg)
Definition: runtime.c:1456
mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf)
Definition: obj.c:507
mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in)
Definition: objint.c:365
void mp_get_buffer_raise(mp_obj_t obj, mp_buffer_info_t *bufinfo, mp_uint_t flags)
Definition: obj.c:524
#define MICROPY_PY_BUILTINS_FLOAT
Definition: mpconfig.h:561
#define mp_warning(...)
Definition: runtime.h:177
bool mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2)
Definition: objstr.c:2050
#define MP_OBJ_TO_PTR(o)
Definition: obj.h:228
const mp_obj_type_t mp_type_tuple
Definition: objtuple.c:220
#define nlr_raise(val)
Definition: nlr.h:89
const char * mp_obj_get_type_str(mp_const_obj_t o_in)
Definition: obj.c:55
#define MP_STACK_CHECK()
Definition: stackctrl.h:44
qstr name
Definition: obj.h:478
uint64_t mp_obj_t
Definition: obj.h:39
int mp_printf(const mp_print_t *print, const char *fmt,...)
Definition: mpprint.c:380
mp_obj_t mp_obj_len(mp_obj_t o_in)
Definition: obj.c:433
const mp_obj_type_t mp_type_int
Definition: obj.h:544
#define MP_OBJ_IS_STR(o)
Definition: obj.h:256
mp_obj_t mp_obj_subscr(mp_obj_t base, mp_obj_t index, mp_obj_t value)
Definition: obj.c:467
Definition: obj.h:415
NORETURN void mp_raise_TypeError(const char *msg)
Definition: runtime.c:1460
mp_int_t mp_obj_get_int_truncated(mp_const_obj_t arg)
Definition: obj.c:247
const mp_obj_type_t mp_type_list
Definition: objlist.c:444
#define MICROPY_PY_BUILTINS_STR_UNICODE
Definition: mpconfig.h:698
bool mp_obj_is_true(mp_obj_t arg)
Definition: obj.c:108
#define true
Definition: stdbool.h:8
#define mp_const_false
Definition: obj.h:615
void mp_obj_print_exception(const mp_print_t *print, mp_obj_t exc)
Definition: obj.c:81