Shamrock 2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
pytypealias.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
22
23namespace PYBIND11_NAMESPACE {
24 namespace detail {
25
26 template<>
27 struct type_caster<f64_3> {
28 public:
29 PYBIND11_TYPE_CASTER(f64_3, const_name("f64_3"));
30
31 bool load(handle src, bool) {
32 PyObject *source = src.ptr();
33
34 f64 x, y, z;
35
36 if (!PyArg_ParseTuple(source, "ddd", &x, &y, &z)) {
37 return false;
38 }
39
40 value = {x, y, z};
41
42 return !PyErr_Occurred();
43 }
44
45 static handle cast(f64_3 src, return_value_policy /* policy */, handle /* parent */) {
46 return Py_BuildValue("ddd", src.x(), src.y(), src.z());
47 }
48 };
49
50 template<>
51 struct type_caster<i32_3> {
52 public:
53 PYBIND11_TYPE_CASTER(i32_3, const_name("i32_3"));
54
55 bool load(handle src, bool) {
56 PyObject *source = src.ptr();
57
58 i32 x, y, z;
59
60 if (!PyArg_ParseTuple(source, "iii", &x, &y, &z)) {
61 return false;
62 }
63
64 value = {x, y, z};
65
66 return !PyErr_Occurred();
67 }
68
69 static handle cast(i32_3 src, return_value_policy /* policy */, handle /* parent */) {
70 return Py_BuildValue("iii", src.x(), src.y(), src.z());
71 }
72 };
73
74 template<>
75 struct type_caster<i64_3> {
76 public:
77 PYBIND11_TYPE_CASTER(i64_3, const_name("i64_3"));
78
79 bool load(handle src, bool) {
80 PyObject *source = src.ptr();
81
82 i64 x, y, z;
83
84 if (!PyArg_ParseTuple(source, "LLL", &x, &y, &z)) {
85 return false;
86 }
87
88 value = {x, y, z};
89
90 return !PyErr_Occurred();
91 }
92
93 static handle cast(i64_3 src, return_value_policy /* policy */, handle /* parent */) {
94 return Py_BuildValue("LLL", src.x(), src.y(), src.z());
95 }
96 };
97
98 template<>
99 struct type_caster<u32_3> {
100 public:
101 PYBIND11_TYPE_CASTER(u32_3, const_name("u32_3"));
102
103 bool load(handle src, bool) {
104 PyObject *source = src.ptr();
105
106 u32 x, y, z;
107
108 if (!PyArg_ParseTuple(source, "III", &x, &y, &z)) {
109 return false;
110 }
111
112 value = {x, y, z};
113
114 return !PyErr_Occurred();
115 }
116
117 static handle cast(u32_3 src, return_value_policy /* policy */, handle /* parent */) {
118 return Py_BuildValue("III", src.x(), src.y(), src.z());
119 }
120 };
121
122 template<>
123 struct type_caster<u64_3> {
124 public:
125 PYBIND11_TYPE_CASTER(u64_3, const_name("u64_3"));
126
127 bool load(handle src, bool) {
128 PyObject *source = src.ptr();
129
130 i64 x, y, z;
131
132 if (!PyArg_ParseTuple(source, "KKK", &x, &y, &z)) {
133 return false;
134 }
135
136 value = {x, y, z};
137
138 return !PyErr_Occurred();
139 }
140
141 static handle cast(u64_3 src, return_value_policy /* policy */, handle /* parent */) {
142 return Py_BuildValue("KKK", src.x(), src.y(), src.z());
143 }
144 };
145
146 } // namespace detail
147} // namespace PYBIND11_NAMESPACE
double f64
Alias for double.
std::uint32_t u32
32 bit unsigned integer
std::int64_t i64
64 bit integer
std::int32_t i32
32 bit integer
Pybind11 include and definitions.