os_parse_float
This commit is contained in:
@@ -9,23 +9,6 @@ struct date_t {
|
|||||||
u16 year;
|
u16 year;
|
||||||
};
|
};
|
||||||
|
|
||||||
#if 0
|
|
||||||
typedef struct core_funcs_t core_funcs_t;
|
|
||||||
struct core_funcs_t {
|
|
||||||
void (*error_box)(char *str);
|
|
||||||
void (*console_log)(char *str);
|
|
||||||
|
|
||||||
date_t (*date_now)(void);
|
|
||||||
f64 (*milliseconds_now)(void);
|
|
||||||
|
|
||||||
void *(*reserve)(usize size);
|
|
||||||
b32 (*commit)(void *p, usize size);
|
|
||||||
b32 (*release)(void *p);
|
|
||||||
b32 (*decommit)(void *p, usize size);
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
fn void os_error_box(char *str);
|
fn void os_error_box(char *str);
|
||||||
fn void os_console_log(char *str);
|
fn void os_console_log(char *str);
|
||||||
fn date_t os_date_now(void);
|
fn date_t os_date_now(void);
|
||||||
|
|||||||
@@ -53,5 +53,9 @@ fn void os_console_log(char *str) {
|
|||||||
puts(str);
|
puts(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn f64 os_parse_float(char *str) {
|
||||||
|
return strtod(str, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
fn void core_init(void) {
|
fn void core_init(void) {
|
||||||
}
|
}
|
||||||
@@ -34,8 +34,7 @@ fn void os_console_log(char *str) {
|
|||||||
wasm_write_to_console((isize)str, str_len(str));
|
wasm_write_to_console((isize)str, str_len(str));
|
||||||
}
|
}
|
||||||
|
|
||||||
fn double strtod(const char *str, char **end_unused) {
|
fn f64 os_parse_float(char *str) {
|
||||||
assert(end_unused == NULL);
|
|
||||||
return wasm_parse_float((isize)str, str_len((char *)str));
|
return wasm_parse_float((isize)str, str_len((char *)str));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -62,5 +62,9 @@ fn void os_console_log(char *str) {
|
|||||||
puts(str);
|
puts(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn f64 os_parse_float(char *str) {
|
||||||
|
return strtod(str, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
fn void core_init(void) {
|
fn void core_init(void) {
|
||||||
}
|
}
|
||||||
@@ -483,7 +483,7 @@ fn u64 u64_from_s8(s8_t s, u64 base) {
|
|||||||
fn f64 f64_from_s8(s8_t string) {
|
fn f64 f64_from_s8(s8_t string) {
|
||||||
ma_temp_t scratch = ma_begin_scratch();
|
ma_temp_t scratch = ma_begin_scratch();
|
||||||
s8_t num_string = s8_copy(scratch.arena, string);
|
s8_t num_string = s8_copy(scratch.arena, string);
|
||||||
f64 result = strtod(num_string.str, NULL);
|
f64 result = os_parse_float(num_string.str);
|
||||||
ma_end_scratch(scratch);
|
ma_end_scratch(scratch);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user