BlitzMax Extended  0.8.16
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 
330 #define BBTYPETAG_KEY(tag) bbToTypeKeyData[(tag)[0]]
331 
336 extern const BBTypeKey bbToTypeKeyData[];
337 
343 {
350  BBSize size;
351 
356  void *init;
357 
362  const char *ident;
363 };
364 
365 typedef struct BBTypeKeyInfo BBTypeKeyInfo;
366 
371 extern const BBTypeKeyInfo bbTypeKeyInfo[];
372 
373 #define BBTYPEKEY_INFO(key) bbTypeKeyInfo[(key)]
374 #define BBTYPEKEY_SIZE(key) bbTypeKeyInfo[(key)].size
375 #define BBTYPEKEY_INIT(key) bbTypeKeyInfo[(key)].init
376 #define BBTYPEKEY_IDENT(key) bbTypeKeyInfo[(key)].ident
377 
378 #define BBTYPETAG_INFO(tag) bbTypeKeyInfo[BBTYPETAG_KEY(tag)]
379 #define BBTYPETAG_SIZE(tag) BBTYPETAG_INFO(tag).size
380 #define BBTYPETAG_INIT(tag) BBTYPETAG_INFO(tag).init
381 #define BBTYPETAG_IDENT(tag) BBTYPETAG_INFO(tag).ident
382 
383 
384 
385 #ifndef BB_DISABLE_DEPRECATED
386 
387 // Don't use these, as they are confusing (BBSTRING is a pointer, BBINT isn't)
388 
389 typedef unsigned char BBBYTE;
390 typedef unsigned short BBSHORT;
391 typedef signed int BBINT;
392 typedef BBInt64 BBLONG;
393 typedef float BBFLOAT;
394 typedef double BBDOUBLE;
395 typedef BBClass* BBCLASS;
396 typedef BBObject* BBOBJECT;
397 typedef BBString* BBSTRING;
398 typedef BBArray* BBARRAY;
399 
400 #endif // !BB_DISABLE_DEPRECATED
401 
402 BB_END_DECLS
403 
404 #endif // BLITZ_TYPES_H