Source

arana-main / arana / primitives.h

/*
 * primitives.h
 *
 * (c) Copyright 2009 by Armin Ronacher.
 */

#ifndef _ARANA_PRIMITIVES_H
#define _ARANA_PRIMITIVES_H

#define AR_IS_NULL(x) (x == AR_NULL)
#define AR_IS_NONE(x) (x == AR_NONE)
#define AR_IS_BOOLEAN(x) (x == AR_TRUE || x == AR_FALSE)

#define AR_NULL  ((AR)0)          /* represents errors, integer 0 */
#define AR_NONE  ((AR)2)          /* a value that does not exist, integer 0 */
#define AR_FALSE ((AR)6)          /* boolean false, integer 0 */
#define AR_TRUE  ((AR)10)         /* boolean true, integer 1 */
#define AR_TEST(x) ((x) != AR_NULL && (x) != AR_NONE && (x) != AR_FALSE && \
                    (!AR_IS_INTEGER(x) || x != AR_INTEGER(0)))
#define AR_BOOLEAN(x) ((x) ? AR_TRUE : AR_FALSE)
#define AR_INTEGER(x) (AR)((((long)(x)) << 1) + 1)

#define AR_AS_LONG(x) ((long)x >> 1)
#define AR_AS_SIZET(x) ((Ar_size_t)x >> 1)

AR_API_DATA(ArObjectType) ArBooleanType;
AR_API_DATA(ArObjectType) ArNoneType;
AR_API_DATA(ArObjectType) ArIntegerType;

AR_API_FUNC(AR) arana_create_integer_type(AR_SIG);
AR_API_FUNC(AR) arana_create_boolean_type(AR_SIG);
AR_API_FUNC(AR) arana_create_none_type(AR_SIG);


#endif /* _ARANA_PRIMITIVES_H */