RAVE
pycartesianparam.h
Go to the documentation of this file.
1/* --------------------------------------------------------------------
2Copyright (C) 2011 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 PYCARTESIANPARAM_H
26#define PYCARTESIANPARAM_H
27#include "cartesianparam.h"
28
32typedef struct {
33 PyObject_HEAD /*Always has to be on top*/
36
37#define PyCartesianParam_Type_NUM 0
39#define PyCartesianParam_GetNative_NUM 1
40#define PyCartesianParam_GetNative_RETURN CartesianParam_t*
41#define PyCartesianParam_GetNative_PROTO (PyCartesianParam*)
43#define PyCartesianParam_New_NUM 2
44#define PyCartesianParam_New_RETURN PyCartesianParam*
45#define PyCartesianParam_New_PROTO (CartesianParam_t*)
47#define PyCartesianParam_API_pointers 3
49#define PyCartesianParam_CAPSULE_NAME "_cartesianparam._C_API"
50
51#ifdef PYCARTESIANPARAM_MODULE
53extern PyTypeObject PyCartesianParam_Type;
54
56#define PyCartesianParam_Check(op) ((op)->ob_type == &PyCartesianParam_Type)
57
60
63
64#else
66static void **PyCartesianParam_API;
67
72#define PyCartesianParam_GetNative \
73 (*(PyCartesianParam_GetNative_RETURN (*)PyCartesianParam_GetNative_PROTO) PyCartesianParam_API[PyCartesianParam_GetNative_NUM])
74
82#define PyCartesianParam_New \
83 (*(PyCartesianParam_New_RETURN (*)PyCartesianParam_New_PROTO) PyCartesianParam_API[PyCartesianParam_New_NUM])
84
85
89#define PyCartesianParam_Check(op) \
90 (Py_TYPE(op) == &PyCartesianParam_Type)
91
92#define PyCartesianParam_Type (*(PyTypeObject*)PyCartesianParam_API[PyCartesianParam_Type_NUM])
93
97#define import_pycartesianparam() \
98 PyCartesianParam_API = (void **)PyCapsule_Import(PyCartesianParam_CAPSULE_NAME, 1);
99
100#ifdef KALLE
104#define PyCartesianParam_Check(op) \
105 ((op)->ob_type == (PyTypeObject *)PyCartesianParam_API[PyCartesianParam_Type_NUM])
106
110static int
112{
113 PyObject *module;
114 PyObject *c_api_object;
115
116 module = PyImport_ImportModule("_cartesianparam");
117 if (module == NULL) {
118 return -1;
119 }
120
121 c_api_object = PyObject_GetAttrString(module, "_C_API");
122 if (c_api_object == NULL) {
123 Py_DECREF(module);
124 return -1;
125 }
126 if (PyCObject_Check(c_api_object)) {
127 PyCartesianParam_API = (void **)PyCObject_AsVoidPtr(c_api_object);
128 }
129 Py_DECREF(c_api_object);
130 Py_DECREF(module);
131 return 0;
132}
133#endif
134
135
136
137#endif
138
139#endif /* PYCARTESIANPARAM_H */
Defines the functions available when working with a cartesian field.
#define PyCartesianParam_GetNative_RETURN
return type for GetNative
Definition pycartesianparam.h:40
#define PyCartesianParam_GetNative_PROTO
arguments for GetNative
Definition pycartesianparam.h:41
#define PyCartesianParam_New_RETURN
return type for New
Definition pycartesianparam.h:44
#define PyCartesianParam_New_PROTO
arguments for New
Definition pycartesianparam.h:45
#define import_pycartesianparam()
Imports the PyCartesianParam module (like import _area in python).
Definition pycartesianparam.h:97
#define PyCartesianParam_New
Creates a new cartesian instance.
Definition pycartesianparam.h:82
#define PyCartesianParam_GetNative
Returns a pointer to the internal cartesian, remember to release the reference when done with the obj...
Definition pycartesianparam.h:72
A cartesian product.
Definition pycartesianparam.h:32
PyObject_HEAD CartesianParam_t * param
the cartesian parameter
Definition pycartesianparam.h:34
Represents the cartesian field product.
Definition cartesianparam.c:40