Skip to content

Commit 7b30a1a

Browse files
authored
Add template availablility for untyped component constants and bits
1 parent c79a34c commit 7b30a1a

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

include/flecs/addons/cpp/mixins/meta/untyped_component.inl

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -188,9 +188,11 @@ untyped_component& member(
188188
}
189189

190190
/** Add constant. */
191+
template <typename T = int32_t>
191192
untyped_component& constant(
192193
const char *name,
193-
int32_t value)
194+
T value,
195+
flecs::entity_t TId = flecs::I32)
194196
{
195197
ecs_add_id(world_, id_, _::type<flecs::Enum>::id(world_));
196198

@@ -201,16 +203,18 @@ untyped_component& constant(
201203
ecs_assert(eid != 0, ECS_INTERNAL_ERROR, NULL);
202204

203205
ecs_set_id(world_, eid,
204-
ecs_pair(flecs::Constant, flecs::I32), sizeof(int32_t),
206+
ecs_pair(flecs::Constant, TId), sizeof(T),
205207
&value);
206208

207209
return *this;
208210
}
209211

210212
/** Add bitmask constant. */
213+
template <typename T = uint32_t>
211214
untyped_component& bit(
212215
const char *name,
213-
uint32_t value)
216+
uint32_t value
217+
flecs::entity_t TId = flecs::U32)
214218
{
215219
ecs_add_id(world_, id_, _::type<flecs::Bitmask>::id(world_));
216220

@@ -221,12 +225,11 @@ untyped_component& bit(
221225
ecs_assert(eid != 0, ECS_INTERNAL_ERROR, NULL);
222226

223227
ecs_set_id(world_, eid,
224-
ecs_pair(flecs::Constant, flecs::U32), sizeof(uint32_t),
228+
ecs_pair(flecs::Constant, TId), sizeof(T),
225229
&value);
226230

227231
return *this;
228232
}
229-
230233
/** Register array metadata for component */
231234
template <typename Elem>
232235
untyped_component& array(

0 commit comments

Comments
 (0)