Skip to content

Commit

Permalink
fix const string serializer
Browse files Browse the repository at this point in the history
  • Loading branch information
jpeletier committed Nov 18, 2024
1 parent 2662620 commit cfc9618
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
10 changes: 9 additions & 1 deletion distr/flecs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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,
}
});

Expand Down
10 changes: 9 additions & 1 deletion src/addons/meta/definitions.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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,
}
});

Expand Down

0 comments on commit cfc9618

Please sign in to comment.