SST 15.0
Structural Simulation Toolkit
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
19DISABLE_WARN_DEPRECATED_REGISTER
20#include <Python.h>
21REENABLE_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#if PY_MINOR_VERSION >= 13
50#define SST_TP_VERSIONS_USED 0,
51#else
52#define SST_TP_VERSIONS_USED
53#endif
54
55// Number protocol macros
56#define SST_NB_DIVIDE(x)
57#define SST_NB_COERCE
58#define SST_NB_INTLONG(x) x,
59#define SST_NB_RESERVED nullptr,
60#define SST_NB_OCT
61#define SST_NB_HEX
62#define SST_NB_INPLACE_DIVIDE(x)
63#define SST_NB_MATRIX_MULTIPLY nullptr,
64#define SST_NB_INPLACE_MATRIX_MULTIPLY nullptr,
65
66#endif // SST_CORE_MODEL_PYTHON_PYMACROS_H