• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

ossia / score / 32092262946

18 Aug 2026 02:33AM UTC coverage: 20.688% (+1.3%) from 19.438%
32092262946

push

github

jcelerier
tests: fake_puppet: support Qt < 6.5

QWebSocket::errorOccurred only exists since Qt 6.5; the Coverage CI
container builds the test tree with Qt 6.4, where the signal is the
overloaded `error`.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

44247 of 213874 relevant lines covered (20.69%)

5667.56 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/clappuppet/clappuppet.cpp
1
#include <score/tools/PuppetClient.hpp>
2

3
#include <clap/all.h>
4

5
#include <filesystem>
6
#include <iostream>
7

8
#if defined(_MSC_VER)
9
#include <boost/asio/impl/src.hpp>
10
#endif
11

12
// https://svn.boost.org/trac10/ticket/3605
13
#if defined(_MSC_VER)
14
#include <boost/asio/detail/winsock_init.hpp>
15
#pragma warning(push)
16
#pragma warning(disable : 4073)
17
#pragma init_seg(lib)
18
boost::asio::detail::winsock_init<2, 2>::manual manual_winsock_init;
19
#pragma warning(pop)
20
#elif defined(_WIN32)
21
#include <boost/asio/detail/winsock_init.hpp>
22
#endif
23

24
#if !defined(__cpp_exceptions)
25
#include <boost/throw_exception.hpp>
26
namespace boost
27
{
28
void throw_exception(std::exception const& e)
29
{
30
  std::terminate();
31
}
32
void throw_exception(std::exception const& e, boost::source_location const& loc)
33
{
34
  std::terminate();
35
}
36
}
37
#endif
38

39
#if defined(_WIN32)
40
#include <windows.h>
41
#else
42
#include <dlfcn.h>
43
#endif
44

45
std::string load_clap(const std::string& path, int id, const std::string& token)
×
46
{
47
  using score::puppet::json_escape;
48
  auto error_json = [&](std::string err) {
×
49
    return fmt::format(
×
50
        R"_({{"Path":"{}","Request":{},"Token":"{}","Error":"{}"}})_",
×
51
        json_escape(path), id, json_escape(token), json_escape(err));
×
52
  };
×
53

54
  try
55
  {
56
    const bool isFile = std::filesystem::exists(path);
×
57
    if(!isFile)
×
58
    {
59
      std::cerr << "Invalid path: " << path << std::endl;
×
60
      return error_json("Invalid path");
×
61
    }
62

63
    // Load the plugin library
64
#if defined(_WIN32)
65
    HMODULE handle = LoadLibraryA(path.c_str());
66
    if(!handle)
67
    {
68
      std::cerr << "Failed to load library: " << path << std::endl;
69
      return error_json("Failed to load library");
70
    }
71

72
    auto entry_fn = (const clap_plugin_entry_t*)GetProcAddress(handle, "clap_entry");
73
#else
74
    void* handle = dlopen(path.c_str(), RTLD_LAZY);
×
75
    if(!handle)
×
76
    {
77
      const char* err = dlerror();
×
78
      std::cerr << "Failed to load library: " << path << " - " << (err ? err : "")
×
79
                << std::endl;
×
80
      return error_json(std::string{"Failed to load library: "} + (err ? err : ""));
×
81
    }
82
    
83
    auto entry_fn = (const clap_plugin_entry_t*)dlsym(handle, "clap_entry");
×
84
#endif
85

86
    if(!entry_fn)
×
87
    {
88
      std::cerr << "No clap_entry found in: " << path << std::endl;
×
89
#if defined(_WIN32)
90
      FreeLibrary(handle);
91
#else
92
      dlclose(handle);
×
93
#endif
94
      return error_json("No clap_entry found");
×
95
    }
96

97
    if(!entry_fn->init(path.c_str()))
×
98
    {
99
      std::cerr << "Failed to initialize CLAP plugin: " << path << std::endl;
×
100
#if defined(_WIN32)
101
      FreeLibrary(handle);
102
#else
103
      dlclose(handle);
×
104
#endif
105
      return error_json("Failed to initialize CLAP plugin");
×
106
    }
107

108
    auto factory = (const clap_plugin_factory_t*)entry_fn->get_factory(CLAP_PLUGIN_FACTORY_ID);
×
109
    if(!factory)
×
110
    {
111
      std::cerr << "No plugin factory found in: " << path << std::endl;
×
112
      entry_fn->deinit();
×
113
#if defined(_WIN32)
114
      FreeLibrary(handle);
115
#else
116
      dlclose(handle);
×
117
#endif
118
      return error_json("No plugin factory found");
×
119
    }
120

121
    std::string root = fmt::format(
×
122
        R"_({{
×
123
"Path":"{}",
124
"Request":{},
125
"Token":"{}",
126
"Plugins":[
127
)_",
128
        json_escape(path), id, json_escape(token));
×
129

130
    uint32_t plugin_count = factory->get_plugin_count(factory);
×
131
    bool first_plugin = true;
×
132
    for(uint32_t i = 0; i < plugin_count; ++i)
×
133
    {
134
      const clap_plugin_descriptor_t* desc = factory->get_plugin_descriptor(factory, i);
×
135
      if(!desc)
×
136
        continue;
×
137

138
      std::string features_str = "[";
×
139
      if(desc->features)
×
140
      {
141
        bool first = true;
×
142
        for(const char* const* feature = desc->features; *feature; ++feature)
×
143
        {
144
          if(!first) features_str += ",";
×
145
          features_str += fmt::format("\"{}\"", json_escape(*feature));
×
146
          first = false;
×
147
        }
×
148
      }
×
149
      features_str += "]";
×
150

151
      auto plugin_json = fmt::format(
×
152
          R"_({{
×
153
"ID":"{}",
154
"Name":"{}",
155
"Vendor":"{}",
156
"Version":"{}",
157
"URL":"{}",
158
"ManualURL":"{}",
159
"SupportURL":"{}",
160
"Description":"{}",
161
"Features":{}
162
}})_",
163
          json_escape(desc->id ? desc->id : ""),
×
164
          json_escape(desc->name ? desc->name : ""),
×
165
          json_escape(desc->vendor ? desc->vendor : ""),
×
166
          json_escape(desc->version ? desc->version : ""),
×
167
          json_escape(desc->url ? desc->url : ""),
×
168
          json_escape(desc->manual_url ? desc->manual_url : ""),
×
169
          json_escape(desc->support_url ? desc->support_url : ""),
×
170
          json_escape(desc->description ? desc->description : ""),
×
171
          features_str);
172

173
      if(!first_plugin)
×
174
        root += ",\n";
×
175
      root += plugin_json;
×
176
      first_plugin = false;
×
177
    }
×
178

179
    root += "]\n}";
×
180

181
    entry_fn->deinit();
×
182
#if defined(_WIN32)
183
    FreeLibrary(handle);
184
#else
185
    dlclose(handle);
×
186
#endif
187

188
    return root;
×
189
  }
×
190
  catch(const std::exception& e)
191
  {
192
    std::cerr << "Exception: " << e.what() << std::endl;
×
193
    return error_json(std::string{"Exception: "} + e.what());
×
194
  }
×
195
  catch(...)
196
  {
197
    return error_json("Unknown exception");
×
198
  }
×
199
}
×
200

201
void init_invisible_window();
202
int main(int argc, char** argv)
×
203
{
204
  init_invisible_window();
×
205

206
  return score::puppet::puppet_main(
×
207
      argc, argv, 37589, "clappuppet", true, 30,
×
208
      [](const std::string& path, int id, const std::string& token) {
×
209
    return load_clap(path, id, token);
×
210
      });
211
}
212

213
#include <score/tools/WinMainToMain.hpp>
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc