Skip to content

Commit 10d36d5

Browse files
committed
fix: force inline for c++ wrappers
* this should help with some linking errors where the wrong ecsact function would be used
1 parent 77c4df8 commit 10d36d5

File tree

6 files changed

+201
-142
lines changed

6 files changed

+201
-142
lines changed

MODULE.bazel.lock

Lines changed: 44 additions & 26 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ecsact/runtime/async.hh

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ public:
2626
* Set async error callback. If callback is already set it will be
2727
* overwritten.
2828
*/
29-
auto set_async_error_callback(async_error_callback_t callback)
30-
-> async_events_collector& {
29+
auto set_async_error_callback(async_error_callback_t callback
30+
) -> async_events_collector& {
3131
_async_error_cb = std::move(callback);
3232
return *this;
3333
}
@@ -36,8 +36,8 @@ public:
3636
* Set async error callback. If callback is already set it will be
3737
* overwritten.
3838
*/
39-
auto set_system_error_callback(system_error_callback_t callback)
40-
-> async_events_collector& {
39+
auto set_system_error_callback(system_error_callback_t callback
40+
) -> async_events_collector& {
4141
_system_error_cb = std::move(callback);
4242
return *this;
4343
}
@@ -46,8 +46,8 @@ public:
4646
* Set async error callback. If callback is already set it will be
4747
* overwritten.
4848
*/
49-
auto set_async_requests_done_callback(async_requests_done_callback_t callback)
50-
-> async_events_collector& {
49+
auto set_async_requests_done_callback(async_requests_done_callback_t callback
50+
) -> async_events_collector& {
5151
_async_requests_done_cb = std::move(callback);
5252
return *this;
5353
}
@@ -136,49 +136,51 @@ private:
136136
}
137137
};
138138

139-
[[nodiscard]] inline auto connect(const std::string& connection_string)
140-
-> ecsact_async_request_id {
139+
[[nodiscard]] ECSACT_ALWAYS_INLINE auto connect(
140+
const std::string& connection_string
141+
) -> ecsact_async_request_id {
141142
return ecsact_async_connect(connection_string.c_str());
142143
}
143144

144-
inline auto disconnect() -> void {
145+
ECSACT_ALWAYS_INLINE auto disconnect() -> void {
145146
ecsact_async_disconnect();
146147
}
147148

148-
[[nodiscard]] inline auto get_current_tick() -> int32_t {
149+
[[nodiscard]] ECSACT_ALWAYS_INLINE auto get_current_tick() -> int32_t {
149150
return ecsact_async_get_current_tick();
150151
}
151152

152-
[[nodiscard]] inline auto enqueue_execution_options(
153+
[[nodiscard]] ECSACT_ALWAYS_INLINE auto enqueue_execution_options(
153154
ecsact::core::execution_options& options
154155
) -> ecsact_async_request_id {
155156
return ecsact_async_enqueue_execution_options(options.c());
156157
}
157158

158-
inline auto flush_events() -> void {
159+
ECSACT_ALWAYS_INLINE auto flush_events() -> void {
159160
ecsact_async_flush_events(nullptr, nullptr);
160161
}
161162

162163
template<typename ExecutionEventsCollector>
163164
requires(std::convertible_to<
164-
decltype(std::declval<ExecutionEventsCollector>().c()),
165-
const ecsact_execution_events_collector>)
166-
inline auto flush_events(ExecutionEventsCollector&& evc) -> void {
165+
decltype(std::declval<ExecutionEventsCollector>().c()),
166+
const ecsact_execution_events_collector>)
167+
ECSACT_ALWAYS_INLINE auto flush_events(ExecutionEventsCollector&& evc) -> void {
167168
const ecsact_execution_events_collector evc_c = evc.c();
168169
ecsact_async_flush_events(&evc_c, nullptr);
169170
}
170171

171172
template<typename AsyncEventsCollector>
172173
requires(std::convertible_to<
173-
decltype(std::declval<AsyncEventsCollector>().c()),
174-
const ecsact_async_events_collector>)
175-
inline auto flush_events(AsyncEventsCollector&& async_evc) -> void {
174+
decltype(std::declval<AsyncEventsCollector>().c()),
175+
const ecsact_async_events_collector>)
176+
ECSACT_ALWAYS_INLINE auto flush_events(AsyncEventsCollector&& async_evc
177+
) -> void {
176178
const ecsact_async_events_collector async_evc_c = async_evc.c();
177179
ecsact_async_flush_events(nullptr, &async_evc_c);
178180
}
179181

180182
template<typename ExecutionEventsCollector, typename AsyncEventsCollector>
181-
inline auto flush_events(
183+
ECSACT_ALWAYS_INLINE auto flush_events(
182184
ExecutionEventsCollector&& evc,
183185
AsyncEventsCollector&& async_evc
184186
) -> void {

ecsact/runtime/common.h

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@
2727
# define ECSACT_IMPORT(ImportModule, ImportName)
2828
#endif
2929

30+
#ifdef _MSC_VER
31+
# define ECSACT_ALWAYS_INLINE __forceinline
32+
#else
33+
# define ECSACT_ALWAYS_INLINE __attribute__((always_inline))
34+
#endif
35+
3036
ECSACT_TYPED_ID(ecsact_package_id);
3137
ECSACT_TYPED_ID(ecsact_system_id);
3238
ECSACT_TYPED_ID(ecsact_action_id);
@@ -50,13 +56,13 @@ ECSACT_TYPED_ID(ecsact_component_like_id);
5056
#ifdef __cplusplus
5157
template<typename To, typename From>
5258
To ecsact_id_cast(From);
53-
# define ECSACT_CAST_ID_FN(From, To) \
54-
template<> \
55-
inline To ecsact_id_cast<To, From>(From id) { \
56-
return (To)id; \
59+
# define ECSACT_CAST_ID_FN(From, To) \
60+
template<> \
61+
ECSACT_ALWAYS_INLINE To ecsact_id_cast<To, From>(From id) { \
62+
return (To)id; \
5763
}
5864
#else
59-
inline int32_t ecsact_id_cast(int32_t id) {
65+
ECSACT_ALWAYS_INLINE int32_t ecsact_id_cast(int32_t id) {
6066
return id;
6167
}
6268

@@ -361,9 +367,8 @@ typedef int (*ecsact_action_compare_fn_t)(const void* a, const void* b);
361367
* necessary function. Any 32 bit integer >=0 is a valid placeholder entity ID.
362368
* Integers <0 are reserved as special placeholder IDs.
363369
*/
364-
inline ecsact_placeholder_entity_id ecsact_util_make_placeholder_entity_id(
365-
int32_t id
366-
) {
370+
ECSACT_ALWAYS_INLINE ecsact_placeholder_entity_id
371+
ecsact_util_make_placeholder_entity_id(int32_t id) {
367372
return (ecsact_placeholder_entity_id)id;
368373
}
369374

0 commit comments

Comments
 (0)