| 1 |
|
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
#ifndef PY_MIDGARD_H |
|---|
| 20 |
#define PY_MIDGARD_H |
|---|
| 21 |
|
|---|
| 22 |
#ifndef PY_MIDGARD_H_INT |
|---|
| 23 |
#define PY_MIDGARD_H_INT |
|---|
| 24 |
|
|---|
| 25 |
#include <Python.h> |
|---|
| 26 |
#include <pygobject.h> |
|---|
| 27 |
#include <midgard/midgard.h> |
|---|
| 28 |
|
|---|
| 29 |
#endif |
|---|
| 30 |
|
|---|
| 31 |
#ifdef G_LOG_DOMAIN |
|---|
| 32 |
#undef G_LOG_DOMAIN |
|---|
| 33 |
#define G_LOG_DOMAIN "midgard-core" |
|---|
| 34 |
#endif |
|---|
| 35 |
|
|---|
| 36 |
extern void py_midgard_dbobject_register_class(PyObject *d, gpointer pygobject_type); |
|---|
| 37 |
extern void py_midgard_object_register_class(PyObject *d, gpointer pygobject_type); |
|---|
| 38 |
extern void py_midgard_config_register_class(PyObject *d, gpointer pygobject_type); |
|---|
| 39 |
extern void py_midgard_connection_register_class(PyObject *d, gpointer pygobject_type); |
|---|
| 40 |
extern void py_midgard_query_builder_register_class(PyObject *d, gpointer pygobject_type); |
|---|
| 41 |
extern void py_midgard_blob_register_class(PyObject *d, gpointer pygobject_type); |
|---|
| 42 |
extern void py_midgard_collector_register_class(PyObject *d, gpointer pygobject_type); |
|---|
| 43 |
extern void py_midgard_reflection_property_register_class(PyObject *d, gpointer pygobject_type); |
|---|
| 44 |
extern void py_midgard_object_class_register_class(PyObject *d, gpointer pygobject_type); |
|---|
| 45 |
extern void py_midgard_replicator_register_class(PyObject *d, gpointer pygobject_type); |
|---|
| 46 |
extern void py_midgard_user_register_class(PyObject *d, gpointer pygobject_type); |
|---|
| 47 |
extern void py_midgard_dbus_register_class(PyObject *d, gpointer pygobject_type); |
|---|
| 48 |
|
|---|
| 49 |
|
|---|
| 50 |
extern PyObject *pymidgard_object_get_parameter(PyGObject *self, PyObject *args); |
|---|
| 51 |
extern PyObject *pymidgard_object_set_parameter(PyGObject *self, PyObject *args); |
|---|
| 52 |
extern PyObject *pymidgard_object_delete_parameters(PyGObject *self, PyObject *args); |
|---|
| 53 |
extern PyObject *pymidgard_object_purge_parameters(PyGObject *self, PyObject *args); |
|---|
| 54 |
extern PyObject *pymidgard_object_list_parameters(PyGObject *self, PyObject *args); |
|---|
| 55 |
extern PyObject *pymidgard_object_find_parameters(PyGObject *self, PyObject *args); |
|---|
| 56 |
|
|---|
| 57 |
|
|---|
| 58 |
extern PyObject *pymidgard_object_create_attachment(PyGObject *self, PyObject *args); |
|---|
| 59 |
extern PyObject *pymidgard_object_delete_attachments(PyGObject *self, PyObject *args); |
|---|
| 60 |
extern PyObject *pymidgard_object_purge_attachments(PyGObject *self, PyObject *args); |
|---|
| 61 |
extern PyObject *pymidgard_object_list_attachments(PyGObject *self, PyObject *args); |
|---|
| 62 |
extern PyObject *pymidgard_object_find_attachments(PyGObject *self, PyObject *args); |
|---|
| 63 |
|
|---|
| 64 |
|
|---|
| 65 |
|
|---|
| 66 |
|
|---|
| 67 |
|
|---|
| 68 |
extern MidgardConnection *MGDCG; |
|---|
| 69 |
|
|---|
| 70 |
|
|---|
| 71 |
PyTypeObject py_midgard_dbobject_get_type_object(void); |
|---|
| 72 |
PyTypeObject py_midgard_query_builder_get_type_object(void); |
|---|
| 73 |
PyTypeObject py_midgard_collector_get_type_object(void); |
|---|
| 74 |
|
|---|
| 75 |
extern void _py_midgard_connection_singleton_set(MidgardConnection *mgd); |
|---|
| 76 |
extern MidgardConnection *_py_midgard_connection_singleton_get(void); |
|---|
| 77 |
extern PyTypeObject *py_midgard_lookup_schema_type(const gchar *name); |
|---|
| 78 |
|
|---|
| 79 |
|
|---|
| 80 |
extern GValue gvalue_from_pyobject(PyObject *obj); |
|---|
| 81 |
extern gchar *_py_midgard_format_string(const gchar *msg , ...); |
|---|
| 82 |
extern GParameter *_py_midgard_parameters_from_args(PyObject *args, guint *n_params); |
|---|
| 83 |
|
|---|
| 84 |
|
|---|
| 85 |
PyObject *_py_midgard_get_object_attribute(PyObject *self, PyObject *attr); |
|---|
| 86 |
int _py_midgard_set_object_attribute(PyObject *self, PyObject *attr, PyObject *value); |
|---|
| 87 |
|
|---|
| 88 |
|
|---|
| 89 |
#define CHECK_MGD \ |
|---|
| 90 |
if(1 < 0) { \ |
|---|
| 91 |
PyTypeObject *tp = self->ob_type; \ |
|---|
| 92 |
PyObject *__class = PyObject_GetAttrString((PyObject *)self, "__class__"); \ |
|---|
| 93 |
PyObject *__name = PyObject_GetAttrString(__class, "__name__"); \ |
|---|
| 94 |
PyObject *__string = PyObject_Str(__name); \ |
|---|
| 95 |
Py_DECREF(__name); \ |
|---|
| 96 |
g_log(G_LOG_DOMAIN, G_LOG_LEVEL_INFO, "%s.%s(...)", tp->tp_name, PyString_AS_STRING(__string)); \ |
|---|
| 97 |
} |
|---|
| 98 |
|
|---|
| 99 |
#define CLASS_METHOD_DEBUG(__classname, __name) \ |
|---|
| 100 |
g_log(G_LOG_DOMAIN, G_LOG_LEVEL_INFO, "%s.%s(...)", __classname, __name); |
|---|
| 101 |
|
|---|
| 102 |
#define OBJECTS2LIST(__gobjects, __rlist) \ |
|---|
| 103 |
guint k = 0; \ |
|---|
| 104 |
while(__gobjects[k] != NULL) { \ |
|---|
| 105 |
PyObject *__pobject = \ |
|---|
| 106 |
Py_BuildValue("O", pygobject_new(G_OBJECT(__gobjects[k]))); \ |
|---|
| 107 |
((PyGObject *)__pobject)->obj = G_OBJECT(__gobjects[k]); \ |
|---|
| 108 |
PyTuple_SetItem(__rlist, k, __pobject); \ |
|---|
| 109 |
k++; \ |
|---|
| 110 |
} |
|---|
| 111 |
|
|---|
| 112 |
#endif |
|---|