Shamrock 2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
pybindaliases.hpp
Go to the documentation of this file.
1// -------------------------------------------------------//
2//
3// SHAMROCK code for hydrodynamics
4// Copyright (c) 2021-2026 Timothée David--Cléris <tim.shamrock@proton.me>
5// SPDX-License-Identifier: CeCILL Free Software License Agreement v2.1
6// Shamrock is licensed under the CeCILL 2.1 License, see LICENSE for more information
7//
8// -------------------------------------------------------//
9
10#pragma once
11
24#include <pybind11/pybind11.h>
25
27namespace py = pybind11;
28
30using fct_sig = std::function<void(py::module &)>;
31
34
38 inline explicit PyBindStaticInit(fct_sig t) { register_pybind_init_func(std::move(t)); }
39};
40
56#define Register_pymod(placeholdername) \
57 void pymod_##placeholdername(py::module &m); \
58 void (*pymod_ptr_##placeholdername)(py::module & m) = pymod_##placeholdername; \
59 PyBindStaticInit pymod_class_obj_##placeholdername(pymod_ptr_##placeholdername); \
60 void pymod_##placeholdername(py::module &m)
std::function< void(py::module &)> fct_sig
alias to pybind11 namespace
void register_pybind_init_func(fct_sig)
Register a python module init function to be ran on init.
Utility struct to register python modules through static init.
PyBindStaticInit(fct_sig t)
Constructor to register the python init function using static init.