MCPcopy Create free account
hub / github.com/DISTRHO/Cardinal / StaticPluginLoader

Method StaticPluginLoader

plugins/plugins.cpp:1059–1103  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1057 json_t* rootJ;
1058
1059 StaticPluginLoader(Plugin* const p, const char* const name)
1060 : plugin(p),
1061 file(nullptr),
1062 rootJ(nullptr)
1063 {
1064#ifdef DEBUG
1065 DEBUG("Loading plugin module %s", name);
1066#endif
1067
1068 p->path = asset::pluginPath(name);
1069
1070 const std::string manifestFilename = asset::pluginManifest(name);
1071
1072 if ((file = std::fopen(manifestFilename.c_str(), "r")) == nullptr)
1073 {
1074 d_stderr2("Manifest file %s does not exist", manifestFilename.c_str());
1075 return;
1076 }
1077
1078 json_error_t error;
1079 if ((rootJ = json_loadf(file, 0, &error)) == nullptr)
1080 {
1081 d_stderr2("JSON parsing error at %s %d:%d %s", manifestFilename.c_str(), error.line, error.column, error.text);
1082 return;
1083 }
1084
1085 std::string version;
1086 if (json_t* const versionJ = json_object_get(rootJ, "version"))
1087 version = json_string_value(versionJ);
1088
1089 if (!string::startsWith(version, APP_VERSION_MAJOR + "."))
1090 {
1091 // force ABI, we use static plugins so this doesnt matter as long as it builds
1092 json_t* const versionJ = json_string((APP_VERSION_MAJOR + ".0").c_str());
1093 json_object_set(rootJ, "version", versionJ);
1094 json_decref(versionJ);
1095 }
1096
1097 // Load manifest
1098 p->fromJson(rootJ);
1099
1100 // Reject plugin if slug already exists
1101 if (Plugin* const existingPlugin = getPlugin(p->slug))
1102 throw Exception("Plugin %s is already loaded, not attempting to load it again", p->slug.c_str());
1103 }
1104
1105 ~StaticPluginLoader()
1106 {

Callers

nothing calls this directly

Calls 6

pluginPathFunction · 0.85
pluginManifestFunction · 0.85
json_object_getFunction · 0.85
getPluginFunction · 0.85
c_strMethod · 0.80
fromJsonMethod · 0.45

Tested by

no test coverage detected