From 150b9e9399aa6aef58935900ae6a27ef3dcf167c Mon Sep 17 00:00:00 2001 From: Kelly Kinkade Date: Fri, 8 Dec 2023 18:27:06 -0600 Subject: [PATCH] data identity changes for stl-variant in 50.12 --- library/DataIdentity.cpp | 22 +++++++++++----------- library/include/DataIdentity.h | 12 +++++------- 2 files changed, 16 insertions(+), 18 deletions(-) diff --git a/library/DataIdentity.cpp b/library/DataIdentity.cpp index 31df1078c..f8d52deb4 100644 --- a/library/DataIdentity.cpp +++ b/library/DataIdentity.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include "DataFuncs.h" #include "DataIdentity.h" @@ -17,9 +18,9 @@ namespace df { category##_identity identity_traits::identity(name); #define INTEGER_IDENTITY_TRAITS(type, name) NUMBER_IDENTITY_TRAITS(integer, type, name) #define FLOAT_IDENTITY_TRAITS(type) NUMBER_IDENTITY_TRAITS(float, type, #type) -#define OPAQUE_IDENTITY_TRAITS_NAME(type, name) \ - opaque_identity identity_traits::identity(sizeof(type), allocator_noassign_fn, name) -#define STL_OPAQUE_IDENTITY_TRAITS(type) OPAQUE_IDENTITY_TRAITS_NAME(std::type, #type) +#define OPAQUE_IDENTITY_TRAITS_NAME(name, ...) \ + opaque_identity identity_traits<__VA_ARGS__ >::identity(sizeof(__VA_ARGS__), allocator_noassign_fn<__VA_ARGS__ >, name) +#define OPAQUE_IDENTITY_TRAITS(...) OPAQUE_IDENTITY_TRAITS_NAME(#__VA_ARGS__, __VA_ARGS__ ) INTEGER_IDENTITY_TRAITS(char, "char"); INTEGER_IDENTITY_TRAITS(signed char, "int8_t"); @@ -44,14 +45,13 @@ 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); - STL_OPAQUE_IDENTITY_TRAITS(future); - STL_OPAQUE_IDENTITY_TRAITS(function); - STL_OPAQUE_IDENTITY_TRAITS(optional); - OPAQUE_IDENTITY_TRAITS_NAME(std::variant, - "variant"); + OPAQUE_IDENTITY_TRAITS(std::condition_variable); + OPAQUE_IDENTITY_TRAITS(std::fstream); + OPAQUE_IDENTITY_TRAITS(std::mutex); + OPAQUE_IDENTITY_TRAITS(std::future); + OPAQUE_IDENTITY_TRAITS(std::function); + OPAQUE_IDENTITY_TRAITS(std::optional >); + OPAQUE_IDENTITY_TRAITS(std::variant >); buffer_container_identity buffer_container_identity::base_instance; } diff --git a/library/include/DataIdentity.h b/library/include/DataIdentity.h index dad9f44cc..98f57368b 100644 --- a/library/include/DataIdentity.h +++ b/library/include/DataIdentity.h @@ -33,6 +33,7 @@ distribution. #include #include #include +#include #include "DataDefs.h" @@ -553,8 +554,8 @@ namespace df // the space after the use of "type" in OPAQUE_IDENTITY_TRAITS is _required_ // without it the macro generates a syntax error when type is a template specification -#define OPAQUE_IDENTITY_TRAITS(type) \ - template<> struct DFHACK_EXPORT identity_traits { \ +#define OPAQUE_IDENTITY_TRAITS(...) \ + template<> struct DFHACK_EXPORT identity_traits<__VA_ARGS__ > { \ static opaque_identity identity; \ static opaque_identity *get() { return &identity; } \ }; @@ -577,11 +578,8 @@ namespace df OPAQUE_IDENTITY_TRAITS(std::mutex); OPAQUE_IDENTITY_TRAITS(std::future); OPAQUE_IDENTITY_TRAITS(std::function); - - typedef std::function void_function; - #define COMMA , - OPAQUE_IDENTITY_TRAITS(std::optional); - OPAQUE_IDENTITY_TRAITS(std::variant); + OPAQUE_IDENTITY_TRAITS(std::optional >); + OPAQUE_IDENTITY_TRAITS(std::variant >); #ifdef BUILD_DFHACK_LIB template