CX Framework
Cross-platform C utility framework
Loading...
Searching...
No Matches
objiface.h
Go to the documentation of this file.
1#pragma once
2
5
7#include <cx/cx.h>
8
9CX_C_BEGIN
10
47
48typedef struct ObjIface ObjIface;
49
54typedef struct ObjIface {
58 size_t _size;
59
60 // Interface method pointers follow this header
61 // The specific methods depend on the interface definition
62} ObjIface;
64
69#define objIfTmplName(iface) iface##_tmpl
70
75#define objIfImport(iface) extern iface objIfTmplName(iface)
76
82#define objIfCheck(iface) \
83 static_assert(((iface)->_implements, \
84 (iface)->_size, \
85 offsetof(*(iface), _parent) == offsetof(ObjIface, _parent)), \
86 "Not an interface")
87
94#define objIfBase(iface) \
95 ((ObjIface*)((iface)->_implements, (iface)->_parent, (iface)->_size, (iface)))
96
98
99CX_C_END
#define saDeclarePtr(name)
Definition sarray.h:100
Dynamic arrays with type-safe generic programming.
size_t _size
Size of the entire interface structure including method pointers.
Definition objiface.h:58
ObjIface * _implements
Implementation only: pointer to interface template being implemented.
Definition objiface.h:56
ObjIface * _parent
Template only: parent interface for inheritance (NULL if no parent)
Definition objiface.h:57