aboutsummaryrefslogtreecommitdiff
path: root/libs/plugin_python/src/pybind11-utils/functional.cpp
diff options
context:
space:
mode:
authorSulfurNitride <SulfurNitride@users.noreply.github.com>2026-02-11 02:37:39 -0600
committerSulfurNitride <SulfurNitride@users.noreply.github.com>2026-02-11 02:37:39 -0600
commit7ee008e150bc5bcf76082d726f719ee0fdfda982 (patch)
tree27fb39be241fdb5ac2734c574de678977d1856d0 /libs/plugin_python/src/pybind11-utils/functional.cpp
Fluorine Manager: full Linux port of Mod Organizer 2
Complete native Linux port with FUSE-based virtual filesystem, Proton/umu-run integration, and Flatpak packaging. Key features: - FUSE VFS replacing Windows USVFS (in-process + standalone helper for Flatpak) - Proton/GE-Proton/umu-run launcher with env var forwarding - Flatpak support (sandbox-aware VFS, NXM handler, umu-run) - Wine prefix management UI - Case-insensitive path resolution for Linux filesystems - QSettings-safe INI handling (avoids Bethesda INI corruption) - Portable instance support with auto-generated launcher scripts Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Diffstat (limited to 'libs/plugin_python/src/pybind11-utils/functional.cpp')
-rw-r--r--libs/plugin_python/src/pybind11-utils/functional.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/libs/plugin_python/src/pybind11-utils/functional.cpp b/libs/plugin_python/src/pybind11-utils/functional.cpp
new file mode 100644
index 0000000..4cc7b6c
--- /dev/null
+++ b/libs/plugin_python/src/pybind11-utils/functional.cpp
@@ -0,0 +1,28 @@
+#include "pybind11_utils/functional.h"
+
+namespace py = pybind11;
+
+namespace mo2::python::detail {
+
+ bool has_compatible_arity(py::function fn, std::size_t arity)
+ {
+ auto inspect = py::module_::import("inspect");
+ auto arg_spec = inspect.attr("getfullargspec")(fn);
+ py::object args = arg_spec.attr("args"), varargs = arg_spec.attr("varargs"),
+ defaults = arg_spec.attr("defaults");
+
+ auto args_count = args.is(py::none()) ? 0 : py::len(args);
+ auto defaults_count = defaults.is(py::none()) ? 0 : py::len(defaults);
+
+ if (inspect.attr("ismethod")(fn).cast<bool>() && py::hasattr(fn, "__self__")) {
+ --args_count;
+ }
+
+ auto required_count = args_count - defaults_count;
+
+ return required_count <= arity // cannot require more parameters than given,
+ && (args_count >= arity ||
+ !varargs.is_none()); // must accept enough parameters.
+ }
+
+} // namespace mo2::python::detail