|
BlitzMax Extended
0.8.9
Pushing Blitz to the Max.
|
00001 00018 #ifndef BLITZ_TYPES_H 00019 #define BLITZ_TYPES_H 00020 00021 #include <float.h> 00022 #include <limits.h> 00023 00024 #include "_common.h" 00025 00026 #ifdef BB_ENV_C99 00027 # include <stdbool.h> 00028 # include <stdint.h> 00029 #endif 00030 00031 BB_BEGIN_DECLS 00032 00033 #if defined (BB_ENV_C99) 00034 00035 typedef int8_t BBInt8; 00036 typedef uint8_t BBUInt8; 00037 typedef int16_t BBInt16; 00038 typedef uint16_t BBUInt16; 00039 typedef int32_t BBInt32; 00040 typedef uint32_t BBUInt32; 00041 typedef int64_t BBInt64; 00042 typedef uint64_t BBUInt64; 00043 00044 #elif defined (_MSC_VER) 00045 00046 typedef __int8 BBInt8; 00047 typedef unsigned __int8 BBUInt8; 00048 typedef __int16 BBInt16; 00049 typedef unsigned __int16 BBUInt16; 00050 typedef __int32 BBInt32; 00051 typedef unsigned __int32 BBUInt32; 00052 typedef __int64 BBInt64; 00053 typedef unsigned __int64 BBUInt64; 00054 00055 #else 00056 00057 // todo: Maybe check for everything separately? 00058 00059 typedef long long BBInt64; 00060 typedef unsigned long long BBUInt64; 00061 00062 #endif 00063 00064 // Primitive data types 00065 00070 typedef unsigned char BBByte; 00071 00076 typedef unsigned short BBShort; 00077 00082 typedef signed int BBInt; 00083 00088 typedef BBInt64 BBLong; 00089 00092 typedef float BBFloat; 00093 00096 typedef double BBDouble; 00097 00099 #define BBBYTE_MIN ((BBByte) 0x00) 00100 00101 #define BBBYTE_MAX ((BBByte) 0xff) 00102 00104 #define BBSHORT_MIN ((BBShort) 0x0000) 00105 00106 #define BBSHORT_MAX ((BBShort) 0xffff) 00107 00109 #define BBINT_MIN INT_MIN 00110 00111 #define BBINT_MAX INT_MAX 00112 00114 #define BBLONG_MIN ((BBLong) 0x800000000000000L) 00115 00116 #define BBLONG_MAX ((BBLong) 0x7ffffffffffffffL) 00117 00119 #define BBFLOAT_MIN ((BBFloat) -FLT_MAX) 00120 00121 #define BBFLOAT_MAX ((BBFloat) FLT_MAX) 00122 00124 #define BBDOUBLE_MIN ((BBDouble) -DBL_MAX) 00125 00126 #define BBDOUBLE_MAX ((BBDouble) DBL_MAX) 00127 00134 typedef unsigned short BBChar; 00135 00137 #define BBCHAR_MIN ((BBChar) 0x0000) 00138 00140 #define BBCHAR_MAX ((BBChar) 0xffff) 00141 00152 typedef enum { BBFALSE, BBTRUE } BBBool; 00153 00154 #ifdef BB_ENABLE_EXPERIMENTAL 00155 00164 typedef unsigned int BBSize; 00165 00166 #else 00167 typedef int BBSize; 00168 #endif // !BB_ENABLE_EXPERIMENTAL 00169 00171 #define BBSIZE_MIN ((BBSIZE_MIN)0) 00172 00173 #if INT_MAX < SIZE_MAX 00174 00181 # define BBSIZE_MAX ((BBSize) INT_MAX) 00182 #else 00183 # define BBSIZE_MAX ((BBSize) SIZE_MAX) 00184 #endif 00185 00186 // Complex data types 00187 00188 typedef struct BBClass BBClass; 00189 typedef struct BBObject BBObject; 00190 typedef struct BBString BBString; 00191 typedef struct BBArray BBArray; 00192 00193 extern const char *bbVoidTypeTag; // "?" 00194 extern const char *bbByteTypeTag; // "b" 00195 extern const char *bbShortTypeTag; // "s" 00196 extern const char *bbIntTypeTag; // "i" 00197 extern const char *bbLongTypeTag; // "l" 00198 extern const char *bbFloatTypeTag; // "f" 00199 extern const char *bbDoubleTypeTag; // "d" 00200 extern const char *bbStringTypeTag; // "$" 00201 extern const char *bbObjectTypeTag; // ":Object" 00202 extern const char *bbBytePtrTypeTag;// "*b" 00203 00204 // Additions by BME 00205 00219 enum BBTypeKey 00220 { 00222 BBTYPEKEY_BYTE, 00223 00225 BBTYPEKEY_SHORT, 00226 00228 BBTYPEKEY_INT, 00229 00231 BBTYPEKEY_LONG, 00232 00234 BBTYPEKEY_FLOAT, 00235 00237 BBTYPEKEY_DOUBLE, 00238 00240 BBTYPEKEY_POINTER, 00241 00246 BBTYPEKEY_VOID, 00247 00249 BBTYPEKEY_FUNCTION, 00250 00252 BBTYPEKEY_OBJECT, 00253 00255 BBTYPEKEY_STRING, 00256 00258 BBTYPEKEY_ARRAY 00259 }; 00260 00261 typedef enum BBTypeKey BBTypeKey; 00262 00271 #define BBTYPEKEY_ISVALID(key) ((key) >= BBTYPEKEY_VOID && (key) <= BBTYPEKEY_ARRAY) 00272 00273 #define BBTYPEKEY_ISPRIMITIVE(key) ((key) <= BBTYPEKEY_OBJECT) 00274 #define BBTYPEKEY_ISCOMPLEX(key) ((key) >= BBTYPEKEY_OBJECT) 00275 00282 #define BBTYPETAG_KEY(tag) bbToTypeKeyData[(tag)[0]] 00283 00284 extern const BBTypeKey bbToTypeKeyData[]; 00285 00290 struct BBTypeKeyInfo 00291 { 00298 size_t size; 00299 00304 void *init; 00305 00306 const char *ident; 00307 }; 00308 00309 typedef struct BBTypeKeyInfo BBTypeKeyInfo; 00310 00315 extern const BBTypeKeyInfo bbTypeKeyInfo[]; 00316 00317 #define BBTYPEKEY_INFO(key) bbTypeKeyInfo[(key)] 00318 #define BBTYPEKEY_SIZE(key) bbTypeKeyInfo[(key)].size 00319 #define BBTYPEKEY_INIT(key) bbTypeKeyInfo[(key)].init 00320 #define BBTYPEKEY_IDENT(key) bbTypeKeyInfo[(key)].ident 00321 00322 #define BBTYPETAG_INFO(tag) bbTypeKeyInfo[BBTYPETAG_KEY(tag)] 00323 #define BBTYPETAG_SIZE(tag) BBTYPETAG_INFO(tag).size 00324 #define BBTYPETAG_INIT(tag) BBTYPETAG_INFO(tag).init 00325 #define BBTYPETAG_IDENT(tag) BBTYPETAG_INFO(tag).ident 00326 00327 00328 00329 #ifndef BB_DISABLE_DEPRECATED 00330 00331 // Don't use these, as they are confusing (BBSTRING is a pointer, BBINT isn't) 00332 00333 typedef BBByte BBBYTE; 00334 typedef BBShort BBSHORT; 00335 typedef BBInt BBINT; 00336 typedef BBLong BBLONG; 00337 typedef BBFloat BBFLOAT; 00338 typedef BBDouble BBDOUBLE; 00339 typedef BBClass* BBCLASS; 00340 typedef BBObject* BBOBJECT; 00341 typedef BBString* BBSTRING; 00342 typedef BBArray* BBARRAY; 00343 00344 #endif // !BB_DISABLE_DEPRECATED 00345 00346 BB_END_DECLS 00347 00348 #endif // BLITZ_TYPES_H
1.8.0