From 2f427451758e6d3467e94da8dd3f202dfbe36e5e Mon Sep 17 00:00:00 2001 From: lethosor Date: Mon, 29 May 2023 01:09:59 -0400 Subject: [PATCH] Add identity_traits, add macro for opaque identities --- library/DataIdentity.cpp | 1 + library/include/DataIdentity.h | 21 +++++++++++---------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/library/DataIdentity.cpp b/library/DataIdentity.cpp index f6a1c2de8..0f85e5d95 100644 --- a/library/DataIdentity.cpp +++ b/library/DataIdentity.cpp @@ -40,6 +40,7 @@ namespace df { stl_bit_vector_identity identity_traits >::identity; bit_array_identity identity_traits >::identity; + STL_OPAQUE_IDENTITY_TRAITS(condition_variable); STL_OPAQUE_IDENTITY_TRAITS(fstream); STL_OPAQUE_IDENTITY_TRAITS(mutex); diff --git a/library/include/DataIdentity.h b/library/include/DataIdentity.h index c5ce0fb73..232b32108 100644 --- a/library/include/DataIdentity.h +++ b/library/include/DataIdentity.h @@ -24,6 +24,7 @@ distribution. #pragma once +#include #include #include #include @@ -542,6 +543,12 @@ namespace df #define INTEGER_IDENTITY_TRAITS(type) NUMBER_IDENTITY_TRAITS(integer, type) #define FLOAT_IDENTITY_TRAITS(type) NUMBER_IDENTITY_TRAITS(float, type) +#define OPAQUE_IDENTITY_TRAITS(type) \ + template<> struct DFHACK_EXPORT identity_traits { \ + static opaque_identity identity; \ + static opaque_identity *get() { return &identity; } \ + }; + INTEGER_IDENTITY_TRAITS(char); INTEGER_IDENTITY_TRAITS(signed char); INTEGER_IDENTITY_TRAITS(unsigned char); @@ -555,6 +562,9 @@ namespace df INTEGER_IDENTITY_TRAITS(unsigned long long); FLOAT_IDENTITY_TRAITS(float); FLOAT_IDENTITY_TRAITS(double); + OPAQUE_IDENTITY_TRAITS(std::condition_variable); + OPAQUE_IDENTITY_TRAITS(std::fstream); + OPAQUE_IDENTITY_TRAITS(std::mutex); template<> struct DFHACK_EXPORT identity_traits { static bool_identity identity; @@ -566,16 +576,6 @@ namespace df static stl_string_identity *get() { return &identity; } }; - template<> struct DFHACK_EXPORT identity_traits { - static opaque_identity identity; - static opaque_identity *get() { return &identity; } - }; - - template<> struct DFHACK_EXPORT identity_traits { - static opaque_identity identity; - static opaque_identity *get() { return &identity; } - }; - template<> struct DFHACK_EXPORT identity_traits { static ptr_string_identity identity; static ptr_string_identity *get() { return &identity; } @@ -604,6 +604,7 @@ namespace df #undef NUMBER_IDENTITY_TRAITS #undef INTEGER_IDENTITY_TRAITS #undef FLOAT_IDENTITY_TRAITS +#undef OPAQUE_IDENTITY_TRAITS // Container declarations