diff --git a/library/DataDefs.cpp b/library/DataDefs.cpp index 5d2386282e..50be583459 100644 --- a/library/DataDefs.cpp +++ b/library/DataDefs.cpp @@ -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) { } @@ -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; diff --git a/library/include/DataDefs.h b/library/include/DataDefs.h index 76e74c9791..6a5695809d 100644 --- a/library/include/DataDefs.h +++ b/library/include/DataDefs.h @@ -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; } @@ -418,13 +418,13 @@ namespace DFHack template 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 @@ -536,10 +536,10 @@ namespace df struct identity_traits {}; template - requires requires () { { &T::_identity } -> std::convertible_to; } + requires requires () { { &T::_identity } -> std::convertible_to; } struct identity_traits { static const bool is_primitive = false; - static compound_identity *get() { return &T::_identity; } + static const compound_identity *get() { return &T::_identity; } }; template diff --git a/library/include/MiscUtils.h b/library/include/MiscUtils.h index 2b9426202d..2ff04282e4 100644 --- a/library/include/MiscUtils.h +++ b/library/include/MiscUtils.h @@ -400,7 +400,7 @@ typename T::mapped_type findPrefixInMap( #endif template -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; } diff --git a/library/include/modules/Gui.h b/library/include/modules/Gui.h index 222779a8ee..63939fc247 100644 --- a/library/include/modules/Gui.h +++ b/library/include/modules/Gui.h @@ -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); diff --git a/library/modules/Gui.cpp b/library/modules/Gui.cpp index dedcc6cdbc..b5df3ca990 100644 --- a/library/modules/Gui.cpp +++ b/library/modules/Gui.cpp @@ -152,9 +152,10 @@ static std::string getNameChunk(virtual_identity *id, int start, int end) */ typedef void (*getFocusStringsHandler)(std::string &str, std::vector &strList, df::viewscreen *screen); -static std::map getFocusStringsHandlers; +static std::map 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 &focusStrings, VIEWSCREEN(screen_type) *screen);\ DFHACK_STATIC_ADD_TO_MAP(\ @@ -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();