BlitzMax Extended  0.7.2
Pushing Blitz to the Max.
Defines
blitz_common.h File Reference

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.

Detailed Description

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.

Author:
Fabian Niemann

Define Documentation

#define BB_EQUALS (   obj,
  rhs 
)
Value:
({                                                                          \
        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.

Parameters:
objThe object which provides the Compare() function  
rhsThe right-hand side object which is compared with the first one
Return values:
trueIf both instances are considered to be equal
falseIf the instances differ in some way
#define BB_ISNULL (   ptr)
Value:
({                                                                          \
        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.

See also:
BBNULLOBJECT, BBNULLSTRING, BBNULLARRAY
Parameters:
xA pointer to test
Return values:
trueIf the pointer is considered to be NULL
falseIf the pointer is referencing to a valid value

Referenced by bbStringSplit().

#define BB_THROW (   cstring_or_obj)
Value:
({                                                                          \
        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.

Parameters:
cstring_or_objA string or object describing the problem