Flecs v3.1
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#if defined(__clang__)
20#define ECS_FUNC_NAME_FRONT(type, name) ((sizeof(#type) + sizeof(" flecs::_::() [T = ") + sizeof(#name)) - 3u)
21#define ECS_FUNC_NAME_BACK (sizeof("]") - 1u)
22#define ECS_FUNC_NAME __PRETTY_FUNCTION__
23#elif defined(__GNUC__)
24#define ECS_FUNC_NAME_FRONT(type, name) ((sizeof(#type) + sizeof(" flecs::_::() [with T = ") + sizeof(#name)) - 3u)
25#define ECS_FUNC_NAME_BACK (sizeof("]") - 1u)
26#define ECS_FUNC_NAME __PRETTY_FUNCTION__
27#elif defined(_WIN32)
28#define ECS_FUNC_NAME_FRONT(type, name) ((sizeof(#type) + sizeof(" __cdecl flecs::_::<") + sizeof(#name)) - 3u)
29#define ECS_FUNC_NAME_BACK (sizeof(">(void)") - 1u)
30#define ECS_FUNC_NAME __FUNCSIG__
31#else
32#error "implicit component registration not supported"
33#endif
34
35#define ECS_FUNC_TYPE_LEN(type, name, str)\
36 (flecs::string::length(str) - (ECS_FUNC_NAME_FRONT(type, name) + ECS_FUNC_NAME_BACK))
37
38FLECS_API
39char* ecs_cpp_get_type_name(
40 char *type_name,
41 const char *func_name,
42 size_t len);
43
44FLECS_API
45char* ecs_cpp_get_symbol_name(
46 char *symbol_name,
47 const char *type_name,
48 size_t len);
49
50FLECS_API
51char* ecs_cpp_get_constant_name(
52 char *constant_name,
53 const char *func_name,
54 size_t len);
55
56FLECS_API
57const char* ecs_cpp_trim_module(
58 ecs_world_t *world,
59 const char *type_name);
60
61FLECS_API
62void ecs_cpp_component_validate(
63 ecs_world_t *world,
64 ecs_entity_t id,
65 const char *name,
66 const char *symbol,
67 size_t size,
68 size_t alignment,
69 bool implicit_name);
70
71FLECS_API
72ecs_entity_t ecs_cpp_component_register(
73 ecs_world_t *world,
74 ecs_entity_t id,
75 const char *name,
76 const char *symbol,
77 ecs_size_t size,
78 ecs_size_t alignment,
79 bool implicit_name,
80 bool *existing_out);
81
82FLECS_API
83ecs_entity_t ecs_cpp_component_register_explicit(
84 ecs_world_t *world,
85 ecs_entity_t s_id,
86 ecs_entity_t id,
87 const char *name,
88 const char *type_name,
89 const char *symbol,
90 size_t size,
91 size_t alignment,
92 bool is_component,
93 bool *existing_out);
94
95FLECS_API
96void ecs_cpp_enum_init(
97 ecs_world_t *world,
98 ecs_entity_t id);
99
100FLECS_API
101ecs_entity_t ecs_cpp_enum_constant_register(
102 ecs_world_t *world,
103 ecs_entity_t parent,
104 ecs_entity_t id,
105 const char *name,
106 int value);
107
108FLECS_API
109int32_t ecs_cpp_reset_count_get(void);
110
111FLECS_API
112int32_t ecs_cpp_reset_count_inc(void);
113
114#ifdef __cplusplus
115}
116#endif
117
118#endif // FLECS_CPP_H
119
120#endif // FLECS_CPP
ecs_id_t ecs_entity_t
An entity identifier.
Definition: flecs.h:220
struct ecs_world_t ecs_world_t
A world is the container for all ECS data and supporting features.
Definition: flecs.h:229