summaryrefslogtreecommitdiff
path: root/include/dbus-python.h
diff options
context:
space:
mode:
authorSimon McVittie <simon.mcvittie@collabora.co.uk>2006-12-18 12:03:27 +0000
committerSimon McVittie <simon.mcvittie@collabora.co.uk>2006-12-18 12:03:27 +0000
commit358403cd0cba20ccda4961a39644c092a0f05b74 (patch)
treeb15809f59616a487df2d3564f592dc8db57bf240 /include/dbus-python.h
parentf4bb2ca522a39fbbf2cce536410c973a73b9059c (diff)
downloaddbus-python-358403cd0cba20ccda4961a39644c092a0f05b74.tar.gz
include/dbus_bindings.h: Rename to include/dbus-python.h, improve namespacing.
_dbus_bindings/conn-internal.h, _dbus_bindings/dbus_bindings-internal.h, _dbus_glib_bindings/module.c: Use dbus-python.h instead of dbus_bindings.h
Diffstat (limited to 'include/dbus-python.h')
-rw-r--r--include/dbus-python.h96
1 files changed, 96 insertions, 0 deletions
diff --git a/include/dbus-python.h b/include/dbus-python.h
new file mode 100644
index 0000000..9d6d581
--- /dev/null
+++ b/include/dbus-python.h
@@ -0,0 +1,96 @@
+/* C API for _dbus_bindings, used by _dbus_glib_bindings.
+ *
+ * Copyright (C) 2006 Collabora Ltd.
+ *
+ * Licensed under the Academic Free License version 2.1
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+#ifndef DBUS_BINDINGS_H
+#define DBUS_BINDINGS_H
+
+#include <Python.h>
+#define DBUS_API_SUBJECT_TO_CHANGE 1
+#include <dbus/dbus.h>
+
+DBUS_BEGIN_DECLS
+
+#define DBUS_BINDINGS_API_COUNT 3
+
+#ifdef INSIDE_DBUS_PYTHON_BINDINGS
+
+#define Connection_BorrowDBusConnection DBusPyConnection_BorrowDBusConnection
+#define NativeMainLoop_New4 DBusPyNativeMainLoop_New4
+extern DBusConnection *DBusPyConnection_BorrowDBusConnection(PyObject *);
+extern PyObject *DBusPyNativeMainLoop_New4(dbus_bool_t (*)(DBusConnection *, void *),
+ dbus_bool_t (*)(DBusServer *, void *),
+ void (*)(void *),
+ void *);
+
+#else
+
+static PyObject *_dbus_bindings_module = NULL;
+static void **dbus_bindings_API;
+
+#define DBusPyConnection_BorrowDBusConnection \
+ (*(DBusConnection *(*)(PyObject *))dbus_bindings_API[1])
+#define DBusPyNativeMainLoop_New4 \
+ ((PyObject *(*)(dbus_bool_t (*)(DBusConnection *, void *),\
+ dbus_bool_t (*)(DBusServer *, void *),\
+ void (*)(void *),\
+ void *))dbus_bindings_API[2])
+
+static int
+import_dbus_bindings(const char *this_module_name)
+{
+ PyObject *c_api;
+ int count;
+
+ _dbus_bindings_module = PyImport_ImportModule("_dbus_bindings");
+ if (!_dbus_bindings_module) {
+ return -1;
+ }
+ c_api = PyObject_GetAttrString(_dbus_bindings_module, "_C_API");
+ if (c_api == NULL) return -1;
+ if (PyCObject_Check(c_api)) {
+ dbus_bindings_API = (void **)PyCObject_AsVoidPtr(c_api);
+ }
+ else {
+ Py_DECREF(c_api);
+ PyErr_SetString(PyExc_RuntimeError, "C API is not a PyCObject");
+ return -1;
+ }
+ Py_DECREF (c_api);
+ count = *(int *)dbus_bindings_API[0];
+ if (count < DBUS_BINDINGS_API_COUNT) {
+ PyErr_Format(PyExc_RuntimeError,
+ "_dbus_bindings has API version %d but %s needs "
+ "_dbus_bindings API version at least %d",
+ count, this_module_name,
+ DBUS_BINDINGS_API_COUNT);
+ return -1;
+ }
+ return 0;
+}
+
+#endif
+
+DBUS_END_DECLS
+
+#endif