Skip to content

Commit

Permalink
--getter interface
Browse files Browse the repository at this point in the history
fix const string serializer
  • Loading branch information
jpeletier committed Nov 29, 2024
1 parent 23bc1d1 commit 74b273f
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 @@ -49657,6 +49657,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 @@ -49701,7 +49708,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 74b273f

Please sign in to comment.