VLCB SDK
An opinionated SDK for VLCB protocol
Loading...
Searching...
No Matches
interface.h
Go to the documentation of this file.
1#pragma once
2
3#include <stddef.h>
4
5#define _INTERFACE_DECLARE(T, ...) \
6 typedef struct T { \
7 __VA_ARGS__ \
8 } T
9
10#define _INTERFACE_METHOD_DECLARE(retT, name, ...) \
11 retT (*const name)(__VA_ARGS__)
12
13#define _INTERFACE_SELF(T) const struct T self
14#define _INTERFACE_SELF_MUT(T) struct T
15#define _INTERFACE_SELF_PTR(T) const struct T *const self
16#define _INTERFACE_SELF_PTR_MUT(T) struct T *const self
17
18#define _INTERFACE_IMPLEMENT(T) T _iface
19
20#define _INTERFACE_VTABLE_DEFINE(T, ...) static T iface##T = {__VA_ARGS__}
21#define _INTERFACE_VTABLE_METHOD(m, ptr, retT, ...) \
22 .m = (retT(*const)(__VA_ARGS__))(ptr)
23
24#define _INTERFACE_ASSIGN_VTABLE(T) ._iface = iface##T
25
26#define _INTERFACE_PTR_STATIC_CALL(o, m, ...) o->m(__VA_ARGS__)
27#define _INTERFACE_STATIC_CALL(o, m, ...) o.m(__VA_ARGS__)
28#define _INTERFACE_PTR_CALL(o, m, ...) o->m(o, ##__VA_ARGS__)
29#define _INTERFACE_CALL(o, m, ...) o.m(&o, ##__VA_ARGS__)