use separate identity classes for each handle type

develop
Myk Taylor 2020-08-10 23:09:03 -07:00
parent 0d9614154f
commit 438d264b31
1 changed files with 13 additions and 6 deletions

@ -48,25 +48,32 @@ using namespace DFHack;
DFHACK_PLUGIN("xlsxreader"); DFHACK_PLUGIN("xlsxreader");
struct handle_identity : public compound_identity { struct xlsx_file_handle_identity : public compound_identity {
handle_identity(): compound_identity(0, nullptr, nullptr, "handle") {}; 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; } DFHack::identity_type type() override { return IDTYPE_OPAQUE; }
}; };
struct xlsx_file_handle { struct xlsx_file_handle {
const xlsxioreader handle; const xlsxioreader handle;
xlsx_file_handle(xlsxioreader handle): handle(handle) {} xlsx_file_handle(xlsxioreader handle): handle(handle) {}
static handle_identity _identity; static xlsx_file_handle_identity _identity;
}; };
struct xlsx_sheet_handle { struct xlsx_sheet_handle {
const xlsxioreadersheet handle; const xlsxioreadersheet handle;
xlsx_sheet_handle(xlsxioreadersheet handle): handle(handle) {} xlsx_sheet_handle(xlsxioreadersheet handle): handle(handle) {}
static handle_identity _identity; static xlsx_sheet_handle_identity _identity;
}; };
handle_identity xlsx_file_handle::_identity; xlsx_file_handle_identity xlsx_file_handle::_identity;
handle_identity xlsx_sheet_handle::_identity; xlsx_sheet_handle_identity xlsx_sheet_handle::_identity;
// returns NULL on error // returns NULL on error
xlsx_file_handle* open_xlsx_file(std::string filename) { xlsx_file_handle* open_xlsx_file(std::string filename) {