Flecs v4.0
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
69ecs_entity_t ecs_cpp_component_find(
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 bool *existing_out);
78
79FLECS_API
80ecs_entity_t ecs_cpp_component_register(
81 ecs_world_t *world,
82 ecs_entity_t s_id,
83 ecs_entity_t id,
84 const char *name,
85 const char *type_name,
86 const char *symbol,
87 size_t size,
88 size_t alignment,
89 bool is_component,
90 bool *existing_out);
91
92FLECS_API
93void ecs_cpp_enum_init(
94 ecs_world_t *world,
95 ecs_entity_t id,
96 ecs_entity_t underlying_type);
97
98FLECS_API
99ecs_entity_t ecs_cpp_enum_constant_register(
100 ecs_world_t *world,
101 ecs_entity_t parent,
102 ecs_entity_t id,
103 const char *name,
104 void *value,
105 ecs_entity_t value_type,
106 size_t value_size);
107
108#ifdef FLECS_META
109FLECS_API
110const ecs_member_t* ecs_cpp_last_member(
111 const ecs_world_t *world,
112 ecs_entity_t type);
113#endif
114
115#ifdef __cplusplus
116}
117#endif
118
119#endif // FLECS_CPP_H
120
121#endif // FLECS_CPP
ecs_id_t ecs_entity_t
An entity identifier.
Definition flecs.h:346
struct ecs_world_t ecs_world_t
A world is the container for all ECS data and supporting features.
Definition flecs.h:390
Element type of members vector in EcsStruct.
Definition meta.h:222