Debian Codegraph @

src/Base/PythonTypeExt.h

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 #ifndef BASE_PYTHONTYPEEXT_H
26 #define BASE_PYTHONTYPEEXT_H
27
28 #include <FCGlobal.h>
29
30 namespace Py
31 {
32 class PythonType;
33 }
34
35 using PyObject = struct _object;
36
37 namespace Base
38 {
39
40 /// class to extend PyCXX PythonType class
41 class BaseExport PythonTypeExt
42 {
43 public:
44 explicit PythonTypeExt(Py::PythonType& type);
45
46 Py::PythonType& set_tp_descr_get(
47 PyObject* (*tp_descr_get)(PyObject* self, PyObject* obj, PyObject* type)
48 );
49 Py::PythonType& set_tp_descr_set(
50 int (*tp_descr_set)(PyObject* self, PyObject* obj, PyObject* value)
51 );
52
53 private:
54 Py::PythonType& pytype;
55 };
56
57 } // namespace Base
58
59 #endif // BASE_PYTHONTYPEEXT_H