1 /* General Python glue code, used in _dbus_bindings but not actually anything
4 * Copyright (C) 2006 Collabora Ltd. <http://www.collabora.co.uk/>
6 * Permission is hereby granted, free of charge, to any person
7 * obtaining a copy of this software and associated documentation
8 * files (the "Software"), to deal in the Software without
9 * restriction, including without limitation the rights to use, copy,
10 * modify, merge, publish, distribute, sublicense, and/or sell copies
11 * of the Software, and to permit persons to whom the Software is
12 * furnished to do so, subject to the following conditions:
14 * The above copyright notice and this permission notice shall be
15 * included in all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
24 * DEALINGS IN THE SOFTWARE.
27 #include "dbus_bindings-internal.h"
29 /* The empty tuple, held globally since dbus-python turns out to use it quite
32 PyObject *dbus_py_empty_tuple = NULL;
35 dbus_py_tp_richcompare_by_pointer(PyObject *self,
39 if (op == Py_EQ || op == Py_NE) {
41 return PyInt_FromLong(op == Py_EQ);
43 return PyInt_FromLong(op == Py_NE);
45 PyErr_SetString(PyExc_TypeError,
46 "Instances of this type are not ordered");
51 dbus_py_tp_hash_by_pointer(PyObject *self)
53 long hash = (long)self;
54 return (hash == -1L ? -2L : hash);
58 dbus_py_immutable_setattro(PyObject *obj UNUSED,
59 PyObject *name UNUSED,
60 PyObject *value UNUSED)
62 PyErr_SetString(PyExc_AttributeError, "Object is immutable");
66 /* Take the global interpreter lock and decrement the reference count.
67 * Suitable for calling from a C callback. */
69 dbus_py_take_gil_and_xdecref(PyObject *obj)
71 PyGILState_STATE gil = PyGILState_Ensure();
73 PyGILState_Release(gil);
77 dbus_py_init_generic(void)
79 dbus_py_empty_tuple = PyTuple_New(0);
80 if (!dbus_py_empty_tuple) return 0;
84 /* vim:set ft=c cino< sw=4 sts=4 et: */