Debian Codegraph @

src/Base/PythonTypeExt.cpp

raw
1 // SPDX-License-Identifier: LGPL-2.1-or-later
2
3 /***************************************************************************
4 * Copyright (c) 2023 Werner Mayer <wmayer[at]users.sourceforge.net> *
5 * Copyright (c) 2023 Mario Passaglia <mpassaglia[at]cbc.uba.ar> *
6 * *
7 * This file is part of FreeCAD. *
8 * *
9 * FreeCAD is free software: you can redistribute it and/or modify it *
10 * under the terms of the GNU Lesser General Public License as *
11 * published by the Free Software Foundation, either version 2.1 of the *
12 * License, or (at your option) any later version. *
13 * *
14 * FreeCAD is distributed in the hope that it will be useful, but *
15 * WITHOUT ANY WARRANTY; without even the implied warranty of *
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
17 * Lesser General Public License for more details. *
18 * *
19 * You should have received a copy of the GNU Lesser General Public *
20 * License along with FreeCAD. If not, see *
21 * <https://www.gnu.org/licenses/>. *
22 * *
23 **************************************************************************/
24
25 #include <CXX/Extensions.hxx>
26
27 #include <Base/PythonTypeExt.h>
28
29
30 using namespace Base;
31
32 PythonTypeExt::PythonTypeExt(Py::PythonType& type)
33 : pytype(type)
34 {}
35
36 Py::PythonType& PythonTypeExt::set_tp_descr_get(
37 PyObject* (*tp_descr_get)(PyObject* self, PyObject* obj, PyObject* type)
38 )
39 {
40 pytype.type_object()->tp_descr_get = tp_descr_get;
41
42 return pytype;
43 }
44
45 Py::PythonType& PythonTypeExt::set_tp_descr_set(
46 int (*tp_descr_set)(PyObject* self, PyObject* obj, PyObject* value)
47 )
48 {
49 pytype.type_object()->tp_descr_set = tp_descr_set;
50
51 return pytype;
52 }