@@ -4,75 +4,41 @@ namespace flecs
4
4
namespace _
5
5
{
6
6
7
- inline void ecs_ctor_illegal (ecs_world_t * w, const ecs_entity_t *,
8
- void *, int32_t , const ecs_type_info_t * info)
9
- {
10
- char *path = ecs_get_path_w_sep (w, 0 , info->component , " ::" , " ::" );
11
- ecs_abort (ECS_INVALID_OPERATION,
12
- " cannnot default construct %s, add %s::%s() or use emplace<T>" ,
13
- path, path, ecs_get_name (w, info->component ));
14
- ecs_os_free (path);
7
+ inline void ecs_ctor_illegal (void *, int32_t , const ecs_type_info_t *) {
8
+ ecs_abort (ECS_INVALID_OPERATION, " invalid constructor" );
15
9
}
16
10
17
- inline void ecs_dtor_illegal (ecs_world_t * w, const ecs_entity_t *,
18
- void *, int32_t , const ecs_type_info_t *info)
19
- {
20
- char *path = ecs_get_path_w_sep (w, 0 , info->component , " ::" , " ::" );
21
- ecs_abort (ECS_INVALID_OPERATION, " cannnot destruct %s, add ~%s::%s()" ,
22
- path, path, ecs_get_name (w, info->component ));
23
- ecs_os_free (path);
11
+ inline void ecs_dtor_illegal (void *, int32_t , const ecs_type_info_t *) {
12
+ ecs_abort (ECS_INVALID_OPERATION, " invalid destructor" );
24
13
}
25
14
26
- inline void ecs_copy_illegal (ecs_world_t * w, const ecs_entity_t *,
27
- const ecs_entity_t *, void *, const void *, int32_t , const ecs_type_info_t *info )
15
+ inline void ecs_copy_illegal (
16
+ void *, const void *, int32_t , const ecs_type_info_t *)
28
17
{
29
- char *path = ecs_get_path_w_sep (w, 0 , info->component , " ::" , " ::" );
30
- ecs_abort (ECS_INVALID_OPERATION,
31
- " cannnot copy assign %s, add %s& %s::operator =(const %s&)" , path,
32
- ecs_get_name (w, info->component ), path, ecs_get_name (w, info->component ), ecs_get_name (w, info->component ));
33
- ecs_os_free (path);
18
+ ecs_abort (ECS_INVALID_OPERATION, " invalid copy assignment" );
34
19
}
35
20
36
- inline void ecs_move_illegal (ecs_world_t * w, const ecs_entity_t *,
37
- const ecs_entity_t *, void *, void *, int32_t , const ecs_type_info_t *info)
38
- {
39
- char *path = ecs_get_path_w_sep (w, 0 , info->component , " ::" , " ::" );
40
- ecs_abort (ECS_INVALID_OPERATION,
41
- " cannnot move assign %s, add %s& %s::operator =(%s&&)" , path,
42
- ecs_get_name (w, info->component ), path, ecs_get_name (w, info->component ), ecs_get_name (w, info->component ));
43
- ecs_os_free (path);
21
+ inline void ecs_move_illegal (void *, void *, int32_t , const ecs_type_info_t *) {
22
+ ecs_abort (ECS_INVALID_OPERATION, " invalid move assignment" );
44
23
}
45
24
46
- inline void ecs_copy_ctor_illegal (ecs_world_t * w,
47
- const ecs_entity_t *, const ecs_entity_t *,
48
- void *, const void *, int32_t , const ecs_type_info_t *info)
25
+ inline void ecs_copy_ctor_illegal (
26
+ void *, const void *, int32_t , const ecs_type_info_t *)
49
27
{
50
- char *path = ecs_get_path_w_sep (w, 0 , info->component , " ::" , " ::" );
51
- ecs_abort (ECS_INVALID_OPERATION,
52
- " cannnot copy construct %s, add %s::%s(const %s&)" ,
53
- path, path, ecs_get_name (w, info->component ), ecs_get_name (w, info->component ));
54
- ecs_os_free (path);
28
+ ecs_abort (ECS_INVALID_OPERATION, " invalid copy construct" );
55
29
}
56
30
57
- inline void ecs_move_ctor_illegal (ecs_world_t * w,
58
- const ecs_entity_t *, const ecs_entity_t *,
59
- void *, void *, int32_t , const ecs_type_info_t *info)
31
+ inline void ecs_move_ctor_illegal (
32
+ void *, void *, int32_t , const ecs_type_info_t *)
60
33
{
61
- char *path = ecs_get_path_w_sep (w, 0 , info->component , " ::" , " ::" );
62
- ecs_abort (ECS_INVALID_OPERATION,
63
- " cannnot move construct %s, add %s::%s(%s&&)" ,
64
- path, path, ecs_get_name (w, info->component ), ecs_get_name (w, info->component ));
65
- ecs_os_free (path);
34
+ ecs_abort (ECS_INVALID_OPERATION, " invalid move construct" );
66
35
}
67
36
68
37
69
38
// T()
70
39
// Can't coexist with T(flecs::entity) or T(flecs::world, flecs::entity)
71
40
template <typename T>
72
- void ctor_impl (
73
- ecs_world_t *, const ecs_entity_t *, void *ptr, int32_t count,
74
- const ecs_type_info_t *info)
75
- {
41
+ void ctor_impl (void *ptr, int32_t count, const ecs_type_info_t *info) {
76
42
(void )info; ecs_assert (info->size == ECS_SIZEOF (T),
77
43
ECS_INTERNAL_ERROR, NULL );
78
44
T *arr = static_cast <T*>(ptr);
@@ -81,18 +47,9 @@ void ctor_impl(
81
47
}
82
48
}
83
49
84
- // T(flecs::world, flecs::entity)
85
- template <typename T>
86
- void ctor_world_entity_impl (
87
- ecs_world_t * world, const ecs_entity_t * ids, void *ptr, int32_t count,
88
- const ecs_type_info_t *info);
89
-
90
50
// ~T()
91
51
template <typename T>
92
- void dtor_impl (
93
- ecs_world_t *, const ecs_entity_t *, void *ptr, int32_t count,
94
- const ecs_type_info_t *info)
95
- {
52
+ void dtor_impl (void *ptr, int32_t count, const ecs_type_info_t *info) {
96
53
(void )info; ecs_assert (info->size == ECS_SIZEOF (T),
97
54
ECS_INTERNAL_ERROR, NULL );
98
55
T *arr = static_cast <T*>(ptr);
@@ -103,9 +60,8 @@ void dtor_impl(
103
60
104
61
// T& operator=(const T&)
105
62
template <typename T>
106
- void copy_impl (
107
- ecs_world_t *, const ecs_entity_t *, const ecs_entity_t *, void *dst_ptr,
108
- const void *src_ptr, int32_t count, const ecs_type_info_t *info)
63
+ void copy_impl (void *dst_ptr, const void *src_ptr, int32_t count,
64
+ const ecs_type_info_t *info)
109
65
{
110
66
(void )info; ecs_assert (info->size == ECS_SIZEOF (T),
111
67
ECS_INTERNAL_ERROR, NULL );
@@ -118,9 +74,8 @@ void copy_impl(
118
74
119
75
// T& operator=(T&&)
120
76
template <typename T>
121
- void move_impl (
122
- ecs_world_t *, const ecs_entity_t *, const ecs_entity_t *, void *dst_ptr,
123
- void *src_ptr, int32_t count, const ecs_type_info_t *info)
77
+ void move_impl (void *dst_ptr, void *src_ptr, int32_t count,
78
+ const ecs_type_info_t *info)
124
79
{
125
80
(void )info; ecs_assert (info->size == ECS_SIZEOF (T),
126
81
ECS_INTERNAL_ERROR, NULL );
@@ -133,9 +88,8 @@ void move_impl(
133
88
134
89
// T(T&)
135
90
template <typename T>
136
- void copy_ctor_impl (
137
- ecs_world_t *, const ecs_entity_t *, const ecs_entity_t *, void *dst_ptr,
138
- const void *src_ptr, int32_t count, const ecs_type_info_t *info)
91
+ void copy_ctor_impl (void *dst_ptr, const void *src_ptr, int32_t count,
92
+ const ecs_type_info_t *info)
139
93
{
140
94
(void )info; ecs_assert (info->size == ECS_SIZEOF (T),
141
95
ECS_INTERNAL_ERROR, NULL );
@@ -148,9 +102,8 @@ void copy_ctor_impl(
148
102
149
103
// T(T&&)
150
104
template <typename T>
151
- void move_ctor_impl (
152
- ecs_world_t *, const ecs_entity_t *, const ecs_entity_t *, void *dst_ptr,
153
- void *src_ptr, int32_t count, const ecs_type_info_t *info)
105
+ void move_ctor_impl (void *dst_ptr, void *src_ptr, int32_t count,
106
+ const ecs_type_info_t *info)
154
107
{
155
108
(void )info; ecs_assert (info->size == ECS_SIZEOF (T),
156
109
ECS_INTERNAL_ERROR, NULL );
@@ -164,9 +117,8 @@ void move_ctor_impl(
164
117
// T(T&&), ~T()
165
118
// Typically used when moving to a new table, and removing from the old table
166
119
template <typename T>
167
- void ctor_move_dtor_impl (
168
- ecs_world_t *, const ecs_entity_t *, const ecs_entity_t *, void *dst_ptr,
169
- void *src_ptr, int32_t count, const ecs_type_info_t *info)
120
+ void ctor_move_dtor_impl (void *dst_ptr, void *src_ptr, int32_t count,
121
+ const ecs_type_info_t *info)
170
122
{
171
123
(void )info; ecs_assert (info->size == ECS_SIZEOF (T),
172
124
ECS_INTERNAL_ERROR, NULL );
@@ -182,9 +134,8 @@ void ctor_move_dtor_impl(
182
134
// Typically used when moving a component to a deleted component
183
135
template <typename T, if_not_t <
184
136
std::is_trivially_move_assignable<T>::value > = 0 >
185
- void move_dtor_impl (
186
- ecs_world_t *, const ecs_entity_t *, const ecs_entity_t *, void *dst_ptr,
187
- void *src_ptr, int32_t count, const ecs_type_info_t *info)
137
+ void move_dtor_impl (void *dst_ptr, void *src_ptr, int32_t count,
138
+ const ecs_type_info_t *info)
188
139
{
189
140
(void )info; ecs_assert (info->size == ECS_SIZEOF (T),
190
141
ECS_INTERNAL_ERROR, NULL );
@@ -203,9 +154,8 @@ void move_dtor_impl(
203
154
// Typically used when moving a component to a deleted component
204
155
template <typename T, if_t <
205
156
std::is_trivially_move_assignable<T>::value > = 0 >
206
- void move_dtor_impl (
207
- ecs_world_t *, const ecs_entity_t *, const ecs_entity_t *, void *dst_ptr,
208
- void *src_ptr, int32_t count, const ecs_type_info_t *info)
157
+ void move_dtor_impl (void *dst_ptr, void *src_ptr, int32_t count,
158
+ const ecs_type_info_t *info)
209
159
{
210
160
(void )info; ecs_assert (info->size == ECS_SIZEOF (T),
211
161
ECS_INTERNAL_ERROR, NULL );
@@ -224,29 +174,11 @@ void move_dtor_impl(
224
174
225
175
} // _
226
176
227
- // Trait to test if type has flecs constructor
228
- template <typename T>
229
- struct has_flecs_ctor {
230
- static constexpr bool value =
231
- std::is_constructible<actual_type_t <T>,
232
- flecs::world&, flecs::entity>::value;
233
- };
234
-
235
177
// Trait to test if type is constructible by flecs
236
178
template <typename T>
237
179
struct is_flecs_constructible {
238
180
static constexpr bool value =
239
- std::is_default_constructible<actual_type_t <T>>::value ||
240
- std::is_constructible<actual_type_t <T>,
241
- flecs::world&, flecs::entity>::value;
242
- };
243
-
244
- // Trait to test if type has a self constructor (flecs::entity, Args...)
245
- template <typename T, typename ... Args>
246
- struct is_self_constructible {
247
- static constexpr bool value =
248
- std::is_constructible<actual_type_t <T>,
249
- flecs::entity, Args...>::value;
181
+ std::is_default_constructible<actual_type_t <T>>::value;
250
182
};
251
183
252
184
namespace _
@@ -260,27 +192,19 @@ ecs_xtor_t ctor() {
260
192
261
193
// Not constructible by flecs
262
194
template <typename T, if_t <
263
- ! std::is_default_constructible<T>::value &&
264
- ! has_flecs_ctor<T>::value > = 0 >
195
+ ! std::is_default_constructible<T>::value > = 0 >
265
196
ecs_xtor_t ctor () {
266
197
return ecs_ctor_illegal;
267
198
}
268
199
269
200
// Default constructible
270
201
template <typename T, if_t <
271
202
! std::is_trivially_constructible<T>::value &&
272
- std::is_default_constructible<T>::value &&
273
- ! has_flecs_ctor<T>::value > = 0 >
203
+ std::is_default_constructible<T>::value > = 0 >
274
204
ecs_xtor_t ctor () {
275
205
return ctor_impl<T>;
276
206
}
277
207
278
- // Flecs constructible: T(flecs::world, flecs::entity)
279
- template <typename T, if_t < has_flecs_ctor<T>::value > = 0 >
280
- ecs_xtor_t ctor () {
281
- return ctor_world_entity_impl<T>;
282
- }
283
-
284
208
// No dtor
285
209
template <typename T, if_t < std::is_trivially_destructible<T>::value > = 0 >
286
210
ecs_xtor_t dtor () {
0 commit comments