38
38
#include "py/stream.h" // for mp_obj_print
39
39
40
40
mp_obj_type_t * mp_obj_get_type (mp_const_obj_t o_in ) {
41
- if (MP_OBJ_IS_SMALL_INT (o_in )) {
41
+ if (mp_obj_is_small_int (o_in )) {
42
42
return (mp_obj_type_t * )& mp_type_int ;
43
- } else if (MP_OBJ_IS_QSTR (o_in )) {
43
+ } else if (mp_obj_is_qstr (o_in )) {
44
44
return (mp_obj_type_t * )& mp_type_str ;
45
45
#if MICROPY_PY_BUILTINS_FLOAT
46
46
} else if (mp_obj_is_float (o_in )) {
@@ -112,7 +112,7 @@ bool mp_obj_is_true(mp_obj_t arg) {
112
112
return 1 ;
113
113
} else if (arg == mp_const_none ) {
114
114
return 0 ;
115
- } else if (MP_OBJ_IS_SMALL_INT (arg )) {
115
+ } else if (mp_obj_is_small_int (arg )) {
116
116
if (MP_OBJ_SMALL_INT_VALUE (arg ) == 0 ) {
117
117
return 0 ;
118
118
} else {
@@ -167,7 +167,7 @@ bool mp_obj_equal(mp_obj_t o1, mp_obj_t o2) {
167
167
&& !mp_obj_is_float (o1 )
168
168
#endif
169
169
#if MICROPY_PY_BUILTINS_COMPLEX
170
- && !MP_OBJ_IS_TYPE (o1 , & mp_type_complex )
170
+ && !mp_obj_is_type (o1 , & mp_type_complex )
171
171
#endif
172
172
) {
173
173
return true;
@@ -177,8 +177,8 @@ bool mp_obj_equal(mp_obj_t o1, mp_obj_t o2) {
177
177
}
178 178
179
179
// fast path for small ints
180
- if (MP_OBJ_IS_SMALL_INT (o1 )) {
181
- if (MP_OBJ_IS_SMALL_INT (o2 )) {
180
+ if (mp_obj_is_small_int (o1 )) {
181
+ if (mp_obj_is_small_int (o2 )) {
182
182
// both SMALL_INT, and not equal if we get here
183
183
return false;
184
184
} else {
@@ -189,19 +189,19 @@ bool mp_obj_equal(mp_obj_t o1, mp_obj_t o2) {
189
189
}
190
190
191
191
// fast path for strings
192
- if (MP_OBJ_IS_STR (o1 )) {
193
- if (MP_OBJ_IS_STR (o2 )) {
192
+ if (mp_obj_is_str (o1 )) {
193
+ if (mp_obj_is_str (o2 )) {
194
194
// both strings, use special function
195
195
return mp_obj_str_equal (o1 , o2 );
196
196
} else {
197
197
// a string is never equal to anything else
198
198
goto str_cmp_err ;
199
199
}
200
- } else if (MP_OBJ_IS_STR (o2 )) {
200
+ } else if (mp_obj_is_str (o2 )) {
201
201
// o1 is not a string (else caught above), so the objects are not equal
202
202
str_cmp_err :
203
203
#if MICROPY_PY_STR_BYTES_CMP_WARN
204
- if (MP_OBJ_IS_TYPE (o1 , & mp_type_bytes ) || MP_OBJ_IS_TYPE (o2 , & mp_type_bytes )) {
204
+ if (mp_obj_is_type (o1 , & mp_type_bytes ) || mp_obj_is_type (o2 , & mp_type_bytes )) {
205
205
mp_warning (MP_WARN_CAT (BytesWarning ), "Comparison between bytes and str" );
206
206
}
207
207
#endif
@@ -230,9 +230,9 @@ mp_int_t mp_obj_get_int(mp_const_obj_t arg) {
230
230
return 0 ;
231
231
} else if (arg == mp_const_true ) {
232
232
return 1 ;
233
- } else if (MP_OBJ_IS_SMALL_INT (arg )) {
233
+ } else if (mp_obj_is_small_int (arg )) {
234
234
return MP_OBJ_SMALL_INT_VALUE (arg );
235
- } else if (MP_OBJ_IS_TYPE (arg , & mp_type_int )) {
235
+ } else if (mp_obj_is_type (arg , & mp_type_int )) {
236
236
return mp_obj_int_get_checked (arg );
237
237
} else {
238
238
mp_obj_t res = mp_unary_op (MP_UNARY_OP_INT , (mp_obj_t )arg );
@@ -241,7 +241,7 @@ mp_int_t mp_obj_get_int(mp_const_obj_t arg) {
241
241
}
242
242
243
243
mp_int_t mp_obj_get_int_truncated (mp_const_obj_t arg ) {
244
- if (MP_OBJ_IS_INT (arg )) {
244
+ if (mp_obj_is_int (arg )) {
245
245
return mp_obj_int_get_truncated (arg );
246
246
} else {
247
247
return mp_obj_get_int (arg );
@@ -256,9 +256,9 @@ bool mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value) {
256
256
* value = 0 ;
257
257
} else if (arg == mp_const_true ) {
258
258
* value = 1 ;
259
- } else if (MP_OBJ_IS_SMALL_INT (arg )) {
259
+ } else if (mp_obj_is_small_int (arg )) {
260
260
* value = MP_OBJ_SMALL_INT_VALUE (arg );
261
- } else if (MP_OBJ_IS_TYPE (arg , & mp_type_int )) {
261
+ } else if (mp_obj_is_type (arg , & mp_type_int )) {
262
262
* value = mp_obj_int_get_checked (arg );
263
263
} else {
264
264
return false;
@@ -274,10 +274,10 @@ bool mp_obj_get_float_maybe(mp_obj_t arg, mp_float_t *value) {
274
274
val = 0 ;
275
275
} else if (arg == mp_const_true ) {
276
276
val = 1 ;
277
- } else if (MP_OBJ_IS_SMALL_INT (arg )) {
277
+ } else if (mp_obj_is_small_int (arg )) {
278
278
val = MP_OBJ_SMALL_INT_VALUE (arg );
279
279
#if MICROPY_LONGINT_IMPL != MICROPY_LONGINT_IMPL_NONE
280
- } else if (MP_OBJ_IS_TYPE (arg , & mp_type_int )) {
280
+ } else if (mp_obj_is_type (arg , & mp_type_int )) {
281
281
val = mp_obj_int_as_float_impl (arg );
282
282
#endif
283
283
} else if (mp_obj_is_float (arg )) {
@@ -313,18 +313,18 @@ void mp_obj_get_complex(mp_obj_t arg, mp_float_t *real, mp_float_t *imag) {
313
313
} else if (arg == mp_const_true ) {
314
314
* real = 1 ;
315
315
* imag = 0 ;
316
- } else if (MP_OBJ_IS_SMALL_INT (arg )) {
316
+ } else if (mp_obj_is_small_int (arg )) {
317
317
* real = MP_OBJ_SMALL_INT_VALUE (arg );
318
318
* imag = 0 ;
319
319
#if MICROPY_LONGINT_IMPL != MICROPY_LONGINT_IMPL_NONE
320
- } else if (MP_OBJ_IS_TYPE (arg , & mp_type_int )) {
320
+ } else if (mp_obj_is_type (arg , & mp_type_int )) {
321
321
* real = mp_obj_int_as_float_impl (arg );
322
322
* imag = 0 ;
323
323
#endif
324
324
} else if (mp_obj_is_float (arg )) {
325
325
* real = mp_obj_float_get (arg );
326
326
* imag = 0 ;
327
- } else if (MP_OBJ_IS_TYPE (arg , & mp_type_complex )) {
327
+ } else if (mp_obj_is_type (arg , & mp_type_complex )) {
328
328
mp_obj_complex_get (arg , real , imag );
329
329
} else {
330
330
if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE ) {
@@ -340,9 +340,9 @@ void mp_obj_get_complex(mp_obj_t arg, mp_float_t *real, mp_float_t *imag) {
340
340
341
341
// note: returned value in *items may point to the interior of a GC block
342
342
void mp_obj_get_array (mp_obj_t o , size_t * len , mp_obj_t * * items ) {
343
- if (MP_OBJ_IS_TYPE (o , & mp_type_tuple )) {
343
+ if (mp_obj_is_type (o , & mp_type_tuple )) {
344
344
mp_obj_tuple_get (o , len , items );
345
- } else if (MP_OBJ_IS_TYPE (o , & mp_type_list )) {
345
+ } else if (mp_obj_is_type (o , & mp_type_list )) {
346
346
mp_obj_list_get (o , len , items );
347
347
} else {
348
348
if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE ) {
@@ -371,7 +371,7 @@ void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items) {
371
371
// is_slice determines whether the index is a slice index
372
372
size_t mp_get_index (const mp_obj_type_t * type , size_t len , mp_obj_t index , bool is_slice ) {
373
373
mp_int_t i ;
374
- if (MP_OBJ_IS_SMALL_INT (index )) {
374
+ if (mp_obj_is_small_int (index )) {
375
375
i = MP_OBJ_SMALL_INT_VALUE (index );
376
376
} else if (!mp_obj_get_int_maybe (index , & i )) {
377
377
if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE ) {
@@ -409,7 +409,7 @@ size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, bool
409
409
410
410
mp_obj_t mp_obj_id (mp_obj_t o_in ) {
411
411
mp_int_t id = (mp_int_t )o_in ;
412
- if (!MP_OBJ_IS_OBJ (o_in )) {
412
+ if (!mp_obj_is_obj (o_in )) {
413
413
return mp_obj_new_int (id );
414
414
} else if (id >= 0 ) {
415
415
// Many OSes and CPUs have affinity for putting "user" memories
@@ -445,9 +445,9 @@ mp_obj_t mp_obj_len_maybe(mp_obj_t o_in) {
445
445
if (
446
446
#if !MICROPY_PY_BUILTINS_STR_UNICODE
447
447
// It's simple - unicode is slow, non-unicode is fast
448
- MP_OBJ_IS_STR (o_in ) ||
448
+ mp_obj_is_str (o_in ) ||
449
449
#endif
450
- MP_OBJ_IS_TYPE (o_in , & mp_type_bytes )) {
450
+ mp_obj_is_type (o_in , & mp_type_bytes )) {
451
451
GET_STR_LEN (o_in , l );
452
452
return MP_OBJ_NEW_SMALL_INT (l );
453
453
} else {
0 commit comments