[Scummvm-git-logs] scummvm master -> 70febd034a6ff16c2945c52198386729a75a68e2

dreammaster paulfgilbert at gmail.com
Sun Apr 28 06:50:32 CEST 2019


This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
401b010ef3 GLK: Implementing more gli object registration
70febd034a GLK: Add gli registration for other object types


Commit: 401b010ef3f488601244129b93a6ea3bf5bc3fb1
    https://github.com/scummvm/scummvm/commit/401b010ef3f488601244129b93a6ea3bf5bc3fb1
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2019-04-28T14:32:49+10:00

Commit Message:
GLK: Implementing more gli object registration

Changed paths:
    engines/glk/glk.cpp
    engines/glk/glk.h
    engines/glk/glk_api.cpp
    engines/glk/glk_api.h
    engines/glk/glk_dispa.cpp
    engines/glk/glk_types.h
    engines/glk/glulxe/glkop.cpp
    engines/glk/glulxe/glulxe.h
    engines/glk/streams.cpp
    engines/glk/streams.h


diff --git a/engines/glk/glk.cpp b/engines/glk/glk.cpp
index 13f185d..5d99fc9 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 9064105..bebb482 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 e2f3117..d86bd26 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 e54cd3c..c47d23a 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 e4d089c..2b71086 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 ef9c709..4d32d5c 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 d19bbd2..2595a87 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 99e8b1a..cdb3735 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 84904f9..8b1a11d 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 c254a89..a34ba6f 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


Commit: 70febd034a6ff16c2945c52198386729a75a68e2
    https://github.com/scummvm/scummvm/commit/70febd034a6ff16c2945c52198386729a75a68e2
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2019-04-28T14:50:01+10:00

Commit Message:
GLK: Add gli registration for other object types

Changed paths:
    engines/glk/sound.cpp
    engines/glk/streams.cpp
    engines/glk/windows.cpp


diff --git a/engines/glk/sound.cpp b/engines/glk/sound.cpp
index 70c33c2..4f56ee2 100644
--- a/engines/glk/sound.cpp
+++ b/engines/glk/sound.cpp
@@ -75,13 +75,16 @@ void Sounds::poll() {
 
 SoundChannel::SoundChannel(Sounds *owner) : _owner(owner), _soundNum(0),
 		_rock(0), _notify(0) {
-	_dispRock.num = 0;
-	_dispRock.ptr = nullptr;
+	if (g_vm->gli_register_obj)
+		_dispRock = (*g_vm->gli_register_obj)(this, gidisp_Class_Schannel);
 }
 
 SoundChannel::~SoundChannel() {
 	stop();
 	_owner->removeSound(this);
+
+	if (g_vm->gli_unregister_obj)
+		(*g_vm->gli_unregister_obj)(this, gidisp_Class_Schannel, _dispRock);
 }
 
 uint SoundChannel::play(uint soundNum, uint repeats, uint notify) {
diff --git a/engines/glk/streams.cpp b/engines/glk/streams.cpp
index 8b1a11d..b124e30 100644
--- a/engines/glk/streams.cpp
+++ b/engines/glk/streams.cpp
@@ -36,12 +36,15 @@ namespace Glk {
 Stream::Stream(Streams *streams, bool readable, bool writable, uint rock, bool unicode) :
 		_streams(streams), _readable(readable), _writable(writable), _rock(0), _unicode(unicode),
 		_readCount(0), _writeCount(0), _prev(nullptr), _next(nullptr) {
-	_dispRock.num = 0;
-	_dispRock.ptr = nullptr;
+	if (g_vm->gli_register_obj)
+		_dispRock = (*g_vm->gli_register_obj)(this, gidisp_Class_Stream);
 }
 
 Stream::~Stream() {
 	_streams->removeStream(this);
+
+	if (g_vm->gli_unregister_obj)
+		(*g_vm->gli_unregister_obj)(this, gidisp_Class_Stream, _dispRock);
 }
 
 Stream *Stream::getNext(uint *rock) const {
diff --git a/engines/glk/windows.cpp b/engines/glk/windows.cpp
index d01f9de..ffb1fbf 100644
--- a/engines/glk/windows.cpp
+++ b/engines/glk/windows.cpp
@@ -517,10 +517,12 @@ Window::Window(Windows *windows, uint rock) : _windows(windows), _rock(rock),
 
 	_bgColor = g_conf->_windowColor;
 	_fgColor = g_conf->_propInfo._moreColor;
-	_dispRock.num = 0;
 
 	Streams &streams = *g_vm->_streams;
 	_stream = streams.openWindowStream(this);
+
+	if (g_vm->gli_register_obj)
+		_dispRock = (*g_vm->gli_register_obj)(this, gidisp_Class_Window);
 }
 
 Window::~Window() {





More information about the Scummvm-git-logs mailing list