From d9041cda3f1a1e95f8555fd753812fc00c92c0eb Mon Sep 17 00:00:00 2001 From: Max Wash Date: Mon, 22 Sep 2025 10:47:33 +0100 Subject: [PATCH] object: to_string() now takes a const object pointer --- object/array.c | 4 ++-- object/dict.c | 4 ++-- object/include/blue/object/object.h | 2 +- object/include/blue/object/type.h | 2 +- object/number.c | 4 ++-- object/object.c | 2 +- object/string.c | 4 ++-- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/object/array.c b/object/array.c index b8cf20c..325a6fa 100644 --- a/object/array.c +++ b/object/array.c @@ -8,7 +8,7 @@ #include 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 = { .t_flags = B_OBJECT_FUNDAMENTAL, @@ -221,7 +221,7 @@ size_t b_array_capacity(const struct b_array *array) 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); diff --git a/object/dict.c b/object/dict.c index c6711ea..d4b1ff0 100644 --- a/object/dict.c +++ b/object/dict.c @@ -24,7 +24,7 @@ uint64_t b_cstr_hash(const char *s) } 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 = { .t_name = "corelib::dict", @@ -186,7 +186,7 @@ bool b_dict_is_empty(const b_dict *dict) 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); diff --git a/object/include/blue/object/object.h b/object/include/blue/object/object.h index 185d6ff..997d1c7 100644 --- a/object/include/blue/object/object.h +++ b/object/include/blue/object/object.h @@ -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 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_comparison_result_t b_compare(const b_object *a, const b_object *b); diff --git a/object/include/blue/object/type.h b/object/include/blue/object/type.h index 2888813..56a3baf 100644 --- a/object/include/blue/object/type.h +++ b/object/include/blue/object/type.h @@ -45,7 +45,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_stream *); + void (*t_to_string)(const struct b_object *, struct b_stream *); } b_object_type; BLUE_API b_status b_object_type_register(b_object_type *type); diff --git a/object/number.c b/object/number.c index ca18f6c..a031cfe 100644 --- a/object/number.c +++ b/object/number.c @@ -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_stream *out); +static void number_to_string(const struct b_object *obj, struct b_stream *out); static struct b_object_type number_type = { .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); switch (number->n_type) { diff --git a/object/object.c b/object/object.c index 812e9c4..750a08d 100644 --- a/object/object.c +++ b/object/object.c @@ -41,7 +41,7 @@ void b_release(struct b_object *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) { obj->ob_type->t_to_string(obj, out); diff --git a/object/string.c b/object/string.c index d2d3077..2d92538 100644 --- a/object/string.c +++ b/object/string.c @@ -23,7 +23,7 @@ enum iterator_mode { }; 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 = { .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); const char *s = b_string_ptr(str);