SST  14.0.0
StructuralSimulationToolkit
pymacros.h
1 // -*- c++ -*-
2 
3 // Copyright 2009-2024 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-2024, 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 #define SST_ConvertToCppString(x) PyUnicode_AsUTF8(x)
29 
30 #if PY_MINOR_VERSION == 8
31 #define SST_TP_PRINT_DEP nullptr,
32 //#define SST_TP_PRINT_DEP DISABLE_WARN_DEPRECATED_DECLARATION nullptr, REENABLE_WARNING
33 #else
34 #define SST_TP_PRINT_DEP
35 #endif
36 
37 #if PY_MINOR_VERSION >= 8
38 #define SST_TP_VECTORCALL nullptr,
39 #else
40 #define SST_TP_VECTORCALL
41 #endif
42 
43 #if PY_MINOR_VERSION >= 12
44 #define SST_TP_WATCHED 0,
45 #else
46 #define SST_TP_WATCHED
47 #endif
48 
49 // Number protocol macros
50 #define SST_NB_DIVIDE(x)
51 #define SST_NB_COERCE
52 #define SST_NB_INTLONG(x) x,
53 #define SST_NB_RESERVED nullptr,
54 #define SST_NB_OCT
55 #define SST_NB_HEX
56 #define SST_NB_INPLACE_DIVIDE(x)
57 #define SST_NB_MATRIX_MULTIPLY nullptr,
58 #define SST_NB_INPLACE_MATRIX_MULTIPLY nullptr,
59 
60 #endif // SST_CORE_MODEL_PYTHON_PYMACROS_H