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 size_t front_len);
44
45FLECS_API
46char* ecs_cpp_get_symbol_name(
47 char *symbol_name,
48 const char *type_name,
49 size_t len);
50
51FLECS_API
52char* ecs_cpp_get_constant_name(
53 char *constant_name,
54 const char *func_name,
55 size_t len,
56 size_t back_len);
57
58FLECS_API
59const char* ecs_cpp_trim_module(
60 ecs_world_t *world,
61 const char *type_name);
62
63FLECS_API
64void ecs_cpp_component_validate(
65 ecs_world_t *world,
66 ecs_entity_t id,
67 const char *name,
68 const char *symbol,
69 size_t size,
70 size_t alignment,
71 bool implicit_name);
72
73FLECS_API
74ecs_entity_t ecs_cpp_component_register(
75 ecs_world_t *world,
76 ecs_entity_t id,
77 const char *name,
78 const char *symbol,
79 ecs_size_t size,
80 ecs_size_t alignment,
81 bool implicit_name,
82 bool *existing_out);
83
84FLECS_API
85ecs_entity_t ecs_cpp_component_register_explicit(
86 ecs_world_t *world,
87 ecs_entity_t s_id,
88 ecs_entity_t id,
89 const char *name,
90 const char *type_name,
91 const char *symbol,
92 size_t size,
93 size_t alignment,
94 bool is_component,
95 bool *existing_out);
96
97FLECS_API
98void ecs_cpp_enum_init(
99 ecs_world_t *world,
100 ecs_entity_t id);
101
102FLECS_API
103ecs_entity_t ecs_cpp_enum_constant_register(
104 ecs_world_t *world,
105 ecs_entity_t parent,
106 ecs_entity_t id,
107 const char *name,
108 int value);
109
110FLECS_API
111int32_t ecs_cpp_reset_count_get(void);
112
113FLECS_API
114int32_t ecs_cpp_reset_count_inc(void);
115
116#ifdef __cplusplus
117}
118#endif
119
120#endif // FLECS_CPP_H
121
122#endif // FLECS_CPP
ecs_id_t ecs_entity_t
An entity identifier.
Definition: flecs.h:219
struct ecs_world_t ecs_world_t
A world is the container for all ECS data and supporting features.
Definition: flecs.h:228