BlitzMax Extended  0.8.11
Pushing Blitz to the Max.
blitz_types.h
Go to the documentation of this file.
00001 
00018 #ifndef BLITZ_TYPES_H
00019 #define BLITZ_TYPES_H
00020 
00021 #include <float.h>
00022 #include <limits.h>
00023 #include <stdint.h>
00024 
00025 #include "_common.h"
00026 
00027 #ifdef BB_ENV_C99
00028 #   include <stdbool.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 #endif
00056 
00057 //  Primitive data types
00058 
00063 typedef unsigned char               BBByte;
00064 
00069 typedef unsigned short              BBShort;
00070 
00075 typedef signed int                  BBInt;
00076 
00081 typedef BBInt64                     BBLong;
00082 
00085 typedef float                       BBFloat;
00086 
00089 typedef double                      BBDouble;
00090 
00092 #define BBBYTE_MIN                  ((BBByte) 0x00)
00093 
00094 #define BBBYTE_MAX                  ((BBByte) 0xff)
00095 
00097 #define BBSHORT_MIN                 ((BBShort) 0x0000)
00098 
00099 #define BBSHORT_MAX                 ((BBShort) 0xffff)
00100 
00102 #define BBINT_MIN                   ((BBInt) 0x80000000)
00103 
00104 #define BBINT_MAX                   ((BBInt) 0x7fffffff)
00105 
00107 #define BBLONG_MIN                  ((BBLong) 0x800000000000000L)
00108 
00109 #define BBLONG_MAX                  ((BBLong) 0x7ffffffffffffffL)
00110 
00112 #define BBFLOAT_MIN                 ((BBFloat) -FLT_MAX)
00113 
00114 #define BBFLOAT_MAX                 ((BBFloat) FLT_MAX)
00115 
00117 #define BBDOUBLE_MIN                ((BBDouble) -DBL_MAX)
00118 
00119 #define BBDOUBLE_MAX                ((BBDouble) DBL_MAX)
00120 
00127 typedef unsigned short              BBChar;
00128 
00130 #define BBCHAR_MIN                  ((BBChar) 0x0000)
00131 
00133 #define BBCHAR_MAX                  ((BBChar) 0xffff)
00134 
00145 typedef enum { BBFALSE, BBTRUE }    BBBool;
00146 
00147 #ifdef BB_ENABLE_EXPERIMENTAL
00148 
00157 typedef unsigned int                BBSize;
00158 
00159 #else
00160 typedef int                         BBSize;
00161 #endif  // !BB_ENABLE_EXPERIMENTAL
00162 
00164 #define BBSIZE_MIN                  ((BBSize) 0)
00165 
00166 #if INT_MAX < SIZE_MAX
00167 
00174 #   define BBSIZE_MAX               ((BBSize) INT_MAX)
00175 #else
00176 #   define BBSIZE_MAX               ((BBSize) SIZE_MAX)
00177 #endif
00178 
00179 //  Complex data types
00180 
00181 typedef struct BBClass              BBClass;
00182 typedef struct BBObject             BBObject;
00183 typedef struct BBString             BBString;
00184 typedef struct BBArray              BBArray;
00185 
00186 extern const char *bbVoidTypeTag;   // "?"
00187 extern const char *bbByteTypeTag;   // "b"
00188 extern const char *bbShortTypeTag;  // "s"
00189 extern const char *bbIntTypeTag;    // "i"
00190 extern const char *bbLongTypeTag;   // "l"
00191 extern const char *bbFloatTypeTag;  // "f"
00192 extern const char *bbDoubleTypeTag; // "d"
00193 extern const char *bbStringTypeTag; // "$"
00194 extern const char *bbObjectTypeTag; // ":Object"
00195 extern const char *bbBytePtrTypeTag;// "*b"
00196 
00197 //  Additions by BME
00198 
00212 enum BBTypeKey
00213 {
00215     BBTYPEKEY_BYTE,
00216     
00218     BBTYPEKEY_SHORT,
00219     
00221     BBTYPEKEY_INT,
00222     
00224     BBTYPEKEY_LONG,
00225     
00227     BBTYPEKEY_FLOAT,
00228     
00230     BBTYPEKEY_DOUBLE,
00231     
00233     BBTYPEKEY_POINTER,
00234 
00236     BBTYPEKEY_VOID, 
00237     
00239     BBTYPEKEY_FUNCTION,
00240     
00242     BBTYPEKEY_OBJECT,
00243     
00245     BBTYPEKEY_STRING,
00246     
00248     BBTYPEKEY_ARRAY
00249 };
00250 
00251 typedef enum BBTypeKey              BBTypeKey;
00252 
00261 #define BBTYPEKEY_ISVALID(key)      ((key) >= BBTYPEKEY_BYTE && (key) <= BBTYPEKEY_ARRAY)
00262 
00278 #define BBTYPEKEY_ISNUMERIC(key)    ((key) >= BBTYPEKEY_BYTE && (key) <= BBTYPEKEY_DOUBLE)
00279 
00297 #define BBTYPEKEY_ISPRIMITIVE(key)  ((key) >= BBTYPEKEY_BYTE && (key) <= BBTYPEKEY_OBJECT)
00298 
00313 #define BBTYPEKEY_ISCOMPLEX(key)    ((key) >= BBTYPEKEY_OBJECT && (key) <= BBTYPEKEY_ARRAY)
00314 
00321 #define BBTYPETAG_KEY(tag)          bbToTypeKeyData[(tag)[0]]
00322 
00323 extern const BBTypeKey bbToTypeKeyData[];
00324 
00329 struct BBTypeKeyInfo
00330 {
00337     size_t      size;
00338     
00343     void        *init;
00344     
00345     const char  *ident;
00346 };
00347 
00348 typedef struct BBTypeKeyInfo        BBTypeKeyInfo;
00349 
00354 extern const BBTypeKeyInfo bbTypeKeyInfo[];
00355 
00356 #define BBTYPEKEY_INFO(key)         bbTypeKeyInfo[(key)]
00357 #define BBTYPEKEY_SIZE(key)         bbTypeKeyInfo[(key)].size
00358 #define BBTYPEKEY_INIT(key)         bbTypeKeyInfo[(key)].init
00359 #define BBTYPEKEY_IDENT(key)        bbTypeKeyInfo[(key)].ident
00360 
00361 #define BBTYPETAG_INFO(tag)         bbTypeKeyInfo[BBTYPETAG_KEY(tag)]
00362 #define BBTYPETAG_SIZE(tag)         BBTYPETAG_INFO(tag).size
00363 #define BBTYPETAG_INIT(tag)         BBTYPETAG_INFO(tag).init
00364 #define BBTYPETAG_IDENT(tag)        BBTYPETAG_INFO(tag).ident
00365 
00366 
00367 
00368 #ifndef BB_DISABLE_DEPRECATED
00369 
00370 //  Don't use these, as they are confusing (BBSTRING is a pointer, BBINT isn't)
00371 
00372 typedef BBByte                      BBBYTE;
00373 typedef BBShort                     BBSHORT;
00374 typedef BBInt                       BBINT;
00375 typedef BBLong                      BBLONG;
00376 typedef BBFloat                     BBFLOAT;
00377 typedef BBDouble                    BBDOUBLE;
00378 typedef BBClass*                    BBCLASS;
00379 typedef BBObject*                   BBOBJECT;
00380 typedef BBString*                   BBSTRING;
00381 typedef BBArray*                    BBARRAY;
00382 
00383 #endif  // !BB_DISABLE_DEPRECATED
00384 
00385 BB_END_DECLS
00386 
00387 #endif  // BLITZ_TYPES_H