From e811be1b778966603c538654742dbf4162fc859d Mon Sep 17 00:00:00 2001 From: Ezekiel Warren Date: Wed, 18 Sep 2024 08:32:26 -0700 Subject: [PATCH] feat: allow export load at runtime (#263) --- ecsact/runtime/async.h | 8 +++++++- ecsact/runtime/core.h | 8 +++++++- ecsact/runtime/dynamic.h | 8 +++++++- ecsact/runtime/meta.h | 8 +++++++- ecsact/runtime/serialize.h | 8 +++++++- ecsact/runtime/static.h | 8 +++++++- 6 files changed, 42 insertions(+), 6 deletions(-) diff --git a/ecsact/runtime/async.h b/ecsact/runtime/async.h index 0df0fdf2..210a549f 100644 --- a/ecsact/runtime/async.h +++ b/ecsact/runtime/async.h @@ -13,7 +13,13 @@ # if defined(ECSACT_ASYNC_API) # define ECSACT_ASYNC_API_FN(ret, name) ECSACT_ASYNC_API ret name # elif defined(ECSACT_ASYNC_API_LOAD_AT_RUNTIME) -# define ECSACT_ASYNC_API_FN(ret, name) ECSACT_EXTERN ret(*name) +# if defined(ECSACT_ASYNC_API_EXPORT) +# define ECSACT_ASYNC_API_FN(ret, name) \ + ECSACT_EXTERN ECSACT_EXPORT(#name) ret(*name) +# else +# define ECSACT_ASYNC_API_FN(ret, name) \ + ECSACT_EXTERN ECSACT_IMPORT("env", #name) ret(*name) +# endif # elif defined(ECSACT_ASYNC_API_EXPORT) # define ECSACT_ASYNC_API_FN(ret, name) \ ECSACT_EXTERN ECSACT_EXPORT(#name) ret name diff --git a/ecsact/runtime/core.h b/ecsact/runtime/core.h index e8efd8c0..9666e010 100644 --- a/ecsact/runtime/core.h +++ b/ecsact/runtime/core.h @@ -14,7 +14,13 @@ # if defined(ECSACT_CORE_API) # define ECSACT_CORE_API_FN(ret, name) ECSACT_CORE_API ret name # elif defined(ECSACT_CORE_API_LOAD_AT_RUNTIME) -# define ECSACT_CORE_API_FN(ret, name) ECSACT_EXTERN ret(*name) +# if defined(ECSACT_CORE_API_EXPORT) +# define ECSACT_CORE_API_FN(ret, name) \ + ECSACT_EXTERN ECSACT_EXPORT(#name) ret(*name) +# else +# define ECSACT_CORE_API_FN(ret, name) \ + ECSACT_EXTERN ECSACT_IMPORT("env", #name) ret(*name) +# endif # elif defined(ECSACT_CORE_API_EXPORT) # define ECSACT_CORE_API_FN(ret, name) \ ECSACT_EXTERN ECSACT_EXPORT(#name) ret name diff --git a/ecsact/runtime/dynamic.h b/ecsact/runtime/dynamic.h index d38fdb83..04499d71 100644 --- a/ecsact/runtime/dynamic.h +++ b/ecsact/runtime/dynamic.h @@ -16,7 +16,13 @@ # if defined(ECSACT_DYNAMIC_API) # define ECSACT_DYNAMIC_API_FN(ret, name) ECSACT_DYNAMIC_API ret name # elif defined(ECSACT_DYNAMIC_API_LOAD_AT_RUNTIME) -# define ECSACT_DYNAMIC_API_FN(ret, name) ECSACT_EXTERN ret(*name) +# if defined(ECSACT_DYNAMIC_API_EXPORT) +# define ECSACT_DYNAMIC_API_FN(ret, name) \ + ECSACT_EXTERN ECSACT_EXPORT(#name) ret(*name) +# else +# define ECSACT_DYNAMIC_API_FN(ret, name) \ + ECSACT_EXTERN ECSACT_IMPORT("env", #name) ret(*name) +# endif # elif defined(ECSACT_DYNAMIC_API_EXPORT) # define ECSACT_DYNAMIC_API_FN(ret, name) \ ECSACT_EXTERN ECSACT_EXPORT(#name) ret name diff --git a/ecsact/runtime/meta.h b/ecsact/runtime/meta.h index cbbf77ee..c5d5dc02 100644 --- a/ecsact/runtime/meta.h +++ b/ecsact/runtime/meta.h @@ -14,7 +14,13 @@ # if defined(ECSACT_META_API) # define ECSACT_META_API_FN(ret, name) ECSACT_META_API ret name # elif defined(ECSACT_META_API_LOAD_AT_RUNTIME) -# define ECSACT_META_API_FN(ret, name) ECSACT_EXTERN ret(*name) +# if defined(ECSACT_META_API_EXPORT) +# define ECSACT_META_API_FN(ret, name) \ + ECSACT_EXTERN ECSACT_EXPORT(#name) ret(*name) +# else +# define ECSACT_META_API_FN(ret, name) \ + ECSACT_EXTERN ECSACT_IMPORT("env", #name) ret(*name) +# endif # elif defined(ECSACT_META_API_EXPORT) # define ECSACT_META_API_FN(ret, name) \ ECSACT_EXTERN ECSACT_EXPORT(#name) ret name diff --git a/ecsact/runtime/serialize.h b/ecsact/runtime/serialize.h index 5bacadaf..59d8ff7a 100644 --- a/ecsact/runtime/serialize.h +++ b/ecsact/runtime/serialize.h @@ -13,7 +13,13 @@ # if defined(ECSACT_SERIALIZE_API) # define ECSACT_SERIALIZE_API_FN(ret, name) ECSACT_SERIALIZE_API ret name # elif defined(ECSACT_SERIALIZE_API_LOAD_AT_RUNTIME) -# define ECSACT_SERIALIZE_API_FN(ret, name) ECSACT_EXTERN ret(*name) +# if defined(ECSACT_SERIALIZE_API_EXPORT) +# define ECSACT_SERIALIZE_API_FN(ret, name) \ + ECSACT_EXTERN ECSACT_EXPORT(#name) ret(*name) +# else +# define ECSACT_SERIALIZE_API_FN(ret, name) \ + ECSACT_EXTERN ECSACT_IMPORT("env", #name) ret(*name) +# endif # elif defined(ECSACT_SERIALIZE_API_EXPORT) # define ECSACT_SERIALIZE_API_FN(ret, name) \ ECSACT_EXTERN ECSACT_EXPORT(#name) ret name diff --git a/ecsact/runtime/static.h b/ecsact/runtime/static.h index abcf5a94..38feb483 100644 --- a/ecsact/runtime/static.h +++ b/ecsact/runtime/static.h @@ -13,7 +13,13 @@ # if defined(ECSACT_STATIC_API) # define ECSACT_STATIC_API_FN(ret, name) ECSACT_STATIC_API ret name # elif defined(ECSACT_STATIC_API_LOAD_AT_RUNTIME) -# define ECSACT_STATIC_API_FN(ret, name) ECSACT_EXTERN ret(*name) +# if defined(ECSACT_STATIC_API_EXPORT) +# define ECSACT_STATIC_API_FN(ret, name) \ + ECSACT_EXTERN ECSACT_EXPORT(#name) ret(*name) +# else +# define ECSACT_STATIC_API_FN(ret, name) \ + ECSACT_EXTERN ECSACT_IMPORT("env", #name) ret(*name) +# endif # elif defined(ECSACT_STATIC_API_EXPORT) # define ECSACT_STATIC_API_FN(ret, name) \ ECSACT_EXTERN ECSACT_EXPORT(#name) ret name