cu/hook.h: Hooks; Templates and Common Instances

Data Structures

struct  cu_hook_node
struct  cu_iter_hook
struct  cu_iterA_hook
struct  cu_iter_ptr_hook
struct  cu_iterA_ptr_hook
struct  cu_ptr_compose_hook


#define CU_HOOK_TEMPLATE(name, f_decl)
#define CU_HOOK_NEXT(node)   cu_from(cu_hook_node, cu_dlink, cu_to(cu_dlink, node)->next)
#define CU_HOOK_FOR(node, hook)


typedef struct cu_hook_nodecu_hook_node_t
typedef struct cu_iter_hookcu_iter_hook_t
typedef struct cu_iterA_hookcu_iterA_hook_t
typedef struct cu_iter_ptr_hookcu_iter_ptr_hook_t
typedef struct cu_iterA_ptr_hookcu_iterA_ptr_hook_t
typedef struct


void cu_iter_hook_init (cu_iter_hook_t hook)
cu_bool_t cu_iter_hook_is_empty (cu_iter_hook_t hook)
void cu_iter_hook_prepend (cu_iter_hook_t hook, cu_clop0(f, void))
void cu_iter_hook_append (cu_iter_hook_t hook, cu_clop0(f, void))
void cu_iter_hook_call (cu_iter_hook_t hook)
void cu_iterA_hook_init (cu_iterA_hook_t hook)
cu_bool_t cu_iterA_hook_is_empty (cu_iterA_hook_t hook)
void cu_iterA_hook_prepend (cu_iterA_hook_t hook, cu_clop0(f, cu_bool_t))
void cu_iterA_hook_append (cu_iterA_hook_t hook, cu_clop0(f, cu_bool_t))
cu_bool_t cu_iterA_hook_call (cu_iterA_hook_t hook)
void cu_iter_ptr_hook_init (cu_iter_ptr_hook_t hook)
cu_bool_t cu_iter_ptr_hook_is_empty (cu_iter_ptr_hook_t hook)
void cu_iter_ptr_hook_prepend (cu_iter_ptr_hook_t hook, cu_clop(f, void, void *))
void cu_iter_ptr_hook_append (cu_iter_ptr_hook_t hook, cu_clop(f, void, void *))
void cu_iter_ptr_hook_call (cu_iter_ptr_hook_t hook, void *arg)
void cu_iterA_ptr_hook_init (cu_iterA_ptr_hook_t hook)
cu_bool_t cu_iterA_ptr_hook_is_empty (cu_iterA_ptr_hook_t hook)
void cu_iterA_ptr_hook_prepend (cu_iterA_ptr_hook_t hook, cu_clop(f, cu_bool_t, void *))
void cu_iterA_ptr_hook_append (cu_iterA_ptr_hook_t hook, cu_clop(f, cu_bool_t, void *))
cu_bool_t cu_iterA_ptr_hook_call (cu_iterA_ptr_hook_t hook, void *arg)
void cu_ptr_compose_hook_init (cu_ptr_compose_hook_t hook)
cu_bool_t cu_ptr_compose_hook_is_empty (cu_ptr_compose_hook_t hook)
void cu_ptr_compose_hook_prepend (cu_ptr_compose_hook_t hook, cu_clop(f, void *, void *))
void cu_ptr_compose_hook_append (cu_ptr_compose_hook_t hook, cu_clop(f, void *, void *))
void * cu_ptr_compose_hook_call (cu_ptr_compose_hook_t hook, void *arg)

Define Documentation

#define CU_HOOK_FOR ( node,
hook   ) 
for (node = CU_HOOK_NEXT(cu_to(cu_hook_node, hook));            \
         node != cu_to(cu_hook_node, hook);                             \
         node = CU_HOOK_NEXT(node))

A template for a for-loop header which iterates over entries of hook. Each entry is assigned to node, which bust be declared with type cu_hook_node_t.

#define CU_HOOK_NEXT ( node   )     cu_from(cu_hook_node, cu_dlink, cu_to(cu_dlink, node)->next)

Initialise hook as an empty hook. True iff hook is empty. Arrange for f to be called before current entries of hook. Arrange for f to be called after current entries of hook.

#define CU_HOOK_TEMPLATE ( name,
f_decl   ) 
typedef struct name *name##_t; /* abstract */                   \
    struct name { cu_inherit (cu_hook_node); };                         \
    CU_SINLINE void name##_init(name##_t hook)                          \
    { cuP_hook_init((cu_hook_node_t)hook); }                            \
    CU_SINLINE cu_bool_t name##_is_empty(name##_t hook)                 \
    { return cu_dlink_is_singleton(cu_to2(cu_dlink, cu_hook_node, hook)); }\
    CU_SINLINE void name##_prepend(name##_t hook, f_decl)               \
    { cuP_hook_prepend((cu_hook_node_t)hook, (cu_clop0(, void))f); }    \
    CU_SINLINE void name##_append(name##_t hook, f_decl)                \
    { cuP_hook_append((cu_hook_node_t)hook, (cu_clop0(, void))f); }

A template for defining a new hook with name prefix name. f_decl must declare a closure pointer parameter f. This template defines an opaque pointer type which can be cast to cu_hook_node_t and functions with suffixes _init, _prepend, and _append. The _call function is hook dependent, and can be defined using CU_HOOK_FOR.

Typedef Documentation

typedef struct cu_hook_node* cu_hook_node_t

A node of a hook for use in hook implementations.

Function Documentation

void cu_iter_hook_call ( cu_iter_hook_t  hook  ) 

Calls each entry of hook in order.

void cu_iter_ptr_hook_call ( cu_iter_ptr_hook_t  hook,
void *  arg 

Calls each entry of hook in order.

cu_bool_t cu_iterA_hook_call ( cu_iterA_hook_t  hook  ) 

Calls each entry of hook in order as long as true is returned, and returns the conjunction of the return values.

cu_bool_t cu_iterA_ptr_hook_call ( cu_iterA_ptr_hook_t  hook,
void *  arg 

Calls each entry of hook in order as long as true is returned, and returns the conjunction of the return values.

void* cu_ptr_compose_hook_call ( cu_ptr_compose_hook_t  hook,
void *  arg 

Evaluates the composition of the functions in hook applied to arg, or returns NULL as soon as an entry returns NULL.

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