27 #ifndef __TR_INTERFACE_H__
28 #define __TR_INTERFACE_H__
30 #include <sys/types.h>
37 #define TR_MAX_IFACE 32 // ATTENTION: every iface_impl will use
49 #define TR_IF(name) ((const struct i_##name const*)&i_##name##_impl)
58 #define TR_INIT_IFACE(name,...) \
59 static const struct i_##name i_##name##_impl = {&i_##name,__VA_ARGS__}
61 #define TR_IFID const struct TR_interface * const _
63 #define TR_INTERFACE(name) \
64 extern const struct TR_interface i_##name; \
70 #define TR_CREATE_INTERFACE(name, nfunc) \
71 const struct TR_interface i_##name = { nfunc }
81 #define TR_IFACE_NUMARGS(...) \
82 (sizeof((const void*[]){__VA_ARGS__})/sizeof(void*))
90 #define TR_INIT_IFACE_IMPL(...) \
91 {TR_IFACE_NUMARGS(__VA_ARGS__), {__VA_ARGS__}}
99 struct TR_iface_impl {
103 const void * impl[TR_MAX_IFACE];
105 typedef struct TR_iface_impl * TR_iface_impl_ptr;
112 struct TR_interface {
113 const size_t nmethods;
116 typedef const struct TR_interface * TR_iface_ptr;
125 #endif // __TR_INTERFACE_H__
TR_iface_ptr TR_interfaceGet(TR_iface_impl_ptr iface_impl, const TR_iface_ptr iface)