OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
PyPluginTrampoline.hpp File Reference
#include "libslic3r/LifecycleEvents.hpp"
#include <exception>
#include <pybind11/embed.h>
#include <boost/log/trivial.hpp>
#include <memory>
#include <optional>
#include <stdexcept>
#include <string>
#include "PythonPluginInterface.hpp"
#include "PythonInterpreter.hpp"
#include "PluginFsUtils.hpp"
#include "PluginAuditManager.hpp"
#include "pybind11/cast.h"
#include <pybind11/pybind11.h>
#include <pybind11/gil.h>
#include <pybind11/pytypes.h>
#include <utility>
Include dependency graph for PyPluginTrampoline.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  Slic3r::ScriptExecuteInvocation
class  Slic3r::PyPluginCommonTrampoline< Base >
class  Slic3r::PyPluginInterfaceTrampoline

Namespaces

namespace  Slic3r
 |/ Copyright (c) Prusa Research 2020 - 2023 Enrico Turri @enricoturri1966 |/ |/ PrusaSlicer is released under the terms of the AGPLv3 or higher |/

Macros

#define ORCA_PY_LOGGED_OVERRIDE_BODY(override_call)
#define ORCA_PY_AUDIT_SCOPE()
#define ORCA_PY_OVERRIDE_AUDITED(audit_setup, override_macro, ret, base, name, ...)

Functions

bool Slic3r::py_is_coroutine (const pybind11::handle &object)
ScriptExecuteInvocation Slic3r::invoke_script_execute (const std::shared_ptr< PluginCapabilityInterface > &capability)

Class Documentation

◆ Slic3r::ScriptExecuteInvocation

struct Slic3r::ScriptExecuteInvocation
Collaboration diagram for Slic3r::ScriptExecuteInvocation:
Class Members
object awaitable
string error
bool is_async = false
ExecutionResult result

Macro Definition Documentation

◆ ORCA_PY_AUDIT_SCOPE

#define ORCA_PY_AUDIT_SCOPE ( )
Value:
std::optional<::Slic3r::ScopedPluginAuditContext> _orca_audit_scope; \
if (const std::string& _orca_audit_key = this->audit_plugin_key(); !_orca_audit_key.empty()) \
_orca_audit_scope.emplace(_orca_audit_key, this->name())
50#define ORCA_PY_AUDIT_SCOPE() \
51 std::optional<::Slic3r::ScopedPluginAuditContext> _orca_audit_scope; \
52 if (const std::string& _orca_audit_key = this->audit_plugin_key(); !_orca_audit_key.empty()) \
53 _orca_audit_scope.emplace(_orca_audit_key, this->name())

Referenced by Slic3r::PyPluginCommonTrampoline< Base >::get_default_config(), Slic3r::PyPagesPluginCapabilityTrampoline::on_message(), and Slic3r::PyPrinterAgentPluginCapabilityTrampoline::request_bind_ticket().

◆ ORCA_PY_LOGGED_OVERRIDE_BODY

#define ORCA_PY_LOGGED_OVERRIDE_BODY ( override_call)
Value:
try { \
override_call; \
} catch (pybind11::error_already_set & err) { \
const bool _orca_audit_denial = ::Slic3r::PluginAuditManager::instance().audit_denial_pending(); \
if (_orca_audit_denial) \
::Slic3r::PluginAuditManager::instance().clear_current_plugin(); \
::Slic3r::log_python_exception_keep(err); \
if (_orca_audit_denial) \
::Slic3r::PluginAuditManager::instance().clear_audit_denial(); \
throw; \
}
bool audit_denial_pending() const
Definition PluginAuditManager.cpp:830
static PluginAuditManager & instance()
Definition PluginAuditManager.cpp:535
34#define ORCA_PY_LOGGED_OVERRIDE_BODY(override_call) \
35 try { \
36 override_call; \
37 } catch (pybind11::error_already_set & err) { \
38 const bool _orca_audit_denial = ::Slic3r::PluginAuditManager::instance().audit_denial_pending(); \
39 if (_orca_audit_denial) \
40 ::Slic3r::PluginAuditManager::instance().clear_current_plugin(); \
41 ::Slic3r::log_python_exception_keep(err); \
42 if (_orca_audit_denial) \
43 ::Slic3r::PluginAuditManager::instance().clear_audit_denial(); \
44 throw; \
45 }

Referenced by Slic3r::PyPagesPluginCapabilityTrampoline::on_message().

◆ ORCA_PY_OVERRIDE_AUDITED

#define ORCA_PY_OVERRIDE_AUDITED ( audit_setup,
override_macro,
ret,
base,
name,
... )
Value:
do { \
::Slic3r::PythonGILState _orca_python_gil; \
if (!_orca_python_gil) \
throw std::runtime_error("Python interpreter is shutting down"); \
ORCA_PY_AUDIT_SCOPE(); \
if (_orca_audit_scope) \
audit_setup(); \
ORCA_PY_LOGGED_OVERRIDE_BODY(override_macro(ret, base, name, ##__VA_ARGS__)); \
} while (0)
Definition PythonPluginInterface.hpp:129
Definition PythonInterpreter.hpp:169
55#define ORCA_PY_OVERRIDE_AUDITED(audit_setup, override_macro, ret, base, name, ...) \
56 do { \
57 ::Slic3r::PluginCapabilityInterface::RefCounter _orca_ref_counter(*this); \
58 ::Slic3r::PythonGILState _orca_python_gil; \
59 if (!_orca_python_gil) \
60 throw std::runtime_error("Python interpreter is shutting down"); \
61 ORCA_PY_AUDIT_SCOPE(); \
62 if (_orca_audit_scope) \
63 audit_setup(); \
64 ORCA_PY_LOGGED_OVERRIDE_BODY(override_macro(ret, base, name, ##__VA_ARGS__)); \
65 } while (0)

Referenced by Slic3r::PyScriptPluginCapabilityTrampoline::execute(), Slic3r::PySlicingPipelinePluginCapabilityTrampoline::execute(), Slic3r::PyPluginCommonTrampoline< Base >::get_config_ui(), Slic3r::PyPagesPluginCapabilityTrampoline::get_icon(), Slic3r::PyPluginCommonTrampoline< Base >::get_name(), Slic3r::PyResourceTexturePluginCapabilityTrampoline::get_texture_dir(), Slic3r::PyPluginInterfaceTrampoline::get_type(), Slic3r::PyPagesPluginCapabilityTrampoline::get_ui(), Slic3r::PyPluginCommonTrampoline< Base >::has_config_ui(), Slic3r::PyPluginCommonTrampoline< Base >::on_cancelled(), Slic3r::PyPluginCommonTrampoline< Base >::on_lifecycle_event(), Slic3r::PyPluginCommonTrampoline< Base >::on_load(), and Slic3r::PyPluginCommonTrampoline< Base >::on_unload().