Skip to content

Commit 9d21275

Browse files
authored
Merge pull request #4676 from ab9rf/vector-identities
`vector<int32_t>` and `vector<int16_t>`
2 parents d040a3f + 7b55030 commit 9d21275

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

library/DataIdentity.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,7 @@ namespace df {
5858
OPAQUE_IDENTITY_TRAITS(std::weak_ptr<df::widget_container>);
5959

6060
buffer_container_identity buffer_container_identity::base_instance;
61+
62+
DFHACK_EXPORT stl_container_identity<std::vector<int32_t> > stl_vector_int32_t_identity("vector", identity_traits<int32_t>::get());
63+
DFHACK_EXPORT stl_container_identity<std::vector<int16_t> > stl_vector_int16_t_identity("vector", identity_traits<int16_t>::get());
6164
}

library/include/DataIdentity.h

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,7 @@ namespace df
370370
return ((uint8_t*)ptr) + idx * item->byte_size();
371371
}
372372
};
373+
#endif
373374

374375
template<class T>
375376
class stl_container_identity : public container_identity {
@@ -406,6 +407,7 @@ namespace df
406407
}
407408
};
408409

410+
#ifdef BUILD_DFHACK_LIB
409411
template<class T>
410412
class ro_stl_container_identity : public container_identity {
411413
protected:
@@ -667,6 +669,18 @@ namespace df
667669
static stl_ptr_vector_identity *get();
668670
};
669671

672+
// explicit specializations for these two types
673+
// for availability in plugins
674+
675+
template<> struct identity_traits<std::vector<int32_t> > {
676+
static container_identity* get();
677+
};
678+
679+
template<> struct identity_traits<std::vector<int16_t> > {
680+
static container_identity* get();
681+
};
682+
683+
670684
#ifdef BUILD_DFHACK_LIB
671685
template<class T> struct identity_traits<std::deque<T> > {
672686
static container_identity *get();
@@ -739,6 +753,19 @@ namespace df
739753
return &identity;
740754
}
741755

756+
// explicit specializations for these two types
757+
// for availability in plugins
758+
759+
extern DFHACK_EXPORT stl_container_identity<std::vector<int32_t> > stl_vector_int32_t_identity;
760+
inline container_identity* identity_traits<std::vector<int32_t> >::get() {
761+
return &stl_vector_int32_t_identity;
762+
}
763+
764+
extern DFHACK_EXPORT stl_container_identity<std::vector<int16_t> > stl_vector_int16_t_identity;
765+
inline container_identity* identity_traits<std::vector<int16_t> >::get() {
766+
return &stl_vector_int16_t_identity;
767+
}
768+
742769
#ifdef BUILD_DFHACK_LIB
743770
template<class T>
744771
inline container_identity *identity_traits<std::deque<T> >::get() {

0 commit comments

Comments
 (0)