comparison datum.h @ 0:76568becd6d6

Rhope Alpha 2a source import
author Mike Pavone <pavone@retrodev.com>
date Tue, 28 Apr 2009 23:06:07 +0000
parents
children 23dd9c766699
comparison
equal deleted inserted replaced
-1:000000000000 0:76568becd6d6
1 #ifndef _DATUM_H_
2 #define _DATUM_H_
3
4 #include "vis_threading.h"
5 #include "debugmacros.h"
6
7 /*
8 Old Datum structure
9 typedef struct
10 {
11 unsigned char type;//0=String,1=Bool,2=Int32,3=UInt32,4=Float, bit 7 = dynamically allocated (i.e. call free when datum is freed)
12 int len;
13 void * contents;
14 } datum;
15 */
16
17 //Support structs for new datum structure
18 #ifdef CPLUSPLUS
19 extern "C" {
20 #endif
21 #ifndef PROGRAM_STRUCT_DECLARED_
22 #define PROGRAM_STRUCT_DECLARED_
23 //icky hack until I figure out a better one
24 //defined in both datum.h and structs.h ugh
25
26 typedef struct
27 {
28 char filename[512];
29 struct defchunk * defs;
30 struct defchunk * current;
31 //struct worker_def * deflist;
32 //int num_defs;
33 //int defs_storage;
34 struct company * companylist;
35 int num_companies;
36 int companies_storage;
37 int refcount;
38 VIS_CRITICAL_SECTION(lock)
39 } program;
40
41 #endif
42
43 typedef struct
44 {
45 unsigned int len;
46 void * data;
47 } generic_data;
48 typedef struct
49 {
50 int num_a;
51 int num_b;
52 } two_ints;
53 //New datum structure
54 typedef struct
55 {
56 //unsigned short type;
57 struct company * company;
58 unsigned char union_type;
59 union
60 {
61 generic_data generic;
62 two_ints integers;
63 double real;
64 } c;
65 int ref_count;
66 VIS_CRITICAL_SECTION(lock)
67 } datum;
68
69 #define DATUMS_PER_STORAGE 512
70 typedef struct datum_storage
71 {
72 datum datums[DATUMS_PER_STORAGE];
73 unsigned short available;
74 unsigned char inuse[DATUMS_PER_STORAGE/8];
75 int num;
76 struct datum_storage * next;
77 } datum_storage;
78 #define CHECK_INUSE(storage, index, subindex) ((storage->inuse[index]) & (1 << (subindex)))
79 #define SET_INUSE(storage, index) (storage->inuse[index >> 3] |= (1 << (index & 7)))
80 #define CLEAR_INUSE(storage, index) (storage->inuse[index >> 3] &= ~(1 << (index & 7)))
81
82 datum * new_datum(unsigned short type, unsigned char union_type, int generic_len, program * prog);
83 datum * add_ref(datum * adatum);
84 void release_ref(datum * adatum);
85 void datum_set_yesno(datum * adatum, int val);
86 void init_datum_storage();
87 datum * copy_datum(datum * adatum, int newsize);
88 #ifdef CPLUSPLUS
89 }
90 #endif
91
92 #define DATUM_YES 1
93 #define DATUM_NO 0
94
95 #define BUILTIN_TYPE_SCREEN_CUSTOM 17
96 #define BUILTIN_TYPE_CUSTOM_WIDGET 16
97 #define BUILTIN_TYPE_CHECKBOX 20
98 #define BUILTIN_TYPE_DROPDOWN 21
99 #ifdef GUI_LIB
100 #ifdef SYLLABLE
101 #define USER_DEFINED_TYPES 22
102 #define BUILTIN_TYPE_BLUEPRINT 19
103 #define BUILTIN_TYPE_BUFFER 18
104 #else
105 #define USER_DEFINED_TYPES 18
106 #define BUILTIN_TYPE_BLUEPRINT 17
107 #define BUILTIN_TYPE_BUFFER 16
108 #endif
109 #define BUILTIN_TYPE_PROGRAM 15
110 #define BUILTIN_TYPE_GLOBAL_STORE 14
111 #define BUILTIN_TYPE_NETCLIENT 13
112 #else
113 #ifdef SEGA
114 #define USER_DEFINED_TYPES 12
115 #define BUILTIN_TYPE_BLUEPRINT 11
116 #define BUILTIN_TYPE_BUFFER 10
117 #define BUILTIN_TYPE_PROGRAM 9
118 #define BUILTIN_TYPE_GLOBAL_STORE 8
119 #else
120 #ifdef NO_NET
121 #define USER_DEFINED_TYPES 13
122 #define BUILTIN_TYPE_BLUEPRINT 12
123 #define BUILTIN_TYPE_BUFFER 11
124 #define BUILTIN_TYPE_PROGRAM 10
125 #define BUILTIN_TYPE_GLOBAL_STORE 9
126 #else
127 #define USER_DEFINED_TYPES 14
128 #define BUILTIN_TYPE_BLUEPRINT 13
129 #define BUILTIN_TYPE_BUFFER 12
130 #define BUILTIN_TYPE_PROGRAM 11
131 #define BUILTIN_TYPE_GLOBAL_STORE 10
132 #endif
133 #endif
134 #define BUILTIN_TYPE_NETCLIENT 9
135 #endif
136 #define BUILTIN_TYPE_INPUTBOX 12
137 #define BUILTIN_TYPE_BUTTON 11
138 #define BUILTIN_TYPE_WINDOW_SHOWN 10
139 #define BUILTIN_TYPE_WINDOW 9
140 #ifdef SEGA
141 #define BUILTIN_TYPE_WORKER 7
142 #else
143 #define BUILTIN_TYPE_WORKER 8
144 #endif //SEGA
145 #define BUILTIN_TYPE_FILE 7
146 #define BUILTIN_TYPE_DICT 6
147 #define BUILTIN_TYPE_LIST 5
148 #define BUILTIN_TYPE_REAL 4
149 #define BUILTIN_TYPE_WHOLE 3
150 #define BUILTIN_TYPE_STRING 2
151 #define BUILTIN_TYPE_YESNO 1
152 #define ANY_TYPE 0
153
154 #endif //_DATUM_H_
155
156
157
158
159
160
161