Flecs v3.2
A fast entity component system (ECS) for C & C++
Loading...
Searching...
No Matches
flecs_cpp.h
Go to the documentation of this file.
1
10#ifdef FLECS_CPP
11
12#ifndef FLECS_CPP_H
13#define FLECS_CPP_H
14
15#ifdef __cplusplus
16extern "C" {
17#endif
18
19// The functions in this file can be used from C or C++, but these macros are only relevant to C++.
20#ifdef __cplusplus
21
22#if defined(__clang__)
23#define ECS_FUNC_NAME_FRONT(type, name) ((sizeof(#type) + sizeof(" flecs::_::() [T = ") + sizeof(#name)) - 3u)
24#define ECS_FUNC_NAME_BACK (sizeof("]") - 1u)
25#define ECS_FUNC_NAME __PRETTY_FUNCTION__
26#elif defined(__GNUC__)
27#define ECS_FUNC_NAME_FRONT(type, name) ((sizeof(#type) + sizeof(" flecs::_::() [with T = ") + sizeof(#name)) - 3u)
28#define ECS_FUNC_NAME_BACK (sizeof("]") - 1u)
29#define ECS_FUNC_NAME __PRETTY_FUNCTION__
30#elif defined(_WIN32)
31#define ECS_FUNC_NAME_FRONT(type, name) ((sizeof(#type) + sizeof(" __cdecl flecs::_::<") + sizeof(#name)) - 3u)
32#define ECS_FUNC_NAME_BACK (sizeof(">(void)") - 1u)
33#define ECS_FUNC_NAME __FUNCSIG__
34#else
35#error "implicit component registration not supported"
36#endif
37
38#define ECS_FUNC_TYPE_LEN(type, name, str)\
39 (flecs::string::length(str) - (ECS_FUNC_NAME_FRONT(type, name) + ECS_FUNC_NAME_BACK))
40
41#endif
42
43FLECS_API
44char* ecs_cpp_get_type_name(
45 char *type_name,
46 const char *func_name,
47 size_t len,
48 size_t front_len);
49
50FLECS_API
51char* ecs_cpp_get_symbol_name(
52 char *symbol_name,
53 const char *type_name,
54 size_t len);
55
56FLECS_API
57char* ecs_cpp_get_constant_name(
58 char *constant_name,
59 const char *func_name,
60 size_t len,
61 size_t back_len);
62
63FLECS_API
64const char* ecs_cpp_trim_module(
65 ecs_world_t *world,
66 const char *type_name);
67
68FLECS_API
69void ecs_cpp_component_validate(
70 ecs_world_t *world,
71 ecs_entity_t id,
72 const char *name,
73 const char *symbol,
74 size_t size,
75 size_t alignment,
76 bool implicit_name);
77
78FLECS_API
79ecs_entity_t ecs_cpp_component_register(
80 ecs_world_t *world,
81 ecs_entity_t id,
82 const char *name,
83 const char *symbol,
84 ecs_size_t size,
85 ecs_size_t alignment,
86 bool implicit_name,
87 bool *existing_out);
88
89FLECS_API
90ecs_entity_t ecs_cpp_component_register_explicit(
91 ecs_world_t *world,
92 ecs_entity_t s_id,
93 ecs_entity_t id,
94 const char *name,
95 const char *type_name,
96 const char *symbol,
97 size_t size,
98 size_t alignment,
99 bool is_component,
100 bool *existing_out);
101
102FLECS_API
103void ecs_cpp_enum_init(
104 ecs_world_t *world,
105 ecs_entity_t id);
106
107FLECS_API
108ecs_entity_t ecs_cpp_enum_constant_register(
109 ecs_world_t *world,
110 ecs_entity_t parent,
111 ecs_entity_t id,
112 const char *name,
113 int value);
114
115FLECS_API
116int32_t ecs_cpp_reset_count_get(void);
117
118FLECS_API
119int32_t ecs_cpp_reset_count_inc(void);
120
121#ifdef FLECS_META
122FLECS_API
123const ecs_member_t* ecs_cpp_last_member(
124 const ecs_world_t *world,
125 ecs_entity_t type);
126#endif
127
128#ifdef __cplusplus
129}
130#endif
131
132#endif // FLECS_CPP_H
133
134#endif // FLECS_CPP
ecs_id_t ecs_entity_t
An entity identifier.
Definition flecs.h:318
struct ecs_world_t ecs_world_t
A world is the container for all ECS data and supporting features.
Definition flecs.h:362
Element type of members vector in EcsStruct.
Definition meta.h:218