1 #ifndef _LIBSAPLING_TYPED_ADAPTERS_H_
2 #define _LIBSAPLING_TYPED_ADAPTERS_H_
30 #define CAST_USER_INFO(TYPE, VAR, INFO) \
31 TYPE VAR = ((struct info_insert *)INFO)->info
43 #define IMPLEMENT_TYPED_ADAPTERS(SYM, TYPE, IMPL) \
45 typedef int (*SYM##__predicate_t)(const TYPE *data, void *info); \
46 typedef void (*SYM##__apply_t)(TYPE *data, void *info); \
49 int SYM##__predicate_0(UNUSED const TYPE *data, UNUSED void *info) \
55 int SYM##__predicate_1(UNUSED const TYPE *data, UNUSED void *info) \
60 struct SYM##__adapt { \
64 SYM##__predicate_t predicate; \
65 SYM##__apply_t apply; \
69 int SYM##__predicate_adapter(const node_t *ref, \
70 const struct info_stack *info) \
73 struct SYM##__adapt *user = info->user; \
75 return user->predicate((const TYPE *)IMPL##__data(node), user); \
79 void SYM##__apply_adapter(node_t *ref, const struct info_stack *info) \
82 struct SYM##__adapt *user = info->user; \
85 user->apply((TYPE *)IMPL##__data(node), user); \
Useful common definitions for typed stuff.