Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vector<int32_t> and vector<int16_t> #4676

Merged
merged 2 commits into from
Jun 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions library/DataIdentity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,7 @@ namespace df {
OPAQUE_IDENTITY_TRAITS(std::weak_ptr<df::widget_container>);

buffer_container_identity buffer_container_identity::base_instance;

DFHACK_EXPORT stl_container_identity<std::vector<int32_t> > stl_vector_int32_t_identity("vector", identity_traits<int32_t>::get());
DFHACK_EXPORT stl_container_identity<std::vector<int16_t> > stl_vector_int16_t_identity("vector", identity_traits<int16_t>::get());
}
27 changes: 27 additions & 0 deletions library/include/DataIdentity.h
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,7 @@ namespace df
return ((uint8_t*)ptr) + idx * item->byte_size();
}
};
#endif

template<class T>
class stl_container_identity : public container_identity {
Expand Down Expand Up @@ -406,6 +407,7 @@ namespace df
}
};

#ifdef BUILD_DFHACK_LIB
template<class T>
class ro_stl_container_identity : public container_identity {
protected:
Expand Down Expand Up @@ -667,6 +669,18 @@ namespace df
static stl_ptr_vector_identity *get();
};

// explicit specializations for these two types
// for availability in plugins

template<> struct identity_traits<std::vector<int32_t> > {
static container_identity* get();
};

template<> struct identity_traits<std::vector<int16_t> > {
static container_identity* get();
};


#ifdef BUILD_DFHACK_LIB
template<class T> struct identity_traits<std::deque<T> > {
static container_identity *get();
Expand Down Expand Up @@ -739,6 +753,19 @@ namespace df
return &identity;
}

// explicit specializations for these two types
// for availability in plugins

extern DFHACK_EXPORT stl_container_identity<std::vector<int32_t> > stl_vector_int32_t_identity;
inline container_identity* identity_traits<std::vector<int32_t> >::get() {
return &stl_vector_int32_t_identity;
}

extern DFHACK_EXPORT stl_container_identity<std::vector<int16_t> > stl_vector_int16_t_identity;
inline container_identity* identity_traits<std::vector<int16_t> >::get() {
return &stl_vector_int16_t_identity;
}

#ifdef BUILD_DFHACK_LIB
template<class T>
inline container_identity *identity_traits<std::deque<T> >::get() {
Expand Down