![]() |
Shamrock 2025.10.0
Astrophysical Code
|
#include "shambase/exception.hpp"#include "shambase/print.hpp"#include "shambase/string.hpp"#include "shambindings/pybindaliases.hpp"#include "shamcmdopt/tty.hpp"#include <pybind11/eval.h>#include <pybind11/iostream.h>#include <pybind11/pybind11.h>#include <string_view>#include <exception>#include <memory>#include <stdexcept>
Include dependency graph for pybindings.cpp:Go to the source code of this file.
Enumerations | |
| enum | { None = 0 , Lib = 1 , Embed = 2 } |
Functions | |
| void | py_func_printer_normal (std::string_view s) |
| With pybind we print using python out stream. | |
| void | py_func_printer_ln (std::string_view s) |
| With pybind we print using python out stream. | |
| void | py_func_flush_func () |
| Python print performs already a flush so we need nothing here. | |
| void | register_pybind_init_func (fct_sig fct) |
| Add a python module init function to the init list. | |
| void | register_py_to_sham_print (py::module &m) |
| template<bool is_lib_mode> | |
| void | shambindings::init (py::module &m) |
| void | shambindings::init_lib (py::module &m) |
| Init python bindings and register them to Python API. | |
| void | shambindings::init_embed (py::module &m, bool hook_stdout=true) |
| Init python bindings and register them to Python API. | |
| void | shambindings::expect_init_lib (SourceLocation loc=SourceLocation{}) |
| Expect python bindings to be initialized as lib mode, throws if not. | |
| void | shambindings::expect_init_embed (SourceLocation loc=SourceLocation{}) |
| Expect python bindings to be initialized as embed mode, throws if not. | |
Variables | |
| std::unique_ptr< std::vector< fct_sig > > | static_init_shamrock_pybind |
| Statically initialized python module init function list We use a unique pointer to ensure that the vector is not reinitialized during program init which would empty the function list otherwise. | |
| enum shambindings:: { ... } | shambindings::init_state = None |
Definition in file pybindings.cpp.
| anonymous enum |
Definition at line 121 of file pybindings.cpp.
| void shambindings::expect_init_embed | ( | SourceLocation | loc = SourceLocation{} | ) |
Expect python bindings to be initialized as embed mode, throws if not.
Definition at line 166 of file pybindings.cpp.
Here is the call graph for this function:| void shambindings::expect_init_lib | ( | SourceLocation | loc = SourceLocation{} | ) |
Expect python bindings to be initialized as lib mode, throws if not.
Definition at line 156 of file pybindings.cpp.
Here is the call graph for this function:| void shambindings::init | ( | py::module & | m | ) |
Definition at line 124 of file pybindings.cpp.
| void shambindings::init_embed | ( | py::module & | m, |
| bool | hook_stdout = true |
||
| ) |
Init python bindings and register them to Python API.
| m | the python module to bind definitions on |
| hook_stdout | if true, sys.stdout and sys.stderr will be hooked |
Definition at line 148 of file pybindings.cpp.
Here is the call graph for this function:| void shambindings::init_lib | ( | py::module & | m | ) |
Init python bindings and register them to Python API.
| m | the python module to bind definitions on |
Definition at line 146 of file pybindings.cpp.
Here is the call graph for this function:| void py_func_flush_func | ( | ) |
Python print performs already a flush so we need nothing here.
Definition at line 46 of file pybindings.cpp.
| void py_func_printer_ln | ( | std::string_view | s | ) |
With pybind we print using python out stream.
Definition at line 40 of file pybindings.cpp.
| void py_func_printer_normal | ( | std::string_view | s | ) |
With pybind we print using python out stream.
Definition at line 34 of file pybindings.cpp.
| void register_py_to_sham_print | ( | py::module & | m | ) |
Definition at line 67 of file pybindings.cpp.
| void register_pybind_init_func | ( | fct_sig | fct | ) |
Add a python module init function to the init list.
Register a python module init function to be ran on init.
Definition at line 59 of file pybindings.cpp.
| std::unique_ptr<std::vector<fct_sig> > static_init_shamrock_pybind |
Statically initialized python module init function list We use a unique pointer to ensure that the vector is not reinitialized during program init which would empty the function list otherwise.
This behavior was observed when building shamrock using object libraries using the unique_ptr fixes it
Definition at line 56 of file pybindings.cpp.