summaryrefslogtreecommitdiffstatshomepage
path: root/py/obj.h
diff options
context:
space:
mode:
Diffstat (limited to 'py/obj.h')
-rw-r--r--py/obj.h35
1 files changed, 35 insertions, 0 deletions
diff --git a/py/obj.h b/py/obj.h
index faf7e096af..af5652c4ec 100644
--- a/py/obj.h
+++ b/py/obj.h
@@ -123,6 +123,41 @@ mp_obj_t mp_obj_new_float(mp_float_t value);
static inline bool MP_OBJ_IS_OBJ(mp_const_obj_t o)
{ return ((((mp_int_t)(o)) & 1) == 0); }
+#elif MICROPY_OBJ_REPR == MICROPY_OBJ_REPR_C
+
+static inline bool MP_OBJ_IS_SMALL_INT(mp_const_obj_t o)
+ { return ((((mp_int_t)(o)) & 1) != 0); }
+#define MP_OBJ_SMALL_INT_VALUE(o) (((mp_int_t)(o)) >> 1)
+#define MP_OBJ_NEW_SMALL_INT(small_int) ((mp_obj_t)((((mp_int_t)(small_int)) << 1) | 1))
+
+#define mp_const_float_e ((mp_obj_t)((0x402df854 & ~3) | 2))
+#define mp_const_float_pi ((mp_obj_t)((0x40490fdb & ~3) | 2))
+
+static inline bool mp_obj_is_float(mp_const_obj_t o)
+ { return (((mp_uint_t)(o)) & 3) == 2 && (((mp_uint_t)(o)) & 0x7f800004) != 0x7f800004; }
+static inline mp_float_t mp_obj_float_get(mp_const_obj_t o) {
+ union {
+ mp_float_t f;
+ mp_uint_t u;
+ } num = {.u = (mp_uint_t)o & ~3};
+ return num.f;
+}
+static inline mp_obj_t mp_obj_new_float(mp_float_t f) {
+ union {
+ mp_float_t f;
+ mp_uint_t u;
+ } num = {.f = f};
+ return (mp_obj_t)((num.u & ~0x3) | 2);
+}
+
+static inline bool MP_OBJ_IS_QSTR(mp_const_obj_t o)
+ { return (((mp_uint_t)(o)) & 0x7f800007) == 0x7f800006; }
+#define MP_OBJ_QSTR_VALUE(o) ((((mp_uint_t)(o)) >> 3) & 0xfffff)
+#define MP_OBJ_NEW_QSTR(qst) ((mp_obj_t)((((mp_uint_t)(qst)) << 3) | 0x7f800006))
+
+static inline bool MP_OBJ_IS_OBJ(mp_const_obj_t o)
+ { return ((((mp_int_t)(o)) & 3) == 0); }
+
#endif
// Macros to convert between mp_obj_t and concrete object types.