mirror of
https://github.com/libretro/scummvm.git
synced 2025-02-01 00:12:59 +00:00
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
svn-id: r40272
This commit is contained in:
parent
50c8821072
commit
79b0711cfd
@ -445,12 +445,12 @@ static void sync_MemObjPtr(Common::Serializer &s, MemObject *&obj) {
|
||||
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);
|
||||
|
@ -367,8 +367,8 @@ MemObject *SegManager::memObjAllocate(SegmentId segid, int hash_id, memObjType t
|
||||
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 @@ SystemStrings *SegManager::allocateSysStrings(SegmentId *segid) {
|
||||
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;
|
||||
}
|
||||
|
@ -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 @@ struct SystemString {
|
||||
reg_t *value;
|
||||
};
|
||||
|
||||
struct SystemStrings {
|
||||
struct SystemStrings : public MemObjectNEW {
|
||||
SystemString strings[SYS_STRINGS_MAX];
|
||||
};
|
||||
|
||||
@ -149,7 +171,7 @@ struct CallsStruct {
|
||||
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 CodeBlock {
|
||||
|
||||
|
||||
|
||||
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 @@ struct Script {
|
||||
};
|
||||
|
||||
/** Data stack */
|
||||
struct dstack_t {
|
||||
struct dstack_t : MemObjectNEW {
|
||||
int nr; /**< Number of stack entries */
|
||||
reg_t *entries;
|
||||
};
|
||||
@ -262,7 +284,7 @@ struct Hunk {
|
||||
};
|
||||
|
||||
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 @@ void free_Hunk_entry(HunkTable *table, int index);
|
||||
|
||||
|
||||
// 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 @@ struct MemObject {
|
||||
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; }
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user