Mercurial > repos > rhope
view structs.h @ 72:f7bcf3db1342
Add =@String, fix bool bug
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Fri, 18 Jun 2010 17:00:50 -0400 |
parents | 94c885692eb5 |
children |
line wrap: on
line source
#ifndef _STRUCTS_H_ #define _STRUCTS_H_ #ifdef WIN32 #include <windows.h> #endif #ifndef BOOL #define BOOL short #define TRUE 1 #define FALSE 0 #endif #ifndef DWORD #define DWORD unsigned long #endif #ifndef WINAPI #define WINAPI #endif #ifndef LPVOID #define LPVOID void * #endif #ifndef NULL #define NULL 0 #endif //#include "interp.h" #include "vis_threading.h" #include "datum.h" #define QUEUE_SIZE 512 #include <stdio.h> #ifdef CPLUSPLUS extern "C" { #endif typedef struct { int type; int num_outputs; int num_inputs; char name[256]; int wire_up_lookup; int wire_down_lookup; void * value_index;//used to associate with a def int io_num; unsigned short magic_cache_type; struct worker_def * magic_cache_implement; VIS_CRITICAL_SECTION(lock) BOOL null_input; } worker; typedef struct { int start_worker; int end_worker; int output_num; int input_num; } wire; typedef struct { datum * value; VIS_CRITICAL_SECTION(worker_lock) int ready_count; datum * params[32]; } worker_instance_data; typedef struct { datum * data; } wire_instance_data; /* Moved to datum.h for stupid reasons typedef struct { char filename[512]; struct worker_def * deflist; int num_defs; int defs_storage; struct company * companylist; int num_companies; int companies_storage; } program; */ /*typedef struct worker_def { worker_impl implement_func; char name[256]; int num_outputs; int num_inputs; unsigned short input_types[32]; // unsigned short output_types[32]; // int parent_out_wires[32]; worker * workerlist; int num_workers; wire * wirelist; int num_wires; int * workers_to_wires_down; int * workers_to_wires_up; // struct worker_def * parent; // int parent_attached_worker; // int parent_attached_workerout; // struct worker_def ** children; // int num_children; BOOL magic; program program; } worker_def;*/ /* typedef struct worker_def_file { worker_impl implement_func; char name[256]; int num_outputs; int num_inputs; unsigned short input_types[32]; // unsigned short output_types[32]; // int parent_out_wires[32]; worker * workerlist; int num_workers; wire * wirelist; int num_wires; int * workers_to_wires_down; int * workers_to_wires_up; // struct worker_def * parent; // int parent_attached_worker; // int parent_attached_workerout; // struct worker_def ** children; // int num_children; BOOL magic; } worker_def;*/ typedef struct { worker * workerlist; int num_workers; int worker_storage; wire * wirelist; int num_wires; int wire_storage; int * workers_to_wires_down; int * workers_to_wires_up; VIS_CRITICAL_SECTION(lock) BOOL dirty; } custom_worker; #define TRANSACTION_WRITE 0x8000 #define TRANSACTION_TYPE_MASK 0xFF #define TRANSACTION_RETRY 0 #define TRANSACTION_FORCE 1 typedef struct worker_def { custom_worker * implement_func; //points to either C function or "custom function struct" char * name; struct opt_entry * optimized; int opt_count; int num_stores; char ** uses_stores; unsigned short num_outputs; unsigned short num_inputs; unsigned short *input_types; unsigned short *output_types; unsigned short type; //Magic, Builtin, Custom unsigned short transaction_flags; #ifdef CPLUSPLUS //ugly hack alert! program * prog; #else program * program; #endif #ifdef USER_PROFILE int count; LARGE_INTEGER total; LARGE_INTEGER worst; VIS_CRITICAL_SECTION(lock) #endif } worker_def; typedef struct defchunk { int num_defs; int defs_storage; struct defchunk * next; worker_def deflist[1]; } defchunk; typedef struct { datum * name; datum * data; //short inuse; } global_store; typedef struct { global_store * store; datum * begin_data; datum * instance_data; VIS_CRITICAL_SECTION(lock) } global_store_use; typedef struct { int num_stores; datum * params[32]; global_store_use stores[1]; } transaction; typedef struct worker_instance { worker_def * def; worker_instance_data * workerlist; datum ** opt_results; int num_workers; wire_instance_data * wirelist; int num_wires; void (*callback)(struct worker_instance *, int, struct worker_instance *, void * data); void * callback_data; struct worker_instance * caller_instance; int worker_in_caller; int in_queue_count; int in_progress_count; int child_count; transaction * trans; #ifdef USER_PROFILE LARGE_INTEGER start; #endif // USER_PROFILE VIS_CRITICAL_SECTION(counter_lock) } worker_instance; typedef void (*instance_callback)(worker_instance *, int, worker_instance *, void * data); typedef struct { int worker_num; worker_instance * instance; } queue_entry; typedef struct queue_section { queue_entry entries[QUEUE_SIZE]; struct queue_section * last; struct queue_section * next; } queue_section; #define ROOM_NO_ACCESS 0 #define ROOM_BYTE 1 #define ROOM_SHORT 2 #define ROOM_LONG 3 #define ROOM_SINGLE 4 #define ROOM_DOUBLE 5 //The param must be set to the max string length for these #define ROOM_CSTRING_STRUCT 6 #define ROOM_PSTRING_STRUCT 7 //Pointer types: For the following it's assumed that it's safe to free the current string #define ROOM_CSTRING 8 #define ROOM_PSTRING 9 //Will copy the contents of a complex value to the destination offset, or the union contents otherwise #define ROOM_VIS_OBJECT 10 //Pointer to datum #define ROOM_VIS_REF 11 //Use a worker to set/get the room #define ROOM_WORKER 12 #define PRIVATE_FLAG 0x8000 #define ROOM_TYPE_MASK 0xFF typedef struct { char * name; void * set_func; void * get_func; int param; unsigned short set_func_type; unsigned short get_func_type; } company_room; typedef struct company { char name[256]; worker_def ** methodlist; int num_methods; int method_storage; company_room * room_list; int num_rooms; int room_storage; int build_size; unsigned short type_id; VIS_CRITICAL_SECTION(lock) } company; typedef struct { int num_entries; datum * entries[1]; } list_data; /* typedef struct ternary_node { struct ternary_node * left; struct ternary_node * right; struct ternary_node * next; datum * payload; char letter; } ternary_node; */ typedef struct ternary_node { int left; int right; int next; datum * payload; char letter; } ternary_node; typedef struct { int num_entries; //Number of entries currently in the dict int num_nodes; //Number of ternary nodes in the dict int node_storage; //Max number of nodes we can store in the dict ternary_node nodes[1]; } dict_data; typedef enum {FILE_NOSIZE, FILE_CLOSED, FILE_WRITE, FILE_READ, FILE_CANT_OPEN} file_status; typedef struct { unsigned int size; #ifndef SEGA FILE * file; #endif VIS_CRITICAL_SECTION(lock) int ref_count; file_status status; char name[1]; } shared_file; typedef struct { unsigned int offset; shared_file * shared; } file_data; typedef struct { datum * title; double width; double height; datum * widget_dict; datum * widget_xpos; datum * widget_ypos; datum * id_list; datum * menu; } vis_window; typedef struct { datum * label; datum * value; double width; double height; int flags; datum * handler_dict; int selected_index; } vis_widget; typedef struct { datum * label_list; datum * action_list; } vis_menu; typedef struct { VIS_CRITICAL_SECTION(lock) datum ** params; BOOL done_flag; } def_done; typedef struct opt_entry { worker_def * def; int original_pos; int * input_data; int null_inputs; int branch1; int branch2; int * output_refs; } opt_entry; typedef struct { worker_def * def; datum * params[32]; } worker_datum; #define MIN_STACK_SIZE 512 //minimum stack size in longwords typedef struct stack_segment { int size; struct stack_segment *parent; struct stack_segment *child; unsigned long current_stack;//only used when stack is in the queue unsigned int data[MIN_STACK_SIZE]; } stack_segment; #define QUEUE_FUNC 0 #define QUEUE_BUILTIN 1 #define QUEUE_BLOCK 2 #define QUEUE_BLOCK_WAIT 3 typedef struct { unsigned long * address; void * params; stack_segment * stack; char type; } virt_queue_entry; typedef struct virt_queue_segment { struct virt_queue_segment * next; struct virt_queue_segment * last; virt_queue_entry entries[QUEUE_SIZE]; } virt_queue_segment; typedef int (*worker_impl)(datum **, queue_entry *); //extern worker_def deflist[100]; //extern int num_defs; //extern datum data[4096]; //extern int num_datum; extern wire wirelist[2048]; extern int num_wires; extern worker workerlist[1024]; extern int num_workers; extern int workers_to_wires_down[2048]; extern int workers_to_wires_up[2048]; #ifdef CPLUSPLUS } #endif #endif //_STRUCTS_H_