Debian Codegraph @

src/Base/PrecisionPyImp.cpp

raw
1 // SPDX-License-Identifier: LGPL-2.1-or-later
2
3 /***************************************************************************
4 * Copyright (c) 2022 Werner Mayer <wmayer[at]users.sourceforge.net> *
5 * *
6 * This file is part of the FreeCAD CAx development system. *
7 * *
8 * This library is free software; you can redistribute it and/or *
9 * modify it under the terms of the GNU Library General Public *
10 * License as published by the Free Software Foundation; either *
11 * version 2 of the License, or (at your option) any later version. *
12 * *
13 * This library is distributed in the hope that it will be useful, *
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16 * GNU Library General Public License for more details. *
17 * *
18 * You should have received a copy of the GNU Library General Public *
19 * License along with this library; see the file COPYING.LIB. If not, *
20 * write to the Free Software Foundation, Inc., 59 Temple Place, *
21 * Suite 330, Boston, MA 02111-1307, USA *
22 * *
23 ***************************************************************************/
24
25
26 // generated out of Precision.pyi
27 #include "PrecisionPy.h"
28 #include "PrecisionPy.cpp"
29
30 using Base::Precision;
31 using Base::PrecisionPy;
32
33 // returns a string which represents the object e.g. when printed in python
34 std::string PrecisionPy::representation() const
35 {
36 return {"<Precision object>"};
37 }
38
39 PyObject* PrecisionPy::angular(PyObject* args)
40 {
41 if (!PyArg_ParseTuple(args, "")) {
42 return nullptr;
43 }
44
45 Py::Float v(Precision::Angular());
46 return Py::new_reference_to(v);
47 }
48
49 PyObject* PrecisionPy::confusion(PyObject* args)
50 {
51 if (!PyArg_ParseTuple(args, "")) {
52 return nullptr;
53 }
54
55 Py::Float v(Precision::Confusion());
56 return Py::new_reference_to(v);
57 }
58
59 PyObject* PrecisionPy::squareConfusion(PyObject* args)
60 {
61 if (!PyArg_ParseTuple(args, "")) {
62 return nullptr;
63 }
64
65 Py::Float v(Precision::SquareConfusion());
66 return Py::new_reference_to(v);
67 }
68
69 PyObject* PrecisionPy::intersection(PyObject* args)
70 {
71 if (!PyArg_ParseTuple(args, "")) {
72 return nullptr;
73 }
74
75 Py::Float v(Precision::Intersection());
76 return Py::new_reference_to(v);
77 }
78
79 PyObject* PrecisionPy::approximation(PyObject* args)
80 {
81 if (!PyArg_ParseTuple(args, "")) {
82 return nullptr;
83 }
84
85 Py::Float v(Precision::Approximation());
86 return Py::new_reference_to(v);
87 }
88
89 PyObject* PrecisionPy::parametric(PyObject* args)
90 {
91 double p {};
92 if (PyArg_ParseTuple(args, "d", &p)) {
93 Py::Float v(Precision::Parametric(p));
94 return Py::new_reference_to(v);
95 }
96
97 PyErr_Clear();
98 double t {};
99 if (PyArg_ParseTuple(args, "dd", &p, &t)) {
100 Py::Float v(Precision::Parametric(p, t));
101 return Py::new_reference_to(v);
102 }
103
104 PyErr_SetString(PyExc_ValueError, "one or two floats expected");
105 return nullptr;
106 }
107
108 PyObject* PrecisionPy::isInfinite(PyObject* args)
109 {
110 double v {};
111 if (!PyArg_ParseTuple(args, "d", &v)) {
112 return nullptr;
113 }
114
115 Py::Boolean b(Precision::IsInfinite(v));
116 return Py::new_reference_to(b);
117 }
118
119 PyObject* PrecisionPy::isPositiveInfinite(PyObject* args)
120 {
121 double v {};
122 if (!PyArg_ParseTuple(args, "d", &v)) {
123 return nullptr;
124 }
125
126 Py::Boolean b(Precision::IsPositiveInfinite(v));
127 return Py::new_reference_to(b);
128 }
129
130 PyObject* PrecisionPy::isNegativeInfinite(PyObject* args)
131 {
132 double v {};
133 if (!PyArg_ParseTuple(args, "d", &v)) {
134 return nullptr;
135 }
136
137 Py::Boolean b(Precision::IsNegativeInfinite(v));
138 return Py::new_reference_to(b);
139 }
140
141 PyObject* PrecisionPy::infinite(PyObject* args)
142 {
143 if (!PyArg_ParseTuple(args, "")) {
144 return nullptr;
145 }
146
147 Py::Float v(Precision::Infinite());
148 return Py::new_reference_to(v);
149 }
150
151 PyObject* PrecisionPy::getCustomAttributes(const char* /*attr*/) const
152 {
153 return nullptr;
154 }
155
156 int PrecisionPy::setCustomAttributes(const char* /*attr*/, PyObject* /*obj*/)
157 {
158 return 0;
159 }