[Scummvm-cvs-logs] SF.net SVN: scummvm:[40272] scummvm/trunk/engines/sci/engine

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Sun May 3 11:31:00 CEST 2009


Revision: 40272
          http://scummvm.svn.sourceforge.net/scummvm/?rev=40272&view=rev
Author:   fingolfin
Date:     2009-05-03 09:30:59 +0000 (Sun, 03 May 2009)

Log Message:
-----------
SCI: Begun conversion of the MemObject union (used to implement poor man's fake inheritance) into a base class of all the various union members

Modified Paths:
--------------
    scummvm/trunk/engines/sci/engine/savegame.cpp
    scummvm/trunk/engines/sci/engine/seg_manager.cpp
    scummvm/trunk/engines/sci/engine/vm.h

Modified: scummvm/trunk/engines/sci/engine/savegame.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/savegame.cpp	2009-05-03 09:30:33 UTC (rev 40271)
+++ scummvm/trunk/engines/sci/engine/savegame.cpp	2009-05-03 09:30:59 UTC (rev 40272)
@@ -445,12 +445,12 @@
 	if (s.isLoading()) {
 		//assert(!obj);
 		obj = (MemObject *)sci_calloc(1, sizeof(MemObject));
-		obj->_type = type;
+		obj->data.tmp_dummy._type = type;
 	} else {
 		assert(obj);
 	}
 	
-	s.syncAsSint32LE(obj->_segmgrId);
+	s.syncAsSint32LE(obj->data.tmp_dummy._segmgrId);
 	switch (type) {
 	case MEM_OBJ_SCRIPT:
 		sync_Script(s, obj->data.script);

Modified: scummvm/trunk/engines/sci/engine/seg_manager.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/seg_manager.cpp	2009-05-03 09:30:33 UTC (rev 40271)
+++ scummvm/trunk/engines/sci/engine/seg_manager.cpp	2009-05-03 09:30:59 UTC (rev 40272)
@@ -367,8 +367,8 @@
 		memset(heap + oldhs, 0, sizeof(MemObject *) * (heap_size - oldhs));
 	}
 
-	mem->_segmgrId = hash_id;
-	mem->_type = type;
+	mem->data.tmp_dummy._segmgrId = hash_id;
+	mem->data.tmp_dummy._type = type;
 
 	// hook it to the heap
 	heap[segid] = mem;
@@ -970,7 +970,7 @@
 	MemObject *memobj = allocNonscriptSegment(MEM_OBJ_SYS_STRINGS, segid);
 	SystemStrings *retval = &(memobj->data.sys_strings);
 
-	memset(retval, 0, sizeof(SystemString)*SYS_STRINGS_MAX);
+	memset(retval->strings, 0, sizeof(retval->strings));
 
 	return retval;
 }

Modified: scummvm/trunk/engines/sci/engine/vm.h
===================================================================
--- scummvm/trunk/engines/sci/engine/vm.h	2009-05-03 09:30:33 UTC (rev 40271)
+++ scummvm/trunk/engines/sci/engine/vm.h	2009-05-03 09:30:59 UTC (rev 40272)
@@ -34,6 +34,28 @@
 
 namespace Sci {
 
+enum memObjType {
+	MEM_OBJ_INVALID = 0,
+	MEM_OBJ_SCRIPT = 1,
+	MEM_OBJ_CLONES = 2,
+	MEM_OBJ_LOCALS = 3,
+	MEM_OBJ_STACK = 4,
+	MEM_OBJ_SYS_STRINGS = 5,
+	MEM_OBJ_LISTS = 6,
+	MEM_OBJ_NODES = 7,
+	MEM_OBJ_HUNK = 8,
+	MEM_OBJ_DYNMEM = 9,
+	MEM_OBJ_STRING_FRAG = 10,
+
+	MEM_OBJ_MAX // For sanity checking
+};
+
+struct MemObjectNEW {
+	memObjType _type;
+	int _segmgrId; /**< Internal value used by the seg_manager's hash map */
+};
+
+
 struct IntMapper;
 
 enum {
@@ -51,7 +73,7 @@
 	reg_t *value;
 };
 
-struct SystemStrings {
+struct SystemStrings : public MemObjectNEW {
 	SystemString strings[SYS_STRINGS_MAX];
 };
 
@@ -149,7 +171,7 @@
 	int type; /**< Same as ExecStack.type */
 };
 
-struct LocalVariables {
+struct LocalVariables : public MemObjectNEW {
 	int script_id; /**< Script ID this local variable block belongs to */
 	reg_t *locals;
 	int nr;
@@ -198,7 +220,7 @@
 
 
 
-struct Script {
+struct Script : public MemObjectNEW {
 	int nr; /**< Script number */
 	byte* buf; /**< Static data buffer, or NULL if not used */
 	size_t buf_size;
@@ -233,7 +255,7 @@
 };
 
 /** Data stack */
-struct dstack_t {
+struct dstack_t : MemObjectNEW {
 	int nr; /**< Number of stack entries */
 	reg_t *entries;
 };
@@ -262,7 +284,7 @@
 };
 
 template<typename T, int INITIAL, int INCREMENT>
-struct Table {
+struct Table : public MemObjectNEW {
 	struct Entry : public T {
 		int next_free; /* Only used for free entries */
 	};
@@ -324,31 +346,15 @@
 
 
 // Free-style memory
-struct DynMem {
+struct DynMem : public MemObjectNEW {
 	int size;
 	char *description;
 	byte *buf;
 };
 
-enum memObjType {
-	MEM_OBJ_INVALID = 0,
-	MEM_OBJ_SCRIPT = 1,
-	MEM_OBJ_CLONES = 2,
-	MEM_OBJ_LOCALS = 3,
-	MEM_OBJ_STACK = 4,
-	MEM_OBJ_SYS_STRINGS = 5,
-	MEM_OBJ_LISTS = 6,
-	MEM_OBJ_NODES = 7,
-	MEM_OBJ_HUNK = 8,
-	MEM_OBJ_DYNMEM = 9,
-	MEM_OBJ_STRING_FRAG = 10,
-	MEM_OBJ_MAX = 11 // For sanity checking
-};
-
 struct MemObject {
-	memObjType _type;
-	int _segmgrId; /**< Internal value used by the seg_manager's hash map */
 	union {
+		MemObjectNEW tmp_dummy;
 		Script script;
 		CloneTable clones;
 		LocalVariables locals;
@@ -360,8 +366,8 @@
 		DynMem dynmem;
 	} data;
 
-	inline memObjType getType() const { return _type; }
-	inline int getSegMgrId() const { return _segmgrId; }
+	inline memObjType getType() const { return data.tmp_dummy._type; }
+	inline int getSegMgrId() const { return data.tmp_dummy._segmgrId; }
 };
 
 


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list