object: update to_string callback to use b_stream instead of b_stringstream

This commit is contained in:
2025-06-27 21:47:55 +01:00
parent 579a9e8505
commit c54d51d381
9 changed files with 237 additions and 51 deletions

View File

@@ -12,7 +12,7 @@
#define B_RVT(t, p) ((t *)(b_make_rvalue(B_OBJECT(p))))
struct b_string;
struct b_stringstream;
struct b_stream;
typedef enum b_comparison_result {
B_LESS = -1,
@@ -30,7 +30,7 @@ BLUE_API b_object *b_make_rvalue(b_object *obj);
BLUE_API b_object *b_retain(b_object *obj);
BLUE_API void b_release(b_object *obj);
BLUE_API void b_to_string(b_object *obj, struct b_stringstream *out);
BLUE_API void b_to_string(b_object *obj, struct b_stream *out);
BLUE_API b_object_type_id b_typeid(const b_object *obj);
BLUE_API b_comparison_result_t b_compare(const b_object *a, const b_object *b);

View File

@@ -5,6 +5,8 @@
#include <blue/object/object.h>
#include <blue/object/type.h>
struct b_stream;
#define B_STRING(p) ((b_string *)(p))
#define B_CSTR(s) (b_string_create_from_cstr(s))
@@ -33,6 +35,7 @@ static inline void b_string_release(b_string *str)
BLUE_API char *b_string_steal(b_string *str);
BLUE_API b_status b_string_reserve(b_string *str, size_t capacity);
BLUE_API b_status b_string_replace_all(b_string *str, const char *new_data);
BLUE_API b_status b_string_open_stream(b_string *str, struct b_stream **out);
BLUE_API void b_string_append_s(b_string *dest, const b_string *src);
BLUE_API void b_string_append_cstr(b_string *dest, const char *src);

View File

@@ -10,7 +10,7 @@
#define B_NPOS ((size_t)INTPTR_MAX)
struct b_object;
struct b_stringstream;
struct b_stream;
typedef uintptr_t b_object_type_id;
@@ -44,7 +44,7 @@ typedef struct b_object_type {
b_queue_entry t_entry;
void (*t_init)(struct b_object *);
void (*t_release)(struct b_object *);
void (*t_to_string)(struct b_object *, struct b_stringstream *);
void (*t_to_string)(struct b_object *, struct b_stream *);
} b_object_type;
BLUE_API b_status b_object_type_register(b_object_type *type);