aboutsummaryrefslogtreecommitdiff
path: root/engines/sci/engine/seg_manager.h
diff options
context:
space:
mode:
Diffstat (limited to 'engines/sci/engine/seg_manager.h')
-rw-r--r--engines/sci/engine/seg_manager.h98
1 files changed, 49 insertions, 49 deletions
diff --git a/engines/sci/engine/seg_manager.h b/engines/sci/engine/seg_manager.h
index 88e6f42dd6..457f74f356 100644
--- a/engines/sci/engine/seg_manager.h
+++ b/engines/sci/engine/seg_manager.h
@@ -83,7 +83,7 @@ struct _mem_obj;
(((mgr).heap[index] && ((mgr).heap[index]->type == MEM_OBJ_SCRIPT || (mgr).heap[index]->type == MEM_OBJ_CLONES))? (mgr).heap[index] \
: NULL): NULL
-typedef struct _seg_manager_t {
+struct SegManager {
int_hash_map_t *id_seg_map; // id - script id; seg - index of heap
struct _mem_obj **heap;
int heap_size; // size of the heap
@@ -101,17 +101,17 @@ typedef struct _seg_manager_t {
seg_id_t lists_seg_id; // ID of the (a) list segment
seg_id_t nodes_seg_id; // ID of the (a) node segment
seg_id_t hunks_seg_id; // ID of the (a) hunk segment
-} seg_manager_t;
+};
// Toplevel functionality
-void sm_init(seg_manager_t *self, int sci1_1);
+void sm_init(SegManager *self, int sci1_1);
// Initialize the segment manager
-void sm_destroy(seg_manager_t *self);
+void sm_destroy(SegManager *self);
// Deallocate all memory associated with the segment manager
-void sm_gc(seg_manager_t *self, EngineState *s);
+void sm_gc(SegManager *self, EngineState *s);
// Perform garbage collection
// Parameters: (state_t *) s: The state to operate on
// Effects : Unreachable objects in 's' are deallocated
@@ -120,7 +120,7 @@ void sm_gc(seg_manager_t *self, EngineState *s);
void sm_free_script(mem_obj_t* mem);
-mem_obj_t *sm_allocate_script(struct _seg_manager_t* self, EngineState *s, int script_nr, int* seg_id);
+mem_obj_t *sm_allocate_script(SegManager* self, EngineState *s, int script_nr, int* seg_id);
// Allocate a script into the segment manager
// Parameters: (int) script_nr: number of the script to load
// (state_t *) s: The state containing resource manager handlers to load the
@@ -130,26 +130,26 @@ mem_obj_t *sm_allocate_script(struct _seg_manager_t* self, EngineState *s, int s
// The script must then be initialised; see section (1b.), below.
-int sm_deallocate_script(struct _seg_manager_t* self, int script_nr);
+int sm_deallocate_script(SegManager* self, int script_nr);
// Forcefully deallocate a previously allocated script
// Parameters: (int) script_nr: number of the script to deallocate
// Returns : (int) 1 on success, 0 on failure
-int sm_script_is_loaded(struct _seg_manager_t* self, int id, id_flag flag);
+int sm_script_is_loaded(SegManager* self, int id, id_flag flag);
// Determines whether a script has been loaded yet
// Parameters: (int) id: number of the script or ID of the script segment to check for
// (id_flag) flag: Whether to address the script by script number (SCRIPT_ID) or
// by its segment (SEG_ID). SEG_ID is faster than SCRIPT_ID,
// but less convenient.
-guint16 sm_validate_export_func(struct _seg_manager_t* self, int pubfunct, int seg);
+guint16 sm_validate_export_func(SegManager* self, int pubfunct, int seg);
// Validate whether the specified public function is exported by the script in the specified segment
// Parameters: (int) pubfunct: Index of the function to validate
// (int) seg: Segment ID of the script the check is to be performed for
// Returns : (guint16) 0 if the public function is invalid, its offset into the script's segment
// otherwise
-int sm_seg_get(seg_manager_t* self, int script_nr);
+int sm_seg_get(SegManager* self, int script_nr);
// Get the segment ID associated with a script number
// Parameters: (int) script_nr: Number of the script to look up
// Returns : (int) The associated segment ID, or -1 if no matching segment exists
@@ -159,7 +159,7 @@ int sm_seg_get(seg_manager_t* self, int script_nr);
// script lock operations
-void sm_increment_lockers(struct _seg_manager_t *self, int id, id_flag flag);
+void sm_increment_lockers(SegManager *self, int id, id_flag flag);
// Increments the number of lockers of the script in question by one
// Parameters: (int) id: ID of the script or script segment to modify
// (id_flag) flag: Whether to address the script by script number (SCRIPT_ID) or
@@ -167,14 +167,14 @@ void sm_increment_lockers(struct _seg_manager_t *self, int id, id_flag flag);
// but less convenient.
-void sm_decrement_lockers(struct _seg_manager_t *self, int id, id_flag flag);
+void sm_decrement_lockers(SegManager *self, int id, id_flag flag);
// Decrements the number of lockers of the script in question by one
// Parameters: (int) id: ID of the script or script segment to modify
// (id_flag) flag: Whether to address the script by script number (SCRIPT_ID) or
// by its segment (SEG_ID). SEG_ID is faster than SCRIPT_ID,
// but less convenient.
-int sm_get_lockers(struct _seg_manager_t *self, int id, id_flag flag);
+int sm_get_lockers(SegManager *self, int id, id_flag flag);
// Retrieves the number of locks held on this script
// Parameters: (int) id: ID of the script or script segment to read from
// (id_flag) flag: Whether to address the script by script number (SCRIPT_ID) or
@@ -183,7 +183,7 @@ int sm_get_lockers(struct _seg_manager_t *self, int id, id_flag flag);
// Returns : (int) The number of locks held on the previously identified script
-void sm_set_lockers(struct _seg_manager_t *self, int lockers, int id, id_flag flag);
+void sm_set_lockers(SegManager *self, int lockers, int id, id_flag flag);
// Sets the number of locks held on the specified script
// Parameters: (int) id: ID of the script or script segment to modify
// (id_flag) flag: Whether to address the script by script number (SCRIPT_ID) or
@@ -191,7 +191,7 @@ void sm_set_lockers(struct _seg_manager_t *self, int lockers, int id, id_flag fl
// but less convenient.
-byte *sm_get_synonyms(struct _seg_manager_t *self, int id, id_flag flag);
+byte *sm_get_synonyms(SegManager *self, int id, id_flag flag);
// Retrieves a pointer to the synonyms associated with the specified script
// Parameters: (int) id: ID of the script or script segment to read from
// (id_flag) flag: Whether to address the script by script number (SCRIPT_ID) or
@@ -201,7 +201,7 @@ byte *sm_get_synonyms(struct _seg_manager_t *self, int id, id_flag flag);
// A dynamic failure is issued if the specified ID does not reference a proper script.
-int sm_get_synonyms_nr(struct _seg_manager_t *self, int id, id_flag flag);
+int sm_get_synonyms_nr(SegManager *self, int id, id_flag flag);
// Retrieves the number of synonyms associated with the specified script
// Parameters: (int) id: ID of the script or script segment to read from
// (id_flag) flag: Whether to address the script by script number (SCRIPT_ID) or
@@ -218,19 +218,19 @@ int sm_get_synonyms_nr(struct _seg_manager_t *self, int id, id_flag flag);
// to be used during script instantiation,
// i.e. loading and linking.
-void sm_script_initialise_locals_zero(struct _seg_manager_t *self, seg_id_t seg, int nr);
+void sm_script_initialise_locals_zero(SegManager *self, seg_id_t seg, int nr);
// Initializes a script's local variable block
// Parameters: (seg_id_t) seg: Segment containing the script to initialize
// (int) nr: Number of local variables to allocate
// All variables are initialized to zero.
-void sm_script_initialise_locals(struct _seg_manager_t *self, reg_t location);
+void sm_script_initialise_locals(SegManager *self, reg_t location);
// Initializes a script's local variable block according to a prototype
// Parameters: (reg_t) location: Location to initialize from
-object_t *sm_script_obj_init(seg_manager_t *self, EngineState *s, reg_t obj_pos);
+object_t *sm_script_obj_init(SegManager *self, EngineState *s, reg_t obj_pos);
// Initializes an object within the segment manager
// Parameters: (reg_t) obj_pos: Location (segment, offset) of the object
// Returns : (object_t *) A newly created object_t describing the object
@@ -239,16 +239,16 @@ object_t *sm_script_obj_init(seg_manager_t *self, EngineState *s, reg_t obj_pos)
// The corresponding object_t is stored within the relevant script.
-void sm_script_add_code_block(struct _seg_manager_t *self, reg_t location);
+void sm_script_add_code_block(SegManager *self, reg_t location);
// Informs the segment manager that a code block must be relocated
// Parameters: (reg_t) location: Start of block to relocate
-void sm_set_export_width(struct _seg_manager_t *self, int flag);
+void sm_set_export_width(SegManager *self, int flag);
// Tells the segment manager whether exports are wide (32-bit) or not.
// Parameters: (int) flag: 1 if exports are wide, 0 otherwise
-void sm_script_relocate(struct _seg_manager_t *self, reg_t block);
+void sm_script_relocate(SegManager *self, reg_t block);
// Processes a relocation block witin a script
// Parameters: (reg_t) obj_pos: Location (segment, offset) of the block
// Returns : (object_t *) Location of the relocation block
@@ -256,14 +256,14 @@ void sm_script_relocate(struct _seg_manager_t *self, reg_t block);
// objects have been instantiated, or a run-time error will occur.
-void sm_script_free_unused_objects(struct _seg_manager_t *self, seg_id_t segid);
+void sm_script_free_unused_objects(SegManager *self, seg_id_t segid);
// Deallocates all unused but allocated entries for objects
// Parameters: (seg_id_t) segid: segment of the script to prune in this way
// These entries are created during script instantiation; deallocating them
// frees up some additional memory.
-void sm_set_export_table_offset(struct _seg_manager_t *self, int offset, int id, id_flag flag);
+void sm_set_export_table_offset(SegManager *self, int offset, int id, id_flag flag);
// Sets the script-relative offset of the exports table
// Parameters: (int) offset: The script-relative exports table offset
// (int) id: ID of the script or script segment to write to
@@ -273,7 +273,7 @@ void sm_set_export_table_offset(struct _seg_manager_t *self, int offset, int id,
// A dynamic failure is issued if the specified ID does not reference a proper script.
-void sm_set_synonyms_offset(struct _seg_manager_t *self, int offset, int id, id_flag flag);
+void sm_set_synonyms_offset(SegManager *self, int offset, int id, id_flag flag);
// Sets the script-relative offset of the synonyms associated with the specified script
// Parameters: (int) offset: The script-relative offset of the synonyms block
// (int) id: ID of the script or script segment to write to
@@ -283,7 +283,7 @@ void sm_set_synonyms_offset(struct _seg_manager_t *self, int offset, int id, id_
// A dynamic failure is issued if the specified ID does not reference a proper script.
-void sm_set_synonyms_nr(struct _seg_manager_t *self, int nr, int id, id_flag flag);
+void sm_set_synonyms_nr(SegManager *self, int nr, int id, id_flag flag);
// Sets the number of synonyms associated with the specified script
// Parameters: (int) nr: The number of synonyms, as to be stored within the script
// (int) id: ID of the script or script segment to write to
@@ -293,7 +293,7 @@ void sm_set_synonyms_nr(struct _seg_manager_t *self, int nr, int id, id_flag fla
// A dynamic failure is issued if the specified ID does not reference a proper script.
-void sm_mark_script_deleted(seg_manager_t *self, int script_nr);
+void sm_mark_script_deleted(SegManager *self, int script_nr);
// Marks the script identified by its script number as deleted
// Parameters: (int) script_nr: Script number to mark as deleted
// This will not actually delete the script. If references remain present on the
@@ -302,12 +302,12 @@ void sm_mark_script_deleted(seg_manager_t *self, int script_nr);
// in its data being updated).
-void sm_unmark_script_deleted(seg_manager_t *self, int script_nr);
+void sm_unmark_script_deleted(SegManager *self, int script_nr);
// Marks the script identified by its script number as not deleted
// Parameters: (int) script_nr: Script number to mark as not deleted
-int sm_script_is_marked_as_deleted(seg_manager_t *self, seg_id_t seg);
+int sm_script_is_marked_as_deleted(SegManager *self, seg_id_t seg);
// Determines whether the script referenced by the indicated segment is marked as being deleted.
// Parameters: (seg_id_t) Segment ID of the script to investigate
// Returns : (int) 1 iff seg points to a script and the segment is deleted, 0 otherwise
@@ -316,13 +316,13 @@ int sm_script_is_marked_as_deleted(seg_manager_t *self, seg_id_t seg);
// 2. Clones
-clone_t *sm_alloc_clone(struct _seg_manager_t *self, reg_t *addr);
+clone_t *sm_alloc_clone(SegManager *self, reg_t *addr);
// Allocate a fresh clone
// Returns : (clone_t*): Reference to the memory allocated for the clone
// (reg_t) *addr: The offset of the freshly allocated clone
-void sm_free_clone(struct _seg_manager_t *self, reg_t addr);
+void sm_free_clone(SegManager *self, reg_t addr);
// Deallocates a clone
// Parameters: (reg_t) addr: Offset of the clone scheduled for termination
@@ -331,19 +331,19 @@ void sm_free_clone(struct _seg_manager_t *self, reg_t addr);
// Not all of these functions are fully operational for clones ATM
-gint16 sm_get_heap(struct _seg_manager_t* self, reg_t reg);
+gint16 sm_get_heap(SegManager* self, reg_t reg);
// Retrieves a 16 bit value from within a script's heap representation
// Parameters: (reg_t) reg: The address to read from
// Returns : (gint16) The value read from the specified location
-void sm_put_heap(struct _seg_manager_t *self, reg_t reg, gint16 value);
+void sm_put_heap(SegManager *self, reg_t reg, gint16 value);
// Writes a 16 bit value into a script's heap representation
// Parameters: (reg_t) reg: The address to write to
// (gint16) value: The value to write
-void sm_mcpy_in_out(seg_manager_t* self, int dst, const void *src, size_t n, int id, int flag);
+void sm_mcpy_in_out(SegManager* self, int dst, const void *src, size_t n, int id, int flag);
// Copies a byte string into a script's heap representation
// Parameters: (int) dst: The script-relative offset of the destination area
// (const void *) src: Pointer to the data source location
@@ -357,7 +357,7 @@ void sm_mcpy_in_out(seg_manager_t* self, int dst, const void *src, size_t n, int
// 4. Stack
-dstack_t *sm_allocate_stack(struct _seg_manager_t *self, int size, seg_id_t *segid);
+dstack_t *sm_allocate_stack(SegManager *self, int size, seg_id_t *segid);
// Allocates a data stack
// Parameters: (int) size: Number of stack entries to reserve
// Returns : (dstack_t *): The physical stack
@@ -366,7 +366,7 @@ dstack_t *sm_allocate_stack(struct _seg_manager_t *self, int size, seg_id_t *seg
// 5. System Strings
-sys_strings_t *sm_allocate_sys_strings(struct _seg_manager_t *self, seg_id_t *segid);
+sys_strings_t *sm_allocate_sys_strings(SegManager *self, seg_id_t *segid);
// Allocates a system string table
// Returns : (dstack_t *): The physical stack
// (seg_id_t) segid: Segment ID of the stack
@@ -375,30 +375,30 @@ sys_strings_t *sm_allocate_sys_strings(struct _seg_manager_t *self, seg_id_t *se
// 6, 7. Lists and Nodes
-list_t *sm_alloc_list(struct _seg_manager_t *self, reg_t *addr);
+list_t *sm_alloc_list(SegManager *self, reg_t *addr);
// Allocate a fresh list
// Returns : (listY_t*): Reference to the memory allocated for the list
// (reg_t) *addr: The offset of the freshly allocated list
-void sm_free_list(struct _seg_manager_t *self, reg_t addr);
+void sm_free_list(SegManager *self, reg_t addr);
// Deallocates a list
// Parameters: (reg_t) addr: Offset of the list scheduled for termination
-node_t *sm_alloc_node(struct _seg_manager_t *self, reg_t *addr);
+node_t *sm_alloc_node(SegManager *self, reg_t *addr);
// Allocate a fresh node
// Returns : (node_t*): Reference to the memory allocated for the node
// (reg_t) *addr: The offset of the freshly allocated node
-void sm_free_node(struct _seg_manager_t *self, reg_t addr);
+void sm_free_node(SegManager *self, reg_t addr);
// Deallocates a list node
// Parameters: (reg_t) addr: Offset of the node scheduled for termination
// 8. Hunk Memory
-hunk_t *sm_alloc_hunk_entry(struct _seg_manager_t *self, const char *hunk_type, int size, reg_t *addr);
+hunk_t *sm_alloc_hunk_entry(SegManager *self, const char *hunk_type, int size, reg_t *addr);
// Allocate a fresh chunk of the hunk
// Parameters: (int) size: Number of bytes to allocate for the hunk entry
// (const char *) hunk_type: A descriptive string for the hunk entry,
@@ -407,14 +407,14 @@ hunk_t *sm_alloc_hunk_entry(struct _seg_manager_t *self, const char *hunk_type,
// (reg_t) *addr: The offset of the freshly allocated hunk entry
-void sm_free_hunk_entry(struct _seg_manager_t *self, reg_t addr);
+void sm_free_hunk_entry(SegManager *self, reg_t addr);
// Deallocates a hunk eentry
// Parameters: (reg_t) addr: Offset of the hunk entry to delete
// 9. Dynamic Memory
-unsigned char *sm_alloc_dynmem(struct _seg_manager_t *self, int size, const char *description, reg_t *addr);
+unsigned char *sm_alloc_dynmem(SegManager *self, int size, const char *description, reg_t *addr);
// Allocate some dynamic memory
// Parameters: (int) size: Number of bytes to allocate
// (const char_ *) description: A descriptive string,
@@ -422,12 +422,12 @@ unsigned char *sm_alloc_dynmem(struct _seg_manager_t *self, int size, const char
// Returns : (unsigned char*): Raw pointer into the allocated dynamic memory
// (reg_t) *addr: The offset of the freshly allocated X
-int sm_free_dynmem(struct _seg_manager_t *self, reg_t addr);
+int sm_free_dynmem(SegManager *self, reg_t addr);
// Deallocates a piece of dynamic memory
// Parameters: (reg_t) addr: Offset of the dynmem chunk to free
-const char *sm_get_description(struct _seg_manager_t *self, reg_t addr);
+const char *sm_get_description(SegManager *self, reg_t addr);
// Gets the description of a dynmem segment
// Parameters: (reg_t) addr: Segment to describe
// Returns : (const char *): Pointer to the descriptive string set in
@@ -436,7 +436,7 @@ const char *sm_get_description(struct _seg_manager_t *self, reg_t addr);
// 10. Reserved segments
-seg_id_t sm_allocate_reserved_segment(struct _seg_manager_t *self, char *name);
+seg_id_t sm_allocate_reserved_segment(SegManager *self, char *name);
// Reserves a special-purpose segment
// Parameters: (char *) name: A string name identifying the segment (the string is cloned and retained)
// Returns : A fresh segment ID for the segment in question
@@ -446,7 +446,7 @@ seg_id_t sm_allocate_reserved_segment(struct _seg_manager_t *self, char *name);
// Generic Operations on Segments and Addresses
-byte *sm_dereference(struct _seg_manager_t *self, reg_t reg, int *size);
+byte *sm_dereference(SegManager *self, reg_t reg, int *size);
// Dereferences a raw memory pointer
// Parameters: (reg_t) reg: The reference to dereference
// Returns : (byte *) The data block referenced
@@ -455,7 +455,7 @@ byte *sm_dereference(struct _seg_manager_t *self, reg_t reg, int *size);
// 11. Segment interface, primarily for GC
typedef struct _seg_interface {
- seg_manager_t *segmgr;
+ SegManager *segmgr;
mem_obj_t *mobj;
seg_id_t seg_id;
mem_obj_enum type_id; // Segment type
@@ -488,7 +488,7 @@ typedef struct _seg_interface {
// Deallocates the segment interface
} seg_interface_t;
-seg_interface_t *get_seg_interface(seg_manager_t *self, seg_id_t segid);
+seg_interface_t *get_seg_interface(SegManager *self, seg_id_t segid);
// Retrieves the segment interface to the specified segment
// Parameters: (seg_id_t) segid: ID of the segment to look up
// Returns : (seg_interface_t *): An interface to the specified segment ID, or NULL on error