mirror of
https://github.com/revng/revng
synced 2026-06-21 14:07:57 +00:00
de75d94597
Move out of the `runPipe`/`runAnalysis` functions the logic that
extracts the container from the vector type. This logic is now
delegated to `containerVectorToTuple` which converts the vector type to
a tuple of references. This allows python's `run{Pipe,Analysis}` to
safely call `nanobind::gil_scoped_release` which releases the GIL for
the entire duration of the `runPipe`/`runAnalysis` execution.
35 lines
1.1 KiB
C++
35 lines
1.1 KiB
C++
#pragma once
|
|
|
|
//
|
|
// This file is distributed under the MIT License. See LICENSE.md for details.
|
|
//
|
|
|
|
#include "nanobind/nanobind.h"
|
|
|
|
#include "revng/PipeboxCommon/Helpers/AnalysisRunner.h"
|
|
#include "revng/PipeboxCommon/Helpers/Python/Helpers.h"
|
|
#include "revng/PipeboxCommon/Model.h"
|
|
|
|
namespace revng::pypeline::helpers::python {
|
|
|
|
template<typename T>
|
|
inline llvm::Error runAnalysis(T &Handle,
|
|
nanobind::handle_t<Model> TheModel,
|
|
nanobind::list Containers,
|
|
Request Incoming,
|
|
llvm::StringRef Configuration) {
|
|
Model *CppModel = nanobind::cast<Model *>(TheModel);
|
|
auto ContainerTuple = containerVectorToTuple<T>(Containers);
|
|
|
|
{
|
|
nanobind::gil_scoped_release X;
|
|
return revng::pypeline::helpers::runAnalysis(Handle,
|
|
*CppModel,
|
|
Incoming,
|
|
Configuration,
|
|
ContainerTuple);
|
|
}
|
|
}
|
|
|
|
} // namespace revng::pypeline::helpers::python
|