Skip to content

Commit 8b51ac1

Browse files
authored
Merge pull request #284 from ruby-rice/dev
Dev
2 parents f9380b5 + 18c3914 commit 8b51ac1

File tree

3 files changed

+17
-14
lines changed

3 files changed

+17
-14
lines changed

FindRuby.cmake

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -378,12 +378,7 @@ set(_Ruby_POSSIBLE_LIB_NAMES
378378
)
379379

380380
if (WIN32 OR MSYS)
381-
if (WIN32)
382-
set(_Ruby_POSSIBLE_RUNTIMES "vcruntime140;vcruntime140_1;msvcr${MSVC_TOOLSET_VERSION}")
383-
else ()
384-
set(_Ruby_POSSIBLE_RUNTIMES "ucrt;msvcrt")
385-
endif ()
386-
381+
set(_Ruby_POSSIBLE_RUNTIMES "ucrt;msvcrt;vcruntime140;vcruntime140_1;msvcr${MSVC_TOOLSET_VERSION}")
387382
set(_Ruby_POSSIBLE_VERSION_SUFFIXES "${_Ruby_VERSION_NODOT};${_Ruby_VERSION_NODOT_ZERO_PATCH}")
388383
# Under MSYS CMAKE_SIZEOF_VOID_P is unset so add prefixes for 32 and 64 architectures
389384
set(_Ruby_POSSIBLE_ARCH_PREFIXES "lib;libx64-;x64-")

rice/Data_Type.hpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,9 +175,7 @@ namespace Rice
175175
// Typed Data support
176176
static inline rb_data_type_t* rb_data_type_ = nullptr;
177177

178-
// Track unbound instances (ie, declared variables of type Data_Type<T>
179-
// before define_class is called)
180-
static inline std::set<Data_Type<T>*>unbound_instances_;
178+
static inline std::set<Data_Type<T>*>& unbound_instances();
181179
};
182180

183181
//! Define a new data class in the namespace given by module.

rice/Data_Type.ipp

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,12 @@ namespace Rice
5959
// Now register with the type registry
6060
detail::Registries::instance.types.add<T>(klass_, rb_data_type_);
6161

62-
auto iter = Data_Type<T>::unbound_instances_.begin();
63-
while (iter != Data_Type<T>::unbound_instances_.end())
62+
auto instances = unbound_instances();
63+
for (auto instance: instances)
6464
{
65-
(*iter)->set_value(klass);
66-
iter = Data_Type<T>::unbound_instances_.erase(iter);
65+
instance->set_value(klass);
6766
}
67+
instances.clear();
6868

6969
return Data_Type<T>();
7070
}
@@ -84,12 +84,22 @@ namespace Rice
8484
rb_data_type_ = nullptr;
8585
}
8686

87+
// Track unbound instances (ie, declared variables of type Data_Type<T>
88+
// before define_class is called). We can't simply use a static inline
89+
// member because it sometimes crashes clang and gcc (msvc seems fine)
90+
template<typename T>
91+
inline std::set<Data_Type<T>*>& Data_Type<T>::unbound_instances()
92+
{
93+
static std::set<Data_Type<T>*> unbound_instances;
94+
return unbound_instances;
95+
}
96+
8797
template<typename T>
8898
inline Data_Type<T>::Data_Type() : Class(klass_ == Qnil ? rb_cObject : klass_)
8999
{
90100
if (!is_bound())
91101
{
92-
this->unbound_instances_.insert(this);
102+
unbound_instances().insert(this);
93103
}
94104
}
95105

0 commit comments

Comments
 (0)