diff --git a/flecs.c b/flecs.c index 589e45e010..d3734fe89d 100644 --- a/flecs.c +++ b/flecs.c @@ -44155,6 +44155,10 @@ const char* meta_parse_member( goto error; } + if (!ptr[0]) { + return ptr; + } + /* Next token is the identifier */ ptr = parse_c_identifier(ptr, token->name, NULL, ctx); if (!ptr) { diff --git a/src/addons/meta_c.c b/src/addons/meta_c.c index 30090b6ad0..3a1397d575 100644 --- a/src/addons/meta_c.c +++ b/src/addons/meta_c.c @@ -319,6 +319,10 @@ const char* meta_parse_member( goto error; } + if (!ptr[0]) { + return ptr; + } + /* Next token is the identifier */ ptr = parse_c_identifier(ptr, token->name, NULL, ctx); if (!ptr) { diff --git a/test/meta/project.json b/test/meta/project.json index 2c73e2c89c..8b97876960 100644 --- a/test/meta/project.json +++ b/test/meta/project.json @@ -800,7 +800,8 @@ "enum_nospace", "struct_nospace", "identifier_w_underscore", - "struct_w_ptr" + "struct_w_ptr", + "private_members" ] }, { "id": "Vars", diff --git a/test/meta/src/MetaUtils.c b/test/meta/src/MetaUtils.c index bc276650ad..7a64fb765d 100644 --- a/test/meta/src/MetaUtils.c +++ b/test/meta/src/MetaUtils.c @@ -47,6 +47,13 @@ ECS_STRUCT(Struct_w_ptrs, { void* ptr_b; }); +ECS_STRUCT(Struct_w_private, { + double x; + double y; +ECS_PRIVATE + double z; +}); + ECS_ENUM(Enum_Default, { Red, Green, Blue }); @@ -388,3 +395,27 @@ void MetaUtils_struct_w_ptr() { ecs_fini(world); } + +void MetaUtils_private_members() { + ecs_world_t *world = ecs_init(); + + ECS_META_COMPONENT(world, Struct_w_private); + + test_assert(ecs_id(Struct_w_private) != 0); + ecs_entity_t s = ecs_id(Struct_w_private); + + { + ecs_entity_t m = ecs_lookup_child(world, s, "x"); + test_assert(m != 0); + } + { + ecs_entity_t m = ecs_lookup_child(world, s, "y"); + test_assert(m != 0); + } + { + ecs_entity_t m = ecs_lookup_child(world, s, "z"); + test_assert(m == 0); + } + + ecs_fini(world); +} diff --git a/test/meta/src/main.c b/test/meta/src/main.c index 4b8193a7f7..5285a629f8 100644 --- a/test/meta/src/main.c +++ b/test/meta/src/main.c @@ -766,6 +766,7 @@ void MetaUtils_enum_nospace(void); void MetaUtils_struct_nospace(void); void MetaUtils_identifier_w_underscore(void); void MetaUtils_struct_w_ptr(void); +void MetaUtils_private_members(void); // Testsuite 'Vars' void Vars_declare_1_var(void); @@ -3851,6 +3852,10 @@ bake_test_case MetaUtils_testcases[] = { { "struct_w_ptr", MetaUtils_struct_w_ptr + }, + { + "private_members", + MetaUtils_private_members } }; @@ -4473,7 +4478,7 @@ static bake_test_suite suites[] = { "MetaUtils", NULL, NULL, - 17, + 18, MetaUtils_testcases }, {