86 #ifndef LUMIERA_INTERFACE_H 87 #define LUMIERA_INTERFACE_H 102 #define LUMIERA_INTERFACE_INAME(name, version) name##_##version 111 #define LUMIERA_INTERFACE_DNAME(iname, version, dname) PPMPL_CAT (LUMIERA_INTERFACE_INAME (iname, version), _##dname) 120 #define LUMIERA_INTERFACE_DSTRING(iname, version, dname) PPMPL_STRINGIFY (LUMIERA_INTERFACE_DNAME (iname, version, dname)) 128 #define LUMIERA_INTERFACE_REF(iname, version, dname) \ 129 (LumieraInterface)&LUMIERA_INTERFACE_DNAME(iname, version, dname) 137 #define LUMIERA_INTERFACE_TYPE(name, version) struct LUMIERA_INTERFACE_INAME(name, version) 146 #define LUMIERA_INTERFACE_CAST(name, version) (LUMIERA_INTERFACE_TYPE(name, version)*) 163 #define LUMIERA_INTERFACE_DECLARE(name, version, ...) \ 164 LUMIERA_INTERFACE_TYPE(name, version) \ 166 lumiera_interface interface_header_; \ 167 PPMPL_FOREACH(_, __VA_ARGS__) \ 176 #define PPMPL_FOREACH_LUMIERA_INTERFACE_SLOT(ret, name, params) \ 177 ret (*name) params; \ 194 #define LUMIERA_INTERFACE_INSTANCE(iname, version, name, descriptor, acquire, release, ...) \ 195 PPMPL_FOREACH(_P1_, __VA_ARGS__) \ 196 LUMIERA_INTERFACE_TYPE(iname, version) LUMIERA_INTERFACE_DNAME(iname, version, name) = \ 202 sizeof (LUMIERA_INTERFACE_TYPE(iname, version)), \ 207 PPMPL_FOREACH(_P2_, __VA_ARGS__) \ 219 #define PPMPL_FOREACH_P1_LUMIERA_INTERFACE_MAP(slot, function) 221 #define PPMPL_FOREACH_P2_LUMIERA_INTERFACE_MAP(slot, function) \ 225 #define PPMPL_FOREACH_P2_LUMIERA_INTERFACE_MAP(slot, function) \ 241 #define PPMPL_FOREACH_P1_LUMIERA_INTERFACE_INLINE(slot, ret, params, ...) \ 243 LUMIERA_INTERFACE_INLINE_NAME(slot) params \ 247 #define PPMPL_FOREACH_P2_LUMIERA_INTERFACE_INLINE(slot, ret, params, ...) \ 248 LUMIERA_INTERFACE_INLINE_NAME(slot),\ 251 #define PPMPL_FOREACH_P2_LUMIERA_INTERFACE_INLINE(slot, ret, params, ...) \ 252 .slot = LUMIERA_INTERFACE_INLINE_NAME(slot),\ 256 #define LUMIERA_INTERFACE_INLINE_NAME(slot) PPMPL_CAT(lumiera_##slot##_l, __LINE__) 259 #define PPMPL_FOREACH_L1_P1_LUMIERA_INTERFACE_DEFINE(iname, version, name, descriptor, acquire, release, ...) \ 260 LUMIERA_INTERFACE_INSTANCE (iname, version, \ 269 #define PPMPL_FOREACH_L1_P2_LUMIERA_INTERFACE_DEFINE(iname, version, name, descriptor, acquire, release, ...) \ 270 &LUMIERA_INTERFACE_DNAME(iname, version, name).interface_header_, 282 #define LUMIERA_EXPORT(...) \ 283 PPMPL_FOREACH_L1(_P1_, __VA_ARGS__) \ 284 static LumieraInterface* \ 285 lumiera_plugin_interfaces (void) \ 287 static LumieraInterface interfaces[] = \ 289 PPMPL_FOREACH_L1(_P2_, __VA_ARGS__) \ 294 LUMIERA_PLUGININTERFACE 300 #ifdef LUMIERA_PLUGIN 301 #define LUMIERA_PLUGIN_INTERFACEHANDLE static LUMIERA_INTERFACE_HANDLE(lumieraorg_interface, 0) lumiera_interface_handle 302 #define LUMIERA_PLUGIN_STORE_INTERFACEHANDLE(name) lumiera_interface_handle = LUMIERA_INTERFACE_CAST (lumieraorg_interface, 0) name 304 #define LUMIERA_PLUGININTERFACE \ 305 LUMIERA_INTERFACE_INSTANCE (lumieraorg__plugin, 0, \ 310 LUMIERA_INTERFACE_MAP (plugin_interfaces, \ 311 lumiera_plugin_interfaces) \ 313 #define LUMIERA_INTERFACE_REGISTEREXPORTED 314 #define LUMIERA_INTERFACE_UNREGISTEREXPORTED 316 #define LUMIERA_INTERFACE_OPEN(interface, version, minminor, name) \ 317 LUMIERA_INTERFACE_CAST(interface, version) lumiera_interface_handle->open (#interface, version, minminor, #name) 319 #define LUMIERA_INTERFACE_CLOSE(handle) \ 320 lumiera_interface_handle->close (&(handle)->interface_header_) 325 #define LUMIERA_PLUGIN_INTERFACEHANDLE static LUMIERA_INTERFACE_HANDLE(lumieraorg_interface, 0) lumiera_interface_handle 326 #define LUMIERA_PLUGIN_STORE_INTERFACEHANDLE(name) lumiera_interface_handle = LUMIERA_INTERFACE_CAST (lumieraorg_interface, 0) name 328 #define LUMIERA_PLUGININTERFACE 333 #define LUMIERA_INTERFACE_REGISTEREXPORTED \ 334 lumiera_interfaceregistry_bulkregister_interfaces (lumiera_plugin_interfaces(), NULL) 339 #define LUMIERA_INTERFACE_UNREGISTEREXPORTED \ 340 lumiera_interfaceregistry_bulkremove_interfaces (lumiera_plugin_interfaces()) 342 #define LUMIERA_INTERFACE_OPEN(interface, version, minminor, name) \ 343 LUMIERA_INTERFACE_CAST(interface, version) lumiera_interface_open (#interface, version, minminor, #name) 345 #define LUMIERA_INTERFACE_CLOSE(handle) \ 346 lumiera_interface_close (&(handle)->interface_header_) 356 #define LUMIERA_INTERFACE_HANDLE(interface, version) \ 357 LUMIERA_INTERFACE_TYPE(interface, version)* 361 typedef lumiera_interfaceslot* LumieraInterfaceslot;
364 typedef lumiera_interface* LumieraInterface;
406 LumieraInterface (*acquire)(LumieraInterface
self, LumieraInterface interfaces);
412 void (*release)(LumieraInterface
self);
416 lumiera_interfaceslot functions[];
457 LUMIERA_INTERFACE_SLOT (LumieraInterface,
459 (
const char* interface,
unsigned version,
size_t minminorversion,
const char*
name)),
460 LUMIERA_INTERFACE_SLOT (
void, close, (LumieraInterface
self)),
461 LUMIERA_INTERFACE_SLOT (
unsigned, version, (LumieraInterface
self,
const char* iname)),
484 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)