Browse Source

Tweak travesty headers as needed by hosts for plugin scanning

Signed-off-by: falkTX <falktx@falktx.com>
pull/321/head
falkTX 3 years ago
parent
commit
e3341cb422
Signed by: falkTX <falktx@falktx.com> GPG Key ID: CDBAA37ABC74FBA0
3 changed files with 48 additions and 0 deletions
  1. +14
    -0
      distrho/src/travesty/base.h
  2. +12
    -0
      distrho/src/travesty/events.h
  3. +22
    -0
      distrho/src/travesty/factory.h

+ 14
- 0
distrho/src/travesty/base.h View File

@@ -207,4 +207,18 @@ uint32_t v3_cpp_obj_unref(T** 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

+ 12
- 0
distrho/src/travesty/events.h View File

@@ -143,4 +143,16 @@ struct v3_event_list {
static constexpr const v3_tuid v3_event_list_iid =
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"

+ 22
- 0
distrho/src/travesty/factory.h View File

@@ -122,4 +122,26 @@ struct v3_plugin_factory_cpp : v3_funknown {
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

Loading…
Cancel
Save