Mercurial > hg > pub > prymula > com
comparison DPF-Prymula-audioplugins/dpf/distrho/src/travesty/factory.h @ 3:84e66ea83026
DPF-Prymula-audioplugins-0.231015-2
author | prymula <prymula76@outlook.com> |
---|---|
date | Mon, 16 Oct 2023 21:53:34 +0200 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
2:cf2cb71d31dd | 3:84e66ea83026 |
---|---|
1 /* | |
2 * travesty, pure C VST3-compatible interface | |
3 * Copyright (C) 2021-2022 Filipe Coelho <falktx@falktx.com> | |
4 * | |
5 * Permission to use, copy, modify, and/or distribute this software for any purpose with | |
6 * or without fee is hereby granted, provided that the above copyright notice and this | |
7 * permission notice appear in all copies. | |
8 * | |
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD | |
10 * TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN | |
11 * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL | |
12 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER | |
13 * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN | |
14 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |
15 */ | |
16 | |
17 #pragma once | |
18 | |
19 #include "base.h" | |
20 | |
21 /** | |
22 * plugin factory v1 | |
23 */ | |
24 | |
25 struct v3_factory_info { | |
26 char vendor[64]; | |
27 char url[256]; | |
28 char email[128]; | |
29 int32_t flags; // set to 0x10 (unicode) | |
30 }; | |
31 | |
32 struct v3_class_info { | |
33 v3_tuid class_id; | |
34 int32_t cardinality; // set to 0x7FFFFFFF (many instances) | |
35 char category[32]; | |
36 char name[64]; | |
37 }; | |
38 | |
39 struct v3_plugin_factory { | |
40 #ifndef __cplusplus | |
41 struct v3_funknown; | |
42 #endif | |
43 v3_result (V3_API *get_factory_info)(void* self, struct v3_factory_info*); | |
44 int32_t (V3_API *num_classes)(void* self); | |
45 v3_result (V3_API *get_class_info)(void* self, int32_t idx, struct v3_class_info*); | |
46 v3_result (V3_API *create_instance)(void* self, const v3_tuid class_id, const v3_tuid iid, void** instance); | |
47 }; | |
48 | |
49 static constexpr const v3_tuid v3_plugin_factory_iid = | |
50 V3_ID(0x7A4D811C, 0x52114A1F, 0xAED9D2EE, 0x0B43BF9F); | |
51 | |
52 /** | |
53 * plugin factory v2 | |
54 */ | |
55 | |
56 enum { | |
57 V3_DISTRIBUTABLE = 1 << 0, | |
58 V3_SIMPLE_MODE = 1 << 1 | |
59 }; | |
60 | |
61 struct v3_class_info_2 { | |
62 v3_tuid class_id; | |
63 int32_t cardinality; // set to 0x7FFFFFFF | |
64 char category[32]; | |
65 char name[64]; | |
66 uint32_t class_flags; | |
67 char sub_categories[128]; | |
68 char vendor[64]; | |
69 char version[64]; | |
70 char sdk_version[64]; | |
71 }; | |
72 | |
73 struct v3_plugin_factory_2 { | |
74 #ifndef __cplusplus | |
75 struct v3_plugin_factory; | |
76 #endif | |
77 v3_result (V3_API *get_class_info_2)(void* self, int32_t idx, struct v3_class_info_2*); | |
78 }; | |
79 | |
80 static constexpr const v3_tuid v3_plugin_factory_2_iid = | |
81 V3_ID(0x0007B650, 0xF24B4C0B, 0xA464EDB9, 0xF00B2ABB); | |
82 | |
83 /** | |
84 * plugin factory v3 | |
85 * (we got it right this time I swear) | |
86 * | |
87 * same as above, but "unicode" (really just utf-16, thanks microsoft!) | |
88 */ | |
89 | |
90 struct v3_class_info_3 { | |
91 v3_tuid class_id; | |
92 int32_t cardinality; // set to 0x7FFFFFFF | |
93 char category[32]; | |
94 int16_t name[64]; | |
95 uint32_t class_flags; | |
96 char sub_categories[128]; | |
97 int16_t vendor[64]; | |
98 int16_t version[64]; | |
99 int16_t sdk_version[64]; | |
100 }; | |
101 | |
102 struct v3_plugin_factory_3 { | |
103 #ifndef __cplusplus | |
104 struct v3_plugin_factory_2; | |
105 #endif | |
106 v3_result (V3_API *get_class_info_utf16)(void* self, int32_t idx, struct v3_class_info_3*); | |
107 v3_result (V3_API *set_host_context)(void* self, struct v3_funknown** host); | |
108 }; | |
109 | |
110 static constexpr const v3_tuid v3_plugin_factory_3_iid = | |
111 V3_ID(0x4555A2AB, 0xC1234E57, 0x9B122910, 0x36878931); | |
112 | |
113 #ifdef __cplusplus | |
114 | |
115 /** | |
116 * C++ variants | |
117 */ | |
118 | |
119 struct v3_plugin_factory_cpp : v3_funknown { | |
120 v3_plugin_factory v1; | |
121 v3_plugin_factory_2 v2; | |
122 v3_plugin_factory_3 v3; | |
123 }; | |
124 | |
125 template<> inline | |
126 constexpr v3_plugin_factory_2* v3_cpp_obj(v3_plugin_factory_2** obj) | |
127 { | |
128 /** | |
129 * this ugly piece of code is required due to C++ assuming `reinterpret_cast` by default, | |
130 * but we need everything to be `static_cast` for it to be `constexpr` compatible. | |
131 */ | |
132 return static_cast<v3_plugin_factory_2*>( | |
133 static_cast<void*>(static_cast<uint8_t*>(static_cast<void*>(*obj)) + sizeof(void*)*7)); | |
134 } | |
135 | |
136 template<> inline | |
137 constexpr v3_plugin_factory_3* v3_cpp_obj(v3_plugin_factory_3** obj) | |
138 { | |
139 /** | |
140 * this ugly piece of code is required due to C++ assuming `reinterpret_cast` by default, | |
141 * but we need everything to be `static_cast` for it to be `constexpr` compatible. | |
142 */ | |
143 return static_cast<v3_plugin_factory_3*>( | |
144 static_cast<void*>(static_cast<uint8_t*>(static_cast<void*>(*obj)) + sizeof(void*)*8)); | |
145 } | |
146 | |
147 #endif |