commit 48fc694c31f709d4a46f727795917fd3371eb0da
parent 3a74debff941f86fadbc083ed10e1f82bc84de13
Author: falkTX <falktx@falktx.com>
Date: Wed, 27 Apr 2022 13:05:51 +0100
Cleanup unclear v3_funknown use
Signed-off-by: falkTX <falktx@falktx.com>
Diffstat:
11 files changed, 86 insertions(+), 66 deletions(-)
diff --git a/distrho/src/DistrhoPluginVST3.cpp b/distrho/src/DistrhoPluginVST3.cpp
@@ -2962,7 +2962,7 @@ struct dpf_edit_controller : v3_edit_controller_cpp {
// ----------------------------------------------------------------------------------------------------------------
// v3_plugin_base
- static v3_result V3_API initialize(void* const self, v3_plugin_base::v3_funknown** const context)
+ static v3_result V3_API initialize(void* const self, v3_funknown** const context)
{
dpf_edit_controller* const controller = *static_cast<dpf_edit_controller**>(self);
@@ -3671,7 +3671,7 @@ struct dpf_component : v3_component_cpp {
// ----------------------------------------------------------------------------------------------------------------
// v3_plugin_base
- static v3_result V3_API initialize(void* const self, v3_plugin_base::v3_funknown** const context)
+ static v3_result V3_API initialize(void* const self, v3_funknown** const context)
{
dpf_component* const component = *static_cast<dpf_component**>(self);
diff --git a/distrho/src/travesty/audio_processor.h b/distrho/src/travesty/audio_processor.h
@@ -1,6 +1,6 @@
/*
* travesty, pure C VST3-compatible interface
- * Copyright (C) 2021 Filipe Coelho <falktx@falktx.com>
+ * Copyright (C) 2021-2022 Filipe Coelho <falktx@falktx.com>
*
* Permission to use, copy, modify, and/or distribute this software for any purpose with
* or without fee is hereby granted, provided that the above copyright notice and this
@@ -90,8 +90,9 @@ struct v3_process_setup {
*/
struct v3_param_value_queue {
+#ifndef __cplusplus
struct v3_funknown;
-
+#endif
v3_param_id (V3_API* get_param_id)(void* self);
int32_t (V3_API* get_point_count)(void* self);
v3_result (V3_API* get_point)(void* self, int32_t idx, int32_t* sample_offset, double* value);
@@ -102,8 +103,9 @@ static constexpr const v3_tuid v3_param_value_queue_iid =
V3_ID(0x01263A18, 0xED074F6F, 0x98C9D356, 0x4686F9BA);
struct v3_param_changes {
+#ifndef __cplusplus
struct v3_funknown;
-
+#endif
int32_t (V3_API* get_param_count)(void* self);
struct v3_param_value_queue** (V3_API* get_param_data)(void* self, int32_t idx);
struct v3_param_value_queue** (V3_API* add_param_data)(void* self, v3_param_id* id, int32_t* index);
@@ -181,8 +183,9 @@ enum {
};
struct v3_process_context_requirements {
+#ifndef __cplusplus
struct v3_funknown;
-
+#endif
uint32_t (V3_API* get_process_context_requirements)(void* self);
};
@@ -222,8 +225,9 @@ struct v3_process_data {
*/
struct v3_audio_processor {
+#ifndef __cplusplus
struct v3_funknown;
-
+#endif
v3_result (V3_API* set_bus_arrangements)(void* self, v3_speaker_arrangement* inputs, int32_t num_inputs,
v3_speaker_arrangement* outputs, int32_t num_outputs);
v3_result (V3_API* get_bus_arrangement)(void* self, int32_t bus_direction, int32_t idx, v3_speaker_arrangement*);
diff --git a/distrho/src/travesty/base.h b/distrho/src/travesty/base.h
@@ -1,6 +1,6 @@
/*
* travesty, pure C VST3-compatible interface
- * Copyright (C) 2021 Filipe Coelho <falktx@falktx.com>
+ * Copyright (C) 2021-2022 Filipe Coelho <falktx@falktx.com>
*
* Permission to use, copy, modify, and/or distribute this software for any purpose with
* or without fee is hereby granted, provided that the above copyright notice and this
@@ -24,34 +24,8 @@
* deal with C vs C++ differences
*/
-#ifdef __cplusplus
-
-/**
- * cast object into its proper C++ type.
- * this is needed because `struct v3_funknown;` on a C++ class does not inherit `v3_funknown`'s fields.
- *
- * we can use this as a little helper for keeping both C and C++ compatiblity.
- * specialized templated calls are defined where required
- * (that is, object inherits from something other than `v3_funknown`)
- *
- * example usage: `v3_cpp_obj(obj)->method(obj, args...);`
- */
-template<class T> static inline
-constexpr T* v3_cpp_obj(T** 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<T*>(static_cast<void*>(static_cast<uint8_t*>(static_cast<void*>(*obj)) + sizeof(void*)*3));
-}
-
-#else
-
-# ifndef constexpr
-# define constexpr
-# endif
-
+#if !defined(__cplusplus) && !defined(constexpr)
+# define constexpr
#endif
/**
@@ -178,8 +152,9 @@ static constexpr const v3_tuid v3_funknown_iid =
*/
struct v3_plugin_base {
+#ifndef __cplusplus
struct v3_funknown;
-
+#endif
v3_result (V3_API* initialize)(void* self, struct v3_funknown** context);
v3_result (V3_API* terminate)(void* self);
};
@@ -190,6 +165,27 @@ static constexpr const v3_tuid v3_plugin_base_iid =
#ifdef __cplusplus
/**
+ * cast object into its proper C++ type.
+ * this is needed because `struct v3_funknown;` on a C++ class does not inherit `v3_funknown`'s fields.
+ *
+ * we can use this as a little helper for keeping both C and C++ compatiblity.
+ * specialized templated calls are defined where required
+ * (that is, object inherits from something other than `v3_funknown`)
+ *
+ * example usage: `v3_cpp_obj(obj)->method(obj, args...);`
+ */
+
+template<class T> static inline
+constexpr T* v3_cpp_obj(T** 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<T*>(static_cast<void*>(static_cast<uint8_t*>(static_cast<void*>(*obj)) + sizeof(void*)*3));
+}
+
+/**
* helper C++ functions to manually call v3_funknown methods on an object.
*/
diff --git a/distrho/src/travesty/bstream.h b/distrho/src/travesty/bstream.h
@@ -1,6 +1,6 @@
/*
* travesty, pure C VST3-compatible interface
- * Copyright (C) 2021 Filipe Coelho <falktx@falktx.com>
+ * Copyright (C) 2021-2022 Filipe Coelho <falktx@falktx.com>
*
* Permission to use, copy, modify, and/or distribute this software for any purpose with
* or without fee is hereby granted, provided that the above copyright notice and this
@@ -25,8 +25,9 @@ enum v3_seek_mode {
};
struct v3_bstream {
+#ifndef __cplusplus
struct v3_funknown;
-
+#endif
v3_result (V3_API *read)(void* self, void* buffer, int32_t num_bytes, int32_t* bytes_read);
v3_result (V3_API *write)(void* self, void* buffer, int32_t num_bytes, int32_t* bytes_written);
v3_result (V3_API *seek)(void* self, int64_t pos, int32_t seek_mode, int64_t* result);
diff --git a/distrho/src/travesty/component.h b/distrho/src/travesty/component.h
@@ -1,6 +1,6 @@
/*
* travesty, pure C VST3-compatible interface
- * Copyright (C) 2021 Filipe Coelho <falktx@falktx.com>
+ * Copyright (C) 2021-2022 Filipe Coelho <falktx@falktx.com>
*
* Permission to use, copy, modify, and/or distribute this software for any purpose with
* or without fee is hereby granted, provided that the above copyright notice and this
@@ -89,8 +89,9 @@ struct v3_bus_info {
struct v3_routing_info;
struct v3_component {
+#ifndef __cplusplus
struct v3_plugin_base;
-
+#endif
v3_result (V3_API *get_controller_class_id)(void* self, v3_tuid class_id);
v3_result (V3_API *set_io_mode)(void* self, int32_t io_mode);
int32_t (V3_API *get_bus_count)(void* self, int32_t media_type, int32_t bus_direction);
diff --git a/distrho/src/travesty/edit_controller.h b/distrho/src/travesty/edit_controller.h
@@ -1,6 +1,6 @@
/*
* travesty, pure C VST3-compatible interface
- * Copyright (C) 2021 Filipe Coelho <falktx@falktx.com>
+ * Copyright (C) 2021-2022 Filipe Coelho <falktx@falktx.com>
*
* Permission to use, copy, modify, and/or distribute this software for any purpose with
* or without fee is hereby granted, provided that the above copyright notice and this
@@ -40,8 +40,9 @@ enum {
};
struct v3_component_handler {
+#ifndef __cplusplus
struct v3_funknown;
-
+#endif
v3_result (V3_API* begin_edit)(void* self, v3_param_id);
v3_result (V3_API* perform_edit)(void* self, v3_param_id, double value_normalised);
v3_result (V3_API* end_edit)(void* self, v3_param_id);
@@ -77,8 +78,9 @@ struct v3_param_info {
};
struct v3_edit_controller {
+#ifndef __cplusplus
struct v3_plugin_base;
-
+#endif
v3_result (V3_API* set_component_state)(void* self, struct v3_bstream**);
v3_result (V3_API* set_state)(void* self, struct v3_bstream**);
v3_result (V3_API* get_state)(void* self, struct v3_bstream**);
@@ -102,8 +104,9 @@ static constexpr const v3_tuid v3_edit_controller_iid =
*/
struct v3_midi_mapping {
+#ifndef __cplusplus
struct v3_funknown;
-
+#endif
v3_result (V3_API* get_midi_controller_assignment)(void* self, int32_t bus, int16_t channel, int16_t cc, v3_param_id* id);
};
diff --git a/distrho/src/travesty/events.h b/distrho/src/travesty/events.h
@@ -1,6 +1,6 @@
/*
* travesty, pure C VST3-compatible interface
- * Copyright (C) 2021 Filipe Coelho <falktx@falktx.com>
+ * Copyright (C) 2021-2022 Filipe Coelho <falktx@falktx.com>
*
* Permission to use, copy, modify, and/or distribute this software for any purpose with
* or without fee is hereby granted, provided that the above copyright notice and this
@@ -132,8 +132,9 @@ struct v3_event {
*/
struct v3_event_list {
+#ifndef __cplusplus
struct v3_funknown;
-
+#endif
uint32_t (V3_API* get_event_count)(void* self);
v3_result (V3_API* get_event)(void* self, int32_t idx, struct v3_event* event);
v3_result (V3_API* add_event)(void* self, struct v3_event* event);
diff --git a/distrho/src/travesty/factory.h b/distrho/src/travesty/factory.h
@@ -1,6 +1,6 @@
/*
* travesty, pure C VST3-compatible interface
- * Copyright (C) 2021 Filipe Coelho <falktx@falktx.com>
+ * Copyright (C) 2021-2022 Filipe Coelho <falktx@falktx.com>
*
* Permission to use, copy, modify, and/or distribute this software for any purpose with
* or without fee is hereby granted, provided that the above copyright notice and this
@@ -37,8 +37,9 @@ struct v3_class_info {
};
struct v3_plugin_factory {
+#ifndef __cplusplus
struct v3_funknown;
-
+#endif
v3_result (V3_API *get_factory_info)(void* self, struct v3_factory_info*);
int32_t (V3_API *num_classes)(void* self);
v3_result (V3_API *get_class_info)(void* self, int32_t idx, struct v3_class_info*);
@@ -70,8 +71,9 @@ struct v3_class_info_2 {
};
struct v3_plugin_factory_2 {
+#ifndef __cplusplus
struct v3_plugin_factory;
-
+#endif
v3_result (V3_API *get_class_info_2)(void* self, int32_t idx, struct v3_class_info_2*);
};
@@ -98,8 +100,9 @@ struct v3_class_info_3 {
};
struct v3_plugin_factory_3 {
+#ifndef __cplusplus
struct v3_plugin_factory_2;
-
+#endif
v3_result (V3_API *get_class_info_utf16)(void* self, int32_t idx, struct v3_class_info_3*);
v3_result (V3_API *set_host_context)(void* self, struct v3_funknown** host);
};
diff --git a/distrho/src/travesty/host.h b/distrho/src/travesty/host.h
@@ -1,6 +1,6 @@
/*
* travesty, pure C VST3-compatible interface
- * Copyright (C) 2021 Filipe Coelho <falktx@falktx.com>
+ * Copyright (C) 2021-2022 Filipe Coelho <falktx@falktx.com>
*
* Permission to use, copy, modify, and/or distribute this software for any purpose with
* or without fee is hereby granted, provided that the above copyright notice and this
@@ -21,12 +21,13 @@
#include "align_push.h"
/**
- * connection point
+ * host application
*/
struct v3_host_application {
+#ifndef __cplusplus
struct v3_funknown;
-
+#endif
v3_result (V3_API* get_name)(void* self, v3_str_128 name); // wtf?
v3_result (V3_API* create_instance)(void* self, v3_tuid cid, v3_tuid iid, void** obj);
};
diff --git a/distrho/src/travesty/message.h b/distrho/src/travesty/message.h
@@ -1,6 +1,6 @@
/*
* travesty, pure C VST3-compatible interface
- * Copyright (C) 2021 Filipe Coelho <falktx@falktx.com>
+ * Copyright (C) 2021-2022 Filipe Coelho <falktx@falktx.com>
*
* Permission to use, copy, modify, and/or distribute this software for any purpose with
* or without fee is hereby granted, provided that the above copyright notice and this
@@ -25,8 +25,9 @@
*/
struct v3_attribute_list {
+#ifndef __cplusplus
struct v3_funknown;
-
+#endif
v3_result (V3_API* set_int)(void* self, const char* id, int64_t value);
v3_result (V3_API* get_int)(void* self, const char* id, int64_t* value);
v3_result (V3_API* set_float)(void* self, const char* id, double value);
@@ -45,8 +46,9 @@ static constexpr const v3_tuid v3_attribute_list_iid =
*/
struct v3_message {
+#ifndef __cplusplus
struct v3_funknown;
-
+#endif
const char* (V3_API* get_message_id)(void* self);
void (V3_API* set_message_id)(void* self, const char* id);
v3_attribute_list** (V3_API* get_attributes)(void* self);
@@ -60,8 +62,9 @@ static constexpr const v3_tuid v3_message_iid =
*/
struct v3_connection_point {
+#ifndef __cplusplus
struct v3_funknown;
-
+#endif
v3_result (V3_API* connect)(void* self, struct v3_connection_point** other);
v3_result (V3_API* disconnect)(void* self, struct v3_connection_point** other);
v3_result (V3_API* notify)(void* self, struct v3_message** message);
diff --git a/distrho/src/travesty/view.h b/distrho/src/travesty/view.h
@@ -1,6 +1,6 @@
/*
* travesty, pure C VST3-compatible interface
- * Copyright (C) 2021 Filipe Coelho <falktx@falktx.com>
+ * Copyright (C) 2021-2022 Filipe Coelho <falktx@falktx.com>
*
* Permission to use, copy, modify, and/or distribute this software for any purpose with
* or without fee is hereby granted, provided that the above copyright notice and this
@@ -48,8 +48,9 @@ struct v3_view_rect {
struct v3_plugin_frame;
struct v3_plugin_view {
+#ifndef __cplusplus
struct v3_funknown;
-
+#endif
v3_result (V3_API* is_platform_type_supported)(void* self, const char* platform_type);
v3_result (V3_API* attached)(void* self, void* parent, const char* platform_type);
v3_result (V3_API* removed)(void* self);
@@ -72,8 +73,9 @@ static constexpr const v3_tuid v3_plugin_view_iid =
*/
struct v3_plugin_frame {
+#ifndef __cplusplus
struct v3_funknown;
-
+#endif
v3_result (V3_API* resize_view)(void* self, struct v3_plugin_view**, struct v3_view_rect*);
};
@@ -86,8 +88,9 @@ static constexpr const v3_tuid v3_plugin_frame_iid =
*/
struct v3_plugin_view_content_scale {
+#ifndef __cplusplus
struct v3_funknown;
-
+#endif
v3_result (V3_API* set_content_scale_factor)(void* self, float factor);
};
@@ -99,8 +102,9 @@ static constexpr const v3_tuid v3_plugin_view_content_scale_iid =
*/
struct v3_plugin_view_parameter_finder {
+#ifndef __cplusplus
struct v3_funknown;
-
+#endif
v3_result (V3_API* find_parameter)(void* self, int32_t x, int32_t y, v3_param_id *);
};
@@ -112,8 +116,9 @@ static constexpr const v3_tuid v3_plugin_view_parameter_finder_iid =
*/
struct v3_event_handler {
+#ifndef __cplusplus
struct v3_funknown;
-
+#endif
void (V3_API* on_fd_is_set)(void* self, int fd);
};
@@ -125,8 +130,9 @@ static constexpr const v3_tuid v3_event_handler_iid =
*/
struct v3_timer_handler {
+#ifndef __cplusplus
struct v3_funknown;
-
+#endif
void (V3_API* on_timer)(void* self);
};
@@ -138,8 +144,9 @@ static constexpr const v3_tuid v3_timer_handler_iid =
*/
struct v3_run_loop {
+#ifndef __cplusplus
struct v3_funknown;
-
+#endif
v3_result (V3_API* register_event_handler)(void* self, v3_event_handler** handler, int fd);
v3_result (V3_API* unregister_event_handler)(void* self, v3_event_handler** handler);
v3_result (V3_API* register_timer)(void* self, v3_timer_handler** handler, uint64_t ms);