SST  15.1.0
StructuralSimulationToolkit
pymacros.h
1 // -*- c++ -*-
2 
3 // Copyright 2009-2025 NTESS. Under the terms
4 // of Contract DE-NA0003525 with NTESS, the U.S.
5 // Government retains certain rights in this software.
6 //
7 // Copyright (c) 2009-2025, NTESS
8 // All rights reserved.
9 //
10 // This file is part of the SST software package. For license
11 // information, see the LICENSE file in the top level directory of the
12 // distribution.
13 
14 #ifndef SST_CORE_MODEL_PYTHON_PYMACROS_H
15 #define SST_CORE_MODEL_PYTHON_PYMACROS_H
16 
17 #include "sst/core/warnmacros.h"
18 
19 DISABLE_WARN_DEPRECATED_REGISTER
20 #include <Python.h>
21 REENABLE_WARNING
22 
23 #define SST_PY_OBJ_HEAD PyVarObject_HEAD_INIT(nullptr, 0)
24 #define SST_ConvertToPythonLong(x) PyLong_FromLong(x)
25 #define SST_ConvertToPythonBool(x) PyBool_FromLong(x)
26 #define SST_ConvertToCppLong(x) PyLong_AsLong(x)
27 #define SST_ConvertToPythonString(x) PyUnicode_FromString(x)
28 
29 // returns const char*. No need to delete, it is managed by object it was called on
30 #define SST_ConvertToCppString(x) PyUnicode_AsUTF8(x)
31 
32 #if PY_MINOR_VERSION == 8
33 #define SST_TP_PRINT_DEP nullptr,
34 // #define SST_TP_PRINT_DEP DISABLE_WARN_DEPRECATED_DECLARATION nullptr, REENABLE_WARNING
35 #else
36 #define SST_TP_PRINT_DEP
37 #endif
38 
39 #if PY_MINOR_VERSION >= 8
40 #define SST_TP_VECTORCALL nullptr,
41 #else
42 #define SST_TP_VECTORCALL
43 #endif
44 
45 #if PY_MINOR_VERSION >= 12
46 #define SST_TP_WATCHED 0,
47 #else
48 #define SST_TP_WATCHED
49 #endif
50 
51 #if PY_MINOR_VERSION >= 13
52 #define SST_TP_VERSIONS_USED 0,
53 #else
54 #define SST_TP_VERSIONS_USED
55 #endif
56 
57 // Number protocol macros
58 #define SST_NB_DIVIDE(x)
59 #define SST_NB_COERCE
60 #define SST_NB_INTLONG(x) x,
61 #define SST_NB_RESERVED nullptr,
62 #define SST_NB_OCT
63 #define SST_NB_HEX
64 #define SST_NB_INPLACE_DIVIDE(x)
65 #define SST_NB_MATRIX_MULTIPLY nullptr,
66 #define SST_NB_INPLACE_MATRIX_MULTIPLY nullptr,
67 
68 #endif // SST_CORE_MODEL_PYTHON_PYMACROS_H