Skip to content

Commit 0453793

Browse files
committed
improve dynamic loading example
1 parent afc15a9 commit 0453793

File tree

6 files changed

+37
-55
lines changed

6 files changed

+37
-55
lines changed

include/boost/openmethod/core.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ struct use_class_aux<Registry, mp11::mp_list<Class, Bases...>>
330330
: std::conditional_t<
331331
Registry::has_deferred_static_rtti, detail::deferred_class_info,
332332
detail::class_info> {
333-
static BOOST_OPENMETHOD_DECLSPEC type_id bases[sizeof...(Bases)];
333+
static type_id bases[sizeof...(Bases)];
334334
use_class_aux() {
335335
this->first_base = bases;
336336
this->last_base = bases + sizeof...(Bases);
@@ -2189,7 +2189,7 @@ class method<Id, ReturnType(Parameters...), Registry>
21892189
//!
21902190
//! @tparam Fn A function that is an overrider of the method.
21912191
template<auto Fn>
2192-
static BOOST_OPENMETHOD_DECLSPEC FunctionPointer next;
2192+
static FunctionPointer next;
21932193

21942194
//! Add overriders to method
21952195
//!
@@ -2305,7 +2305,7 @@ class method<Id, ReturnType(Parameters...), Registry>
23052305
explicit override_impl(FunctionPointer* next = nullptr);
23062306
void resolve_type_ids();
23072307

2308-
static BOOST_OPENMETHOD_DECLSPEC type_id vp_type_ids[Arity];
2308+
static type_id vp_type_ids[Arity];
23092309
};
23102310

23112311
template<auto Function, typename FunctionType>
@@ -2317,7 +2317,7 @@ class method<Id, ReturnType(Parameters...), Registry>
23172317
(void)&impl;
23182318
}
23192319

2320-
static BOOST_OPENMETHOD_DECLSPEC override_impl<Function, FnReturnType>
2320+
static override_impl<Function, FnReturnType>
23212321
impl;
23222322
};
23232323
};

include/boost/openmethod/macros.hpp

Lines changed: 20 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -55,40 +55,28 @@ struct va_args<ReturnType> {
5555
#define BOOST_OPENMETHOD_GUIDE(NAME) \
5656
BOOST_PP_CAT(BOOST_OPENMETHOD_ID(NAME), _guide)
5757

58+
#define BOOST_OPENMETHOD_TYPE(NAME, ARGS, ...) \
59+
::boost::openmethod::method< \
60+
BOOST_OPENMETHOD_ID(NAME), \
61+
::boost::openmethod::detail::va_args<__VA_ARGS__>::return_type ARGS, \
62+
::boost::openmethod::detail::va_args<__VA_ARGS__>::registry>
63+
5864
#define BOOST_OPENMETHOD(NAME, ARGS, ...) \
5965
struct BOOST_OPENMETHOD_ID(NAME); \
6066
template<typename... ForwarderParameters> \
6167
typename ::boost::openmethod::detail::enable_forwarder< \
62-
void, \
63-
::boost::openmethod::method< \
64-
BOOST_OPENMETHOD_ID(NAME), \
65-
::boost::openmethod::detail::va_args<__VA_ARGS__>::return_type \
66-
ARGS, \
67-
::boost::openmethod::detail::va_args<__VA_ARGS__>::registry>, \
68-
typename ::boost::openmethod::method< \
69-
BOOST_OPENMETHOD_ID(NAME), \
70-
::boost::openmethod::detail::va_args<__VA_ARGS__>::return_type \
71-
ARGS, \
72-
::boost::openmethod::detail::va_args<__VA_ARGS__>::registry>, \
68+
void, BOOST_OPENMETHOD_TYPE(NAME, ARGS, __VA_ARGS__), \
69+
typename BOOST_OPENMETHOD_TYPE(NAME, ARGS, __VA_ARGS__), \
7370
ForwarderParameters...>::type \
7471
BOOST_OPENMETHOD_GUIDE(NAME)(ForwarderParameters && ... args); \
7572
template<typename... ForwarderParameters> \
76-
inline auto NAME(ForwarderParameters&&... args) -> \
77-
typename ::boost::openmethod::detail::enable_forwarder< \
78-
void, \
79-
::boost::openmethod::method< \
80-
BOOST_OPENMETHOD_ID(NAME), \
81-
::boost::openmethod::detail::va_args<__VA_ARGS__>::return_type \
82-
ARGS, \
83-
::boost::openmethod::detail::va_args<__VA_ARGS__>::registry>, \
73+
inline auto NAME(ForwarderParameters&&... args) \
74+
->typename ::boost::openmethod::detail::enable_forwarder< \
75+
void, BOOST_OPENMETHOD_TYPE(NAME, ARGS, __VA_ARGS__), \
8476
::boost::openmethod::detail::va_args<__VA_ARGS__>::return_type, \
8577
ForwarderParameters...>::type { \
86-
return ::boost::openmethod::method< \
87-
BOOST_OPENMETHOD_ID(NAME), \
88-
::boost::openmethod::detail::va_args<__VA_ARGS__>::return_type \
89-
ARGS, \
90-
::boost::openmethod::detail::va_args<__VA_ARGS__>::registry>:: \
91-
fn(std::forward<ForwarderParameters>(args)...); \
78+
return BOOST_OPENMETHOD_TYPE(NAME, ARGS, __VA_ARGS__)::fn( \
79+
std::forward<ForwarderParameters>(args)...); \
9280
}
9381

9482
#define BOOST_OPENMETHOD_DETAIL_LOCATE_METHOD(NAME, ARGS) \
@@ -106,19 +94,21 @@ struct va_args<ReturnType> {
10694
template<> \
10795
struct BOOST_OPENMETHOD_OVERRIDERS(NAME)<__VA_ARGS__ ARGS> { \
10896
BOOST_OPENMETHOD_DETAIL_LOCATE_METHOD(NAME, ARGS); \
109-
static auto fn ARGS->__VA_ARGS__; \
97+
static auto fn ARGS -> __VA_ARGS__; \
11098
static auto has_next() -> bool; \
11199
template<typename... Args> \
112100
static auto next(Args&&... args) -> decltype(auto); \
113101
}; \
114102
inline auto BOOST_OPENMETHOD_OVERRIDERS( \
115-
NAME)<__VA_ARGS__ ARGS>::has_next() -> bool { \
103+
NAME)<__VA_ARGS__ ARGS>::has_next() \
104+
->bool { \
116105
return boost_openmethod_detail_locate_method_aux< \
117106
void ARGS>::type::has_next<fn>(); \
118107
} \
119108
template<typename... Args> \
120109
inline auto BOOST_OPENMETHOD_OVERRIDERS(NAME)<__VA_ARGS__ ARGS>::next( \
121-
Args&&... args) -> decltype(auto) { \
110+
Args&&... args) \
111+
->decltype(auto) { \
122112
BOOST_ASSERT(has_next()); \
123113
return boost_openmethod_detail_locate_method_aux< \
124114
void ARGS>::type::next<fn>(std::forward<Args>(args)...); \
@@ -134,7 +124,7 @@ struct va_args<ReturnType> {
134124
#define BOOST_OPENMETHOD_DEFINE_OVERRIDER(NAME, ARGS, ...) \
135125
BOOST_OPENMETHOD_DETAIL_REGISTER_OVERRIDER(NAME, ARGS, __VA_ARGS__) \
136126
auto BOOST_OPENMETHOD_OVERRIDER(NAME, ARGS, __VA_ARGS__)::fn ARGS \
137-
-> boost::mp11::mp_back<boost::mp11::mp_list<__VA_ARGS__>>
127+
->boost::mp11::mp_back<boost::mp11::mp_list<__VA_ARGS__>>
138128

139129
#define BOOST_OPENMETHOD_OVERRIDE(NAME, ARGS, ...) \
140130
BOOST_OPENMETHOD_DECLARE_OVERRIDER(NAME, ARGS, __VA_ARGS__) \
@@ -144,7 +134,7 @@ struct va_args<ReturnType> {
144134
BOOST_OPENMETHOD_DECLARE_OVERRIDER(NAME, ARGS, __VA_ARGS__) \
145135
BOOST_OPENMETHOD_DETAIL_REGISTER_OVERRIDER(NAME, ARGS, __VA_ARGS__) \
146136
inline auto BOOST_OPENMETHOD_OVERRIDER(NAME, ARGS, __VA_ARGS__)::fn ARGS \
147-
-> boost::mp11::mp_back<boost::mp11::mp_list<__VA_ARGS__>>
137+
->boost::mp11::mp_back<boost::mp11::mp_list<__VA_ARGS__>>
148138

149139
#define BOOST_OPENMETHOD_CLASSES(...) \
150140
BOOST_OPENMETHOD_REGISTER(::boost::openmethod::use_classes<__VA_ARGS__>);

include/boost/openmethod/policies/default_error_handler.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ struct default_error_handler : error_handler {
119119
}
120120

121121
private:
122-
static BOOST_OPENMETHOD_DECLSPEC function_type handler;
122+
static function_type handler;
123123
};
124124
};
125125

include/boost/openmethod/policies/fast_perfect_hash.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,10 @@ struct fast_perfect_hash : type_hash {
7373
//! @tparam Registry The registry containing this policy
7474
template<class Registry>
7575
class fn {
76-
static BOOST_OPENMETHOD_DECLSPEC std::size_t mult;
77-
static BOOST_OPENMETHOD_DECLSPEC std::size_t shift;
78-
static BOOST_OPENMETHOD_DECLSPEC std::size_t min_value;
79-
static BOOST_OPENMETHOD_DECLSPEC std::size_t max_value;
76+
static std::size_t mult;
77+
static std::size_t shift;
78+
static std::size_t min_value;
79+
static std::size_t max_value;
8080

8181
static void check(std::size_t index, type_id type);
8282

include/boost/openmethod/policies/stderr_output.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ struct stderr_output : output {
1919
template<class Registry>
2020
struct fn {
2121
//! A @ref LightweightOuputStream.
22-
static BOOST_OPENMETHOD_DECLSPEC detail::ostderr os;
22+
static detail::ostderr os;
2323
};
2424
};
2525

include/boost/openmethod/preamble.hpp

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,6 @@
1515
#pragma warning(disable : 4702)
1616
#endif
1717

18-
#ifdef BOOST_OPENMETHOD_EXPORT
19-
#define BOOST_OPENMETHOD_DECLSPEC __declspec(dllexport)
20-
#elif defined(BOOST_OPENMETHOD_IMPORT)
21-
#define BOOST_OPENMETHOD_DECLSPEC __declspec(dllimport)
22-
#else
23-
#define BOOST_OPENMETHOD_DECLSPEC
24-
#endif
25-
2618
namespace boost::openmethod {
2719

2820
namespace detail {
@@ -97,9 +89,9 @@ struct odr_violation : openmethod_error {
9789

9890
template<class Registry>
9991
struct odr_check {
100-
static BOOST_OPENMETHOD_DECLSPEC std::size_t count;
92+
static std::size_t count;
10193
template<class R>
102-
static BOOST_OPENMETHOD_DECLSPEC std::size_t inc;
94+
static std::size_t inc;
10395

10496
odr_check() {
10597
[[maybe_unused]] auto _ = &inc<typename Registry::registry_type>;
@@ -871,16 +863,16 @@ struct initialize_aux;
871863
//! @see @ref policies
872864
template<class... Policy>
873865
class registry : detail::registry_base {
874-
static BOOST_OPENMETHOD_DECLSPEC detail::class_catalog classes;
875-
static BOOST_OPENMETHOD_DECLSPEC detail::method_catalog methods;
866+
static detail::class_catalog classes;
867+
static detail::method_catalog methods;
876868

877869
template<class...>
878870
friend struct detail::use_class_aux;
879871
template<typename Name, typename ReturnType, class Registry>
880872
friend class method;
881873

882-
static BOOST_OPENMETHOD_DECLSPEC std::vector<detail::word> dispatch_data;
883-
static BOOST_OPENMETHOD_DECLSPEC bool initialized;
874+
static std::vector<detail::word> dispatch_data;
875+
static bool initialized;
884876

885877
template<class... Options>
886878
struct compiler;
@@ -920,7 +912,7 @@ class registry : detail::registry_base {
920912
//!
921913
//! @tparam Class A registered class.
922914
template<class Class>
923-
static BOOST_OPENMETHOD_DECLSPEC vptr_type static_vptr;
915+
static vptr_type static_vptr;
924916

925917
//! List of policies selected in a registry.
926918
//!

0 commit comments

Comments
 (0)