77 #ifndef LUMIERA_INTERFACE_H 78 #define LUMIERA_INTERFACE_H 93 #define LUMIERA_INTERFACE_INAME(name, version) name##_##version 102 #define LUMIERA_INTERFACE_DNAME(iname, version, dname) PPMPL_CAT (LUMIERA_INTERFACE_INAME (iname, version), _##dname) 111 #define LUMIERA_INTERFACE_DSTRING(iname, version, dname) PPMPL_STRINGIFY (LUMIERA_INTERFACE_DNAME (iname, version, dname)) 119 #define LUMIERA_INTERFACE_REF(iname, version, dname) \ 120 (LumieraInterface)&LUMIERA_INTERFACE_DNAME(iname, version, dname) 128 #define LUMIERA_INTERFACE_TYPE(name, version) struct LUMIERA_INTERFACE_INAME(name, version) 137 #define LUMIERA_INTERFACE_CAST(name, version) (LUMIERA_INTERFACE_TYPE(name, version)*) 154 #define LUMIERA_INTERFACE_DECLARE(name, version, ...) \ 155 LUMIERA_INTERFACE_TYPE(name, version) \ 157 lumiera_interface interface_header_; \ 158 PPMPL_FOREACH(_, __VA_ARGS__) \ 167 #define PPMPL_FOREACH_LUMIERA_INTERFACE_SLOT(ret, name, params) \ 168 ret (*name) params; \ 185 #define LUMIERA_INTERFACE_INSTANCE(iname, version, name, descriptor, acquire, release, ...) \ 186 PPMPL_FOREACH(_P1_, __VA_ARGS__) \ 187 LUMIERA_INTERFACE_TYPE(iname, version) LUMIERA_INTERFACE_DNAME(iname, version, name) = \ 193 sizeof (LUMIERA_INTERFACE_TYPE(iname, version)), \ 198 PPMPL_FOREACH(_P2_, __VA_ARGS__) \ 210 #define PPMPL_FOREACH_P1_LUMIERA_INTERFACE_MAP(slot, function) 212 #define PPMPL_FOREACH_P2_LUMIERA_INTERFACE_MAP(slot, function) \ 216 #define PPMPL_FOREACH_P2_LUMIERA_INTERFACE_MAP(slot, function) \ 232 #define PPMPL_FOREACH_P1_LUMIERA_INTERFACE_INLINE(slot, ret, params, ...) \ 234 LUMIERA_INTERFACE_INLINE_NAME(slot) params \ 238 #define PPMPL_FOREACH_P2_LUMIERA_INTERFACE_INLINE(slot, ret, params, ...) \ 239 LUMIERA_INTERFACE_INLINE_NAME(slot),\ 242 #define PPMPL_FOREACH_P2_LUMIERA_INTERFACE_INLINE(slot, ret, params, ...) \ 243 .slot = LUMIERA_INTERFACE_INLINE_NAME(slot),\ 247 #define LUMIERA_INTERFACE_INLINE_NAME(slot) PPMPL_CAT(lumiera_##slot##_l, __LINE__) 250 #define PPMPL_FOREACH_L1_P1_LUMIERA_INTERFACE_DEFINE(iname, version, name, descriptor, acquire, release, ...) \ 251 LUMIERA_INTERFACE_INSTANCE (iname, version, \ 260 #define PPMPL_FOREACH_L1_P2_LUMIERA_INTERFACE_DEFINE(iname, version, name, descriptor, acquire, release, ...) \ 261 &LUMIERA_INTERFACE_DNAME(iname, version, name).interface_header_, 273 #define LUMIERA_EXPORT(...) \ 274 PPMPL_FOREACH_L1(_P1_, __VA_ARGS__) \ 275 static LumieraInterface* \ 276 lumiera_plugin_interfaces (void) \ 278 static LumieraInterface interfaces[] = \ 280 PPMPL_FOREACH_L1(_P2_, __VA_ARGS__) \ 285 LUMIERA_PLUGININTERFACE 291 #ifdef LUMIERA_PLUGIN 292 #define LUMIERA_PLUGIN_INTERFACEHANDLE static LUMIERA_INTERFACE_HANDLE(lumieraorg_interface, 0) lumiera_interface_handle 293 #define LUMIERA_PLUGIN_STORE_INTERFACEHANDLE(name) lumiera_interface_handle = LUMIERA_INTERFACE_CAST (lumieraorg_interface, 0) name 295 #define LUMIERA_PLUGININTERFACE \ 296 LUMIERA_INTERFACE_INSTANCE (lumieraorg__plugin, 0, \ 301 LUMIERA_INTERFACE_MAP (plugin_interfaces, \ 302 lumiera_plugin_interfaces) \ 304 #define LUMIERA_INTERFACE_REGISTEREXPORTED 305 #define LUMIERA_INTERFACE_UNREGISTEREXPORTED 307 #define LUMIERA_INTERFACE_OPEN(interface, version, minminor, name) \ 308 LUMIERA_INTERFACE_CAST(interface, version) lumiera_interface_handle->open (#interface, version, minminor, #name) 310 #define LUMIERA_INTERFACE_CLOSE(handle) \ 311 lumiera_interface_handle->close (&(handle)->interface_header_) 316 #define LUMIERA_PLUGIN_INTERFACEHANDLE static LUMIERA_INTERFACE_HANDLE(lumieraorg_interface, 0) lumiera_interface_handle 317 #define LUMIERA_PLUGIN_STORE_INTERFACEHANDLE(name) lumiera_interface_handle = LUMIERA_INTERFACE_CAST (lumieraorg_interface, 0) name 319 #define LUMIERA_PLUGININTERFACE 324 #define LUMIERA_INTERFACE_REGISTEREXPORTED \ 325 lumiera_interfaceregistry_bulkregister_interfaces (lumiera_plugin_interfaces(), NULL) 330 #define LUMIERA_INTERFACE_UNREGISTEREXPORTED \ 331 lumiera_interfaceregistry_bulkremove_interfaces (lumiera_plugin_interfaces()) 333 #define LUMIERA_INTERFACE_OPEN(interface, version, minminor, name) \ 334 LUMIERA_INTERFACE_CAST(interface, version) lumiera_interface_open (#interface, version, minminor, #name) 336 #define LUMIERA_INTERFACE_CLOSE(handle) \ 337 lumiera_interface_close (&(handle)->interface_header_) 347 #define LUMIERA_INTERFACE_HANDLE(interface, version) \ 348 LUMIERA_INTERFACE_TYPE(interface, version)* 352 typedef lumiera_interfaceslot* LumieraInterfaceslot;
355 typedef lumiera_interface* LumieraInterface;
397 LumieraInterface (*acquire)(LumieraInterface
self, LumieraInterface interfaces);
403 void (*release)(LumieraInterface
self);
407 lumiera_interfaceslot functions[];
448 LUMIERA_INTERFACE_SLOT (LumieraInterface,
450 (
const char* interface,
unsigned version,
size_t minminorversion,
const char*
name)),
451 LUMIERA_INTERFACE_SLOT (
void, close, (LumieraInterface
self)),
452 LUMIERA_INTERFACE_SLOT (
unsigned, version, (LumieraInterface
self,
const char* iname)),
475 LUMIERA_INTERFACE_SLOT (LumieraInterface*, plugin_interfaces, (
void)),
Header for an interface, just the absolute necessary metadata.
void lumiera_interface_init(void)
registering implementations of the above interface
const char * name
name of this instance
#define LUMIERA_INTERFACE_DECLARE(name, version,...)
Declare an interface.
unsigned version
major version, 0 means experimental
This is just a placeholder for an entry in a interface table.
LumieraInterface lumiera_interface_open(const char *interface, unsigned version, size_t minminorversion, const char *name)
Open an interface by version and name.
Probabilistic splay tree.
LumieraInterface descriptor
metadata descriptor, itself a interface (or NULL)
Preprocessor metaprogramming library.
const char * interface
name of the interface (type)
void lumiera_interface_close(LumieraInterface self)
Close an interface after use.
void lumiera_interface_destroy(void)
deregistering implementations of the above interface
unsigned lumiera_interface_version(LumieraInterface self, const char *iname)
Runtime check for interface type and version.
size_t size
size of the whole interface structure (minor version)