Skip to content

Commit 164d861

Browse files
committed
support dynamic loading on Windows
1 parent 134a5bc commit 164d861

File tree

3 files changed

+22
-21
lines changed

3 files changed

+22
-21
lines changed

include/boost/openmethod/core.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ struct use_class_aux<Registry, mp11::mp_list<Class, Bases...>>
360360
}
361361

362362
// coverity[uninit] - zero-initialized static storage
363-
Registry::st.classes.push_back(*this);
363+
Registry::static_::st.classes.push_back(*this);
364364
}
365365

366366
void resolve_type_ids() {
@@ -370,7 +370,7 @@ struct use_class_aux<Registry, mp11::mp_list<Class, Bases...>>
370370
}
371371

372372
~use_class_aux() {
373-
Registry::st.classes.remove(*this);
373+
Registry::static_::st.classes.remove(*this);
374374
}
375375
};
376376

@@ -2420,7 +2420,7 @@ method<Id, ReturnType(Parameters...), Registry>::method() {
24202420

24212421
// zero-initalized static variable
24222422
// coverity[uninit_use]
2423-
Registry::st.methods.push_back(*this);
2423+
Registry::static_::st.methods.push_back(*this);
24242424
}
24252425

24262426
template<
@@ -2440,7 +2440,7 @@ void method<Id, ReturnType(Parameters...), Registry>::resolve_type_ids() {
24402440
template<
24412441
typename Id, typename... Parameters, typename ReturnType, class Registry>
24422442
method<Id, ReturnType(Parameters...), Registry>::~method() {
2443-
Registry::st.methods.remove(*this);
2443+
Registry::static_::st.methods.remove(*this);
24442444
}
24452445

24462446
// -----------------------------------------------------------------------------

include/boost/openmethod/initialize.hpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -585,7 +585,7 @@ template<class... Options>
585585
void registry<Policies...>::compiler<Options...>::initialize() {
586586
compile();
587587
install_global_tables();
588-
registry<Policies...>::st.initialized = true;
588+
registry<Policies...>::static_::st.initialized = true;
589589
}
590590

591591
#ifdef _MSC_VER
@@ -654,7 +654,7 @@ void registry<Policies...>::compiler<Options...>::augment_classes() {
654654
// The standard does not guarantee that there is exactly one
655655
// type_info object per class. However, it guarantees that the
656656
// type_index for a class has a unique value.
657-
for (auto& cr : registry::st.classes) {
657+
for (auto& cr : registry::static_::st.classes) {
658658
if constexpr (has_deferred_static_rtti) {
659659
static_cast<deferred_class_info&>(cr).resolve_type_ids();
660660
}
@@ -691,7 +691,7 @@ void registry<Policies...>::compiler<Options...>::augment_classes() {
691691
// All known classes now have exactly one associated class_* in the
692692
// map. Collect the bases.
693693

694-
for (auto& cr : registry::st.classes) {
694+
for (auto& cr : registry::static_::st.classes) {
695695
auto rtc = class_map[rtti::type_index(cr.type)];
696696

697697
for (auto& base : range{cr.first_base, cr.last_base}) {
@@ -820,14 +820,14 @@ void registry<Policies...>::compiler<Options...>::augment_methods() {
820820
using namespace policies;
821821
using namespace detail;
822822

823-
methods.resize(registry::st.methods.size());
823+
methods.resize(registry::static_::st.methods.size());
824824

825825
++tr << "Methods:\n";
826826
indent _(tr);
827827

828828
auto meth_iter = methods.begin();
829829

830-
for (auto& meth_info : registry::st.methods) {
830+
for (auto& meth_info : registry::static_::st.methods) {
831831
if constexpr (has_deferred_static_rtti) {
832832
static_cast<deferred_method_info&>(meth_info).resolve_type_ids();
833833
}
@@ -1530,7 +1530,7 @@ void registry<Policies...>::compiler<Options...>::write_global_data() {
15301530

15311531
detail::initialize_policies<registry>::fn(*this, options);
15321532

1533-
new_dispatch_data.swap(st.dispatch_data);
1533+
new_dispatch_data.swap(registry::static_::st.dispatch_data);
15341534
}
15351535

15361536
template<class... Policies>
@@ -1771,8 +1771,8 @@ auto registry<Policies...>::finalize(Options... opts) -> void {
17711771
}
17721772
});
17731773

1774-
st.dispatch_data.clear();
1775-
st.initialized = false;
1774+
registry::static_::st.dispatch_data.clear();
1775+
registry::static_::st.initialized = false;
17761776
}
17771777

17781778
//! Release resources held by registry.

include/boost/openmethod/preamble.hpp

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1037,25 +1037,26 @@ struct attributes_guide final : attributes {
10371037
//!
10381038
//! @see @ref policies
10391039
template<class... Policy>
1040-
class registry
1041-
: public detail::registry_base,
1042-
detail::static_st<
1043-
detail::registry_state<registry<Policy...>>,
1044-
typename detail::find_first_derived_of<
1045-
policies::attributes, mp11::mp_list<Policy...>,
1046-
policies::attributes_guide<registry<Policy...>>>::guide_type> {
1040+
class registry : public detail::registry_base {
10471041

10481042
template<class...>
10491043
friend struct detail::use_class_aux;
10501044
template<typename Name, typename ReturnType, class Registry>
10511045
friend class method;
10521046

1047+
using static_ = detail::static_st<
1048+
detail::registry_state<registry<Policy...>>,
1049+
typename detail::find_first_derived_of<
1050+
policies::attributes, mp11::mp_list<Policy...>,
1051+
policies::attributes_guide<registry<Policy...>>>::guide_type>;
1052+
10531053
public:
10541054
//! The type of this registry.
10551055
using registry_type = registry;
1056+
using declspec = typename static_::declspec;
10561057

10571058
static const void* id() {
1058-
return static_cast<const void*>(&st);
1059+
return static_cast<const void*>(&static_::st);
10591060
}
10601061

10611062
template<class... Options>
@@ -1162,7 +1163,7 @@ class registry
11621163
template<class... Policies>
11631164
void registry<Policies...>::require_initialized() {
11641165
if constexpr (registry::has_runtime_checks) {
1165-
if (!st.initialized) {
1166+
if (!static_::st.initialized) {
11661167
if constexpr (registry::has_error_handler) {
11671168
error_handler::error(not_initialized());
11681169
}

0 commit comments

Comments
 (0)