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
6#include <cx/cx.h>
8
45
46typedef struct ObjIface ObjIface;
47
52typedef struct ObjIface
53{
56 size_t _size;
57
58 // Interface method pointers follow this header
59 // The specific methods depend on the interface definition
60} ObjIface;
62
67#define objIfTmplName(iface) iface##_tmpl
68
73#define objIfImport(iface) extern iface objIfTmplName(iface)
74
80#define objIfCheck(iface) static_assert(((iface)->_implements, (iface)->_size, offsetof(*(iface), _parent) == offsetof(ObjIface, _parent)), "Not an interface")
81
88#define objIfBase(iface) ((ObjIface*)((iface)->_implements, (iface)->_parent, (iface)->_size, (iface)))
89
#define saDeclarePtr(name)
Definition sarray.h:98
Dynamic arrays with type-safe generic programming.
size_t _size
Size of the entire interface structure including method pointers.
Definition objiface.h:56
ObjIface * _implements
Implementation only: pointer to interface template being implemented.
Definition objiface.h:54
ObjIface * _parent
Template only: parent interface for inheritance (NULL if no parent)
Definition objiface.h:55