SST  11.0.0
StructuralSimulationToolkit
pymacros.h
1 // -*- c++ -*-
2 
3 // Copyright 2009-2021 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-2021, 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_python_macros_h
15 #define sst_core_python_macros_h
16 
17 #include "sst/core/warnmacros.h"
18 
19 #if PY_MAJOR_VERSION >= 3
20  #define SST_PY_OBJ_HEAD PyVarObject_HEAD_INIT(nullptr, 0)
21  #define SST_ConvertToPythonLong(x) PyLong_FromLong(x)
22  #define SST_ConvertToCppLong(x) PyLong_AsLong(x)
23  #define SST_ConvertToPythonString(x) PyUnicode_FromString(x)
24  #define SST_ConvertToCppString(x) PyUnicode_AsUTF8(x)
25  #define SST_TP_FINALIZE nullptr,
26  #define SST_TP_VECTORCALL_OFFSET 0,
27  #define SST_TP_PRINT
28  #define SST_TP_COMPARE(x)
29  #define SST_TP_RICH_COMPARE(x) x,
30  #define SST_TP_AS_SYNC nullptr,
31  #define SST_PY_INIT_MODULE(name, methods, moddef) PyModule_Create(&moddef)
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  #if PY_MINOR_VERSION >= 8
39  #define SST_TP_VECTORCALL nullptr,
40  #else
41  #define SST_TP_VECTORCALL
42  #endif
43 
44 // Number protocol macros
45  #define SST_NB_DIVIDE(x)
46  #define SST_NB_COERCE
47  #define SST_NB_INTLONG(x) x,
48  #define SST_NB_RESERVED nullptr,
49  #define SST_NB_OCT
50  #define SST_NB_HEX
51  #define SST_NB_INPLACE_DIVIDE(x)
52  #define SST_NB_MATRIX_MULTIPLY nullptr,
53  #define SST_NB_INPLACE_MATRIX_MULTIPLY nullptr,
54 
55 #else
56 
57  #define Py_TYPE(ob) (((PyObject*)(ob))->ob_type)
58  #define SST_PY_OBJ_HEAD PyVarObject_HEAD_INIT(nullptr, 0)
59  #define SST_ConvertToPythonLong(x) PyInt_FromLong(x)
60  #define SST_ConvertToCppLong(x) PyInt_AsLong(x)
61  #define SST_ConvertToPythonString(x) PyString_FromString(x)
62  #define SST_ConvertToCppString(x) PyString_AsString(x)
63  #define SST_TP_FINALIZE
64  #define SST_TP_VECTORCALL_OFFSET
65  #define SST_TP_PRINT nullptr,
66  #define SST_TP_COMPARE(x) x,
67  #define SST_TP_RICH_COMPARE(x) nullptr,
68  #define SST_TP_AS_SYNC
69  #define SST_TP_VECTORCALL
70  #define SST_TP_PRINT_DEP
71  #define SST_PY_INIT_MODULE(name, methods, moddef) Py_InitModule(name, methods)
72 
73 // Number protocol macros
74  #define SST_NB_DIVIDE(x) x,
75  #define SST_NB_COERCE nullptr,
76  #define SST_NB_INTLONG(x) x, x,
77  #define SST_NB_RESERVED
78  #define SST_NB_OCT nullptr,
79  #define SST_NB_HEX nullptr,
80  #define SST_NB_INPLACE_DIVIDE(x) x,
81  #define SST_NB_MATRIX_MULTIPLY
82  #define SST_NB_INPLACE_MATRIX_MULTIPLY
83 #endif
84 
85 #endif