fx.serial: toml: replace fx_number with new number types
This commit is contained in:
+15
-12
@@ -1,14 +1,17 @@
|
||||
#include <fx/bool.h>
|
||||
#include <fx/collections/array.h>
|
||||
#include <fx/collections/datetime.h>
|
||||
#include <fx/collections/dict.h>
|
||||
#include <fx/collections/hashmap.h>
|
||||
#include <fx/double.h>
|
||||
#include <fx/error.h>
|
||||
#include <fx/number.h>
|
||||
#include <fx/int.h>
|
||||
#include <fx/serial/ctx.h>
|
||||
#include <fx/serial/toml.h>
|
||||
#include <fx/status.h>
|
||||
#include <fx/string.h>
|
||||
#include <fx/stringstream.h>
|
||||
#include <fx/uint.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@@ -1688,22 +1691,22 @@ static fx_result parse_string(struct ctx *ctx, fx_object **result)
|
||||
static fx_result parse_int(struct ctx *ctx, fx_object **result)
|
||||
{
|
||||
struct token *tok = peek_token(ctx);
|
||||
fx_number *val = FX_LONGLONG(tok->tok_value.i.v);
|
||||
fx_int *val = fx_int_create(tok->tok_value.i.v);
|
||||
if (!val) {
|
||||
return FX_RESULT_ERR(NO_MEMORY);
|
||||
}
|
||||
|
||||
if (tok->tok_value.i.inf) {
|
||||
if (tok->tok_value.i.v >= 0) {
|
||||
fx_number_set_inf_positive(val, true);
|
||||
fx_int_set_value_inf(val);
|
||||
} else {
|
||||
fx_number_set_inf_negative(val, true);
|
||||
fx_int_set_value_inf_negative(val);
|
||||
}
|
||||
} else if (tok->tok_value.i.nan) {
|
||||
if (tok->tok_value.i.v >= 0) {
|
||||
fx_number_set_nan_positive(val, true);
|
||||
fx_int_set_value_nan(val);
|
||||
} else {
|
||||
fx_number_set_nan_negative(val, true);
|
||||
fx_int_set_value_nan_negative(val);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1714,22 +1717,22 @@ static fx_result parse_int(struct ctx *ctx, fx_object **result)
|
||||
static fx_result parse_float(struct ctx *ctx, fx_object **result)
|
||||
{
|
||||
struct token *tok = peek_token(ctx);
|
||||
fx_number *val = FX_DOUBLE(tok->tok_value.f.v);
|
||||
fx_double *val = fx_double_create(tok->tok_value.f.v);
|
||||
if (!val) {
|
||||
return FX_RESULT_ERR(NO_MEMORY);
|
||||
}
|
||||
|
||||
if (tok->tok_value.f.inf) {
|
||||
if (tok->tok_value.f.v >= 0) {
|
||||
fx_number_set_inf_positive(val, true);
|
||||
fx_double_set_value_inf(val);
|
||||
} else {
|
||||
fx_number_set_inf_negative(val, true);
|
||||
fx_double_set_value_inf_negative(val);
|
||||
}
|
||||
} else if (tok->tok_value.f.nan) {
|
||||
if (tok->tok_value.f.v >= 0) {
|
||||
fx_number_set_nan_positive(val, true);
|
||||
fx_double_set_value_nan(val);
|
||||
} else {
|
||||
fx_number_set_nan_negative(val, true);
|
||||
fx_double_set_value_nan_negative(val);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1740,7 +1743,7 @@ static fx_result parse_float(struct ctx *ctx, fx_object **result)
|
||||
static fx_result parse_bool(struct ctx *ctx, fx_object **result)
|
||||
{
|
||||
struct token *tok = peek_token(ctx);
|
||||
fx_number *val = FX_INT8(tok->tok_value.b);
|
||||
fx_bool *val = fx_bool_create(tok->tok_value.b);
|
||||
if (!val) {
|
||||
return FX_RESULT_ERR(NO_MEMORY);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user