From 438d264b3154cb95fbf6c66d0146202b8347016c Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Mon, 10 Aug 2020 23:09:03 -0700 Subject: [PATCH] use separate identity classes for each handle type --- plugins/xlsxreader.cpp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/plugins/xlsxreader.cpp b/plugins/xlsxreader.cpp index 02b83127d..58321705d 100644 --- a/plugins/xlsxreader.cpp +++ b/plugins/xlsxreader.cpp @@ -48,25 +48,32 @@ using namespace DFHack; DFHACK_PLUGIN("xlsxreader"); -struct handle_identity : public compound_identity { - handle_identity(): compound_identity(0, nullptr, nullptr, "handle") {}; +struct xlsx_file_handle_identity : public compound_identity { + xlsx_file_handle_identity() + :compound_identity(0, nullptr, nullptr, "handle") {}; + DFHack::identity_type type() override { return IDTYPE_OPAQUE; } +}; + +struct xlsx_sheet_handle_identity : public compound_identity { + xlsx_sheet_handle_identity() + :compound_identity(0, nullptr, nullptr, "handle") {}; DFHack::identity_type type() override { return IDTYPE_OPAQUE; } }; struct xlsx_file_handle { const xlsxioreader handle; xlsx_file_handle(xlsxioreader handle): handle(handle) {} - static handle_identity _identity; + static xlsx_file_handle_identity _identity; }; struct xlsx_sheet_handle { const xlsxioreadersheet handle; xlsx_sheet_handle(xlsxioreadersheet handle): handle(handle) {} - static handle_identity _identity; + static xlsx_sheet_handle_identity _identity; }; -handle_identity xlsx_file_handle::_identity; -handle_identity xlsx_sheet_handle::_identity; +xlsx_file_handle_identity xlsx_file_handle::_identity; +xlsx_sheet_handle_identity xlsx_sheet_handle::_identity; // returns NULL on error xlsx_file_handle* open_xlsx_file(std::string filename) {