From cfc96182915f281731e45bae2f8c28801aa61da0 Mon Sep 17 00:00:00 2001 From: Javier Peletier Date: Wed, 16 Oct 2024 22:02:50 +0200 Subject: [PATCH] fix const string serializer --- distr/flecs.c | 10 +++++++++- src/addons/meta/definitions.c | 10 +++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/distr/flecs.c b/distr/flecs.c index 80ef14787..534ae66fc 100644 --- a/distr/flecs.c +++ b/distr/flecs.c @@ -49463,6 +49463,13 @@ size_t flecs_addon_vec_count(const void *ptr) { return flecs_ito(size_t, count); } +static +int flecs_const_str_serialize(const ecs_serializer_t *ser, const void *ptr) { + char **data = ECS_CONST_CAST(char**, ptr); + ser->value(ser, ecs_id(ecs_string_t), data); + return 0; +} + static const char* flecs_const_get_string(const void *ptr) { return *((const char *const *) ptr); @@ -49507,7 +49514,8 @@ void flecs_meta_import_core_definitions( }), .type = { .as_type = ecs_id(ecs_string_t), - .get_string = flecs_const_get_string, + .serialize = flecs_const_str_serialize, + .get_string = flecs_const_get_string, } }); diff --git a/src/addons/meta/definitions.c b/src/addons/meta/definitions.c index 2769ea194..555689648 100644 --- a/src/addons/meta/definitions.c +++ b/src/addons/meta/definitions.c @@ -30,6 +30,13 @@ size_t flecs_addon_vec_count(const void *ptr) { return flecs_ito(size_t, count); } +static +int flecs_const_str_serialize(const ecs_serializer_t *ser, const void *ptr) { + char **data = ECS_CONST_CAST(char**, ptr); + ser->value(ser, ecs_id(ecs_string_t), data); + return 0; +} + static const char* flecs_const_get_string(const void *ptr) { return *((const char *const *) ptr); @@ -74,7 +81,8 @@ void flecs_meta_import_core_definitions( }), .type = { .as_type = ecs_id(ecs_string_t), - .get_string = flecs_const_get_string, + .serialize = flecs_const_str_serialize, + .get_string = flecs_const_get_string, } });