cu/box.h: Boxing and Unboxing Operations [Data Types]

union  cu_box_t

Defines

#define CU_BOX_SIZE   CU_WORD_SIZE
#define CU_BOX_FITS_FLOAT   1
#define CU_BOX_FITS_DOUBLE   1
#define CU_BOX_FITS_LONGDOUBLE
#define CU_BOX_GNEW_TEMPLATE(fn, type)
#define cu_box_gnew(type, obj)   cu_box_galloc(sizeof(type), &(obj))
#define cu_box_void()   cuP_box_word(0)
#define CU_BOX_VOID_INIT   CUP_BOX_WORD_INIT(0)

Functions

cu_box_t cu_box_galloc (size_t size, void *addr)

Integer Types

cu_box_t cu_box_int (int i)
int cu_unbox_int (cu_box_t box)
cu_box_t cu_box_uint (unsigned int i)
unsigned int cu_unbox_uint (cu_box_t box)
cu_box_t cu_box_long (long i)
long cu_unbox_long (cu_box_t box)
cu_box_t cu_box_ulong (unsigned long i)
unsigned long cu_unbox_ulong (cu_box_t box)

Floating Point Types

cu_box_t cu_box_float (float x)
float cu_unbox_float (cu_box_t box)
cu_box_t cu_box_double (double x)
double cu_unbox_double (cu_box_t box)
cu_box_t cu_box_longdouble (long double x)
long double cu_unbox_longdouble (cu_box_t box)

Pointers, Functions, and Enums

#define cu_box_ptr(type, ptr)   cuP_box_ptr(1? (ptr) : (type)(ptr))
#define cu_unbox_ptr(type, box)   ((type)cuP_unbox_ptr(box))
#define CU_BOX_PTR_INIT(type, ptr)   CUP_BOX_PTR_INIT(1? (ptr) : (type)(ptr))
#define CU_BOX_NULL_PTR_INIT   CUP_BOX_PTR_INIT(NULL)
#define cu_box_fptr(type, fp)   cuP_box_fptr((cu_fnptr_t)(1? (fp) : (type)(fp)))
#define cu_unbox_fptr(type, box)   ((type)cuP_unbox_fptr(box))
#define CU_BOX_FPTR_INIT(type, fptr)   CUP_BOX_FPTR_INIT(1? (fptr) : (type)(fptr))
#define CU_BOX_NULL_FPTR_INIT   CUP_BOX_FPTR_INIT(NULL)
#define cu_box_clop(type, cp)   cu_box_ptr(type, cp)
#define cu_unbox_clop(type, box)   cu_unbox_ptr(type, box)
#define cu_box_enum(type, i)   cuP_box_word(1? (i) : (type)(i))
#define cu_unbox_enum(type, box)   ((type)cuP_unbox_word(box))
#define CU_BOX_ENUM_INIT(type, i)   CUP_BOX_WORD_INIT(1? (i) : (type)(i))

Define Documentation

 #define cu_box_clop ( type, cp ) cu_box_ptr(type, cp)

Boxes a closure pointer of the specified type.

 #define cu_box_enum ( type, i ) cuP_box_word(1? (i) : (type)(i))

Boxes an enum of the given type.

 #define CU_BOX_ENUM_INIT ( type, i ) CUP_BOX_WORD_INIT(1? (i) : (type)(i))

An initialiser for a box if enum type type.

 #define cu_box_fptr ( type, fp ) cuP_box_fptr((cu_fnptr_t)(1? (fp) : (type)(fp)))

Boxes a function pointer of the specified type.

 #define CU_BOX_FPTR_INIT ( type, fptr ) CUP_BOX_FPTR_INIT(1? (fptr) : (type)(fptr))

An initialiser for a function pointer box.

 #define CU_BOX_GNEW_TEMPLATE ( fn, type )
Value:
```cu_box_t fn(type x)                                                     \
{                                                                   \
cu_box_t box;                                                   \
box.as_ptr = cu_gnew(type);                                     \
*(type *)box.as_ptr = x;                                        \
return box;                                                     \
}                                                                   \
CU_END_BOILERPLATE
```

A boilerplate to emit a definition of a function fn for boxing a large type type using garbage collected storage.

 #define CU_BOX_NULL_FPTR_INIT   CUP_BOX_FPTR_INIT(NULL)

A `NULL` function pointer box initialiser.

 #define CU_BOX_NULL_PTR_INIT   CUP_BOX_PTR_INIT(NULL)

A `NULL` pointer box initialiser.

 #define cu_box_ptr ( type, ptr ) cuP_box_ptr(1? (ptr) : (type)(ptr))

Boxes a pointer of the specified type.

 #define CU_BOX_PTR_INIT ( type, ptr ) CUP_BOX_PTR_INIT(1? (ptr) : (type)(ptr))

An initialiser for a pointer box.

 #define cu_unbox_clop ( type, box ) cu_unbox_ptr(type, box)

Unboxes a closure pointer of the specified type.

 #define cu_unbox_enum ( type, box ) ((type)cuP_unbox_word(box))

Unboxes an enum of the given type.

 #define cu_unbox_fptr ( type, box ) ((type)cuP_unbox_fptr(box))

Unboxes a function pointer of the specified type.

 #define cu_unbox_ptr ( type, box ) ((type)cuP_unbox_ptr(box))

Unboxes a pointer of the specified type.

Function Documentation

 cu_box_t cu_box_float ( float x )

Boxes a `float`.

 cu_box_t cu_box_int ( int i )

Boxes an `int` or any shorter integer types.

 cu_box_t cu_box_long ( long i )

Boxes a `long`.

 cu_box_t cu_box_longdouble ( long double x )

Boxes a `long double`.

 cu_box_t cu_box_uint ( unsigned int i )

Boxes an `unsigned int` or any shorter unsigned integer type.

 cu_box_t cu_box_ulong ( unsigned long i )

Boxes an `unsigned long`.

 float cu_unbox_float ( cu_box_t box )

Unboxes a `float`.

 int cu_unbox_int ( cu_box_t box )

Unboxes an `int` or any shorter integer type.

 long cu_unbox_long ( cu_box_t box )

Unboxes a `long`.

 long double cu_unbox_longdouble ( cu_box_t box )

Unboxes a `long double`.

 unsigned int cu_unbox_uint ( cu_box_t box )

Unboxes an `unsigned int` or any shorter unsigned integer type.

 unsigned long cu_unbox_ulong ( cu_box_t box )

Unboxes an `unsigned long`.

Generated 2009-11-23 for culibs-0.25 using Doxygen. Maintained by Petter Urkedal.