Skip to content
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
6 changes: 3 additions & 3 deletions library/DataDefs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,8 @@ const std::string df::buffer_container_identity::getFullName(const type_identity
}

union_identity::union_identity(size_t size, const TAllocateFn alloc,
compound_identity *scope_parent, const char *dfhack_name,
struct_identity *parent, const struct_field_info *fields)
const compound_identity *scope_parent, const char *dfhack_name,
const struct_identity *parent, const struct_field_info *fields)
: struct_identity(size, alloc, scope_parent, dfhack_name, parent, fields)
{
}
Expand Down Expand Up @@ -350,7 +350,7 @@ virtual_identity *virtual_identity::find(void *vtable)
return NULL;
}

void virtual_identity::adjust_vtable(virtual_ptr obj, virtual_identity *main)
void virtual_identity::adjust_vtable(virtual_ptr obj, const virtual_identity *main) const
{
if (vtable_ptr) {
*(void**)obj = vtable_ptr;
Expand Down
14 changes: 7 additions & 7 deletions library/include/DataDefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -326,8 +326,8 @@ namespace DFHack
class DFHACK_EXPORT union_identity : public struct_identity {
public:
union_identity(size_t size, TAllocateFn alloc,
compound_identity *scope_parent, const char *dfhack_name,
struct_identity *parent, const struct_field_info *fields);
const compound_identity *scope_parent, const char *dfhack_name,
const struct_identity *parent, const struct_field_info *fields);

virtual identity_type type() const { return IDTYPE_UNION; }

Expand Down Expand Up @@ -418,13 +418,13 @@ namespace DFHack
template<class P> static P get_vmethod_ptr(P selector);

public:
bool can_instantiate() { return can_allocate(); }
virtual_ptr instantiate() { return can_instantiate() ? (virtual_ptr)do_allocate() : NULL; }
bool can_instantiate() const { return can_allocate(); }
virtual_ptr instantiate() const { return can_instantiate() ? (virtual_ptr)do_allocate() : NULL; }
static virtual_ptr clone(virtual_ptr obj);

public:
// Strictly for use in virtual class constructors
void adjust_vtable(virtual_ptr obj, virtual_identity *main);
void adjust_vtable(virtual_ptr obj, const virtual_identity *main) const;
};

template<class T>
Expand Down Expand Up @@ -536,10 +536,10 @@ namespace df
struct identity_traits {};

template<class T>
requires requires () { { &T::_identity } -> std::convertible_to<compound_identity*>; }
requires requires () { { &T::_identity } -> std::convertible_to<const compound_identity*>; }
struct identity_traits<T> {
static const bool is_primitive = false;
static compound_identity *get() { return &T::_identity; }
static const compound_identity *get() { return &T::_identity; }
};

template<class T>
Expand Down
2 changes: 1 addition & 1 deletion library/include/MiscUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ typename T::mapped_type findPrefixInMap(
#endif

template<class CT>
inline bool static_add_to_map(CT *pmap, typename CT::key_type key, typename CT::mapped_type value) {
inline bool static_add_to_map(CT *pmap, const typename CT::key_type key, const typename CT::mapped_type value) {
(*pmap)[key] = value;
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion library/include/modules/Gui.h
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ namespace DFHack
/// Get the current top-level view-screen
DFHACK_EXPORT df::viewscreen *getCurViewscreen(bool skip_dismissed = false);

DFHACK_EXPORT df::viewscreen *getViewscreenByIdentity(virtual_identity &id, int n = 1);
DFHACK_EXPORT df::viewscreen *getViewscreenByIdentity(const virtual_identity &id, int n = 1);

/// Get the top-most underlying DF viewscreen (not owned by DFHack)
DFHACK_EXPORT df::viewscreen *getDFViewscreen(bool skip_dismissed = false, df::viewscreen *top = NULL);
Expand Down
5 changes: 3 additions & 2 deletions library/modules/Gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,10 @@ static std::string getNameChunk(virtual_identity *id, int start, int end)
*/

typedef void (*getFocusStringsHandler)(std::string &str, std::vector<std::string> &strList, df::viewscreen *screen);
static std::map<virtual_identity*, getFocusStringsHandler> getFocusStringsHandlers;
static std::map<const virtual_identity*, getFocusStringsHandler> getFocusStringsHandlers;

#define VIEWSCREEN(name) df::viewscreen_##name##st

#define DEFINE_GET_FOCUS_STRING_HANDLER(screen_type) \
static void getFocusStrings_##screen_type(const std::string &baseFocus, std::vector<std::string> &focusStrings, VIEWSCREEN(screen_type) *screen);\
DFHACK_STATIC_ADD_TO_MAP(\
Expand Down Expand Up @@ -2718,7 +2719,7 @@ df::viewscreen *Gui::getCurViewscreen(bool skip_dismissed)
return ws;
}

df::viewscreen *Gui::getViewscreenByIdentity (virtual_identity &id, int n)
df::viewscreen *Gui::getViewscreenByIdentity (const virtual_identity &id, int n)
{
bool limit = (n > 0);
df::viewscreen *screen = Gui::getCurViewscreen();
Expand Down