From 4c562a3a82500f4fec54aed9ec606878bb9cafe7 Mon Sep 17 00:00:00 2001 From: Kelly Kinkade Date: Thu, 6 Jun 2024 08:02:58 -0500 Subject: [PATCH 1/2] `vector` and `vector` this makes identity traits for these two specializations available in plugins with this change, the `stl_vector_identity` template will be visible to plugins, but the identity objects _themselves_ will not (except for `vector` and `vector`) so any attempt to actually use a `vector` other than one of these two types or of a pointer type (which is covered elsewhere by the `vector` specialization which is exported) will result in linkage errors --- library/DataIdentity.cpp | 3 +++ library/include/DataIdentity.h | 29 ++++++++++++++++++++++++++++- 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/library/DataIdentity.cpp b/library/DataIdentity.cpp index 2e15e0d048..3d8373bcd0 100644 --- a/library/DataIdentity.cpp +++ b/library/DataIdentity.cpp @@ -58,4 +58,7 @@ namespace df { OPAQUE_IDENTITY_TRAITS(std::weak_ptr); buffer_container_identity buffer_container_identity::base_instance; + + DFHACK_EXPORT stl_container_identity > stl_vector_int32_t_identity("vector", identity_traits::get()); + DFHACK_EXPORT stl_container_identity > stl_vector_int16_t_identity("vector", identity_traits::get()); } diff --git a/library/include/DataIdentity.h b/library/include/DataIdentity.h index a3dd3216e5..0f28be983d 100644 --- a/library/include/DataIdentity.h +++ b/library/include/DataIdentity.h @@ -370,6 +370,7 @@ namespace df return ((uint8_t*)ptr) + idx * item->byte_size(); } }; +#endif template class stl_container_identity : public container_identity { @@ -406,6 +407,7 @@ namespace df } }; +#ifdef BUILD_DFHACK_LIB template class ro_stl_container_identity : public container_identity { protected: @@ -657,16 +659,28 @@ namespace df template struct identity_traits { static container_identity *get(); }; +#endif template struct identity_traits > { static container_identity *get(); }; -#endif template struct identity_traits > { static stl_ptr_vector_identity *get(); }; + // explicit specializations for these two types + // for availability in plugins + + template<> struct identity_traits > { + static container_identity* get(); + }; + + template<> struct identity_traits > { + static container_identity* get(); + }; + + #ifdef BUILD_DFHACK_LIB template struct identity_traits > { static container_identity *get(); @@ -739,6 +753,19 @@ namespace df return &identity; } + // explicit specializations for these two types + // for availability in plugins + + extern DFHACK_EXPORT stl_container_identity > stl_vector_int32_t_identity; + inline container_identity* identity_traits >::get() { + return &stl_vector_int32_t_identity; + } + + extern DFHACK_EXPORT stl_container_identity > stl_vector_int16_t_identity; + inline container_identity* identity_traits >::get() { + return &stl_vector_int16_t_identity; + } + #ifdef BUILD_DFHACK_LIB template inline container_identity *identity_traits >::get() { From 7b55030a5b4cdc044cc46849c0c0e8387ac1814f Mon Sep 17 00:00:00 2001 From: Kelly Kinkade Date: Thu, 6 Jun 2024 08:15:02 -0500 Subject: [PATCH 2/2] oops missed this, it was supposed to have been moved back but i forgot --- library/include/DataIdentity.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/include/DataIdentity.h b/library/include/DataIdentity.h index 0f28be983d..6d1806c2f4 100644 --- a/library/include/DataIdentity.h +++ b/library/include/DataIdentity.h @@ -659,11 +659,11 @@ namespace df template struct identity_traits { static container_identity *get(); }; -#endif template struct identity_traits > { static container_identity *get(); }; +#endif template struct identity_traits > { static stl_ptr_vector_identity *get();