Skip to content

Commit

Permalink
fix: use correct macro in async header (#265)
Browse files Browse the repository at this point in the history
  • Loading branch information
zaucy authored Oct 14, 2024
1 parent b034c85 commit dbce850
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 14 deletions.
13 changes: 9 additions & 4 deletions dylib/dylib.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include <cstring>
#include <cassert>
#include <type_traits>
#include "ecsact/runtime/dylib.h"

#ifdef ECSACT_ASYNC_API_LOAD_AT_RUNTIME
Expand Down Expand Up @@ -47,10 +48,14 @@ FOR_EACH_ECSACT_SERIALIZE_API_FN(ECSACT_DYLIB_UTIL_FN_PTR_DEFN);
#define HAS_FN_CHECK(fn_name, target_fn_name) \
if(std::strcmp(target_fn_name, #fn_name) == 0) return true

#define ASSIGN_FN_IF(fn_name, target_fn_name, fn_ptr) \
if(std::strcmp(#fn_name, target_fn_name) == 0) { \
fn_name = reinterpret_cast<decltype(fn_name)>(fn_ptr); \
} \
#define ASSIGN_FN_IF(fn_name, target_fn_name, fn_ptr) \
static_assert( \
std::is_pointer_v<decltype(fn_name)>, \
"Ecsact dylib may only be used for functions available at runtime" \
); \
if(std::strcmp(#fn_name, target_fn_name) == 0) { \
fn_name = reinterpret_cast<decltype(fn_name)>(fn_ptr); \
} \
static_assert(true, "macro requires ;")

bool ecsact_dylib_has_fn(const char* fn_name) {
Expand Down
1 change: 1 addition & 0 deletions dylib/index.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ def cc_ecsact_dylib(name = None, srcs = [], ecsact_modules = [], deps = [], defi
name = name,
deps = deps + ["@ecsact_runtime//:dylib", "@ecsact_runtime//dylib:util"] + ["@ecsact_runtime//:{}".format(m) for m in ecsact_modules],
srcs = srcs + ["@ecsact_runtime//dylib:dylib.cc"],
local_defines = ["ECSACT_{}_API_EXPORT".format(m.upper()) for m in ecsact_modules],
defines = #
defines +
["ECSACT_{}_API_LOAD_AT_RUNTIME".format(m.upper()) for m in ecsact_modules],
Expand Down
22 changes: 12 additions & 10 deletions ecsact/runtime/async.h
Original file line number Diff line number Diff line change
Expand Up @@ -213,22 +213,24 @@ ECSACT_ASYNC_API_FN(int32_t, ecsact_async_get_current_tick)(void);
* fields must be supplied as a sequential array in declaration order,
* otherwise may be NULL.
*/
ECSACT_CORE_API_FN(ecsact_async_request_id, ecsact_async_stream)
ECSACT_ASYNC_API_FN(ecsact_async_request_id, ecsact_async_stream)
( //
ecsact_entity_id entity,
ecsact_component_id component_id,
const void* component_data,
const void* indexed_field_values
);

#define FOR_EACH_ECSACT_ASYNC_API_FN(fn, ...) \
fn(ecsact_async_enqueue_execution_options, __VA_ARGS__); \
fn(ecsact_async_flush_events, __VA_ARGS__); \
fn(ecsact_async_connect, __VA_ARGS__); \
fn(ecsact_async_disconnect, __VA_ARGS__); \
fn(ecsact_async_get_current_tick, __VA_ARGS__); \
fn(ecsact_async_stream, __VA_ARGS__)
#ifdef ECSACT_MSVC_TRADITIONAL
# define FOR_EACH_ECSACT_ASYNC_API_FN(fn, ...) ECSACT_MSVC_TRADITIONAL_ERROR()
#else
# define FOR_EACH_ECSACT_ASYNC_API_FN(fn, ...) \
fn(ecsact_async_enqueue_execution_options, __VA_ARGS__); \
fn(ecsact_async_flush_events, __VA_ARGS__); \
fn(ecsact_async_connect, __VA_ARGS__); \
fn(ecsact_async_disconnect, __VA_ARGS__); \
fn(ecsact_async_get_current_tick, __VA_ARGS__); \
fn(ecsact_async_stream, __VA_ARGS__)
#endif

#undef ECSACT_ASYNC_API
#undef ECSACT_ASYNC_API_FN
#endif // ECSACT_RUNTIME_ASYNC_H

0 comments on commit dbce850

Please sign in to comment.