mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-12-05 03:53:41 +00:00
75 lines
2 KiB
Diff
75 lines
2 KiB
Diff
|
From 9b05a6f331506afa5aca8865677af83403d2a32d Mon Sep 17 00:00:00 2001
|
||
|
From: Tadeo Kondrak <me@tadeo.ca>
|
||
|
Date: Mon, 25 Jan 2021 11:17:44 -0700
|
||
|
Subject: [PATCH] Call weak function to allow adding preloaded plugins after
|
||
|
compile
|
||
|
|
||
|
---
|
||
|
src/core/vscore.cpp | 19 +++++++++++++++++++
|
||
|
src/core/vscore.h | 5 +++++
|
||
|
2 files changed, 24 insertions(+)
|
||
|
|
||
|
diff --git a/src/core/vscore.cpp b/src/core/vscore.cpp
|
||
|
index 2d29844d..35c509ed 100644
|
||
|
--- a/src/core/vscore.cpp
|
||
|
+++ b/src/core/vscore.cpp
|
||
|
@@ -1229,6 +1229,20 @@ void VSCore::destroyFilterInstance(VSNode *node) {
|
||
|
freeDepth--;
|
||
|
}
|
||
|
|
||
|
+extern "C" {
|
||
|
+void __attribute__((weak)) VSLoadPluginsNix(void (*load)(void *data, const char *path), void *data);
|
||
|
+
|
||
|
+struct VSLoadPluginsNixCallbackData {
|
||
|
+ VSCore *core;
|
||
|
+ const char *filter;
|
||
|
+};
|
||
|
+
|
||
|
+static void VSLoadPluginsNixCallback(void *data, const char *path) {
|
||
|
+ auto callbackData = static_cast<VSLoadPluginsNixCallbackData *>(data);
|
||
|
+ callbackData->core->loadAllPluginsInPath(path, callbackData->filter);
|
||
|
+}
|
||
|
+}
|
||
|
+
|
||
|
VSCore::VSCore(int threads) :
|
||
|
coreFreed(false),
|
||
|
numFilterInstances(1),
|
||
|
@@ -1351,6 +1365,11 @@ VSCore::VSCore(int threads) :
|
||
|
} // If neither exists, an empty string will do.
|
||
|
#endif
|
||
|
|
||
|
+ if (VSLoadPluginsNix != nullptr) {
|
||
|
+ VSLoadPluginsNixCallbackData data{this, filter.c_str()};
|
||
|
+ VSLoadPluginsNix(VSLoadPluginsNixCallback, &data);
|
||
|
+ }
|
||
|
+
|
||
|
VSMap *settings = readSettings(configFile);
|
||
|
const char *error = vs_internal_vsapi.getError(settings);
|
||
|
if (error) {
|
||
|
diff --git a/src/core/vscore.h b/src/core/vscore.h
|
||
|
index 74df8a84..3efac811 100644
|
||
|
--- a/src/core/vscore.h
|
||
|
+++ b/src/core/vscore.h
|
||
|
@@ -582,6 +582,9 @@ public:
|
||
|
VSFunction() : functionData(nullptr), func(nullptr) {}
|
||
|
};
|
||
|
|
||
|
+extern "C" {
|
||
|
+static void VSLoadPluginsNixCallback(void *data, const char *path);
|
||
|
+}
|
||
|
|
||
|
struct VSPlugin {
|
||
|
private:
|
||
|
@@ -683,6 +686,8 @@ public:
|
||
|
|
||
|
explicit VSCore(int threads);
|
||
|
void freeCore();
|
||
|
+
|
||
|
+ friend void VSLoadPluginsNixCallback(void *data, const char *path);
|
||
|
};
|
||
|
|
||
|
#endif // VSCORE_H
|
||
|
--
|
||
|
2.30.0
|
||
|
|