BlitzMax Extended
0.7.2
Pushing Blitz to the Max.
|
Commonly used macros and standard libaries. More...
#include <ctype.h>
#include <errno.h>
#include <stdarg.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "blitz_macros.h"
#include "blitz_types.h"
Go to the source code of this file.
Defines | |
#define | BB_ISNULL(ptr) |
Checks if a pointer is NULL. | |
#define | BB_EQUALS(obj, rhs) |
Checks if two objects are equal. | |
#define | BB_THROW(cstring_or_obj) |
Throws a BlitzMax exception. |
Commonly used macros and standard libaries.
This file should be included everywhere, as it provides a range of commonly used macros and libraries as well as the basic functionality needed by every part of a library working with BlitzMax.
#define BB_EQUALS | ( | obj, | |
rhs | |||
) |
({ \ typeof (obj) _x = (obj); typeof (rhs) _y = (rhs); \ bool out = \ __builtin_choose_expr ( \ __builtin_types_compatible_p (typeof (_x), BBString*) \ && __builtin_types_compatible_p (typeof (_y), BBString*), \ bbStringEquals(_x, _y), \ __builtin_choose_expr ( \ __builtin_types_compatible_p (typeof (_x), BBArray*) \ && __builtin_types_compatible_p (typeof (_y), BBArray*), \ bbArrayEquals(_x, _y), \ _x->clas->Compare(_x, _y) == 0 \ ) \ ); \ out; \ })
Checks if two objects are equal.
obj | The object which provides the Compare() function |
rhs | The right-hand side object which is compared with the first one |
true | If both instances are considered to be equal |
false | If the instances differ in some way |
#define BB_ISNULL | ( | ptr | ) |
({ \ typeof (ptr) _x = (ptr); \ __builtin_choose_expr ( \ __builtin_types_compatible_p (typeof (_x), BBString*), \ _x == BBNULLSTRING, \ __builtin_choose_expr ( \ __builtin_types_compatible_p (typeof (_x), BBArray*) \ || __builtin_types_compatible_p (typeof (_x), BBByteArray*) \ || __builtin_types_compatible_p (typeof (_x), BBShortArray*) \ || __builtin_types_compatible_p (typeof (_x), BBIntArray*) \ || __builtin_types_compatible_p (typeof (_x), BBFloatArray*) \ || __builtin_types_compatible_p (typeof (_x), BBDoubleArray*) \ || __builtin_types_compatible_p (typeof (_x), BBStringArray*), \ _x == BBNULLARRAY, \ __builtin_choose_expr ( \ __builtin_types_compatible_p (typeof (_x), BBObject*), \ _x == BBNULLOBJECT, \ _x == NULL \ ) \ ) \ ); \ })
Checks if a pointer is NULL.
The BlitzMax runtime has three compile time objects to represents NULL instances of their specific type (Object, String, Array).
Checking for those is performed via GCC builtin functionality. If the given parameter x is neither of the three above mentioned, this returns if x is the C NULL
pointer.
x | A pointer to test |
true | If the pointer is considered to be NULL |
false | If the pointer is referencing to a valid value |
Referenced by bbStringSplit().
#define BB_THROW | ( | cstring_or_obj | ) |
({ \ typeof (cstring_or_obj) _x = (cstring_or_obj); \ __builtin_choose_expr ( \ __builtin_types_compatible_p (typeof (_x), const char*) \ || __builtin_types_compatible_p (typeof (_x), char*) \ || __builtin_types_compatible_p (typeof (_x), char[]), \ bbExThrowCString(_x), \ bbExThrow(_x) \ ); \ })
Throws a BlitzMax exception.
cstring_or_obj | A string or object describing the problem |