Helpful Macros

Helpful Macros — Various macros to eliminate tedious typing, beyond those provided by glib.

Synopsis

#define             GSK_DECLARE_POOL_ALLOCATORS         (Type, type, pool_count)
#define             GSK_STRUCT_MEMBER_SIZE              (type, member)
#define             GSK_STRUCT_MEMBER_END_OFFSET        (struct, member)
#define             _                                   (s)
#define             GSK_SKIP_CHAR_TYPE                  (ptr, condition)
#define             GSK_SKIP_WHITESPACE                 (char_ptr)
#define             GSK_SKIP_NONWHITESPACE              (char_ptr)

Description

Details

GSK_DECLARE_POOL_ALLOCATORS()

#define             GSK_DECLARE_POOL_ALLOCATORS(Type, type, pool_count)

Declare static inline functions type_free and type_alloc, (where type is the second parameter to this macro) which use GMemChunks to implement fast allocation. Type is the name of the name of structure to allocate; and pool_count is the number to allocate at once.

Type :

Real type of the things to allocate.

type :

Lowercased type name, for mangling into the function name.

pool_count :

Number of things to allocate at once.

GSK_STRUCT_MEMBER_SIZE()

#define             GSK_STRUCT_MEMBER_SIZE(type, member)

Find size in bytes of a structure member.

type :

member :


GSK_STRUCT_MEMBER_END_OFFSET()

#define             GSK_STRUCT_MEMBER_END_OFFSET(struct, member)

Find offset of a member's end in bytes.

struct :

member :


_()

#define             _(s)

s :


GSK_SKIP_CHAR_TYPE()

#define             GSK_SKIP_CHAR_TYPE(ptr, condition)

Skip ptr along until it fails the condition.

ptr :

pointer to a NUL-terminated string.

condition :

function predicate to test characters with.

GSK_SKIP_WHITESPACE()

#define             GSK_SKIP_WHITESPACE(char_ptr)

Skip char_ptr along until it gets to a non-whitespace character, or the end of the string.

char_ptr :

the pointer to advance.

GSK_SKIP_NONWHITESPACE()

#define             GSK_SKIP_NONWHITESPACE(char_ptr)

Skip char_ptr along until it gets to a whitespace character, or the end of the string.

char_ptr :

the pointer to advance.