diff options
Diffstat (limited to 'engines')
-rw-r--r-- | engines/glk/glk.cpp | 5 | ||||
-rw-r--r-- | engines/glk/glk.h | 7 | ||||
-rw-r--r-- | engines/glk/glk_api.cpp | 3 | ||||
-rw-r--r-- | engines/glk/glk_api.h | 9 | ||||
-rw-r--r-- | engines/glk/glk_dispa.cpp | 4 | ||||
-rw-r--r-- | engines/glk/glk_types.h | 2 | ||||
-rw-r--r-- | engines/glk/glulxe/glkop.cpp | 8 | ||||
-rw-r--r-- | engines/glk/glulxe/glulxe.h | 4 | ||||
-rw-r--r-- | engines/glk/streams.cpp | 12 | ||||
-rw-r--r-- | engines/glk/streams.h | 9 |
10 files changed, 38 insertions, 25 deletions
diff --git a/engines/glk/glk.cpp b/engines/glk/glk.cpp index 13f185d586..5d99fc93b7 100644 --- a/engines/glk/glk.cpp +++ b/engines/glk/glk.cpp @@ -47,8 +47,9 @@ GlkEngine::GlkEngine(OSystem *syst, const GlkGameDescription &gameDesc) : _gameDescription(gameDesc), Engine(syst), _random("Glk"), _blorb(nullptr), _clipboard(nullptr), _conf(nullptr), _events(nullptr), _pictures(nullptr), _screen(nullptr), _selection(nullptr), _sounds(nullptr), _windows(nullptr), - _copySelect(false), _terminated(false), gli_unregister_obj(nullptr), - _pcSpeaker(nullptr), gli_register_arr(nullptr), gli_unregister_arr(nullptr) { + _copySelect(false), _terminated(false), _pcSpeaker(nullptr), + gli_register_obj(nullptr), gli_unregister_obj(nullptr), gli_register_arr(nullptr), + gli_unregister_arr(nullptr) { g_vm = this; } diff --git a/engines/glk/glk.h b/engines/glk/glk.h index 9064105aa7..bebb4827f5 100644 --- a/engines/glk/glk.h +++ b/engines/glk/glk.h @@ -115,10 +115,11 @@ public: Windows *_windows; bool _copySelect; bool _terminated; - void (*gli_unregister_obj)(void *obj, uint objclass, gidispatch_rock_t objrock); - gidispatch_rock_t (*gli_register_arr)(void *array, uint len, const char *typecode); - void (*gli_unregister_arr)(void *array, uint len, const char *typecode, gidispatch_rock_t objrock); + gidispatch_rock_t(*gli_register_obj)(void *obj, uint objclass); + void(*gli_unregister_obj)(void *obj, uint objclass, gidispatch_rock_t objrock); + gidispatch_rock_t(*gli_register_arr)(void *array, uint len, const char *typecode); + void(*gli_unregister_arr)(void *array, uint len, const char *typecode, gidispatch_rock_t objrock); public: GlkEngine(OSystem *syst, const GlkGameDescription &gameDesc); virtual ~GlkEngine(); diff --git a/engines/glk/glk_api.cpp b/engines/glk/glk_api.cpp index e2f3117ef7..d86bd26e3f 100644 --- a/engines/glk/glk_api.cpp +++ b/engines/glk/glk_api.cpp @@ -36,8 +36,7 @@ namespace Glk { GlkAPI::GlkAPI(OSystem *syst, const GlkGameDescription &gameDesc) : - GlkEngine(syst, gameDesc), _gliFirstEvent(false), gli_register_obj(nullptr), - gli_unregister_obj(nullptr), gli_register_arr(nullptr), gli_unregister_arr(nullptr) { + GlkEngine(syst, gameDesc), _gliFirstEvent(false) { // Set uppercase/lowercase tables int ix, res; for (ix = 0; ix < 256; ix++) { diff --git a/engines/glk/glk_api.h b/engines/glk/glk_api.h index e54cd3c042..c47d23aba2 100644 --- a/engines/glk/glk_api.h +++ b/engines/glk/glk_api.h @@ -52,11 +52,6 @@ private: bool _gliFirstEvent; unsigned char _charTolowerTable[256]; unsigned char _charToupperTable[256]; - - gidispatch_rock_t(*gli_register_obj)(void *obj, uint objclass); - void(*gli_unregister_obj)(void *obj, uint objclass, gidispatch_rock_t objrock); - gidispatch_rock_t(*gli_register_arr)(void *array, uint len, char *typecode); - void(*gli_unregister_arr)(void *array, uint len, char *typecode, gidispatch_rock_t objrock); public: /** * Constructor @@ -306,8 +301,8 @@ public: void gidispatch_set_object_registry(gidispatch_rock_t(*regi)(void *obj, uint objclass), void(*unregi)(void *obj, uint objclass, gidispatch_rock_t objrock)); - void gidispatch_set_retained_registry(gidispatch_rock_t(*regi)(void *array, uint len, char *typecode), - void(*unregi)(void *array, uint len, char *typecode, gidispatch_rock_t objrock)); + void gidispatch_set_retained_registry(gidispatch_rock_t(*regi)(void *array, uint len, const char *typecode), + void(*unregi)(void *array, uint len, const char *typecode, gidispatch_rock_t objrock)); uint32 gidispatch_count_classes() const; const gidispatch_intconst_t *gidispatch_get_class(uint32 index) const; diff --git a/engines/glk/glk_dispa.cpp b/engines/glk/glk_dispa.cpp index e4d089cbe8..2b7108641c 100644 --- a/engines/glk/glk_dispa.cpp +++ b/engines/glk/glk_dispa.cpp @@ -369,8 +369,8 @@ void GlkAPI::gidispatch_set_object_registry(gidispatch_rock_t(*regi)(void *obj, } } -void GlkAPI::gidispatch_set_retained_registry(gidispatch_rock_t(*regi)(void *array, uint len, char *typecode), - void(*unregi)(void *array, uint len, char *typecode, gidispatch_rock_t objrock)) { +void GlkAPI::gidispatch_set_retained_registry(gidispatch_rock_t(*regi)(void *array, uint len, const char *typecode), + void(*unregi)(void *array, uint len, const char *typecode, gidispatch_rock_t objrock)) { gli_register_arr = regi; gli_unregister_arr = unregi; } diff --git a/engines/glk/glk_types.h b/engines/glk/glk_types.h index ef9c709354..4d32d5c7a0 100644 --- a/engines/glk/glk_types.h +++ b/engines/glk/glk_types.h @@ -221,6 +221,8 @@ enum ImageAlign { union gidispatch_rock_t { uint num; void *ptr; + + gidispatch_rock_t() : num(0), ptr(nullptr) {} }; union gluniversal_union { diff --git a/engines/glk/glulxe/glkop.cpp b/engines/glk/glulxe/glkop.cpp index d19bbd2088..2595a870b1 100644 --- a/engines/glk/glulxe/glkop.cpp +++ b/engines/glk/glulxe/glkop.cpp @@ -73,11 +73,11 @@ static void classtable_unregister(void *obj, uint objclass, gidispatch_rock_t ob g_vm->glulxe_classtable_unregister(obj, objclass, objrock); } -static gidispatch_rock_t retained_register(void *array, uint len, char *typecode) { +static gidispatch_rock_t retained_register(void *array, uint len, const char *typecode) { return g_vm->glulxe_retained_register(array, len, typecode); } -static void retained_unregister(void *array, uint len, char *typecode, gidispatch_rock_t objrock) { +static void retained_unregister(void *array, uint len, const char *typecode, gidispatch_rock_t objrock) { g_vm->glulxe_retained_unregister(array, len, typecode, objrock); } @@ -1132,7 +1132,7 @@ void Glulxe::release_temp_ptr_array(void **arr, uint addr, uint len, int objclas } } -gidispatch_rock_t Glulxe::glulxe_retained_register(void *array, uint len, char *typecode) { +gidispatch_rock_t Glulxe::glulxe_retained_register(void *array, uint len, const char *typecode) { gidispatch_rock_t rock; arrayref_t *arref = nullptr; arrayref_t **aptr; @@ -1164,7 +1164,7 @@ gidispatch_rock_t Glulxe::glulxe_retained_register(void *array, uint len, char * return rock; } -void Glulxe::glulxe_retained_unregister(void *array, uint len, char *typecode, gidispatch_rock_t objrock) { +void Glulxe::glulxe_retained_unregister(void *array, uint len, const char *typecode, gidispatch_rock_t objrock) { arrayref_t *arref = nullptr; arrayref_t **aptr; uint ix, addr2, val; diff --git a/engines/glk/glulxe/glulxe.h b/engines/glk/glulxe/glulxe.h index 99e8b1a643..cdb3735bb7 100644 --- a/engines/glk/glulxe/glulxe.h +++ b/engines/glk/glulxe/glulxe.h @@ -762,8 +762,8 @@ public: void glulxe_classtable_unregister(void *obj, uint objclass, gidispatch_rock_t objrock); - gidispatch_rock_t glulxe_retained_register(void *array, uint len, char *typecode); - void glulxe_retained_unregister(void *array, uint len, char *typecode, gidispatch_rock_t objrock); + gidispatch_rock_t glulxe_retained_register(void *array, uint len, const char *typecode); + void glulxe_retained_unregister(void *array, uint len, const char *typecode, gidispatch_rock_t objrock); /** * Turn a list of Glulx arguments into a list of Glk arguments, dispatch the function call, and return the result. diff --git a/engines/glk/streams.cpp b/engines/glk/streams.cpp index 84904f9a70..8b1a11d354 100644 --- a/engines/glk/streams.cpp +++ b/engines/glk/streams.cpp @@ -1575,6 +1575,18 @@ frefid_t Streams::iterate(frefid_t fref, uint *rock) { /*--------------------------------------------------------------------------*/ +FileReference::FileReference(int slot, const Common::String &desc, uint usage, uint rock) : + _rock(rock), _slotNumber(slot), _description(desc), + _fileType((FileUsage)(usage & fileusage_TypeMask)), _textMode(usage & fileusage_TextMode) { + if (g_vm->gli_register_obj) + _dispRock = (*g_vm->gli_register_obj)(this, gidisp_Class_Fileref); +} + +FileReference::~FileReference() { + if (g_vm->gli_unregister_obj) + (*g_vm->gli_unregister_obj)(this, gidisp_Class_Fileref, _dispRock); +} + const Common::String FileReference::getSaveName() const { assert(_slotNumber != -1); return g_vm->getSaveName(_slotNumber); diff --git a/engines/glk/streams.h b/engines/glk/streams.h index c254a89a28..a34ba6f0a4 100644 --- a/engines/glk/streams.h +++ b/engines/glk/streams.h @@ -103,9 +103,12 @@ struct FileReference { /** * Constructor */ - FileReference(int slot, const Common::String &desc, uint usage, uint rock = 0) : - _rock(rock), _slotNumber(slot), _description(desc), - _fileType((FileUsage)(usage & fileusage_TypeMask)), _textMode(usage & fileusage_TextMode) {} + FileReference(int slot, const Common::String &desc, uint usage, uint rock = 0); + + /** + * Destructor + */ + ~FileReference(); /** * Get savegame filename |