SST 16.0.0
Structural Simulation Toolkit
pymacros.h
1// -*- c++ -*-
2
3// Copyright 2009-2026 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-2026, 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
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#define SST_TP_VECTORCALL nullptr,
33
34#if PY_MINOR_VERSION >= 12
35#define SST_TP_WATCHED 0,
36#else
37#define SST_TP_WATCHED
38#endif
39
40#if PY_MINOR_VERSION >= 13
41#define SST_TP_VERSIONS_USED 0,
42#else
43#define SST_TP_VERSIONS_USED
44#endif
45
46// Number protocol macros
47#define SST_NB_DIVIDE(x)
48#define SST_NB_COERCE
49#define SST_NB_INTLONG(x) x,
50#define SST_NB_RESERVED nullptr,
51#define SST_NB_OCT
52#define SST_NB_HEX
53#define SST_NB_INPLACE_DIVIDE(x)
54#define SST_NB_MATRIX_MULTIPLY nullptr,
55#define SST_NB_INPLACE_MATRIX_MULTIPLY nullptr,
56
57#endif // SST_CORE_MODEL_PYTHON_PYMACROS_H