python.h
#ifndef WREPORT_PYTHON_H
#define WREPORT_PYTHON_H
#define WREPORT_3_21_COMPAT
#ifdef WREPORT_3_21_COMPAT
// TODO: remove when DB-All.e as deployed does not need this anymore
#include <wreport/var.h>
#define PY_SSIZE_T_CLEAN
#include <Python.h>
extern "C" {
typedef struct {
PyObject_HEAD
wreport::Var var;
} wrpy_Var;
extern PyTypeObject* wrpy_Var_Type;
}
#endif
#include <wreport/fwd.h>
#include <string>
#ifndef PyObject_HEAD
// Forward-declare PyObjetc and PyTypeObject
// see https://mail.python.org/pipermail/python-dev/2003-August/037601.html
extern "C" {
struct _object;
typedef _object PyObject;
struct _typeobject;
typedef _typeobject PyTypeObject;
}
#endif
extern "C" {
struct wrpy_c_api {
// API version 1.x
// TODO: return PyObject* when we drop legacy support
wrpy_Var* (*var_create)(const wreport::Varinfo&);
PyObject* (*var_create_i)(const wreport::Varinfo&, int);
PyObject* (*var_create_d)(const wreport::Varinfo&, double);
PyObject* (*var_create_c)(const wreport::Varinfo&, const char*);
PyObject* (*var_create_s)(const wreport::Varinfo&, const std::string&);
PyObject* (*var_create_copy)(const wreport::Var&);
PyObject* (*var_value_to_python)(const wreport::Var&);
int (*var_value_from_python)(PyObject* o, wreport::Var&);
PyObject* (*varinfo_create)(wreport::Varinfo);
PyObject* (*vartable_create)(const wreport::Vartable*);
unsigned version_major;
unsigned version_minor;
PyTypeObject* varinfo_type;
PyTypeObject* vartable_type;
PyTypeObject* var_type;
// API version 1.1
PyObject* (*var_create_move)(wreport::Var&&);
wreport:: Var* (*var)(PyObject* o);
PyObject* (*var_create_v)(const wreport::Varinfo&, const wreport::Var&);
};
}
#endif
wreport::Var
A physical variable.
Definition var.h:25
wreport::Vartable
Holds a variable information table.
Definition vartable.h:30
wreport::Varinfo
const _Varinfo * Varinfo
Varinfo reference.
Definition fwd.h:11
wrpy_Var
wreport.Var python object
Definition python.h:15
wrpy_c_api
C++ functions exported by the wreport python bindings, to be used by other C++ bindings.
Definition python.h:52
wrpy_c_api::vartable_type
PyTypeObject * vartable_type
Vartable type.
Definition python.h:97
wrpy_c_api::version_minor
unsigned version_minor
C API minor version (updated on backwards-compatible changes).
Definition python.h:91
wrpy_c_api::var_type
PyTypeObject * var_type
Var type.
Definition python.h:100
wrpy_c_api::var_value_from_python
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
wrpy_c_api::version_major
unsigned version_major
C API major version (updated on incompatible changes).
Definition python.h:88
wrpy_c_api::varinfo_type
PyTypeObject * varinfo_type
Varinfo type.
Definition python.h:94