Skip to content

Commit 10341dc

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 d568662 commit 10341dc

File tree

6 files changed

+176
-120
lines changed

6 files changed

+176
-120
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: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -139,35 +139,37 @@ private:
139139
}
140140
};
141141

142-
[[nodiscard]] inline auto connect( //
142+
[[nodiscard]] ECSACT_ALWAYS_INLINE auto connect(
143143
const std::string& connection_string
144144
) -> ecsact_async_request_id {
145145
return ecsact_async_connect(connection_string.c_str());
146146
}
147147

148-
inline auto disconnect() -> void {
148+
ECSACT_ALWAYS_INLINE auto disconnect() -> void {
149149
ecsact_async_disconnect();
150150
}
151151

152-
[[nodiscard]] inline auto get_current_tick() -> int32_t {
152+
[[nodiscard]] ECSACT_ALWAYS_INLINE auto get_current_tick() -> int32_t {
153153
return ecsact_async_get_current_tick();
154154
}
155155

156-
[[nodiscard]] inline auto enqueue_execution_options(
156+
[[nodiscard]] ECSACT_ALWAYS_INLINE auto enqueue_execution_options(
157157
ecsact::core::execution_options& options
158158
) -> ecsact_async_request_id {
159159
return ecsact_async_enqueue_execution_options(options.c());
160160
}
161161

162-
inline auto flush_events() -> void {
162+
ECSACT_ALWAYS_INLINE auto flush_events() -> void {
163163
ecsact_async_flush_events(nullptr, nullptr);
164164
}
165165

166166
template<typename ExecutionEventsCollector>
167167
requires(std::convertible_to<
168168
decltype(std::declval<ExecutionEventsCollector>().c()),
169169
const ecsact_execution_events_collector>)
170-
inline auto flush_events(ExecutionEventsCollector&& evc) -> void {
170+
ECSACT_ALWAYS_INLINE auto flush_events( //
171+
ExecutionEventsCollector&& evc
172+
) -> void {
171173
const ecsact_execution_events_collector evc_c = evc.c();
172174
ecsact_async_flush_events(&evc_c, nullptr);
173175
}
@@ -176,13 +178,15 @@ template<typename AsyncEventsCollector>
176178
requires(std::convertible_to<
177179
decltype(std::declval<AsyncEventsCollector>().c()),
178180
const ecsact_async_events_collector>)
179-
inline auto flush_events(AsyncEventsCollector&& async_evc) -> void {
181+
ECSACT_ALWAYS_INLINE auto flush_events( //
182+
AsyncEventsCollector&& async_evc
183+
) -> void {
180184
const ecsact_async_events_collector async_evc_c = async_evc.c();
181185
ecsact_async_flush_events(nullptr, &async_evc_c);
182186
}
183187

184188
template<typename ExecutionEventsCollector, typename AsyncEventsCollector>
185-
inline auto flush_events(
189+
ECSACT_ALWAYS_INLINE auto flush_events(
186190
ExecutionEventsCollector&& evc,
187191
AsyncEventsCollector&& async_evc
188192
) -> 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)