Skip to content

fix: force inline for c++ wrappers #231

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 44 additions & 26 deletions MODULE.bazel.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 12 additions & 8 deletions ecsact/runtime/async.hh
Original file line number Diff line number Diff line change
Expand Up @@ -139,35 +139,37 @@ private:
}
};

[[nodiscard]] inline auto connect( //
[[nodiscard]] ECSACT_ALWAYS_INLINE auto connect(
const std::string& connection_string
) -> ecsact_async_request_id {
return ecsact_async_connect(connection_string.c_str());
}

inline auto disconnect() -> void {
ECSACT_ALWAYS_INLINE auto disconnect() -> void {
ecsact_async_disconnect();
}

[[nodiscard]] inline auto get_current_tick() -> int32_t {
[[nodiscard]] ECSACT_ALWAYS_INLINE auto get_current_tick() -> int32_t {
return ecsact_async_get_current_tick();
}

[[nodiscard]] inline auto enqueue_execution_options(
[[nodiscard]] ECSACT_ALWAYS_INLINE auto enqueue_execution_options(
ecsact::core::execution_options& options
) -> ecsact_async_request_id {
return ecsact_async_enqueue_execution_options(options.c());
}

inline auto flush_events() -> void {
ECSACT_ALWAYS_INLINE auto flush_events() -> void {
ecsact_async_flush_events(nullptr, nullptr);
}

template<typename ExecutionEventsCollector>
requires(std::convertible_to<
decltype(std::declval<ExecutionEventsCollector>().c()),
const ecsact_execution_events_collector>)
inline auto flush_events(ExecutionEventsCollector&& evc) -> void {
ECSACT_ALWAYS_INLINE auto flush_events( //
ExecutionEventsCollector&& evc
) -> void {
const ecsact_execution_events_collector evc_c = evc.c();
ecsact_async_flush_events(&evc_c, nullptr);
}
Expand All @@ -176,13 +178,15 @@ template<typename AsyncEventsCollector>
requires(std::convertible_to<
decltype(std::declval<AsyncEventsCollector>().c()),
const ecsact_async_events_collector>)
inline auto flush_events(AsyncEventsCollector&& async_evc) -> void {
ECSACT_ALWAYS_INLINE auto flush_events( //
AsyncEventsCollector&& async_evc
) -> void {
const ecsact_async_events_collector async_evc_c = async_evc.c();
ecsact_async_flush_events(nullptr, &async_evc_c);
}

template<typename ExecutionEventsCollector, typename AsyncEventsCollector>
inline auto flush_events(
ECSACT_ALWAYS_INLINE auto flush_events(
ExecutionEventsCollector&& evc,
AsyncEventsCollector&& async_evc
) -> void {
Expand Down
21 changes: 13 additions & 8 deletions ecsact/runtime/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@
# define ECSACT_IMPORT(ImportModule, ImportName)
#endif

#ifdef _MSC_VER
# define ECSACT_ALWAYS_INLINE __forceinline
#else
# define ECSACT_ALWAYS_INLINE __attribute__((always_inline))
#endif

ECSACT_TYPED_ID(ecsact_package_id);
ECSACT_TYPED_ID(ecsact_system_id);
ECSACT_TYPED_ID(ecsact_action_id);
Expand All @@ -50,13 +56,13 @@ ECSACT_TYPED_ID(ecsact_component_like_id);
#ifdef __cplusplus
template<typename To, typename From>
To ecsact_id_cast(From);
# define ECSACT_CAST_ID_FN(From, To) \
template<> \
inline To ecsact_id_cast<To, From>(From id) { \
return (To)id; \
# define ECSACT_CAST_ID_FN(From, To) \
template<> \
ECSACT_ALWAYS_INLINE To ecsact_id_cast<To, From>(From id) { \
return (To)id; \
}
#else
inline int32_t ecsact_id_cast(int32_t id) {
ECSACT_ALWAYS_INLINE int32_t ecsact_id_cast(int32_t id) {
return id;
}

Expand Down Expand Up @@ -361,9 +367,8 @@ typedef int (*ecsact_action_compare_fn_t)(const void* a, const void* b);
* necessary function. Any 32 bit integer >=0 is a valid placeholder entity ID.
* Integers <0 are reserved as special placeholder IDs.
*/
inline ecsact_placeholder_entity_id ecsact_util_make_placeholder_entity_id(
int32_t id
) {
ECSACT_ALWAYS_INLINE ecsact_placeholder_entity_id
ecsact_util_make_placeholder_entity_id(int32_t id) {
return (ecsact_placeholder_entity_id)id;
}

Expand Down
Loading