object: update to_string callback to use b_stream instead of b_stringstream
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
#include "number.h"
|
||||
|
||||
#include <blue/core/stringstream.h>
|
||||
#include <blue/core/stream.h>
|
||||
#include <blue/object/type.h>
|
||||
#include <inttypes.h>
|
||||
#include <stdlib.h>
|
||||
@@ -10,7 +10,7 @@ typedef int (*number_converter_t)(const struct b_number *, void *);
|
||||
|
||||
static number_converter_t converters[B_NUMBER_TYPE_COUNT][B_NUMBER_TYPE_COUNT];
|
||||
|
||||
static void number_to_string(struct b_object *obj, struct b_stringstream *out);
|
||||
static void number_to_string(struct b_object *obj, struct b_stream *out);
|
||||
|
||||
static struct b_object_type number_type = {
|
||||
.t_name = "corelib::number",
|
||||
@@ -175,55 +175,55 @@ size_t b_number_data_size(const struct b_number *number)
|
||||
}
|
||||
}
|
||||
|
||||
static void number_to_string(struct b_object *obj, struct b_stringstream *out)
|
||||
static void number_to_string(struct b_object *obj, struct b_stream *out)
|
||||
{
|
||||
struct b_number *number = B_NUMBER(obj);
|
||||
switch (number->n_type) {
|
||||
case B_NUMBER_INT8:
|
||||
b_stringstream_addf(out, "%" PRIu8, number->n_value.v_int8);
|
||||
b_stream_write_fmt(out, NULL, "%" PRIu8, number->n_value.v_int8);
|
||||
break;
|
||||
case B_NUMBER_INT16:
|
||||
b_stringstream_addf(out, "%" PRIu16, number->n_value.v_int16);
|
||||
b_stream_write_fmt(out, NULL, "%" PRIu16, number->n_value.v_int16);
|
||||
break;
|
||||
case B_NUMBER_INT32:
|
||||
b_stringstream_addf(out, "%" PRIu32, number->n_value.v_int32);
|
||||
b_stream_write_fmt(out, NULL, "%" PRIu32, number->n_value.v_int32);
|
||||
break;
|
||||
case B_NUMBER_INT64:
|
||||
b_stringstream_addf(out, "%" PRIu64, number->n_value.v_int64);
|
||||
b_stream_write_fmt(out, NULL, "%" PRIu64, number->n_value.v_int64);
|
||||
break;
|
||||
case B_NUMBER_FLOAT32:
|
||||
b_stringstream_addf(out, "%f", number->n_value.v_float32);
|
||||
b_stream_write_fmt(out, NULL, "%f", number->n_value.v_float32);
|
||||
break;
|
||||
case B_NUMBER_FLOAT64:
|
||||
b_stringstream_addf(out, "%lf", number->n_value.v_float64);
|
||||
b_stream_write_fmt(out, NULL, "%lf", number->n_value.v_float64);
|
||||
break;
|
||||
case B_NUMBER_CHAR:
|
||||
b_stringstream_addf(out, "%d", number->n_value.v_char);
|
||||
b_stream_write_fmt(out, NULL, "%d", number->n_value.v_char);
|
||||
break;
|
||||
case B_NUMBER_SHORT:
|
||||
b_stringstream_addf(out, "%d", number->n_value.v_short);
|
||||
b_stream_write_fmt(out, NULL, "%d", number->n_value.v_short);
|
||||
break;
|
||||
case B_NUMBER_INT:
|
||||
b_stringstream_addf(out, "%d", number->n_value.v_int);
|
||||
b_stream_write_fmt(out, NULL, "%d", number->n_value.v_int);
|
||||
break;
|
||||
case B_NUMBER_LONG:
|
||||
b_stringstream_addf(out, "%ld", number->n_value.v_long);
|
||||
b_stream_write_fmt(out, NULL, "%ld", number->n_value.v_long);
|
||||
break;
|
||||
case B_NUMBER_LONGLONG:
|
||||
b_stringstream_addf(out, "%lld", number->n_value.v_longlong);
|
||||
b_stream_write_fmt(out, NULL, "%lld", number->n_value.v_longlong);
|
||||
break;
|
||||
case B_NUMBER_FLOAT:
|
||||
b_stringstream_addf(out, "%f", number->n_value.v_float);
|
||||
b_stream_write_fmt(out, NULL, "%f", number->n_value.v_float);
|
||||
break;
|
||||
case B_NUMBER_DOUBLE:
|
||||
b_stringstream_addf(out, "%lf", number->n_value.v_double);
|
||||
b_stream_write_fmt(out, NULL, "%lf", number->n_value.v_double);
|
||||
break;
|
||||
case B_NUMBER_SIZE_T:
|
||||
b_stringstream_addf(out, "%zu", number->n_value.v_size_t);
|
||||
b_stream_write_fmt(out, NULL, "%zu", number->n_value.v_size_t);
|
||||
break;
|
||||
case B_NUMBER_HANDLE:
|
||||
b_stringstream_addf(
|
||||
out, "%016" PRIx64, number->n_value.v_size_t);
|
||||
b_stream_write_fmt(
|
||||
out, NULL, "%016" PRIx64, number->n_value.v_size_t);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user