libkovan  1
The kovan standard library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
vtable.h
Go to the documentation of this file.
1 #ifndef __KOVAN_VTABLE_H__
2 #define __KOVAN_VTABLE_H__
3 
4 #ifdef __cplusplus
5 extern "C" {
6 #endif
7 
8 #include "export.h"
9 
10 #define VF
11 #define VFL
12 #define VI
13 #define VIL
14 #define VH
15 
16 #ifdef __GNUC__
17 #define POSSIBLY_UNUSED __attribute__ ((unused))
18 #else
19 #define POSSIBLY_UNUSED
20 #endif
21 
22 #define VTABLE_FUNC_VOID(name, signature, args) \
23  typedef void (*name##_func) signature; \
24  EXPORT_SYM extern name##_func g_##name##_func; \
25  EXPORT_SYM extern const name##_func g_##name##_func_default; \
26  static const char *const name##_signature = "void" #signature; \
27  POSSIBLY_UNUSED static void name signature { (*g_##name##_func) args; }
28 
29 #define VTABLE_FUNC(name, returnType, signature, args) \
30  typedef returnType (*name##_func) signature; \
31  EXPORT_SYM extern name##_func g_##name##_func; \
32  EXPORT_SYM extern const name##_func g_##name##_func_default; \
33  static const char *const name##_signature = #returnType #signature; \
34  POSSIBLY_UNUSED static returnType name signature { return (*g_##name##_func) args; }
35 
36 #define VTABLE_SET_DEFAULT(name, impl) \
37  const name##_func g_##name##_func_default = &impl; \
38  name##_func g_##name##_func = g_##name##_func_default
39 
40 #ifdef __cplusplus
41 }
42 #endif
43 
44 #endif