File tree Expand file tree Collapse file tree 10 files changed +129
-10
lines changed
test/custom_builds/cpp/no_enum_reflection Expand file tree Collapse file tree 10 files changed +129
-10
lines changed Original file line number Diff line number Diff line change @@ -6758,10 +6758,10 @@ ecs_entity_t ecs_component_init(
67586758 ptr->alignment = desc->type.alignment;
67596759 if (!new_component || ptr->size != desc->type.size) {
67606760 if (!ptr->size) {
6761- ecs_trace("#[green]tag#[reset] %s created ",
6761+ ecs_trace("#[green]tag#[reset] %s registered ",
67626762 ecs_get_name(world, result));
67636763 } else {
6764- ecs_trace("#[green]component#[reset] %s created ",
6764+ ecs_trace("#[green]component#[reset] %s registered ",
67656765 ecs_get_name(world, result));
67666766 }
67676767 }
@@ -18093,9 +18093,6 @@ static const char *flecs_addons_info[] = {
1809318093#ifdef FLECS_MODULE
1809418094 "FLECS_MODULE",
1809518095#endif
18096- #ifdef FLECS_SCRIPT
18097- "FLECS_SCRIPT",
18098- #endif
1809918096#ifdef FLECS_STATS
1810018097 "FLECS_STATS",
1810118098#endif
@@ -18138,6 +18135,12 @@ static const char *flecs_addons_info[] = {
1813818135#ifdef FLECS_OS_API_IMPL
1813918136 "FLECS_OS_API_IMPL",
1814018137#endif
18138+ #ifdef FLECS_PARSER
18139+ "FLECS_PARSER",
18140+ #endif
18141+ #ifdef FLECS_QUERY_DSL
18142+ "FLECS_QUERY_DSL",
18143+ #endif
1814118144#ifdef FLECS_SCRIPT
1814218145 "FLECS_SCRIPT",
1814318146#endif
Original file line number Diff line number Diff line change 156156 */
157157// #define FLECS_CPP_NO_AUTO_REGISTRATION
158158
159+ /** @def FLECS_CPP_NO_ENUM_REFLECTION
160+ * When set, the C++ API will not attempt to discover and register enum
161+ * constants for registered enum components. This will cause C++ APIs that
162+ * accept enum constants to not work.
163+ * Disabling this feature can significantly improve compile times and reduces
164+ * the RAM footprint of an application.
165+ */
166+ // #define FLECS_CPP_NO_ENUM_REFLECTION
167+
159168/** @def FLECS_CUSTOM_BUILD
160169 * This macro lets you customize which addons to build flecs with.
161170 * Without any addons Flecs is just a minimal ECS storage, but addons add
@@ -17880,6 +17889,12 @@ struct string_view : string {
1788017889#define FLECS_ENUM_MAX(T) _::to_constant<T, 126>::value
1788117890#define FLECS_ENUM_MAX_COUNT (FLECS_ENUM_MAX(int) + 1)
1788217891
17892+ // Flag to turn off enum reflection
17893+ #ifdef FLECS_CPP_NO_ENUM_REFLECTION
17894+ #define FLECS_CPP_ENUM_REFLECTION_SUPPORT 0
17895+ #endif
17896+
17897+ // Test if we're using a compiler that supports the required features
1788317898#ifndef FLECS_CPP_ENUM_REFLECTION_SUPPORT
1788417899#if !defined(__clang__) && defined(__GNUC__)
1788517900#if __GNUC__ > 7 || (__GNUC__ == 7 && __GNUC_MINOR__ >= 5)
Original file line number Diff line number Diff line change 154154 */
155155// #define FLECS_CPP_NO_AUTO_REGISTRATION
156156
157+ /** @def FLECS_CPP_NO_ENUM_REFLECTION
158+ * When set, the C++ API will not attempt to discover and register enum
159+ * constants for registered enum components. This will cause C++ APIs that
160+ * accept enum constants to not work.
161+ * Disabling this feature can significantly improve compile times and reduces
162+ * the RAM footprint of an application.
163+ */
164+ // #define FLECS_CPP_NO_ENUM_REFLECTION
165+
157166/** @def FLECS_CUSTOM_BUILD
158167 * This macro lets you customize which addons to build flecs with.
159168 * Without any addons Flecs is just a minimal ECS storage, but addons add
Original file line number Diff line number Diff line change 1414#define FLECS_ENUM_MAX (T ) _::to_constant<T, 126 >::value
1515#define FLECS_ENUM_MAX_COUNT (FLECS_ENUM_MAX(int ) + 1 )
1616
17+ // Flag to turn off enum reflection
18+ #ifdef FLECS_CPP_NO_ENUM_REFLECTION
19+ #define FLECS_CPP_ENUM_REFLECTION_SUPPORT 0
20+ #endif
21+
22+ // Test if we're using a compiler that supports the required features
1723#ifndef FLECS_CPP_ENUM_REFLECTION_SUPPORT
1824#if !defined(__clang__) && defined(__GNUC__)
1925#if __GNUC__ > 7 || (__GNUC__ == 7 && __GNUC_MINOR__ >= 5)
Original file line number Diff line number Diff line change @@ -2272,10 +2272,10 @@ ecs_entity_t ecs_component_init(
22722272 ptr -> alignment = desc -> type .alignment ;
22732273 if (!new_component || ptr -> size != desc -> type .size ) {
22742274 if (!ptr -> size ) {
2275- ecs_trace ("#[green]tag#[reset] %s created " ,
2275+ ecs_trace ("#[green]tag#[reset] %s registered " ,
22762276 ecs_get_name (world , result ));
22772277 } else {
2278- ecs_trace ("#[green]component#[reset] %s created " ,
2278+ ecs_trace ("#[green]component#[reset] %s registered " ,
22792279 ecs_get_name (world , result ));
22802280 }
22812281 }
Original file line number Diff line number Diff line change @@ -812,9 +812,6 @@ static const char *flecs_addons_info[] = {
812812#ifdef FLECS_MODULE
813813 "FLECS_MODULE" ,
814814#endif
815- #ifdef FLECS_SCRIPT
816- "FLECS_SCRIPT" ,
817- #endif
818815#ifdef FLECS_STATS
819816 "FLECS_STATS" ,
820817#endif
@@ -857,6 +854,12 @@ static const char *flecs_addons_info[] = {
857854#ifdef FLECS_OS_API_IMPL
858855 "FLECS_OS_API_IMPL" ,
859856#endif
857+ #ifdef FLECS_PARSER
858+ "FLECS_PARSER" ,
859+ #endif
860+ #ifdef FLECS_QUERY_DSL
861+ "FLECS_QUERY_DSL" ,
862+ #endif
860863#ifdef FLECS_SCRIPT
861864 "FLECS_SCRIPT" ,
862865#endif
Original file line number Diff line number Diff line change 1+ #ifndef NO_ENUM_REFLECTION_H
2+ #define NO_ENUM_REFLECTION_H
3+
4+ /* This generated file contains includes for project dependencies */
5+ #include "no_enum_reflection/bake_config.h"
6+
7+ #ifdef __cplusplus
8+ extern "C" {
9+ #endif
10+
11+ #ifdef __cplusplus
12+ }
13+ #endif
14+
15+ #endif
16+
Original file line number Diff line number Diff line change 1+ /*
2+ )
3+ (.)
4+ .|.
5+ | |
6+ _.--| |--._
7+ .-'; ;`-'& ; `&.
8+ \ & ; & &_/
9+ |"""---...---"""|
10+ \ | | | | | | | /
11+ `---.|.|.|.---'
12+
13+ * This file is generated by bake.lang.c for your convenience. Headers of
14+ * dependencies will automatically show up in this file. Include bake_config.h
15+ * in your main project file. Do not edit! */
16+
17+ #ifndef NO_ENUM_REFLECTION_BAKE_CONFIG_H
18+ #define NO_ENUM_REFLECTION_BAKE_CONFIG_H
19+
20+ /* Headers of public dependencies */
21+ #include <flecs.h>
22+
23+ #endif
24+
Original file line number Diff line number Diff line change 1+ {
2+ "id" : " no_enum_reflection" ,
3+ "type" : " application" ,
4+ "value" : {
5+ "use" : [
6+ " flecs"
7+ ],
8+ "language" : " c++" ,
9+ "public" : false
10+ },
11+ "lang.cpp" : {
12+ "defines" : [" FLECS_CPP_NO_ENUM_REFLECTION" ]
13+ }
14+ }
Original file line number Diff line number Diff line change 1+ #include < no_enum_reflection.h>
2+ #include < iostream>
3+
4+ enum Color {
5+ Red, Green, Blue
6+ };
7+
8+ int main (int argc, char *argv[]) {
9+ flecs::world world (argc, argv);
10+
11+ auto c = world.component <Color>();
12+
13+ if (c.lookup (" Red" ) != 0 ) {
14+ printf (" enum constant should not be defined\n " );
15+ return -1 ;
16+ }
17+
18+ if (c.lookup (" Green" ) != 0 ) {
19+ printf (" enum constant should not be defined\n " );
20+ return -1 ;
21+ }
22+
23+ if (c.lookup (" Blue" ) != 0 ) {
24+ printf (" enum constant should not be defined\n " );
25+ return -1 ;
26+ }
27+
28+ return 0 ;
29+ }
You can’t perform that action at this time.
0 commit comments