BlitzMax Extended  0.8.17
Pushing Blitz to the Max.
blitz_types.h
Go to the documentation of this file.
1 
18 #ifndef BLITZ_TYPES_H
19 #define BLITZ_TYPES_H
20 
21 #include <float.h>
22 #include <limits.h>
23 #include <stdint.h>
24 
25 #include "_common.h"
26 
27 #ifdef BB_ENV_C99
28 # include <stdbool.h>
29 #endif
30 
31 BB_BEGIN_DECLS
32 
33 #if defined BB_ENV_C99
34 
35 typedef int8_t BBInt8;
36 typedef uint8_t BBUInt8;
37 typedef int16_t BBInt16;
38 typedef uint16_t BBUInt16;
39 typedef int32_t BBInt32;
40 typedef uint32_t BBUInt32;
41 typedef int64_t BBInt64;
42 typedef uint64_t BBUInt64;
43 
44 #elif defined _MSC_VER
45 
46 typedef __int8 BBInt8;
47 typedef unsigned __int8 BBUInt8;
48 typedef __int16 BBInt16;
49 typedef unsigned __int16 BBUInt16;
50 typedef __int32 BBInt32;
51 typedef unsigned __int32 BBUInt32;
52 typedef __int64 BBInt64;
53 typedef unsigned __int64 BBUInt64;
54 
55 #else
56 
57 typedef signed char BBInt8;
58 typedef unsigned char BBUInt8;
59 typedef short BBInt16;
60 typedef unsigned short BBUInt16;
61 typedef int BBInt32;
62 typedef unsigned int BBUInt32;
63 typedef long long BBInt64;
64 typedef unsigned long long BBUInt64;
65 
66 #endif
67 
68 // Primitive data types
69 
74 typedef unsigned char BBByte;
75 
80 typedef unsigned short BBShort;
81 
86 typedef signed int BBInt;
87 
92 typedef BBInt64 BBLong;
93 
96 typedef float BBFloat;
97 
100 typedef double BBDouble;
101 
103 #define BBBYTE_MIN ((BBByte) 0x00)
104 
105 #define BBBYTE_MAX ((BBByte) 0xff)
106 
108 #define BBSHORT_MIN ((BBShort) 0x0000)
109 
110 #define BBSHORT_MAX ((BBShort) 0xffff)
111 
113 #define BBINT_MIN ((BBInt) 0x80000000)
114 
115 #define BBINT_MAX ((BBInt) 0x7fffffff)
116 
118 #define BBLONG_MIN ((BBLong) 0x800000000000000L)
119 
120 #define BBLONG_MAX ((BBLong) 0x7ffffffffffffffL)
121 
123 #define BBFLOAT_MIN ((BBFloat) -FLT_MAX)
124 
125 #define BBFLOAT_MAX ((BBFloat) FLT_MAX)
126 
128 #define BBDOUBLE_MIN ((BBDouble) -DBL_MAX)
129 
130 #define BBDOUBLE_MAX ((BBDouble) DBL_MAX)
131 
138 typedef BBUInt16 BBChar;
139 
141 #define BBCHAR_MIN ((BBChar) 0x0000)
142 
144 #define BBCHAR_MAX ((BBChar) 0xffff)
145 
156 typedef enum { BBFALSE, BBTRUE } BBBool;
157 
158 #ifdef BB_ENABLE_EXPERIMENTAL
159 
168 typedef unsigned int BBSize;
169 
170 #else
171 typedef int BBSize;
172 #endif // !BB_ENABLE_EXPERIMENTAL
173 
175 #define BBSIZE_MIN ((BBSize) 0)
176 
184 #define BBSIZE_MAX ((BBSize) INT_MAX)
185 
186 // Complex data types
187 
188 typedef struct BBClass BBClass;
189 typedef struct BBObject BBObject;
190 typedef struct BBString BBString;
191 typedef struct BBArray BBArray;
192 
193 extern const char *bbVoidTypeTag; // "?"
194 extern const char *bbByteTypeTag; // "b"
195 extern const char *bbShortTypeTag; // "s"
196 extern const char *bbIntTypeTag; // "i"
197 extern const char *bbLongTypeTag; // "l"
198 extern const char *bbFloatTypeTag; // "f"
199 extern const char *bbDoubleTypeTag; // "d"
200 extern const char *bbStringTypeTag; // "$"
201 extern const char *bbObjectTypeTag; // ":Object"
202 extern const char *bbBytePtrTypeTag;// "*b"
203 
204 // Additions by BME
205 
222 {
225 
228 
231 
234 
237 
240 
243 
246 
249 
252 
255 
258 };
259 
260 typedef enum BBTypeKey BBTypeKey;
261 
270 #define BBTYPEKEY_ISVALID(key) ((key) >= BBTYPEKEY_BYTE && (key) <= BBTYPEKEY_ARRAY)
271 
287 #define BBTYPEKEY_ISNUMERIC(key) ((key) >= BBTYPEKEY_BYTE && (key) <= BBTYPEKEY_DOUBLE)
288 
306 #define BBTYPEKEY_ISPRIMITIVE(key) ((key) >= BBTYPEKEY_BYTE && (key) <= BBTYPEKEY_OBJECT)
307 
322 #define BBTYPEKEY_ISCOMPLEX(key) ((key) >= BBTYPEKEY_OBJECT && (key) <= BBTYPEKEY_ARRAY)
323 
327 #define BBTYPEKEY_TAG(key) bbToTypeTagData[(key)]
328 
333 extern const BBTypeKey bbToTypeKeyData[];
334 
339 extern const char *bbToTypeTagData[];
340 
346 {
353  BBSize size;
354 
359  void *init;
360 
365  const char *ident;
366 };
367 
368 typedef struct BBTypeKeyInfo BBTypeKeyInfo;
369 
374 extern const BBTypeKeyInfo bbTypeKeyInfo[];
375 
376 #define BBTYPEKEY_INFO(key) bbTypeKeyInfo[(key)]
377 #define BBTYPEKEY_SIZE(key) bbTypeKeyInfo[(key)].size
378 #define BBTYPEKEY_INIT(key) bbTypeKeyInfo[(key)].init
379 #define BBTYPEKEY_IDENT(key) bbTypeKeyInfo[(key)].ident
380 
387 #define BBTYPETAG_KEY(tag) bbToTypeKeyData[(tag)[0]]
388 
389 #define BBTYPETAG_INFO(tag) bbTypeKeyInfo[BBTYPETAG_KEY(tag)]
390 #define BBTYPETAG_SIZE(tag) BBTYPETAG_INFO(tag).size
391 #define BBTYPETAG_INIT(tag) BBTYPETAG_INFO(tag).init
392 #define BBTYPETAG_IDENT(tag) BBTYPETAG_INFO(tag).ident
393 
394 
395 
396 // Don't use these, as they are confusing (BBSTRING is a pointer, BBINT isn't)
397 
398 typedef unsigned char BBBYTE;
399 typedef unsigned short BBSHORT;
400 typedef signed int BBINT;
401 typedef BBInt64 BBLONG;
402 typedef float BBFLOAT;
403 typedef double BBDOUBLE;
404 typedef BBClass* BBCLASS;
405 typedef BBObject* BBOBJECT;
406 typedef BBString* BBSTRING;
407 typedef BBArray* BBARRAY;
408 
409 BB_END_DECLS
410 
411 #endif // BLITZ_TYPES_H