mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-20 01:08:15 +01:00
[python] Avoid modifying micropython external source, use parsenum.h methods directly
This commit is contained in:
committed by
LeaNumworks
parent
e76abcf67e
commit
f5e8d4d9bb
@@ -90,7 +90,6 @@ static inline bool mp_obj_is_qstr(mp_const_obj_t o)
|
||||
{ return ((((mp_int_t)(o)) & 3) == 2); }
|
||||
#define MP_OBJ_QSTR_VALUE(o) (((mp_uint_t)(o)) >> 2)
|
||||
#define MP_OBJ_NEW_QSTR(qst) ((mp_obj_t)((((mp_uint_t)(qst)) << 2) | 2))
|
||||
mp_obj_t mp_obj_new_int_via_str(const char* value, int base);
|
||||
|
||||
#if MICROPY_PY_BUILTINS_FLOAT
|
||||
#define mp_const_float_e MP_ROM_PTR(&mp_const_float_e_obj)
|
||||
@@ -101,7 +100,6 @@ extern const struct _mp_obj_float_t mp_const_float_pi_obj;
|
||||
#define mp_obj_is_float(o) mp_obj_is_type((o), &mp_type_float)
|
||||
mp_float_t mp_obj_float_get(mp_obj_t self_in);
|
||||
mp_obj_t mp_obj_new_float(mp_float_t value);
|
||||
mp_obj_t mp_obj_new_float_via_str(const char* value);
|
||||
#endif
|
||||
|
||||
static inline bool mp_obj_is_obj(mp_const_obj_t o)
|
||||
|
||||
@@ -201,24 +201,6 @@ mp_obj_t mp_obj_new_float(mp_float_t value) {
|
||||
return MP_OBJ_FROM_PTR(o);
|
||||
}
|
||||
|
||||
mp_obj_t mp_obj_new_float_via_str(const char* value) {
|
||||
mp_obj_float_t *o = m_new(mp_obj_float_t, 1);
|
||||
o->base.type = &mp_type_float;
|
||||
//Avoid \x0
|
||||
int length = 0;
|
||||
for(int i = 0; i <= sizeof(value); i++){
|
||||
if(value[i] == '\x0'){
|
||||
length = i;
|
||||
break;
|
||||
}
|
||||
};
|
||||
if(length == 0){
|
||||
length = (int) sizeof(value);
|
||||
}
|
||||
o->value = mp_obj_float_get(mp_parse_num_decimal(value, length, false, false, NULL));
|
||||
return MP_OBJ_FROM_PTR(o);
|
||||
}
|
||||
|
||||
mp_float_t mp_obj_float_get(mp_obj_t self_in) {
|
||||
assert(mp_obj_is_float(self_in));
|
||||
mp_obj_float_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
|
||||
@@ -462,17 +462,3 @@ const mp_obj_type_t mp_type_int = {
|
||||
.binary_op = mp_obj_int_binary_op,
|
||||
.locals_dict = (mp_obj_dict_t*)&int_locals_dict,
|
||||
};
|
||||
|
||||
mp_obj_t mp_obj_new_int_via_str(const char* value, int base) {
|
||||
int length = 0;
|
||||
for(int i = 0; i <= sizeof(value); i++){
|
||||
if(value[i] == '\x0'){
|
||||
length = i;
|
||||
break;
|
||||
}
|
||||
};
|
||||
if(length == 0){
|
||||
length = (int) sizeof(value);
|
||||
}
|
||||
return mp_parse_num_integer(value, length, base, NULL);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user