BlitzMax Extended
0.7.2
Pushing Blitz to the Max.
|
00001 00012 #ifndef BLITZ_COMMON_H 00013 #define BLITZ_COMMON_H 00014 00015 // Standard includes 00016 00017 #include <ctype.h> 00018 #include <errno.h> 00019 #include <stdarg.h> 00020 #include <stddef.h> 00021 #include <stdio.h> 00022 #include <stdlib.h> 00023 #include <string.h> 00024 00025 #ifdef BB_OS_WIN32 00026 # include <windows.h> 00027 #endif 00028 00029 #include "blitz_macros.h" 00030 #include "blitz_types.h" 00031 00032 BB_BEGIN_DECLS 00033 00034 #ifdef BB_ENABLE_HELPER 00035 00051 #define BB_ISNULL(ptr) \ 00052 ({ \ 00053 typeof (ptr) _x = (ptr); \ 00054 __builtin_choose_expr ( \ 00055 __builtin_types_compatible_p (typeof (_x), BBString*), \ 00056 _x == BBNULLSTRING, \ 00057 __builtin_choose_expr ( \ 00058 __builtin_types_compatible_p (typeof (_x), BBArray*) \ 00059 || __builtin_types_compatible_p (typeof (_x), BBByteArray*) \ 00060 || __builtin_types_compatible_p (typeof (_x), BBShortArray*) \ 00061 || __builtin_types_compatible_p (typeof (_x), BBIntArray*) \ 00062 || __builtin_types_compatible_p (typeof (_x), BBFloatArray*) \ 00063 || __builtin_types_compatible_p (typeof (_x), BBDoubleArray*) \ 00064 || __builtin_types_compatible_p (typeof (_x), BBStringArray*), \ 00065 _x == BBNULLARRAY, \ 00066 __builtin_choose_expr ( \ 00067 __builtin_types_compatible_p (typeof (_x), BBObject*), \ 00068 _x == BBNULLOBJECT, \ 00069 _x == NULL \ 00070 ) \ 00071 ) \ 00072 ); \ 00073 }) 00074 00075 /* 00076 #define BB_TOSTRING(x) \ 00077 ({ \ 00078 typeof (x) _x = (x); \ 00079 BBString *out = \ 00080 __builtin_choose_expr ( \ 00081 __builtin_types_compatible_p (typeof (_x), BBString*), \ 00082 _x, \ 00083 __builtin_choose_expr ( \ 00084 __builtin_types_compatible_p (typeof (_x), const char*) \ 00085 || __builtin_types_compatible_p (typeof (_x), char[]), \ 00086 bbStringFromCString(_x), \ 00087 __builtin_choose_expr ( \ 00088 __builtin_types_compatible_p (typeof (_x), const wchar_t*) \ 00089 || __builtin_types_compatible_p (typeof (_x), wchar_t[]), \ 00090 bbStringFromWString(_x), \ 00091 __builtin_choose_expr ( \ 00092 __builtin_types_compatible_p (typeof (_x), BBInt) \ 00093 || __builtin_types_compatible_p (typeof (_x), BBShort) \ 00094 || __builtin_types_compatible_p (typeof (_x), BBByte), \ 00095 bbStringFromInt(_x), \ 00096 __builtin_choose_expr ( \ 00097 __builtin_types_compatible_p (typeof (_x), BBLong), \ 00098 bbStringFromLong(_x), \ 00099 __builtin_choose_expr ( \ 00100 __builtin_types_compatible_p (typeof (_x), BBObject*), \ 00101 _x->clas->ToString(_x), \ 00102 BBNULLSTRING \ 00103 ) \ 00104 ) \ 00105 ) \ 00106 ) \ 00107 ) \ 00108 ); \ 00109 out; \ 00110 }) 00111 */ 00112 00120 #define BB_EQUALS(obj, rhs) \ 00121 ({ \ 00122 typeof (obj) _x = (obj); typeof (rhs) _y = (rhs); \ 00123 bool out = \ 00124 __builtin_choose_expr ( \ 00125 __builtin_types_compatible_p (typeof (_x), BBString*) \ 00126 && __builtin_types_compatible_p (typeof (_y), BBString*), \ 00127 bbStringEquals(_x, _y), \ 00128 __builtin_choose_expr ( \ 00129 __builtin_types_compatible_p (typeof (_x), BBArray*) \ 00130 && __builtin_types_compatible_p (typeof (_y), BBArray*), \ 00131 bbArrayEquals(_x, _y), \ 00132 _x->clas->Compare(_x, _y) == 0 \ 00133 ) \ 00134 ); \ 00135 out; \ 00136 }) 00137 00142 #define BB_THROW(cstring_or_obj) \ 00143 ({ \ 00144 typeof (cstring_or_obj) _x = (cstring_or_obj); \ 00145 __builtin_choose_expr ( \ 00146 __builtin_types_compatible_p (typeof (_x), const char*) \ 00147 || __builtin_types_compatible_p (typeof (_x), char*) \ 00148 || __builtin_types_compatible_p (typeof (_x), char[]), \ 00149 bbExThrowCString(_x), \ 00150 bbExThrow(_x) \ 00151 ); \ 00152 }) 00153 00154 #endif // BB_ENABLE_HELPER 00155 00156 BB_END_DECLS 00157 00158 #endif // BLITZ_COMMON_H