Skip to content

Commit 3344bd6

Browse files
committed
Fix issue where Script component couldn't be used in builds with FLECS_CPP_NO_AUTO_REGISTRATION
1 parent 4dcc63e commit 3344bd6

File tree

4 files changed

+26
-0
lines changed

4 files changed

+26
-0
lines changed

include/flecs/addons/cpp/impl/world.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ inline void world::init_builtin_components() {
4242
# ifdef FLECS_META
4343
meta::_::init(*this);
4444
# endif
45+
# ifdef FLECS_SCRIPT
46+
script::_::init(*this);
47+
# endif
4548
}
4649

4750
template <typename T>

include/flecs/addons/cpp/mixins/script/decl.hpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,14 @@ struct script_builder;
2020

2121
using Script = EcsScript;
2222

23+
namespace script {
24+
namespace _ {
25+
26+
void init(flecs::world& world);
27+
28+
} // namespace _
29+
}
30+
2331
/** @} */
2432

2533
}

include/flecs/addons/cpp/mixins/script/impl.hpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ inline flecs::entity script_builder::run() const {
1616
}
1717

1818
namespace _ {
19+
1920
inline ecs_value_t get_const_var(const flecs::world_t *world, const char *name) {
2021
flecs::entity_t v = ecs_lookup_path_w_sep(
2122
world, 0, name, "::", "::", false);
@@ -188,4 +189,15 @@ void world::get_const_var(
188189
world_, name, value, type, default_value);
189190
}
190191

192+
193+
namespace script {
194+
namespace _ {
195+
196+
inline void init(flecs::world& world) {
197+
world.component<Script>("flecs::script::Script");
198+
}
199+
200+
}
201+
}
202+
191203
}

test/custom_builds/cpp/no_auto_registration/src/main.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,5 +208,8 @@ int main(int, char *[]) {
208208
world.id<flecs::units::Bel>();
209209
world.id<flecs::units::DeciBel>();
210210

211+
// script
212+
world.id<flecs::Script>();
213+
211214
return 0;
212215
}

0 commit comments

Comments
 (0)