1616
1717#include < sstream>
1818#include < iostream>
19+ #include < cstring>
1920
2021// VST3 SDK includes
2122#include " public.sdk/source/vst/hosting/module.h"
2223#include " public.sdk/source/vst/hosting/hostclasses.h"
2324#include " public.sdk/source/vst/hosting/plugprovider.h"
24- #include " public.sdk/source/vst/testsuite/vsttestsuite.h"
2525#include " pluginterfaces/vst/ivstaudioprocessor.h"
2626#include " pluginterfaces/vst/ivsteditcontroller.h"
2727#include " pluginterfaces/vst/ivsthostapplication.h"
@@ -41,10 +41,12 @@ class ValidatorHostApp : public IHostApplication
4141
4242 tresult PLUGIN_API getName (String128 name) override
4343 {
44- return StringCopy (name, u" pluginval VST3 Validator" );
44+ const char16_t hostName[] = u" pluginval VST3 Validator" ;
45+ std::memcpy (name, hostName, sizeof (hostName));
46+ return kResultOk ;
4547 }
4648
47- tresult PLUGIN_API createInstance (TUID cid, TUID iid , void ** obj) override
49+ tresult PLUGIN_API createInstance (TUID /* cid*/ , TUID /* _iid */ , void ** obj) override
4850 {
4951 *obj = nullptr ;
5052 return kResultFalse ;
@@ -62,47 +64,6 @@ class ValidatorHostApp : public IHostApplication
6264 uint32 PLUGIN_API release () override { return 1 ; }
6365};
6466
65- // ==============================================================================
66- /* * Test result handler that captures output. */
67- class TestResultHandler : public ITestResult
68- {
69- public:
70- TestResultHandler (std::ostream& os, bool verbose)
71- : output (os), verboseOutput (verbose)
72- {
73- }
74-
75- void PLUGIN_API addErrorMessage (const char8* msg) override
76- {
77- if (msg)
78- {
79- output << " ERROR: " << msg << " \n " ;
80- hasErrors = true ;
81- }
82- }
83-
84- void PLUGIN_API addMessage (const char8* msg) override
85- {
86- if (msg && verboseOutput)
87- output << msg << " \n " ;
88- }
89-
90- tresult PLUGIN_API queryInterface (const TUID, void ** obj) override
91- {
92- *obj = nullptr ;
93- return kNoInterface ;
94- }
95-
96- uint32 PLUGIN_API addRef () override { return 1 ; }
97- uint32 PLUGIN_API release () override { return 1 ; }
98-
99- bool hasErrors = false ;
100-
101- private:
102- std::ostream& output;
103- bool verboseOutput;
104- };
105-
10667// ==============================================================================
10768Result runValidator (const Options& options)
10869{
@@ -153,9 +114,6 @@ Result runValidator (const Options& options)
153114 // Create host application
154115 ValidatorHostApp hostApp;
155116
156- // Create test result handler
157- TestResultHandler testResult (outputStream, options.verbose );
158-
159117 bool allTestsPassed = true ;
160118 int numProcessorClasses = 0 ;
161119
@@ -172,9 +130,9 @@ Result runValidator (const Options& options)
172130 numProcessorClasses++;
173131 outputStream << " [Audio Processor]\n " ;
174132
175- // Create the component
176- IPtr <IComponent> component ;
177- if (factory. createInstance (classInfo. ID (), component) != kResultOk || ! component)
133+ // Create the component using the template method
134+ auto component = factory. createInstance <IComponent> (classInfo. ID ()) ;
135+ if (! component)
178136 {
179137 outputStream << " ERROR: Failed to create component instance\n " ;
180138 allTestsPassed = false ;
@@ -192,8 +150,8 @@ Result runValidator (const Options& options)
192150 outputStream << " Component created and initialized successfully\n " ;
193151
194152 // Get audio processor interface
195- IPtr <IAudioProcessor> processor;
196- if (component-> queryInterface (IAudioProcessor::iid, ( void **)&processor) != kResultOk || ! processor)
153+ FUnknownPtr <IAudioProcessor> processor (component) ;
154+ if (! processor)
197155 {
198156 outputStream << " WARNING: Component does not implement IAudioProcessor\n " ;
199157 }
@@ -206,8 +164,8 @@ Result runValidator (const Options& options)
206164 TUID controllerCID;
207165 if (component->getControllerClassId (controllerCID) == kResultOk )
208166 {
209- IPtr <IEditController> controller ;
210- if (factory. createInstance ( VST3::UID (controllerCID), controller) == kResultOk && controller)
167+ auto controller = factory. createInstance <IEditController> ( VST3::UID (controllerCID)) ;
168+ if (controller)
211169 {
212170 if (controller->initialize (&hostApp) == kResultOk )
213171 {
@@ -244,10 +202,10 @@ Result runValidator (const Options& options)
244202 outputStream << " ----------------------------------------\n " ;
245203 outputStream << " Validation Summary:\n " ;
246204 outputStream << " Audio Processor classes found: " << numProcessorClasses << " \n " ;
247- outputStream << " Result: " << (allTestsPassed && ! testResult. hasErrors ? " PASSED" : " FAILED" ) << " \n " ;
205+ outputStream << " Result: " << (allTestsPassed ? " PASSED" : " FAILED" ) << " \n " ;
248206
249207 result.output = outputStream.str ();
250- result.success = allTestsPassed && ! testResult. hasErrors ;
208+ result.success = allTestsPassed;
251209 result.exitCode = result.success ? 0 : 1 ;
252210
253211 return result;
0 commit comments