1 /* _dbus_bindings internal API. For use within _dbus_bindings only.
3 * Copyright (C) 2006 Collabora Ltd. <http://www.collabora.co.uk/>
5 * Licensed under the Academic Free License version 2.1
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 #ifndef DBUS_BINDINGS_INTERNAL_H
26 #define DBUS_BINDINGS_INTERNAL_H
29 #define INSIDE_DBUS_BINDINGS
30 #include "dbus_bindings.h"
32 /* no need for extern "C", this is only for internal use */
34 /* on/off switch for debugging support (see below) */
36 /* #define USING_DBG 1 */
38 #define DEFINE_CHECK(type) \
39 static inline int type##_Check (PyObject *o) \
41 return (PyObject_TypeCheck (o, &type##_Type)); \
45 extern PyTypeObject DBusPyConnection_Type
;
46 DEFINE_CHECK(DBusPyConnection
)
47 extern PyObject
*DBusPyConnection_NewConsumingDBusConnection(PyTypeObject
*,
50 extern dbus_bool_t
dbus_py_init_conn_types(void);
51 extern dbus_bool_t
dbus_py_insert_conn_types(PyObject
*this_module
);
54 extern dbus_bool_t
dbus_py_init_bus_types(void);
55 extern dbus_bool_t
dbus_py_insert_bus_types(PyObject
*this_module
);
58 extern PyObject
*DBusPyException
;
59 extern PyObject
*DBusPyException_ConsumeError(DBusError
*error
);
60 extern dbus_bool_t
dbus_py_init_exception_types(void);
61 extern dbus_bool_t
dbus_py_insert_exception_types(PyObject
*this_module
);
64 extern PyTypeObject DBusPyBoolean_Type
;
65 DEFINE_CHECK(DBusPyBoolean
)
66 extern PyTypeObject DBusPyObjectPath_Type
, DBusPySignature_Type
;
67 DEFINE_CHECK(DBusPyObjectPath
)
68 DEFINE_CHECK(DBusPySignature
)
69 extern PyTypeObject DBusPyArray_Type
, DBusPyDict_Type
, DBusPyStruct_Type
;
70 DEFINE_CHECK(DBusPyArray
)
71 DEFINE_CHECK(DBusPyDict
)
72 DEFINE_CHECK(DBusPyStruct
)
73 extern PyTypeObject DBusPyByte_Type
, DBusPyByteArray_Type
;
74 DEFINE_CHECK(DBusPyByteArray
)
75 DEFINE_CHECK(DBusPyByte
)
76 extern PyTypeObject DBusPyUTF8String_Type
, DBusPyString_Type
;
77 DEFINE_CHECK(DBusPyUTF8String
)
78 DEFINE_CHECK(DBusPyString
)
79 extern PyTypeObject DBusPyDouble_Type
;
80 DEFINE_CHECK(DBusPyDouble
)
81 extern PyTypeObject DBusPyInt16_Type
, DBusPyUInt16_Type
;
82 DEFINE_CHECK(DBusPyInt16
)
83 DEFINE_CHECK(DBusPyUInt16
)
84 extern PyTypeObject DBusPyInt32_Type
, DBusPyUInt32_Type
;
85 DEFINE_CHECK(DBusPyInt32
)
86 DEFINE_CHECK(DBusPyUInt32
)
87 extern PyTypeObject DBusPyInt64_Type
, DBusPyUInt64_Type
;
88 DEFINE_CHECK(DBusPyInt64
)
89 DEFINE_CHECK(DBusPyUInt64
)
90 extern dbus_bool_t
dbus_py_init_abstract(void);
91 extern dbus_bool_t
dbus_py_init_signature(void);
92 extern dbus_bool_t
dbus_py_init_int_types(void);
93 extern dbus_bool_t
dbus_py_init_string_types(void);
94 extern dbus_bool_t
dbus_py_init_float_types(void);
95 extern dbus_bool_t
dbus_py_init_container_types(void);
96 extern dbus_bool_t
dbus_py_init_byte_types(void);
97 extern dbus_bool_t
dbus_py_insert_abstract_types(PyObject
*this_module
);
98 extern dbus_bool_t
dbus_py_insert_signature(PyObject
*this_module
);
99 extern dbus_bool_t
dbus_py_insert_int_types(PyObject
*this_module
);
100 extern dbus_bool_t
dbus_py_insert_string_types(PyObject
*this_module
);
101 extern dbus_bool_t
dbus_py_insert_float_types(PyObject
*this_module
);
102 extern dbus_bool_t
dbus_py_insert_container_types(PyObject
*this_module
);
103 extern dbus_bool_t
dbus_py_insert_byte_types(PyObject
*this_module
);
106 extern void dbus_py_take_gil_and_xdecref(PyObject
*);
107 extern int dbus_py_immutable_setattro(PyObject
*, PyObject
*, PyObject
*);
108 extern PyObject
*dbus_py_tp_richcompare_by_pointer(PyObject
*,
111 extern long dbus_py_tp_hash_by_pointer(PyObject
*self
);
112 extern PyObject
*dbus_py_empty_tuple
;
113 extern dbus_bool_t
dbus_py_init_generic(void);
116 extern DBusMessage
*DBusPyMessage_BorrowDBusMessage(PyObject
*msg
);
117 extern PyObject
*DBusPyMessage_ConsumeDBusMessage(DBusMessage
*);
118 extern dbus_bool_t
dbus_py_init_message_types(void);
119 extern dbus_bool_t
dbus_py_insert_message_types(PyObject
*this_module
);
122 extern PyObject
*DBusPyPendingCall_ConsumeDBusPendingCall(DBusPendingCall
*,
124 extern dbus_bool_t
dbus_py_init_pending_call(void);
125 extern dbus_bool_t
dbus_py_insert_pending_call(PyObject
*this_module
);
128 extern dbus_bool_t
dbus_py_set_up_connection(PyObject
*conn
,
130 extern PyObject
*dbus_py_get_default_main_loop(void);
131 extern dbus_bool_t
dbus_py_check_mainloop_sanity(PyObject
*);
132 extern dbus_bool_t
dbus_py_init_mainloop(void);
133 extern dbus_bool_t
dbus_py_insert_mainloop_types(PyObject
*);
136 dbus_bool_t
dbus_py_validate_bus_name(const char *name
,
137 dbus_bool_t may_be_unique
,
138 dbus_bool_t may_be_not_unique
);
139 dbus_bool_t
dbus_py_validate_member_name(const char *name
);
140 dbus_bool_t
dbus_py_validate_interface_name(const char *name
);
141 dbus_bool_t
dbus_py_validate_object_path(const char *path
);
142 #define dbus_py_validate_error_name dbus_py_validate_interface_name
144 /* debugging support */
145 void _dbus_py_assertion_failed(const char *);
146 #define DBUS_PY_RAISE_VIA_NULL_IF_FAIL(assertion) \
147 do { if (!(assertion)) { \
148 _dbus_py_assertion_failed(#assertion); \
153 #define DBUS_PY_RAISE_VIA_GOTO_IF_FAIL(assertion, label) \
154 do { if (!(assertion)) { \
155 _dbus_py_assertion_failed(#assertion); \
160 #define DBUS_PY_RAISE_VIA_RETURN_IF_FAIL(assertion, value) \
161 do { if (!(assertion)) { \
162 _dbus_py_assertion_failed(#assertion); \
167 /* verbose debugging support */
170 # include <sys/types.h>
173 void _dbus_py_dbg_exc(void);
174 void _dbus_py_whereami(void);
175 void _dbus_py_dbg_dump_message(DBusMessage
*);
177 # define DBG(format, ...) fprintf(stderr, "DEBUG: " format "\n",\
179 # define DBG_EXC(format, ...) do {DBG(format, __VA_ARGS__); \
180 _dbus_py_dbg_exc();} while (0)
181 # define DBG_DUMP_MESSAGE(x) _dbus_py_dbg_dump_message(x)
183 #else /* !defined(USING_DBG) */
185 # define DBG(format, ...) do {} while (0)
186 # define DBG_EXC(format, ...) do {} while (0)
187 # define DBG_DUMP_MESSAGE(x) do {} while(0)
189 #endif /* !defined(USING_DBG) */
191 /* General-purpose Python glue */
193 #define DEFERRED_ADDRESS(ADDR) 0
195 #if defined(__GNUC__)
197 # define UNUSED __attribute__((__unused__))
199 # define UNUSED /*nothing*/
202 # define UNUSED /*nothing*/