object: to_string() now takes a const object pointer

This commit is contained in:
2025-09-22 10:47:33 +01:00
parent 16b68b6fba
commit d9041cda3f
7 changed files with 11 additions and 11 deletions

View File

@@ -8,7 +8,7 @@
#include <string.h> #include <string.h>
static void array_release(struct b_object *obj); static void array_release(struct b_object *obj);
static void array_to_string(struct b_object *obj, struct b_stream *out); static void array_to_string(const struct b_object *obj, struct b_stream *out);
static struct b_object_type array_type = { static struct b_object_type array_type = {
.t_flags = B_OBJECT_FUNDAMENTAL, .t_flags = B_OBJECT_FUNDAMENTAL,
@@ -221,7 +221,7 @@ size_t b_array_capacity(const struct b_array *array)
return array->ar_cap; return array->ar_cap;
} }
static void array_to_string(struct b_object *obj, struct b_stream *out) static void array_to_string(const struct b_object *obj, struct b_stream *out)
{ {
struct b_array *array = B_ARRAY(obj); struct b_array *array = B_ARRAY(obj);

View File

@@ -24,7 +24,7 @@ uint64_t b_cstr_hash(const char *s)
} }
static void dict_release(struct b_object *obj); static void dict_release(struct b_object *obj);
static void dict_to_string(struct b_object *obj, struct b_stream *out); static void dict_to_string(const struct b_object *obj, struct b_stream *out);
static struct b_object_type dict_type = { static struct b_object_type dict_type = {
.t_name = "corelib::dict", .t_name = "corelib::dict",
@@ -186,7 +186,7 @@ bool b_dict_is_empty(const b_dict *dict)
return false; return false;
} }
static void dict_to_string(struct b_object *obj, struct b_stream *out) static void dict_to_string(const struct b_object *obj, struct b_stream *out)
{ {
struct b_dict *dict = B_DICT(obj); struct b_dict *dict = B_DICT(obj);

View File

@@ -32,7 +32,7 @@ BLUE_API b_object *b_make_rvalue(b_object *obj);
BLUE_API b_object *b_retain(b_object *obj); BLUE_API b_object *b_retain(b_object *obj);
BLUE_API void b_release(b_object *obj); BLUE_API void b_release(b_object *obj);
BLUE_API void b_to_string(b_object *obj, struct b_stream *out); BLUE_API void b_to_string(const b_object *obj, struct b_stream *out);
BLUE_API b_object_type_id b_typeid(const b_object *obj); 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); BLUE_API b_comparison_result_t b_compare(const b_object *a, const b_object *b);

View File

@@ -45,7 +45,7 @@ typedef struct b_object_type {
b_queue_entry t_entry; b_queue_entry t_entry;
void (*t_init)(struct b_object *); void (*t_init)(struct b_object *);
void (*t_release)(struct b_object *); void (*t_release)(struct b_object *);
void (*t_to_string)(struct b_object *, struct b_stream *); void (*t_to_string)(const struct b_object *, struct b_stream *);
} b_object_type; } b_object_type;
BLUE_API b_status b_object_type_register(b_object_type *type); BLUE_API b_status b_object_type_register(b_object_type *type);

View File

@@ -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 number_converter_t converters[B_NUMBER_TYPE_COUNT][B_NUMBER_TYPE_COUNT];
static void number_to_string(struct b_object *obj, struct b_stream *out); static void number_to_string(const struct b_object *obj, struct b_stream *out);
static struct b_object_type number_type = { static struct b_object_type number_type = {
.t_name = "corelib::number", .t_name = "corelib::number",
@@ -175,7 +175,7 @@ size_t b_number_data_size(const struct b_number *number)
} }
} }
static void number_to_string(struct b_object *obj, struct b_stream *out) static void number_to_string(const struct b_object *obj, struct b_stream *out)
{ {
struct b_number *number = B_NUMBER(obj); struct b_number *number = B_NUMBER(obj);
switch (number->n_type) { switch (number->n_type) {

View File

@@ -41,7 +41,7 @@ void b_release(struct b_object *obj)
free(obj); free(obj);
} }
void b_to_string(struct b_object *obj, struct b_stream *out) void b_to_string(const struct b_object *obj, struct b_stream *out)
{ {
if (obj->ob_type->t_to_string) { if (obj->ob_type->t_to_string) {
obj->ob_type->t_to_string(obj, out); obj->ob_type->t_to_string(obj, out);

View File

@@ -23,7 +23,7 @@ enum iterator_mode {
}; };
static void string_release(struct b_object *obj); static void string_release(struct b_object *obj);
static void string_to_string(struct b_object *obj, struct b_stream *out); static void string_to_string(const struct b_object *obj, struct b_stream *out);
static struct b_object_type string_type = { static struct b_object_type string_type = {
.t_name = "corelib::string", .t_name = "corelib::string",
@@ -1644,7 +1644,7 @@ static void string_release(struct b_object *obj)
} }
} }
static void string_to_string(struct b_object *obj, struct b_stream *out) static void string_to_string(const struct b_object *obj, struct b_stream *out)
{ {
b_string *str = B_STRING(obj); b_string *str = B_STRING(obj);
const char *s = b_string_ptr(str); const char *s = b_string_ptr(str);