RAVE
pypia.h
Go to the documentation of this file.
1/* --------------------------------------------------------------------
2Copyright (C) 2014 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 PYPIA_H
26#define PYPIA_H
27#include "Python.h"
28#include "ravepia.h"
29
33typedef struct {
34 PyObject_HEAD /*Always has to be on top*/
36} PyPia;
37
38#define PyPia_Type_NUM 0
39
40#define PyPia_GetNative_NUM 1
41#define PyPia_GetNative_RETURN RavePIA_t*
42#define PyPia_GetNative_PROTO (PyPia*)
43
44#define PyPia_New_NUM 2
45#define PyPia_New_RETURN PyPia*
46#define PyPia_New_PROTO (RavePIA_t*)
47
48#define PyPia_API_pointers 3
49
50#define PyPia_CAPSULE_NAME "_pia._C_API"
51
52
53#ifdef PYPIA_MODULE
55extern PyTypeObject PyPia_Type;
56
58#define PyPia_Check(op) ((op)->ob_type == &PyPia_Type)
59
62
65
66#else
68static void **PyPia_API;
69
74#define PyPia_GetNative \
75 (*(PyPia_GetNative_RETURN (*)PyPia_GetNative_PROTO) PyPia_API[PyPia_GetNative_NUM])
76
84#define PyPia_New \
85 (*(PyPia_New_RETURN (*)PyPia_New_PROTO) PyPia_API[PyPia_New_NUM])
86
90#define PyPia_Check(op) \
91 (Py_TYPE(op) == &PyPia_Type)
92
93#define PyPia_Type (*(PyTypeObject*)PyPia_API[PyPia_Type_NUM])
94
98#define import_pia() \
99 PyPia_API = (void **)PyCapsule_Import(PyPia_CAPSULE_NAME, 1);
100
101#endif
102
103#endif /* PYPIA_H */
#define PyPia_GetNative
Returns a pointer to the internal pia, remember to release the reference when done with the object.
Definition pypia.h:74
#define PyPia_New_PROTO
arguments for New
Definition pypia.h:46
#define PyPia_GetNative_RETURN
return type for GetNative
Definition pypia.h:41
#define PyPia_New_RETURN
return type for New
Definition pypia.h:45
#define PyPia_GetNative_PROTO
arguments for GetNative
Definition pypia.h:42
#define PyPia_New
Creates a new pia instance.
Definition pypia.h:84
This object does support RAVE_OBJECT_CLONE.
struct _RavePIA_t RavePIA_t
Defines PIA.
Definition ravepia.h:35
A pia.
Definition pypia.h:33
PyObject_HEAD RavePIA_t * pia
the pia
Definition pypia.h:35