Signed-off-by: falkTX <falktx@falktx.com>pull/321/head
@@ -207,4 +207,18 @@ uint32_t v3_cpp_obj_unref(T** obj) | |||||
return static_cast<v3_funknown*>(static_cast<void*>(*obj))->unref(obj); | return static_cast<v3_funknown*>(static_cast<void*>(*obj))->unref(obj); | ||||
} | } | ||||
template<class T> static inline | |||||
v3_result v3_cpp_obj_initialize(T** obj, v3_funknown** context) | |||||
{ | |||||
return static_cast<v3_plugin_base*>( | |||||
static_cast<void*>(static_cast<uint8_t*>(static_cast<void*>(*obj)) + sizeof(void*)*3))->initialize(obj, context); | |||||
} | |||||
template<class T> static inline | |||||
v3_result v3_cpp_obj_terminate(T** obj) | |||||
{ | |||||
return static_cast<v3_plugin_base*>( | |||||
static_cast<void*>(static_cast<uint8_t*>(static_cast<void*>(*obj)) + sizeof(void*)*3))->terminate(obj); | |||||
} | |||||
#endif | #endif |
@@ -143,4 +143,16 @@ struct v3_event_list { | |||||
static constexpr const v3_tuid v3_event_list_iid = | static constexpr const v3_tuid v3_event_list_iid = | ||||
V3_ID(0x3A2C4214, 0x346349FE, 0xB2C4F397, 0xB9695A44); | V3_ID(0x3A2C4214, 0x346349FE, 0xB2C4F397, 0xB9695A44); | ||||
#ifdef __cplusplus | |||||
/** | |||||
* C++ variants | |||||
*/ | |||||
struct v3_event_list_cpp : v3_funknown { | |||||
v3_event_list list; | |||||
}; | |||||
#endif | |||||
#include "align_pop.h" | #include "align_pop.h" |
@@ -122,4 +122,26 @@ struct v3_plugin_factory_cpp : v3_funknown { | |||||
v3_plugin_factory_3 v3; | v3_plugin_factory_3 v3; | ||||
}; | }; | ||||
template<> inline | |||||
constexpr v3_plugin_factory_2* v3_cpp_obj(v3_plugin_factory_2** obj) | |||||
{ | |||||
/** | |||||
* this ugly piece of code is required due to C++ assuming `reinterpret_cast` by default, | |||||
* but we need everything to be `static_cast` for it to be `constexpr` compatible. | |||||
*/ | |||||
return static_cast<v3_plugin_factory_2*>( | |||||
static_cast<void*>(static_cast<uint8_t*>(static_cast<void*>(*obj)) + sizeof(void*)*7)); | |||||
} | |||||
template<> inline | |||||
constexpr v3_plugin_factory_3* v3_cpp_obj(v3_plugin_factory_3** obj) | |||||
{ | |||||
/** | |||||
* this ugly piece of code is required due to C++ assuming `reinterpret_cast` by default, | |||||
* but we need everything to be `static_cast` for it to be `constexpr` compatible. | |||||
*/ | |||||
return static_cast<v3_plugin_factory_3*>( | |||||
static_cast<void*>(static_cast<uint8_t*>(static_cast<void*>(*obj)) + sizeof(void*)*8)); | |||||
} | |||||
#endif | #endif |