Define identity_traits<shared_ptr<T>> for all T (opaque for now)

develop
lethosor 2023-09-13 21:57:28 -04:00
parent 49e449a422
commit 017e280b18
No known key found for this signature in database
GPG Key ID: 76A269552F4F58C1
2 changed files with 12 additions and 6 deletions

@ -47,7 +47,6 @@ namespace df {
STL_OPAQUE_IDENTITY_TRAITS(condition_variable); STL_OPAQUE_IDENTITY_TRAITS(condition_variable);
STL_OPAQUE_IDENTITY_TRAITS(fstream); STL_OPAQUE_IDENTITY_TRAITS(fstream);
STL_OPAQUE_IDENTITY_TRAITS(mutex); STL_OPAQUE_IDENTITY_TRAITS(mutex);
STL_OPAQUE_IDENTITY_TRAITS(shared_ptr<df::widget>);
STL_OPAQUE_IDENTITY_TRAITS(future<void>); STL_OPAQUE_IDENTITY_TRAITS(future<void>);
STL_OPAQUE_IDENTITY_TRAITS(function<void()>); STL_OPAQUE_IDENTITY_TRAITS(function<void()>);
STL_OPAQUE_IDENTITY_TRAITS(optional<std::function<void()> >); STL_OPAQUE_IDENTITY_TRAITS(optional<std::function<void()> >);

@ -40,10 +40,6 @@ namespace std {
class mutex; class mutex;
}; };
namespace df {
struct widget;
}
/* /*
* Definitions of DFHack namespace structs used by generated headers. * Definitions of DFHack namespace structs used by generated headers.
*/ */
@ -579,10 +575,21 @@ namespace df
OPAQUE_IDENTITY_TRAITS(std::fstream); OPAQUE_IDENTITY_TRAITS(std::fstream);
OPAQUE_IDENTITY_TRAITS(std::mutex); OPAQUE_IDENTITY_TRAITS(std::mutex);
OPAQUE_IDENTITY_TRAITS(std::future<void>); OPAQUE_IDENTITY_TRAITS(std::future<void>);
OPAQUE_IDENTITY_TRAITS(std::shared_ptr<df::widget>);
OPAQUE_IDENTITY_TRAITS(std::function<void()>); OPAQUE_IDENTITY_TRAITS(std::function<void()>);
OPAQUE_IDENTITY_TRAITS(std::optional<std::function<void()> >); OPAQUE_IDENTITY_TRAITS(std::optional<std::function<void()> >);
#ifdef BUILD_DFHACK_LIB
template<typename T>
struct DFHACK_EXPORT identity_traits<std::shared_ptr<T>> {
static opaque_identity *get() {
typedef std::shared_ptr<T> type;
static std::string name = std::string("shared_ptr<") + typeid(T).name() + ">";
static opaque_identity identity(sizeof(type), allocator_noassign_fn<type>, name);
return &identity;
}
};
#endif
template<> struct DFHACK_EXPORT identity_traits<bool> { template<> struct DFHACK_EXPORT identity_traits<bool> {
static bool_identity identity; static bool_identity identity;
static bool_identity *get() { return &identity; } static bool_identity *get() { return &identity; }