diff --git a/ds/include/blue/ds/number.h b/ds/include/blue/ds/number.h index fee87f6..78d5944 100644 --- a/ds/include/blue/ds/number.h +++ b/ds/include/blue/ds/number.h @@ -1,11 +1,10 @@ -#ifndef BLUELIB_NUMBER_H -#define BLUELIB_NUMBER_H +#ifndef BLUE_DS_NUMBER_H +#define BLUE_DS_NUMBER_H -#include -#include +#include #include -#define B_NUMBER(p) ((b_number *)(p)) +B_DECLS_BEGIN; #define B_INT8(v) (b_number_create_int8(v)) #define B_INT16(v) (b_number_create_int16(v)) @@ -40,7 +39,12 @@ #define B_NUMBER_IVAL(p) (b_number_get_size_t(p)) #define B_NUMBER_FVAL(p) (b_number_get_double(p)) -typedef struct b_number b_number; +#define B_TYPE_NUMBER (b_number_get_type()) + +B_DECLARE_TYPE(b_number); + +B_TYPE_CLASS_DECLARATION_BEGIN(b_number) +B_TYPE_CLASS_DECLARATION_END(b_number) typedef enum b_number_type { B_NUMBER_INT8, @@ -66,15 +70,9 @@ typedef enum b_number_type { B_NUMBER_QWORD = B_NUMBER_INT64, } b_number_type; +BLUE_API b_type b_number_get_type(void); + BLUE_API b_number *b_number_create(b_number_type type, void *value_ptr); -static inline b_number *b_number_retain(b_number *number) -{ - return B_NUMBER(b_retain(B_DSREF(number))); -} -static inline void b_number_release(b_number *number) -{ - b_release(B_DSREF(number)); -} static inline b_number *b_number_create_int8(int8_t value) { @@ -133,7 +131,7 @@ static inline b_number *b_number_create_size_t(size_t value) return b_number_create(B_NUMBER_SIZE_T, &value); } -BLUE_API b_number_type b_number_get_type(const b_number *number); +BLUE_API b_number_type b_number_get_number_type(const b_number *number); BLUE_API int b_number_get_value( const b_number *number, b_number_type type, void *value_ptr); @@ -251,4 +249,6 @@ BLUE_API void b_number_set_nan_negative(b_number *number, bool v); BLUE_API size_t b_number_data_size(const b_number *number); +B_DECLS_END; + #endif diff --git a/ds/number.c b/ds/number.c index 2e5be41..b4345e1 100644 --- a/ds/number.c +++ b/ds/number.c @@ -1,99 +1,50 @@ -#include "number.h" - #include -#include +#include #include #include #include -typedef int (*number_converter_t)(const struct b_number *, void *); +/*** PRIVATE DATA *************************************************************/ + +enum b_number_flags { + NUMBER_F_INF = 0x01u, + NUMBER_F_NAN = 0x02u, +}; + +struct b_number_p { + b_number_type n_type; + enum b_number_flags n_flags; + union { + int8_t v_int8; + int16_t v_int16; + int32_t v_int32; + int64_t v_int64; + float v_float32; + double v_float64; + char v_char; + short v_short; + int v_int; + long v_long; + long long v_longlong; + float v_float; + double v_double; + size_t v_size_t; + } n_value; +}; + +typedef int (*number_converter_t)(const struct b_number_p *, void *); static number_converter_t converters[B_NUMBER_TYPE_COUNT][B_NUMBER_TYPE_COUNT]; -static void number_to_string(const struct b_dsref *obj, struct b_stream *out); +/*** PRIVATE FUNCTIONS ********************************************************/ -static struct b_dsref_type number_type = { - .t_name = "corelib::number", - .t_flags = B_DSREF_FUNDAMENTAL, - .t_id = B_DSREF_TYPE_NUMBER, - .t_instance_size = sizeof(b_number), - .t_to_string = number_to_string, -}; - -struct b_number *b_number_create(b_number_type type, void *value_ptr) -{ - struct b_number *n - = (struct b_number *)b_dsref_type_instantiate(&number_type); - if (!n) { - return NULL; - } - - n->n_type = type; - - if (!value_ptr) { - return n; - } - - switch (n->n_type) { - case B_NUMBER_INT8: - memcpy(&n->n_value.v_int8, value_ptr, sizeof n->n_value.v_int8); - break; - case B_NUMBER_INT16: - memcpy(&n->n_value.v_int16, value_ptr, sizeof n->n_value.v_int16); - break; - case B_NUMBER_INT32: - memcpy(&n->n_value.v_int32, value_ptr, sizeof n->n_value.v_int32); - break; - case B_NUMBER_INT64: - memcpy(&n->n_value.v_int64, value_ptr, sizeof n->n_value.v_int64); - break; - case B_NUMBER_FLOAT32: - memcpy(&n->n_value.v_float32, value_ptr, - sizeof n->n_value.v_float32); - break; - case B_NUMBER_FLOAT64: - memcpy(&n->n_value.v_float64, value_ptr, - sizeof n->n_value.v_float64); - break; - case B_NUMBER_CHAR: - memcpy(&n->n_value.v_char, value_ptr, sizeof n->n_value.v_char); - break; - case B_NUMBER_SHORT: - memcpy(&n->n_value.v_short, value_ptr, sizeof n->n_value.v_short); - break; - case B_NUMBER_INT: - memcpy(&n->n_value.v_int, value_ptr, sizeof n->n_value.v_int); - break; - case B_NUMBER_LONG: - memcpy(&n->n_value.v_long, value_ptr, sizeof n->n_value.v_long); - break; - case B_NUMBER_LONGLONG: - memcpy(&n->n_value.v_longlong, value_ptr, - sizeof n->n_value.v_longlong); - break; - case B_NUMBER_FLOAT: - memcpy(&n->n_value.v_float, value_ptr, sizeof n->n_value.v_float); - break; - case B_NUMBER_DOUBLE: - memcpy(&n->n_value.v_double, value_ptr, sizeof n->n_value.v_double); - break; - case B_NUMBER_SIZE_T: - memcpy(&n->n_value.v_size_t, value_ptr, sizeof n->n_value.v_size_t); - break; - default: - break; - } - - return n; -} - -b_number_type b_number_get_type(const struct b_number *number) +static b_number_type number_get_number_type(const struct b_number_p *number) { return number->n_type; } -int b_number_get_value( - const struct b_number *number, b_number_type type, void *value_ptr) +static int number_get_value( + const struct b_number_p *number, b_number_type type, void *value_ptr) { b_number_type srb_type = number->n_type; b_number_type dest_type = type; @@ -106,7 +57,7 @@ int b_number_get_value( return converter(number, value_ptr); } -bool b_number_is_integer(const struct b_number *number) +static bool number_is_integer(const struct b_number_p *number) { switch (number->n_type) { case B_NUMBER_INT8: @@ -126,7 +77,7 @@ bool b_number_is_integer(const struct b_number *number) } } -bool b_number_is_float(const struct b_number *number) +static bool number_is_float(const struct b_number_p *number) { switch (number->n_type) { case B_NUMBER_FLOAT: @@ -139,12 +90,12 @@ bool b_number_is_float(const struct b_number *number) } } -bool b_number_is_inf(const b_number *number) +static bool number_is_inf(const struct b_number_p *number) { return (number->n_flags & NUMBER_F_INF) != 0; } -bool b_number_is_inf_positive(const b_number *number) +static bool number_is_inf_positive(const struct b_number_p *number) { if (!(number->n_flags & NUMBER_F_INF)) { return false; @@ -184,7 +135,7 @@ bool b_number_is_inf_positive(const b_number *number) } } -bool b_number_is_inf_negative(const b_number *number) +static bool number_is_inf_negative(const struct b_number_p *number) { if (!(number->n_flags & NUMBER_F_INF)) { return false; @@ -224,12 +175,12 @@ bool b_number_is_inf_negative(const b_number *number) } } -bool b_number_is_nan(const b_number *number) +static bool number_is_nan(const struct b_number_p *number) { return (number->n_flags & NUMBER_F_NAN) != 0; } -bool b_number_is_nan_positive(const b_number *number) +static bool number_is_nan_positive(const struct b_number_p *number) { if (!(number->n_flags & NUMBER_F_NAN)) { return false; @@ -269,7 +220,7 @@ bool b_number_is_nan_positive(const b_number *number) } } -bool b_number_is_nan_negative(const b_number *number) +static bool number_is_nan_negative(const struct b_number_p *number) { if (!(number->n_flags & NUMBER_F_NAN)) { return false; @@ -309,7 +260,7 @@ bool b_number_is_nan_negative(const b_number *number) } } -void b_number_set_inf_positive(b_number *number, bool v) +static void number_set_inf_positive(struct b_number_p *number, bool v) { if (!v) { number->n_flags &= ~NUMBER_F_INF; @@ -367,7 +318,7 @@ void b_number_set_inf_positive(b_number *number, bool v) } } -void b_number_set_inf_negative(b_number *number, bool v) +static void number_set_inf_negative(struct b_number_p *number, bool v) { if (!v) { number->n_flags &= ~NUMBER_F_INF; @@ -425,7 +376,7 @@ void b_number_set_inf_negative(b_number *number, bool v) } } -void b_number_set_nan_positive(b_number *number, bool v) +static void number_set_nan_positive(struct b_number_p *number, bool v) { if (!v) { number->n_flags &= ~NUMBER_F_NAN; @@ -483,7 +434,7 @@ void b_number_set_nan_positive(b_number *number, bool v) } } -void b_number_set_nan_negative(b_number *number, bool v) +static void number_set_nan_negative(struct b_number_p *number, bool v) { if (!v) { number->n_flags &= ~NUMBER_F_NAN; @@ -541,7 +492,7 @@ void b_number_set_nan_negative(b_number *number, bool v) } } -size_t b_number_data_size(const struct b_number *number) +static size_t number_data_size(const struct b_number_p *number) { switch (number->n_type) { case B_NUMBER_INT8: @@ -577,7 +528,7 @@ size_t b_number_data_size(const struct b_number *number) } } -static void print_inf(const struct b_number *n, struct b_stream *out) +static void print_inf(const struct b_number_p *n, struct b_stream *out) { switch (n->n_type) { case B_NUMBER_INT8: @@ -632,7 +583,7 @@ static void print_inf(const struct b_number *n, struct b_stream *out) b_stream_write_string(out, "INF", NULL); } -static void print_nan(const struct b_number *n, struct b_stream *out) +static void print_nan(const struct b_number_p *n, struct b_stream *out) { switch (n->n_type) { case B_NUMBER_INT8: @@ -687,9 +638,167 @@ static void print_nan(const struct b_number *n, struct b_stream *out) b_stream_write_string(out, "NaN", NULL); } -static void number_to_string(const struct b_dsref *obj, struct b_stream *out) +/*** PUBLIC FUNCTIONS *********************************************************/ + +b_number *b_number_create(b_number_type type, void *value_ptr) { - struct b_number *number = B_NUMBER(obj); + b_number *n = b_object_create(B_TYPE_NUMBER); + if (!n) { + return NULL; + } + + struct b_number_p *p = b_object_get_private(n, B_TYPE_NUMBER); + + p->n_type = type; + + if (!value_ptr) { + return n; + } + + switch (p->n_type) { + case B_NUMBER_INT8: + memcpy(&p->n_value.v_int8, value_ptr, sizeof p->n_value.v_int8); + break; + case B_NUMBER_INT16: + memcpy(&p->n_value.v_int16, value_ptr, sizeof p->n_value.v_int16); + break; + case B_NUMBER_INT32: + memcpy(&p->n_value.v_int32, value_ptr, sizeof p->n_value.v_int32); + break; + case B_NUMBER_INT64: + memcpy(&p->n_value.v_int64, value_ptr, sizeof p->n_value.v_int64); + break; + case B_NUMBER_FLOAT32: + memcpy(&p->n_value.v_float32, value_ptr, + sizeof p->n_value.v_float32); + break; + case B_NUMBER_FLOAT64: + memcpy(&p->n_value.v_float64, value_ptr, + sizeof p->n_value.v_float64); + break; + case B_NUMBER_CHAR: + memcpy(&p->n_value.v_char, value_ptr, sizeof p->n_value.v_char); + break; + case B_NUMBER_SHORT: + memcpy(&p->n_value.v_short, value_ptr, sizeof p->n_value.v_short); + break; + case B_NUMBER_INT: + memcpy(&p->n_value.v_int, value_ptr, sizeof p->n_value.v_int); + break; + case B_NUMBER_LONG: + memcpy(&p->n_value.v_long, value_ptr, sizeof p->n_value.v_long); + break; + case B_NUMBER_LONGLONG: + memcpy(&p->n_value.v_longlong, value_ptr, + sizeof p->n_value.v_longlong); + break; + case B_NUMBER_FLOAT: + memcpy(&p->n_value.v_float, value_ptr, sizeof p->n_value.v_float); + break; + case B_NUMBER_DOUBLE: + memcpy(&p->n_value.v_double, value_ptr, sizeof p->n_value.v_double); + break; + case B_NUMBER_SIZE_T: + memcpy(&p->n_value.v_size_t, value_ptr, sizeof p->n_value.v_size_t); + break; + default: + break; + } + + return n; +} + +b_number_type b_number_get_number_type(const b_number *number) +{ + B_CLASS_DISPATCH_STATIC_0(B_TYPE_NUMBER, number_get_number_type, number); +} + +int b_number_get_value(const b_number *number, b_number_type type, void *value_ptr) +{ + B_CLASS_DISPATCH_STATIC( + B_TYPE_NUMBER, number_get_value, number, type, value_ptr); +} + +bool b_number_is_integer(const b_number *number) +{ + B_CLASS_DISPATCH_STATIC_0(B_TYPE_NUMBER, number_is_integer, number); +} + +bool b_number_is_float(const b_number *number) +{ + B_CLASS_DISPATCH_STATIC_0(B_TYPE_NUMBER, number_is_float, number); +} + +bool b_number_is_inf(const b_number *number) +{ + B_CLASS_DISPATCH_STATIC_0(B_TYPE_NUMBER, number_is_inf, number); +} + +bool b_number_is_inf_positive(const b_number *number) +{ + B_CLASS_DISPATCH_STATIC_0(B_TYPE_NUMBER, number_is_inf_positive, number); +} + +bool b_number_is_inf_negative(const b_number *number) +{ + B_CLASS_DISPATCH_STATIC_0(B_TYPE_NUMBER, number_is_inf_negative, number); +} + +bool b_number_is_nan(const b_number *number) +{ + B_CLASS_DISPATCH_STATIC_0(B_TYPE_NUMBER, number_is_nan, number); +} + +bool b_number_is_nan_positive(const b_number *number) +{ + B_CLASS_DISPATCH_STATIC_0(B_TYPE_NUMBER, number_is_nan_positive, number); +} + +bool b_number_is_nan_negative(const b_number *number) +{ + B_CLASS_DISPATCH_STATIC_0(B_TYPE_NUMBER, number_is_nan_negative, number); +} + +void b_number_set_inf_positive(b_number *number, bool v) +{ + B_CLASS_DISPATCH_STATIC(B_TYPE_NUMBER, number_set_inf_positive, number, v); +} + +void b_number_set_inf_negative(b_number *number, bool v) +{ + B_CLASS_DISPATCH_STATIC(B_TYPE_NUMBER, number_set_inf_negative, number, v); +} + +void b_number_set_nan_positive(b_number *number, bool v) +{ + B_CLASS_DISPATCH_STATIC(B_TYPE_NUMBER, number_set_nan_positive, number, v); +} + +void b_number_set_nan_negative(b_number *number, bool v) +{ + B_CLASS_DISPATCH_STATIC(B_TYPE_NUMBER, number_set_nan_negative, number, v); +} + +size_t b_number_data_size(const b_number *number) +{ + B_CLASS_DISPATCH_STATIC_0(B_TYPE_NUMBER, number_data_size, number); +} + +/*** VIRTUAL FUNCTIONS ********************************************************/ + +static void number_init(b_object *obj, void *priv) +{ + struct b_number_p *number = priv; +} + +static void number_fini(b_object *obj, void *priv) +{ + struct b_number_p *number = priv; +} + +static void number_to_string(const b_object *obj, struct b_stream *out) +{ + struct b_number_p *number = b_object_get_private(obj, B_TYPE_NUMBER); if (number->n_flags & NUMBER_F_INF) { print_inf(number, out); @@ -753,87 +862,104 @@ static void number_to_string(const struct b_dsref *obj, struct b_stream *out) } } +/*** CLASS DEFINITION *********************************************************/ + +B_TYPE_CLASS_DEFINITION_BEGIN(b_number) + B_TYPE_CLASS_INTERFACE_BEGIN(b_object, B_TYPE_OBJECT) + B_INTERFACE_ENTRY(to_string) = number_to_string; + B_TYPE_CLASS_INTERFACE_END(b_object, B_TYPE_OBJECT) +B_TYPE_CLASS_DEFINITION_END(b_number) + +B_TYPE_DEFINITION_BEGIN(b_number) + B_TYPE_ID(0xa713b0ea, 0x240f, 0x4bc5, 0xbe73, 0xbc3e56401bd3); + B_TYPE_CLASS(b_number_class); + B_TYPE_INSTANCE_INIT(number_init); + B_TYPE_INSTANCE_INIT(number_fini); +B_TYPE_DEFINITION_END(b_number) + +/*** MISC FUNCTIONS ***********************************************************/ + /* ++++++++++++++++++ int8 -> xyz CONVERTER CALLBACKS ++++++++++++++++++ */ -static int int8_to_int8(const struct b_number *number, void *value_ptr) +static int int8_to_int8(const struct b_number_p *number, void *value_ptr) { *(int8_t *)value_ptr = number->n_value.v_int8; return 0; } -static int int8_to_int16(const struct b_number *number, void *value_ptr) +static int int8_to_int16(const struct b_number_p *number, void *value_ptr) { *(int16_t *)value_ptr = (int16_t)number->n_value.v_int8; return 0; } -static int int8_to_int32(const struct b_number *number, void *value_ptr) +static int int8_to_int32(const struct b_number_p *number, void *value_ptr) { *(int32_t *)value_ptr = (int32_t)number->n_value.v_int8; return 0; } -static int int8_to_int64(const struct b_number *number, void *value_ptr) +static int int8_to_int64(const struct b_number_p *number, void *value_ptr) { *(int64_t *)value_ptr = (int64_t)number->n_value.v_int8; return 0; } -static int int8_to_float32(const struct b_number *number, void *value_ptr) +static int int8_to_float32(const struct b_number_p *number, void *value_ptr) { *(float *)value_ptr = number->n_value.v_int8; return 0; } -static int int8_to_float64(const struct b_number *number, void *value_ptr) +static int int8_to_float64(const struct b_number_p *number, void *value_ptr) { *(double *)value_ptr = number->n_value.v_int8; return 0; } -static int int8_to_char(const struct b_number *number, void *value_ptr) +static int int8_to_char(const struct b_number_p *number, void *value_ptr) { *(char *)value_ptr = number->n_value.v_int8; return 0; } -static int int8_to_short(const struct b_number *number, void *value_ptr) +static int int8_to_short(const struct b_number_p *number, void *value_ptr) { *(short *)value_ptr = (short)number->n_value.v_int8; return 0; } -static int int8_to_int(const struct b_number *number, void *value_ptr) +static int int8_to_int(const struct b_number_p *number, void *value_ptr) { *(int *)value_ptr = (int)number->n_value.v_int8; return 0; } -static int int8_to_long(const struct b_number *number, void *value_ptr) +static int int8_to_long(const struct b_number_p *number, void *value_ptr) { *(long *)value_ptr = (long)number->n_value.v_int8; return 0; } -static int int8_to_longlong(const struct b_number *number, void *value_ptr) +static int int8_to_longlong(const struct b_number_p *number, void *value_ptr) { *(long long *)value_ptr = (long long)number->n_value.v_int8; return 0; } -static int int8_to_float(const struct b_number *number, void *value_ptr) +static int int8_to_float(const struct b_number_p *number, void *value_ptr) { *(float *)value_ptr = number->n_value.v_int8; return 0; } -static int int8_to_double(const struct b_number *number, void *value_ptr) +static int int8_to_double(const struct b_number_p *number, void *value_ptr) { *(double *)value_ptr = number->n_value.v_int8; return 0; } -static int int8_to_size_t(const struct b_number *number, void *value_ptr) +static int int8_to_size_t(const struct b_number_p *number, void *value_ptr) { *(size_t *)value_ptr = (size_t)number->n_value.v_int8; return 0; @@ -841,85 +967,85 @@ static int int8_to_size_t(const struct b_number *number, void *value_ptr) /* ++++++++++++++++++ int16 -> xyz CONVERTER CALLBACKS ++++++++++++++++++ */ -static int int16_to_int8(const struct b_number *number, void *value_ptr) +static int int16_to_int8(const struct b_number_p *number, void *value_ptr) { *(int8_t *)value_ptr = (int8_t)number->n_value.v_int16; return 0; } -static int int16_to_int16(const struct b_number *number, void *value_ptr) +static int int16_to_int16(const struct b_number_p *number, void *value_ptr) { *(int16_t *)value_ptr = number->n_value.v_int16; return 0; } -static int int16_to_int32(const struct b_number *number, void *value_ptr) +static int int16_to_int32(const struct b_number_p *number, void *value_ptr) { *(int32_t *)value_ptr = number->n_value.v_int16; return 0; } -static int int16_to_int64(const struct b_number *number, void *value_ptr) +static int int16_to_int64(const struct b_number_p *number, void *value_ptr) { *(int64_t *)value_ptr = number->n_value.v_int16; return 0; } -static int int16_to_float32(const struct b_number *number, void *value_ptr) +static int int16_to_float32(const struct b_number_p *number, void *value_ptr) { *(float *)value_ptr = number->n_value.v_int16; return 0; } -static int int16_to_float64(const struct b_number *number, void *value_ptr) +static int int16_to_float64(const struct b_number_p *number, void *value_ptr) { *(double *)value_ptr = number->n_value.v_int16; return 0; } -static int int16_to_char(const struct b_number *number, void *value_ptr) +static int int16_to_char(const struct b_number_p *number, void *value_ptr) { *(char *)value_ptr = (char)number->n_value.v_int16; return 0; } -static int int16_to_short(const struct b_number *number, void *value_ptr) +static int int16_to_short(const struct b_number_p *number, void *value_ptr) { *(short *)value_ptr = number->n_value.v_int16; return 0; } -static int int16_to_int(const struct b_number *number, void *value_ptr) +static int int16_to_int(const struct b_number_p *number, void *value_ptr) { *(int *)value_ptr = number->n_value.v_int16; return 0; } -static int int16_to_long(const struct b_number *number, void *value_ptr) +static int int16_to_long(const struct b_number_p *number, void *value_ptr) { *(long *)value_ptr = number->n_value.v_int16; return 0; } -static int int16_to_longlong(const struct b_number *number, void *value_ptr) +static int int16_to_longlong(const struct b_number_p *number, void *value_ptr) { *(long long *)value_ptr = number->n_value.v_int16; return 0; } -static int int16_to_float(const struct b_number *number, void *value_ptr) +static int int16_to_float(const struct b_number_p *number, void *value_ptr) { *(float *)value_ptr = number->n_value.v_int16; return 0; } -static int int16_to_double(const struct b_number *number, void *value_ptr) +static int int16_to_double(const struct b_number_p *number, void *value_ptr) { *(double *)value_ptr = number->n_value.v_int16; return 0; } -static int int16_to_size_t(const struct b_number *number, void *value_ptr) +static int int16_to_size_t(const struct b_number_p *number, void *value_ptr) { *(size_t *)value_ptr = number->n_value.v_int16; return 0; @@ -927,85 +1053,85 @@ static int int16_to_size_t(const struct b_number *number, void *value_ptr) /* ++++++++++++++++++ int32 -> xyz CONVERTER CALLBACKS ++++++++++++++++++ */ -static int int32_to_int8(const struct b_number *number, void *value_ptr) +static int int32_to_int8(const struct b_number_p *number, void *value_ptr) { *(int8_t *)value_ptr = (int8_t)number->n_value.v_int32; return 0; } -static int int32_to_int16(const struct b_number *number, void *value_ptr) +static int int32_to_int16(const struct b_number_p *number, void *value_ptr) { *(int16_t *)value_ptr = (int16_t)number->n_value.v_int32; return 0; } -static int int32_to_int32(const struct b_number *number, void *value_ptr) +static int int32_to_int32(const struct b_number_p *number, void *value_ptr) { *(int32_t *)value_ptr = number->n_value.v_int32; return 0; } -static int int32_to_int64(const struct b_number *number, void *value_ptr) +static int int32_to_int64(const struct b_number_p *number, void *value_ptr) { *(int64_t *)value_ptr = number->n_value.v_int32; return 0; } -static int int32_to_float32(const struct b_number *number, void *value_ptr) +static int int32_to_float32(const struct b_number_p *number, void *value_ptr) { *(float *)value_ptr = (float)number->n_value.v_int32; return 0; } -static int int32_to_float64(const struct b_number *number, void *value_ptr) +static int int32_to_float64(const struct b_number_p *number, void *value_ptr) { *(double *)value_ptr = number->n_value.v_int32; return 0; } -static int int32_to_char(const struct b_number *number, void *value_ptr) +static int int32_to_char(const struct b_number_p *number, void *value_ptr) { *(char *)value_ptr = (char)number->n_value.v_int32; return 0; } -static int int32_to_short(const struct b_number *number, void *value_ptr) +static int int32_to_short(const struct b_number_p *number, void *value_ptr) { *(short *)value_ptr = (short)number->n_value.v_int32; return 0; } -static int int32_to_int(const struct b_number *number, void *value_ptr) +static int int32_to_int(const struct b_number_p *number, void *value_ptr) { *(int *)value_ptr = number->n_value.v_int32; return 0; } -static int int32_to_long(const struct b_number *number, void *value_ptr) +static int int32_to_long(const struct b_number_p *number, void *value_ptr) { *(long *)value_ptr = number->n_value.v_int32; return 0; } -static int int32_to_longlong(const struct b_number *number, void *value_ptr) +static int int32_to_longlong(const struct b_number_p *number, void *value_ptr) { *(long long *)value_ptr = number->n_value.v_int32; return 0; } -static int int32_to_float(const struct b_number *number, void *value_ptr) +static int int32_to_float(const struct b_number_p *number, void *value_ptr) { *(float *)value_ptr = (float)number->n_value.v_int32; return 0; } -static int int32_to_double(const struct b_number *number, void *value_ptr) +static int int32_to_double(const struct b_number_p *number, void *value_ptr) { *(double *)value_ptr = number->n_value.v_int32; return 0; } -static int int32_to_size_t(const struct b_number *number, void *value_ptr) +static int int32_to_size_t(const struct b_number_p *number, void *value_ptr) { *(size_t *)value_ptr = number->n_value.v_int32; return 0; @@ -1013,85 +1139,85 @@ static int int32_to_size_t(const struct b_number *number, void *value_ptr) /* ++++++++++++++++++ int64 -> xyz CONVERTER CALLBACKS ++++++++++++++++++ */ -static int int64_to_int8(const struct b_number *number, void *value_ptr) +static int int64_to_int8(const struct b_number_p *number, void *value_ptr) { *(int8_t *)value_ptr = (int8_t)number->n_value.v_int64; return 0; } -static int int64_to_int16(const struct b_number *number, void *value_ptr) +static int int64_to_int16(const struct b_number_p *number, void *value_ptr) { *(int16_t *)value_ptr = (int16_t)number->n_value.v_int64; return 0; } -static int int64_to_int32(const struct b_number *number, void *value_ptr) +static int int64_to_int32(const struct b_number_p *number, void *value_ptr) { *(int32_t *)value_ptr = (int32_t)number->n_value.v_int64; return 0; } -static int int64_to_int64(const struct b_number *number, void *value_ptr) +static int int64_to_int64(const struct b_number_p *number, void *value_ptr) { *(int64_t *)value_ptr = number->n_value.v_int64; return 0; } -static int int64_to_float32(const struct b_number *number, void *value_ptr) +static int int64_to_float32(const struct b_number_p *number, void *value_ptr) { *(float *)value_ptr = (float)number->n_value.v_int64; return 0; } -static int int64_to_float64(const struct b_number *number, void *value_ptr) +static int int64_to_float64(const struct b_number_p *number, void *value_ptr) { *(double *)value_ptr = (double)number->n_value.v_int64; return 0; } -static int int64_to_char(const struct b_number *number, void *value_ptr) +static int int64_to_char(const struct b_number_p *number, void *value_ptr) { *(char *)value_ptr = (char)number->n_value.v_int64; return 0; } -static int int64_to_short(const struct b_number *number, void *value_ptr) +static int int64_to_short(const struct b_number_p *number, void *value_ptr) { *(short *)value_ptr = (short)number->n_value.v_int64; return 0; } -static int int64_to_int(const struct b_number *number, void *value_ptr) +static int int64_to_int(const struct b_number_p *number, void *value_ptr) { *(int *)value_ptr = (int)number->n_value.v_int64; return 0; } -static int int64_to_long(const struct b_number *number, void *value_ptr) +static int int64_to_long(const struct b_number_p *number, void *value_ptr) { *(long *)value_ptr = number->n_value.v_int64; return 0; } -static int int64_to_longlong(const struct b_number *number, void *value_ptr) +static int int64_to_longlong(const struct b_number_p *number, void *value_ptr) { *(long long *)value_ptr = number->n_value.v_int64; return 0; } -static int int64_to_float(const struct b_number *number, void *value_ptr) +static int int64_to_float(const struct b_number_p *number, void *value_ptr) { *(float *)value_ptr = (float)number->n_value.v_int64; return 0; } -static int int64_to_double(const struct b_number *number, void *value_ptr) +static int int64_to_double(const struct b_number_p *number, void *value_ptr) { *(double *)value_ptr = (double)number->n_value.v_int64; return 0; } -static int int64_to_size_t(const struct b_number *number, void *value_ptr) +static int int64_to_size_t(const struct b_number_p *number, void *value_ptr) { *(size_t *)value_ptr = number->n_value.v_int64; return 0; @@ -1099,85 +1225,85 @@ static int int64_to_size_t(const struct b_number *number, void *value_ptr) /* ++++++++++++++++++ float32 -> xyz CONVERTER CALLBACKS ++++++++++++++++++ */ -static int float32_to_int8(const struct b_number *number, void *value_ptr) +static int float32_to_int8(const struct b_number_p *number, void *value_ptr) { *(int8_t *)value_ptr = (int8_t)number->n_value.v_float32; return 0; } -static int float32_to_int16(const struct b_number *number, void *value_ptr) +static int float32_to_int16(const struct b_number_p *number, void *value_ptr) { *(int16_t *)value_ptr = (int16_t)number->n_value.v_float32; return 0; } -static int float32_to_int32(const struct b_number *number, void *value_ptr) +static int float32_to_int32(const struct b_number_p *number, void *value_ptr) { *(int32_t *)value_ptr = (int32_t)number->n_value.v_float32; return 0; } -static int float32_to_int64(const struct b_number *number, void *value_ptr) +static int float32_to_int64(const struct b_number_p *number, void *value_ptr) { *(int64_t *)value_ptr = (int64_t)number->n_value.v_float32; return 0; } -static int float32_to_float32(const struct b_number *number, void *value_ptr) +static int float32_to_float32(const struct b_number_p *number, void *value_ptr) { *(float *)value_ptr = number->n_value.v_float32; return 0; } -static int float32_to_float64(const struct b_number *number, void *value_ptr) +static int float32_to_float64(const struct b_number_p *number, void *value_ptr) { *(double *)value_ptr = number->n_value.v_float32; return 0; } -static int float32_to_char(const struct b_number *number, void *value_ptr) +static int float32_to_char(const struct b_number_p *number, void *value_ptr) { *(char *)value_ptr = (char)number->n_value.v_float32; return 0; } -static int float32_to_short(const struct b_number *number, void *value_ptr) +static int float32_to_short(const struct b_number_p *number, void *value_ptr) { *(short *)value_ptr = (short)number->n_value.v_float32; return 0; } -static int float32_to_int(const struct b_number *number, void *value_ptr) +static int float32_to_int(const struct b_number_p *number, void *value_ptr) { *(int *)value_ptr = (int)number->n_value.v_float32; return 0; } -static int float32_to_long(const struct b_number *number, void *value_ptr) +static int float32_to_long(const struct b_number_p *number, void *value_ptr) { *(long *)value_ptr = number->n_value.v_float32; return 0; } -static int float32_to_longlong(const struct b_number *number, void *value_ptr) +static int float32_to_longlong(const struct b_number_p *number, void *value_ptr) { *(long long *)value_ptr = number->n_value.v_float32; return 0; } -static int float32_to_float(const struct b_number *number, void *value_ptr) +static int float32_to_float(const struct b_number_p *number, void *value_ptr) { *(float *)value_ptr = number->n_value.v_float32; return 0; } -static int float32_to_double(const struct b_number *number, void *value_ptr) +static int float32_to_double(const struct b_number_p *number, void *value_ptr) { *(double *)value_ptr = number->n_value.v_float32; return 0; } -static int float32_to_size_t(const struct b_number *number, void *value_ptr) +static int float32_to_size_t(const struct b_number_p *number, void *value_ptr) { *(size_t *)value_ptr = number->n_value.v_float32; return 0; @@ -1185,85 +1311,85 @@ static int float32_to_size_t(const struct b_number *number, void *value_ptr) /* ++++++++++++++++++ float64 -> xyz CONVERTER CALLBACKS ++++++++++++++++++ */ -static int float64_to_int8(const struct b_number *number, void *value_ptr) +static int float64_to_int8(const struct b_number_p *number, void *value_ptr) { *(int8_t *)value_ptr = number->n_value.v_float64; return 0; } -static int float64_to_int16(const struct b_number *number, void *value_ptr) +static int float64_to_int16(const struct b_number_p *number, void *value_ptr) { *(int16_t *)value_ptr = number->n_value.v_float64; return 0; } -static int float64_to_int32(const struct b_number *number, void *value_ptr) +static int float64_to_int32(const struct b_number_p *number, void *value_ptr) { *(int32_t *)value_ptr = number->n_value.v_float64; return 0; } -static int float64_to_int64(const struct b_number *number, void *value_ptr) +static int float64_to_int64(const struct b_number_p *number, void *value_ptr) { *(int64_t *)value_ptr = number->n_value.v_float64; return 0; } -static int float64_to_float32(const struct b_number *number, void *value_ptr) +static int float64_to_float32(const struct b_number_p *number, void *value_ptr) { *(float *)value_ptr = number->n_value.v_float64; return 0; } -static int float64_to_float64(const struct b_number *number, void *value_ptr) +static int float64_to_float64(const struct b_number_p *number, void *value_ptr) { *(double *)value_ptr = number->n_value.v_float64; return 0; } -static int float64_to_char(const struct b_number *number, void *value_ptr) +static int float64_to_char(const struct b_number_p *number, void *value_ptr) { *(char *)value_ptr = number->n_value.v_float64; return 0; } -static int float64_to_short(const struct b_number *number, void *value_ptr) +static int float64_to_short(const struct b_number_p *number, void *value_ptr) { *(short *)value_ptr = number->n_value.v_float64; return 0; } -static int float64_to_int(const struct b_number *number, void *value_ptr) +static int float64_to_int(const struct b_number_p *number, void *value_ptr) { *(int *)value_ptr = number->n_value.v_float64; return 0; } -static int float64_to_long(const struct b_number *number, void *value_ptr) +static int float64_to_long(const struct b_number_p *number, void *value_ptr) { *(long *)value_ptr = number->n_value.v_float64; return 0; } -static int float64_to_longlong(const struct b_number *number, void *value_ptr) +static int float64_to_longlong(const struct b_number_p *number, void *value_ptr) { *(long long *)value_ptr = number->n_value.v_float64; return 0; } -static int float64_to_float(const struct b_number *number, void *value_ptr) +static int float64_to_float(const struct b_number_p *number, void *value_ptr) { *(float *)value_ptr = number->n_value.v_float64; return 0; } -static int float64_to_double(const struct b_number *number, void *value_ptr) +static int float64_to_double(const struct b_number_p *number, void *value_ptr) { *(double *)value_ptr = number->n_value.v_float64; return 0; } -static int float64_to_size_t(const struct b_number *number, void *value_ptr) +static int float64_to_size_t(const struct b_number_p *number, void *value_ptr) { *(size_t *)value_ptr = number->n_value.v_float64; return 0; @@ -1271,85 +1397,85 @@ static int float64_to_size_t(const struct b_number *number, void *value_ptr) /* ++++++++++++++++++ char -> xyz CONVERTER CALLBACKS ++++++++++++++++++ */ -static int char_to_int8(const struct b_number *number, void *value_ptr) +static int char_to_int8(const struct b_number_p *number, void *value_ptr) { *(int8_t *)value_ptr = number->n_value.v_char; return 0; } -static int char_to_int16(const struct b_number *number, void *value_ptr) +static int char_to_int16(const struct b_number_p *number, void *value_ptr) { *(int16_t *)value_ptr = number->n_value.v_char; return 0; } -static int char_to_int32(const struct b_number *number, void *value_ptr) +static int char_to_int32(const struct b_number_p *number, void *value_ptr) { *(int32_t *)value_ptr = number->n_value.v_char; return 0; } -static int char_to_int64(const struct b_number *number, void *value_ptr) +static int char_to_int64(const struct b_number_p *number, void *value_ptr) { *(int64_t *)value_ptr = number->n_value.v_char; return 0; } -static int char_to_float32(const struct b_number *number, void *value_ptr) +static int char_to_float32(const struct b_number_p *number, void *value_ptr) { *(float *)value_ptr = number->n_value.v_char; return 0; } -static int char_to_float64(const struct b_number *number, void *value_ptr) +static int char_to_float64(const struct b_number_p *number, void *value_ptr) { *(double *)value_ptr = number->n_value.v_char; return 0; } -static int char_to_char(const struct b_number *number, void *value_ptr) +static int char_to_char(const struct b_number_p *number, void *value_ptr) { *(char *)value_ptr = number->n_value.v_char; return 0; } -static int char_to_short(const struct b_number *number, void *value_ptr) +static int char_to_short(const struct b_number_p *number, void *value_ptr) { *(short *)value_ptr = number->n_value.v_char; return 0; } -static int char_to_int(const struct b_number *number, void *value_ptr) +static int char_to_int(const struct b_number_p *number, void *value_ptr) { *(int *)value_ptr = number->n_value.v_char; return 0; } -static int char_to_long(const struct b_number *number, void *value_ptr) +static int char_to_long(const struct b_number_p *number, void *value_ptr) { *(long *)value_ptr = number->n_value.v_char; return 0; } -static int char_to_longlong(const struct b_number *number, void *value_ptr) +static int char_to_longlong(const struct b_number_p *number, void *value_ptr) { *(long long *)value_ptr = number->n_value.v_char; return 0; } -static int char_to_float(const struct b_number *number, void *value_ptr) +static int char_to_float(const struct b_number_p *number, void *value_ptr) { *(float *)value_ptr = number->n_value.v_char; return 0; } -static int char_to_double(const struct b_number *number, void *value_ptr) +static int char_to_double(const struct b_number_p *number, void *value_ptr) { *(double *)value_ptr = number->n_value.v_char; return 0; } -static int char_to_size_t(const struct b_number *number, void *value_ptr) +static int char_to_size_t(const struct b_number_p *number, void *value_ptr) { *(size_t *)value_ptr = number->n_value.v_char; return 0; @@ -1357,85 +1483,85 @@ static int char_to_size_t(const struct b_number *number, void *value_ptr) /* ++++++++++++++++++ short -> xyz CONVERTER CALLBACKS ++++++++++++++++++ */ -static int short_to_int8(const struct b_number *number, void *value_ptr) +static int short_to_int8(const struct b_number_p *number, void *value_ptr) { *(int8_t *)value_ptr = number->n_value.v_short; return 0; } -static int short_to_int16(const struct b_number *number, void *value_ptr) +static int short_to_int16(const struct b_number_p *number, void *value_ptr) { *(int16_t *)value_ptr = number->n_value.v_short; return 0; } -static int short_to_int32(const struct b_number *number, void *value_ptr) +static int short_to_int32(const struct b_number_p *number, void *value_ptr) { *(int32_t *)value_ptr = number->n_value.v_short; return 0; } -static int short_to_int64(const struct b_number *number, void *value_ptr) +static int short_to_int64(const struct b_number_p *number, void *value_ptr) { *(int64_t *)value_ptr = number->n_value.v_short; return 0; } -static int short_to_float32(const struct b_number *number, void *value_ptr) +static int short_to_float32(const struct b_number_p *number, void *value_ptr) { *(float *)value_ptr = number->n_value.v_short; return 0; } -static int short_to_float64(const struct b_number *number, void *value_ptr) +static int short_to_float64(const struct b_number_p *number, void *value_ptr) { *(double *)value_ptr = number->n_value.v_short; return 0; } -static int short_to_char(const struct b_number *number, void *value_ptr) +static int short_to_char(const struct b_number_p *number, void *value_ptr) { *(char *)value_ptr = number->n_value.v_short; return 0; } -static int short_to_short(const struct b_number *number, void *value_ptr) +static int short_to_short(const struct b_number_p *number, void *value_ptr) { *(short *)value_ptr = number->n_value.v_short; return 0; } -static int short_to_int(const struct b_number *number, void *value_ptr) +static int short_to_int(const struct b_number_p *number, void *value_ptr) { *(int *)value_ptr = number->n_value.v_short; return 0; } -static int short_to_long(const struct b_number *number, void *value_ptr) +static int short_to_long(const struct b_number_p *number, void *value_ptr) { *(long *)value_ptr = number->n_value.v_short; return 0; } -static int short_to_longlong(const struct b_number *number, void *value_ptr) +static int short_to_longlong(const struct b_number_p *number, void *value_ptr) { *(long long *)value_ptr = number->n_value.v_short; return 0; } -static int short_to_float(const struct b_number *number, void *value_ptr) +static int short_to_float(const struct b_number_p *number, void *value_ptr) { *(float *)value_ptr = number->n_value.v_short; return 0; } -static int short_to_double(const struct b_number *number, void *value_ptr) +static int short_to_double(const struct b_number_p *number, void *value_ptr) { *(double *)value_ptr = number->n_value.v_short; return 0; } -static int short_to_size_t(const struct b_number *number, void *value_ptr) +static int short_to_size_t(const struct b_number_p *number, void *value_ptr) { *(size_t *)value_ptr = number->n_value.v_short; return 0; @@ -1443,85 +1569,85 @@ static int short_to_size_t(const struct b_number *number, void *value_ptr) /* ++++++++++++++++++ int -> xyz CONVERTER CALLBACKS ++++++++++++++++++ */ -static int int_to_int8(const struct b_number *number, void *value_ptr) +static int int_to_int8(const struct b_number_p *number, void *value_ptr) { *(int8_t *)value_ptr = number->n_value.v_int; return 0; } -static int int_to_int16(const struct b_number *number, void *value_ptr) +static int int_to_int16(const struct b_number_p *number, void *value_ptr) { *(int16_t *)value_ptr = number->n_value.v_int; return 0; } -static int int_to_int32(const struct b_number *number, void *value_ptr) +static int int_to_int32(const struct b_number_p *number, void *value_ptr) { *(int32_t *)value_ptr = number->n_value.v_int; return 0; } -static int int_to_int64(const struct b_number *number, void *value_ptr) +static int int_to_int64(const struct b_number_p *number, void *value_ptr) { *(int64_t *)value_ptr = number->n_value.v_int; return 0; } -static int int_to_float32(const struct b_number *number, void *value_ptr) +static int int_to_float32(const struct b_number_p *number, void *value_ptr) { *(float *)value_ptr = number->n_value.v_int; return 0; } -static int int_to_float64(const struct b_number *number, void *value_ptr) +static int int_to_float64(const struct b_number_p *number, void *value_ptr) { *(double *)value_ptr = number->n_value.v_int; return 0; } -static int int_to_char(const struct b_number *number, void *value_ptr) +static int int_to_char(const struct b_number_p *number, void *value_ptr) { *(char *)value_ptr = number->n_value.v_int; return 0; } -static int int_to_short(const struct b_number *number, void *value_ptr) +static int int_to_short(const struct b_number_p *number, void *value_ptr) { *(short *)value_ptr = number->n_value.v_int; return 0; } -static int int_to_int(const struct b_number *number, void *value_ptr) +static int int_to_int(const struct b_number_p *number, void *value_ptr) { *(int *)value_ptr = number->n_value.v_int; return 0; } -static int int_to_long(const struct b_number *number, void *value_ptr) +static int int_to_long(const struct b_number_p *number, void *value_ptr) { *(long *)value_ptr = number->n_value.v_int; return 0; } -static int int_to_longlong(const struct b_number *number, void *value_ptr) +static int int_to_longlong(const struct b_number_p *number, void *value_ptr) { *(long long *)value_ptr = number->n_value.v_int; return 0; } -static int int_to_float(const struct b_number *number, void *value_ptr) +static int int_to_float(const struct b_number_p *number, void *value_ptr) { *(float *)value_ptr = number->n_value.v_int; return 0; } -static int int_to_double(const struct b_number *number, void *value_ptr) +static int int_to_double(const struct b_number_p *number, void *value_ptr) { *(double *)value_ptr = number->n_value.v_int; return 0; } -static int int_to_size_t(const struct b_number *number, void *value_ptr) +static int int_to_size_t(const struct b_number_p *number, void *value_ptr) { *(size_t *)value_ptr = number->n_value.v_int; return 0; @@ -1529,85 +1655,85 @@ static int int_to_size_t(const struct b_number *number, void *value_ptr) /* ++++++++++++++++++ long -> xyz CONVERTER CALLBACKS ++++++++++++++++++ */ -static int long_to_int8(const struct b_number *number, void *value_ptr) +static int long_to_int8(const struct b_number_p *number, void *value_ptr) { *(int8_t *)value_ptr = number->n_value.v_long; return 0; } -static int long_to_int16(const struct b_number *number, void *value_ptr) +static int long_to_int16(const struct b_number_p *number, void *value_ptr) { *(int16_t *)value_ptr = number->n_value.v_long; return 0; } -static int long_to_int32(const struct b_number *number, void *value_ptr) +static int long_to_int32(const struct b_number_p *number, void *value_ptr) { *(int32_t *)value_ptr = number->n_value.v_long; return 0; } -static int long_to_int64(const struct b_number *number, void *value_ptr) +static int long_to_int64(const struct b_number_p *number, void *value_ptr) { *(int64_t *)value_ptr = number->n_value.v_long; return 0; } -static int long_to_float32(const struct b_number *number, void *value_ptr) +static int long_to_float32(const struct b_number_p *number, void *value_ptr) { *(float *)value_ptr = number->n_value.v_long; return 0; } -static int long_to_float64(const struct b_number *number, void *value_ptr) +static int long_to_float64(const struct b_number_p *number, void *value_ptr) { *(double *)value_ptr = number->n_value.v_long; return 0; } -static int long_to_char(const struct b_number *number, void *value_ptr) +static int long_to_char(const struct b_number_p *number, void *value_ptr) { *(char *)value_ptr = number->n_value.v_long; return 0; } -static int long_to_short(const struct b_number *number, void *value_ptr) +static int long_to_short(const struct b_number_p *number, void *value_ptr) { *(short *)value_ptr = number->n_value.v_long; return 0; } -static int long_to_int(const struct b_number *number, void *value_ptr) +static int long_to_int(const struct b_number_p *number, void *value_ptr) { *(int *)value_ptr = number->n_value.v_long; return 0; } -static int long_to_long(const struct b_number *number, void *value_ptr) +static int long_to_long(const struct b_number_p *number, void *value_ptr) { *(long *)value_ptr = number->n_value.v_long; return 0; } -static int long_to_longlong(const struct b_number *number, void *value_ptr) +static int long_to_longlong(const struct b_number_p *number, void *value_ptr) { *(long long *)value_ptr = number->n_value.v_long; return 0; } -static int long_to_float(const struct b_number *number, void *value_ptr) +static int long_to_float(const struct b_number_p *number, void *value_ptr) { *(float *)value_ptr = number->n_value.v_long; return 0; } -static int long_to_double(const struct b_number *number, void *value_ptr) +static int long_to_double(const struct b_number_p *number, void *value_ptr) { *(double *)value_ptr = number->n_value.v_long; return 0; } -static int long_to_size_t(const struct b_number *number, void *value_ptr) +static int long_to_size_t(const struct b_number_p *number, void *value_ptr) { *(size_t *)value_ptr = number->n_value.v_long; return 0; @@ -1615,85 +1741,85 @@ static int long_to_size_t(const struct b_number *number, void *value_ptr) /* ++++++++++++++++++ longlong -> xyz CONVERTER CALLBACKS ++++++++++++++++++ */ -static int longlong_to_int8(const struct b_number *number, void *value_ptr) +static int longlong_to_int8(const struct b_number_p *number, void *value_ptr) { *(int8_t *)value_ptr = number->n_value.v_longlong; return 0; } -static int longlong_to_int16(const struct b_number *number, void *value_ptr) +static int longlong_to_int16(const struct b_number_p *number, void *value_ptr) { *(int16_t *)value_ptr = number->n_value.v_longlong; return 0; } -static int longlong_to_int32(const struct b_number *number, void *value_ptr) +static int longlong_to_int32(const struct b_number_p *number, void *value_ptr) { *(int32_t *)value_ptr = number->n_value.v_longlong; return 0; } -static int longlong_to_int64(const struct b_number *number, void *value_ptr) +static int longlong_to_int64(const struct b_number_p *number, void *value_ptr) { *(int64_t *)value_ptr = number->n_value.v_longlong; return 0; } -static int longlong_to_float32(const struct b_number *number, void *value_ptr) +static int longlong_to_float32(const struct b_number_p *number, void *value_ptr) { *(float *)value_ptr = number->n_value.v_longlong; return 0; } -static int longlong_to_float64(const struct b_number *number, void *value_ptr) +static int longlong_to_float64(const struct b_number_p *number, void *value_ptr) { *(double *)value_ptr = number->n_value.v_longlong; return 0; } -static int longlong_to_char(const struct b_number *number, void *value_ptr) +static int longlong_to_char(const struct b_number_p *number, void *value_ptr) { *(char *)value_ptr = number->n_value.v_longlong; return 0; } -static int longlong_to_short(const struct b_number *number, void *value_ptr) +static int longlong_to_short(const struct b_number_p *number, void *value_ptr) { *(short *)value_ptr = number->n_value.v_longlong; return 0; } -static int longlong_to_int(const struct b_number *number, void *value_ptr) +static int longlong_to_int(const struct b_number_p *number, void *value_ptr) { *(int *)value_ptr = number->n_value.v_longlong; return 0; } -static int longlong_to_long(const struct b_number *number, void *value_ptr) +static int longlong_to_long(const struct b_number_p *number, void *value_ptr) { *(long *)value_ptr = number->n_value.v_longlong; return 0; } -static int longlong_to_longlong(const struct b_number *number, void *value_ptr) +static int longlong_to_longlong(const struct b_number_p *number, void *value_ptr) { *(long long *)value_ptr = number->n_value.v_longlong; return 0; } -static int longlong_to_float(const struct b_number *number, void *value_ptr) +static int longlong_to_float(const struct b_number_p *number, void *value_ptr) { *(float *)value_ptr = number->n_value.v_longlong; return 0; } -static int longlong_to_double(const struct b_number *number, void *value_ptr) +static int longlong_to_double(const struct b_number_p *number, void *value_ptr) { *(double *)value_ptr = number->n_value.v_longlong; return 0; } -static int longlong_to_size_t(const struct b_number *number, void *value_ptr) +static int longlong_to_size_t(const struct b_number_p *number, void *value_ptr) { *(size_t *)value_ptr = number->n_value.v_longlong; return 0; @@ -1701,85 +1827,85 @@ static int longlong_to_size_t(const struct b_number *number, void *value_ptr) /* ++++++++++++++++++ float -> xyz CONVERTER CALLBACKS ++++++++++++++++++ */ -static int float_to_int8(const struct b_number *number, void *value_ptr) +static int float_to_int8(const struct b_number_p *number, void *value_ptr) { *(int8_t *)value_ptr = number->n_value.v_float; return 0; } -static int float_to_int16(const struct b_number *number, void *value_ptr) +static int float_to_int16(const struct b_number_p *number, void *value_ptr) { *(int16_t *)value_ptr = number->n_value.v_float; return 0; } -static int float_to_int32(const struct b_number *number, void *value_ptr) +static int float_to_int32(const struct b_number_p *number, void *value_ptr) { *(int32_t *)value_ptr = number->n_value.v_float; return 0; } -static int float_to_int64(const struct b_number *number, void *value_ptr) +static int float_to_int64(const struct b_number_p *number, void *value_ptr) { *(int64_t *)value_ptr = number->n_value.v_float; return 0; } -static int float_to_float32(const struct b_number *number, void *value_ptr) +static int float_to_float32(const struct b_number_p *number, void *value_ptr) { *(float *)value_ptr = number->n_value.v_float; return 0; } -static int float_to_float64(const struct b_number *number, void *value_ptr) +static int float_to_float64(const struct b_number_p *number, void *value_ptr) { *(double *)value_ptr = number->n_value.v_float; return 0; } -static int float_to_char(const struct b_number *number, void *value_ptr) +static int float_to_char(const struct b_number_p *number, void *value_ptr) { *(char *)value_ptr = number->n_value.v_float; return 0; } -static int float_to_short(const struct b_number *number, void *value_ptr) +static int float_to_short(const struct b_number_p *number, void *value_ptr) { *(short *)value_ptr = number->n_value.v_float; return 0; } -static int float_to_int(const struct b_number *number, void *value_ptr) +static int float_to_int(const struct b_number_p *number, void *value_ptr) { *(int *)value_ptr = number->n_value.v_float; return 0; } -static int float_to_long(const struct b_number *number, void *value_ptr) +static int float_to_long(const struct b_number_p *number, void *value_ptr) { *(long *)value_ptr = number->n_value.v_float; return 0; } -static int float_to_longlong(const struct b_number *number, void *value_ptr) +static int float_to_longlong(const struct b_number_p *number, void *value_ptr) { *(long long *)value_ptr = number->n_value.v_float; return 0; } -static int float_to_float(const struct b_number *number, void *value_ptr) +static int float_to_float(const struct b_number_p *number, void *value_ptr) { *(float *)value_ptr = number->n_value.v_float; return 0; } -static int float_to_double(const struct b_number *number, void *value_ptr) +static int float_to_double(const struct b_number_p *number, void *value_ptr) { *(double *)value_ptr = number->n_value.v_float; return 0; } -static int float_to_size_t(const struct b_number *number, void *value_ptr) +static int float_to_size_t(const struct b_number_p *number, void *value_ptr) { *(size_t *)value_ptr = number->n_value.v_float; return 0; @@ -1787,85 +1913,85 @@ static int float_to_size_t(const struct b_number *number, void *value_ptr) /* ++++++++++++++++++ double -> xyz CONVERTER CALLBACKS ++++++++++++++++++ */ -static int double_to_int8(const struct b_number *number, void *value_ptr) +static int double_to_int8(const struct b_number_p *number, void *value_ptr) { *(int8_t *)value_ptr = number->n_value.v_double; return 0; } -static int double_to_int16(const struct b_number *number, void *value_ptr) +static int double_to_int16(const struct b_number_p *number, void *value_ptr) { *(int16_t *)value_ptr = number->n_value.v_double; return 0; } -static int double_to_int32(const struct b_number *number, void *value_ptr) +static int double_to_int32(const struct b_number_p *number, void *value_ptr) { *(int32_t *)value_ptr = number->n_value.v_double; return 0; } -static int double_to_int64(const struct b_number *number, void *value_ptr) +static int double_to_int64(const struct b_number_p *number, void *value_ptr) { *(int64_t *)value_ptr = number->n_value.v_double; return 0; } -static int double_to_float32(const struct b_number *number, void *value_ptr) +static int double_to_float32(const struct b_number_p *number, void *value_ptr) { *(float *)value_ptr = number->n_value.v_double; return 0; } -static int double_to_float64(const struct b_number *number, void *value_ptr) +static int double_to_float64(const struct b_number_p *number, void *value_ptr) { *(double *)value_ptr = number->n_value.v_double; return 0; } -static int double_to_char(const struct b_number *number, void *value_ptr) +static int double_to_char(const struct b_number_p *number, void *value_ptr) { *(char *)value_ptr = number->n_value.v_double; return 0; } -static int double_to_short(const struct b_number *number, void *value_ptr) +static int double_to_short(const struct b_number_p *number, void *value_ptr) { *(short *)value_ptr = number->n_value.v_double; return 0; } -static int double_to_int(const struct b_number *number, void *value_ptr) +static int double_to_int(const struct b_number_p *number, void *value_ptr) { *(int *)value_ptr = number->n_value.v_double; return 0; } -static int double_to_long(const struct b_number *number, void *value_ptr) +static int double_to_long(const struct b_number_p *number, void *value_ptr) { *(long *)value_ptr = number->n_value.v_double; return 0; } -static int double_to_longlong(const struct b_number *number, void *value_ptr) +static int double_to_longlong(const struct b_number_p *number, void *value_ptr) { *(long long *)value_ptr = number->n_value.v_double; return 0; } -static int double_to_float(const struct b_number *number, void *value_ptr) +static int double_to_float(const struct b_number_p *number, void *value_ptr) { *(float *)value_ptr = number->n_value.v_double; return 0; } -static int double_to_double(const struct b_number *number, void *value_ptr) +static int double_to_double(const struct b_number_p *number, void *value_ptr) { *(double *)value_ptr = number->n_value.v_double; return 0; } -static int double_to_size_t(const struct b_number *number, void *value_ptr) +static int double_to_size_t(const struct b_number_p *number, void *value_ptr) { *(size_t *)value_ptr = number->n_value.v_double; return 0; @@ -1873,85 +1999,85 @@ static int double_to_size_t(const struct b_number *number, void *value_ptr) /* ++++++++++++++++++ size_t -> xyz CONVERTER CALLBACKS ++++++++++++++++++ */ -static int size_t_to_int8(const struct b_number *number, void *value_ptr) +static int size_t_to_int8(const struct b_number_p *number, void *value_ptr) { *(int8_t *)value_ptr = number->n_value.v_size_t; return 0; } -static int size_t_to_int16(const struct b_number *number, void *value_ptr) +static int size_t_to_int16(const struct b_number_p *number, void *value_ptr) { *(int16_t *)value_ptr = number->n_value.v_size_t; return 0; } -static int size_t_to_int32(const struct b_number *number, void *value_ptr) +static int size_t_to_int32(const struct b_number_p *number, void *value_ptr) { *(int32_t *)value_ptr = number->n_value.v_size_t; return 0; } -static int size_t_to_int64(const struct b_number *number, void *value_ptr) +static int size_t_to_int64(const struct b_number_p *number, void *value_ptr) { *(int64_t *)value_ptr = number->n_value.v_size_t; return 0; } -static int size_t_to_float32(const struct b_number *number, void *value_ptr) +static int size_t_to_float32(const struct b_number_p *number, void *value_ptr) { *(float *)value_ptr = number->n_value.v_size_t; return 0; } -static int size_t_to_float64(const struct b_number *number, void *value_ptr) +static int size_t_to_float64(const struct b_number_p *number, void *value_ptr) { *(double *)value_ptr = number->n_value.v_size_t; return 0; } -static int size_t_to_char(const struct b_number *number, void *value_ptr) +static int size_t_to_char(const struct b_number_p *number, void *value_ptr) { *(char *)value_ptr = number->n_value.v_size_t; return 0; } -static int size_t_to_short(const struct b_number *number, void *value_ptr) +static int size_t_to_short(const struct b_number_p *number, void *value_ptr) { *(short *)value_ptr = number->n_value.v_size_t; return 0; } -static int size_t_to_int(const struct b_number *number, void *value_ptr) +static int size_t_to_int(const struct b_number_p *number, void *value_ptr) { *(int *)value_ptr = number->n_value.v_size_t; return 0; } -static int size_t_to_long(const struct b_number *number, void *value_ptr) +static int size_t_to_long(const struct b_number_p *number, void *value_ptr) { *(long *)value_ptr = number->n_value.v_size_t; return 0; } -static int size_t_to_longlong(const struct b_number *number, void *value_ptr) +static int size_t_to_longlong(const struct b_number_p *number, void *value_ptr) { *(long long *)value_ptr = number->n_value.v_size_t; return 0; } -static int size_t_to_float(const struct b_number *number, void *value_ptr) +static int size_t_to_float(const struct b_number_p *number, void *value_ptr) { *(float *)value_ptr = number->n_value.v_size_t; return 0; } -static int size_t_to_double(const struct b_number *number, void *value_ptr) +static int size_t_to_double(const struct b_number_p *number, void *value_ptr) { *(double *)value_ptr = number->n_value.v_size_t; return 0; } -static int size_t_to_size_t(const struct b_number *number, void *value_ptr) +static int size_t_to_size_t(const struct b_number_p *number, void *value_ptr) { *(size_t *)value_ptr = number->n_value.v_size_t; return 0; @@ -2197,8 +2323,3 @@ static number_converter_t converters[B_NUMBER_TYPE_COUNT][B_NUMBER_TYPE_COUNT] = [B_NUMBER_SIZE_T] = size_t_to_size_t, }, }; - -b_dsref_type_id b_number_type_id(void) -{ - return (b_dsref_type_id)&number_type; -} diff --git a/ds/number.h b/ds/number.h deleted file mode 100644 index cd3166b..0000000 --- a/ds/number.h +++ /dev/null @@ -1,35 +0,0 @@ -#ifndef _BLUELIB_NUMBER_H_ -#define _BLUELIB_NUMBER_H_ - -#include "object.h" - -#include - -enum b_number_flags { - NUMBER_F_INF = 0x01u, - NUMBER_F_NAN = 0x02u, -}; - -struct b_number { - struct b_dsref n_base; - b_number_type n_type; - enum b_number_flags n_flags; - union { - int8_t v_int8; - int16_t v_int16; - int32_t v_int32; - int64_t v_int64; - float v_float32; - double v_float64; - char v_char; - short v_short; - int v_int; - long v_long; - long long v_longlong; - float v_float; - double v_double; - size_t v_size_t; - } n_value; -}; - -#endif