~ubuntu-branches/ubuntu/precise/dbus-python/precise

« back to all changes in this revision

Viewing changes to .pc/python3-support.patch/include/dbus-python.h

  • Committer: Package Import Robot
  • Author(s): Simon McVittie
  • Date: 2012-01-24 19:07:26 UTC
  • mfrom: (2.2.2 experimental)
  • Revision ID: package-import@ubuntu.com-20120124190726-baugtt60mzf3tfpd
Tags: 1.0.0-1
* New upstream version 1.0.0
  - increase Python requirement to 2.6
  - build for Python 3 too
  - split python-dbus-dev into a separate package to be shared between
    versions
  - make python-dbus depend on python-dbus-dev for now, to preserve
    historical functionality (but packages which use it, like PyQt, should
    switch to depending on it explicitly)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* C API for _dbus_bindings, used by _dbus_glib_bindings and any third-party
2
 
 * main loop integration which might happen in future.
3
 
 *
4
 
 * This file is currently Python-version-independent - please keep it that way.
5
 
 *
6
 
 * Copyright (C) 2006 Collabora Ltd. <http://www.collabora.co.uk/>
7
 
 *
8
 
 * Permission is hereby granted, free of charge, to any person
9
 
 * obtaining a copy of this software and associated documentation
10
 
 * files (the "Software"), to deal in the Software without
11
 
 * restriction, including without limitation the rights to use, copy,
12
 
 * modify, merge, publish, distribute, sublicense, and/or sell copies
13
 
 * of the Software, and to permit persons to whom the Software is
14
 
 * furnished to do so, subject to the following conditions:
15
 
 *
16
 
 * The above copyright notice and this permission notice shall be
17
 
 * included in all copies or substantial portions of the Software.
18
 
 *
19
 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20
 
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21
 
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
22
 
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
23
 
 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
24
 
 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
 
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
26
 
 * DEALINGS IN THE SOFTWARE.
27
 
 */
28
 
 
29
 
#ifndef DBUS_PYTHON_H
30
 
#define DBUS_PYTHON_H
31
 
 
32
 
#include <Python.h>
33
 
#include <dbus/dbus.h>
34
 
 
35
 
DBUS_BEGIN_DECLS
36
 
 
37
 
typedef void (*_dbus_py_func_ptr)(void);
38
 
 
39
 
typedef dbus_bool_t (*_dbus_py_conn_setup_func)(DBusConnection *, void *);
40
 
typedef dbus_bool_t (*_dbus_py_srv_setup_func)(DBusServer *, void *);
41
 
typedef void (*_dbus_py_free_func)(void *);
42
 
 
43
 
#define DBUS_BINDINGS_API_COUNT 3
44
 
 
45
 
#ifdef INSIDE_DBUS_PYTHON_BINDINGS
46
 
 
47
 
extern DBusConnection *DBusPyConnection_BorrowDBusConnection(PyObject *);
48
 
extern PyObject *DBusPyNativeMainLoop_New4(_dbus_py_conn_setup_func,
49
 
                                           _dbus_py_srv_setup_func,
50
 
                                           _dbus_py_free_func,
51
 
                                           void *);
52
 
 
53
 
#else
54
 
 
55
 
static PyObject *_dbus_bindings_module = NULL;
56
 
static _dbus_py_func_ptr *dbus_bindings_API;
57
 
 
58
 
#define DBusPyConnection_BorrowDBusConnection \
59
 
        (*(DBusConnection *(*)(PyObject *))dbus_bindings_API[1])
60
 
#define DBusPyNativeMainLoop_New4 \
61
 
    ((PyObject *(*)(_dbus_py_conn_setup_func, _dbus_py_srv_setup_func, \
62
 
                    _dbus_py_free_func, void *))dbus_bindings_API[2])
63
 
 
64
 
static int
65
 
import_dbus_bindings(const char *this_module_name)
66
 
{
67
 
    PyObject *c_api;
68
 
    int count;
69
 
 
70
 
    _dbus_bindings_module = PyImport_ImportModule("_dbus_bindings");
71
 
    if (!_dbus_bindings_module) {
72
 
        return -1;
73
 
    }
74
 
    c_api = PyObject_GetAttrString(_dbus_bindings_module, "_C_API");
75
 
    if (c_api == NULL) return -1;
76
 
    if (PyCObject_Check(c_api)) {
77
 
        dbus_bindings_API = (_dbus_py_func_ptr *)PyCObject_AsVoidPtr(c_api);
78
 
    }
79
 
    else {
80
 
        Py_DECREF(c_api);
81
 
        PyErr_SetString(PyExc_RuntimeError, "C API is not a PyCObject");
82
 
        return -1;
83
 
    }
84
 
    Py_DECREF (c_api);
85
 
    count = *(int *)dbus_bindings_API[0];
86
 
    if (count < DBUS_BINDINGS_API_COUNT) {
87
 
        PyErr_Format(PyExc_RuntimeError,
88
 
                     "_dbus_bindings has API version %d but %s needs "
89
 
                     "_dbus_bindings API version at least %d",
90
 
                     count, this_module_name,
91
 
                     DBUS_BINDINGS_API_COUNT);
92
 
        return -1;
93
 
    }
94
 
    return 0;
95
 
}
96
 
 
97
 
#endif
98
 
 
99
 
DBUS_END_DECLS
100
 
 
101
 
#endif