RAVE
pyravevalue.h
Go to the documentation of this file.
1/* --------------------------------------------------------------------
2Copyright (C) 2025 Swedish Meteorological and Hydrological Institute, SMHI,
3
4This file is part of RAVE.
5
6RAVE is free software: you can redistribute it and/or modify
7it under the terms of the GNU Lesser General Public License as published by
8the Free Software Foundation, either version 3 of the License, or
9(at your option) any later version.
10
11RAVE is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU Lesser General Public License for more details.
15
16You should have received a copy of the GNU Lesser General Public License
17along with RAVE. If not, see <http://www.gnu.org/licenses/>.
18------------------------------------------------------------------------*/
25#ifndef PYRAVE_VALUE_H
26#define PYRAVE_VALUE_H
27#include "Python.h"
28#include "rave_value.h"
29
33typedef struct {
34 PyObject_HEAD /*Always has to be on top*/
37
38#define PyRaveValue_Type_NUM 0
39
40#define PyRaveValue_GetNative_NUM 1
41#define PyRaveValue_GetNative_RETURN RaveValue_t*
42#define PyRaveValue_GetNative_PROTO (PyRaveValue*)
43
44#define PyRaveValue_New_NUM 2
45#define PyRaveValue_New_RETURN PyRaveValue*
46#define PyRaveValue_New_PROTO (RaveValue_t*)
47
48#define PyRaveValue_API_pointers 3
49
50#define PyRaveValue_CAPSULE_NAME "_ravevalue._C_API"
51
52#ifdef PYRAVEVALUE_MODULE
54extern PyTypeObject PyRaveValue_Type;
55
57#define PyRaveValue_Check(op) ((op)->ob_type == &PyRaveValue_Type)
58
61
64
65#else
67static void **PyRaveValue_API;
68
73#define PyRaveValue_GetNative \
74 (*(PyRaveValue_GetNative_RETURN (*)PyRaveValue_GetNative_PROTO) PyRaveValue_API[PyRaveValue_GetNative_NUM])
75
83#define PyRaveValue_New \
84 (*(PyRaveValue_New_RETURN (*)PyRaveValue_New_PROTO) PyRaveValue_API[PyRaveValue_New_NUM])
85
89#define PyRaveValue_Check(op) \
90 (Py_TYPE(op) == &PyRaveValue_Type)
91
92#define PyRaveValue_Type (*(PyTypeObject*)PyRaveValue_API[PyRaveValue_Type_NUM])
93
97#define import_ravevalue() \
98 PyRaveValue_API = (void **)PyCapsule_Import(PyRaveValue_CAPSULE_NAME, 1);
99
100#endif
101
102#endif /* PYRAVEVALUE_H */
#define PyRaveValue_GetNative
Returns a pointer to the internal area, remember to release the reference when done with the object.
Definition pyravevalue.h:73
#define PyRaveValue_New_PROTO
arguments for New
Definition pyravevalue.h:46
#define PyRaveValue_New_RETURN
return type for New
Definition pyravevalue.h:45
#define PyRaveValue_GetNative_PROTO
arguments for GetNative
Definition pyravevalue.h:42
#define PyRaveValue_New
Creates a new rave value instance.
Definition pyravevalue.h:83
#define PyRaveValue_GetNative_RETURN
return type for GetNative
Definition pyravevalue.h:41
A value object that can represent standard types like int, double, .
struct _RaveValue_t RaveValue_t
Defines a rave value.
Definition rave_value.h:47
A cartesian product.
Definition pyravevalue.h:33
PyObject_HEAD RaveValue_t * value
the value
Definition pyravevalue.h:35