37 static const char* cppTypeName = ecs_cpp_get_type_name(result, ECS_FUNC_NAME, len, front_len);
125 static_assert(is_pointer<T>::value ==
false,
126 "pointer types are not allowed for components");
130 bool allow_tag =
true)
132 s_index = flecs_component_ids_index_get();
133 s_allow_tag = allow_tag;
135 s_alignment =
alignof(T);
136 if (is_empty<T>::value && allow_tag) {
142 static void init_builtin(
143 flecs::world_t *
world,
145 bool allow_tag =
true)
148 flecs_component_ids_set(
world, s_index,
id);
152 static entity_t register_id(world_t *
world,
153 const char *name =
nullptr,
bool allow_tag =
true, flecs::id_t
id = 0,
154 bool is_component =
false,
bool implicit_name =
true,
const char *n =
nullptr,
155 flecs::entity_t module = 0)
162 ecs_assert(s_index != 0, ECS_INTERNAL_ERROR, NULL);
165 flecs::entity_t c = flecs_component_ids_get(
world, s_index);
179 bool existing =
false;
180 c = ecs_cpp_component_find(
181 world,
id, n, symbol_name<T>(), size(), alignment(),
182 implicit_name, &existing);
184 const char *symbol =
nullptr;
189 symbol = symbol_name<T>();
192 c = ecs_cpp_component_register(
world, c, c, name, type_name<T>(),
193 symbol, size(), alignment(), is_component, &existing);
201 if (size() && !existing) {
202 register_lifecycle_actions<T>(
world, c);
206 flecs_component_ids_set(
world, s_index, c);
211 #if FLECS_CPP_ENUM_REFLECTION_SUPPORT
212 _::init_enum<T>(
world, c);
224 static entity_t
id(world_t *
world)
226#ifdef FLECS_CPP_NO_AUTO_REGISTRATION
228 "component '%s' must be registered before use",
231 flecs::entity_t c = flecs_component_ids_get(
world, s_index);
234 "component '%s' was deleted, reregister before using",
237 flecs::entity_t c = flecs_component_ids_get_alive(
world, s_index);
239 c = register_id(
world);
246 static size_t size() {
247 ecs_assert(s_index != 0, ECS_INTERNAL_ERROR, NULL);
252 static size_t alignment() {
253 ecs_assert(s_index != 0, ECS_INTERNAL_ERROR, NULL);
258 static bool registered(flecs::world_t *
world) {
265 if (!flecs_component_ids_get(
world, s_index)) {
274 static void reset() {
281 static int32_t s_index;
282 static size_t s_size;
283 static size_t s_alignment;
284 static bool s_allow_tag;