libwreport 3.37
python.h
1#ifndef WREPORT_PYTHON_H
2#define WREPORT_PYTHON_H
3
4#define WREPORT_3_21_COMPAT
5
6#ifdef WREPORT_3_21_COMPAT
7// TODO: remove when DB-All.e as deployed does not need this anymore
8#include <wreport/var.h>
9
10#define PY_SSIZE_T_CLEAN
11#include <Python.h>
12
13extern "C" {
15typedef struct {
16 PyObject_HEAD
17 wreport::Var var;
18} wrpy_Var;
19
21extern PyTypeObject* wrpy_Var_Type;
22}
23#endif
24
25
26#include <wreport/fwd.h>
27#include <string>
28
29#ifndef PyObject_HEAD
30// Forward-declare PyObjetc and PyTypeObject
31// see https://mail.python.org/pipermail/python-dev/2003-August/037601.html
32extern "C" {
33struct _object;
34typedef _object PyObject;
35struct _typeobject;
36typedef _typeobject PyTypeObject;
37}
38#endif
39
40extern "C" {
41
52struct wrpy_c_api {
53
54// API version 1.x
55
57 // TODO: return PyObject* when we drop legacy support
58 wrpy_Var* (*var_create)(const wreport::Varinfo&);
59
61 PyObject* (*var_create_i)(const wreport::Varinfo&, int);
62
64 PyObject* (*var_create_d)(const wreport::Varinfo&, double);
65
67 PyObject* (*var_create_c)(const wreport::Varinfo&, const char*);
68
70 PyObject* (*var_create_s)(const wreport::Varinfo&, const std::string&);
71
73 PyObject* (*var_create_copy)(const wreport::Var&);
74
76 PyObject* (*var_value_to_python)(const wreport::Var&);
77
79 int (*var_value_from_python)(PyObject* o, wreport::Var&);
80
82 PyObject* (*varinfo_create)(wreport::Varinfo);
83
85 PyObject* (*vartable_create)(const wreport::Vartable*);
86
88 unsigned version_major;
89
91 unsigned version_minor;
92
94 PyTypeObject* varinfo_type;
95
97 PyTypeObject* vartable_type;
98
100 PyTypeObject* var_type;
101
102// API version 1.1
103
105 PyObject* (*var_create_move)(wreport::Var&&);
106
108 wreport:: Var* (*var)(PyObject* o);
109
111 PyObject* (*var_create_v)(const wreport::Varinfo&, const wreport::Var&);
112};
113
114}
115
116#endif
A physical variable.
Definition: var.h:25
Holds a variable information table.
Definition: vartable.h:30
const _Varinfo * Varinfo
Varinfo reference.
Definition: fwd.h:11
Information about a variable.
Definition: varinfo.h:139
wreport.Var python object
Definition: python.h:15
C++ functions exported by the wreport python bindings, to be used by other C++ bindings.
Definition: python.h:52
PyTypeObject * vartable_type
Vartable type.
Definition: python.h:97
unsigned version_minor
C API minor version (updated on backwards-compatible changes)
Definition: python.h:91
PyTypeObject * var_type
Var type.
Definition: python.h:100
int(* var_value_from_python)(PyObject *o, wreport::Var &)
Set the value of a variable from a Python object (borrowed reference)
Definition: python.h:79
unsigned version_major
C API major version (updated on incompatible changes)
Definition: python.h:88
PyTypeObject * varinfo_type
Varinfo type.
Definition: python.h:94