Flecs v4.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// 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_register(
70 ecs_world_t *world,
71 ecs_entity_t id,
72 int32_t ids_index,
73 const char *name,
74 const char *cpp_name,
75 const char *cpp_symbol,
76 size_t size,
77 size_t alignment,
78 bool is_component,
79 bool explicit_registration,
80 bool *registered_out,
81 bool *existing_out);
82
83FLECS_API
84void ecs_cpp_enum_init(
85 ecs_world_t *world,
86 ecs_entity_t id,
87 ecs_entity_t underlying_type);
88
89FLECS_API
90ecs_entity_t ecs_cpp_enum_constant_register(
91 ecs_world_t *world,
92 ecs_entity_t parent,
93 ecs_entity_t id,
94 const char *name,
95 void *value,
96 ecs_entity_t value_type,
97 size_t value_size);
98
99typedef struct ecs_cpp_get_mut_t {
100 ecs_world_t *world;
101 ecs_stage_t *stage;
102 void *ptr;
103 bool call_modified;
104} ecs_cpp_get_mut_t;
105
106FLECS_API
107FLECS_ALWAYS_INLINE ecs_cpp_get_mut_t ecs_cpp_set(
108 ecs_world_t *world,
109 ecs_entity_t entity,
110 ecs_id_t component,
111 const void *new_ptr,
112 size_t size);
113
114FLECS_API
115FLECS_ALWAYS_INLINE ecs_cpp_get_mut_t ecs_cpp_assign(
116 ecs_world_t *world,
117 ecs_entity_t entity,
118 ecs_id_t component,
119 const void *new_ptr,
120 size_t size);
121
122FLECS_API
123FLECS_ALWAYS_INLINE ecs_entity_t ecs_cpp_new(
124 ecs_world_t *world,
125 ecs_entity_t parent,
126 const char *name,
127 const char *sep,
128 const char *root_sep);
129
130#ifdef FLECS_META
131FLECS_API
132ecs_member_t* ecs_cpp_last_member(
133 const ecs_world_t *world,
134 ecs_entity_t type);
135#endif
136
137#ifdef __cplusplus
138}
139#endif
140
141#endif // FLECS_CPP_H
142
143#endif // FLECS_CPP
struct ecs_stage_t ecs_stage_t
A stage enables modification while iterating and from multiple threads.
Definition flecs.h:428
ecs_id_t ecs_entity_t
An entity identifier.
Definition flecs.h:381
struct ecs_world_t ecs_world_t
A world is the container for all ECS data and supporting features.
Definition flecs.h:425
uint64_t ecs_id_t
Ids are the things that can be added to an entity.
Definition flecs.h:374
Element type of members vector in EcsStruct.
Definition meta.h:220