Split out exceptions, pending call, message into separate .c files
[dbus-python-phuang.git] / _dbus_bindings / dbus_bindings-internal.h
blob77190df1fbec8283d634adc8f2b865e2a7c5b1e8
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
28 #include <Python.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) */
35 #undef USING_DBG
36 /* #define USING_DBG */
38 #define DEFINE_CHECK(type) \
39 static inline int type##_Check (PyObject *o) \
40 { \
41 return (PyObject_TypeCheck (o, &type##_Type)); \
44 /* conn.c */
45 extern PyTypeObject DBusPyConnection_Type;
46 DEFINE_CHECK(DBusPyConnection)
47 extern PyObject *DBusPyConnection_NewConsumingDBusConnection(PyTypeObject *,
48 DBusConnection *,
49 PyObject *);
50 extern dbus_bool_t dbus_py_init_conn_types(void);
51 extern dbus_bool_t dbus_py_insert_conn_types(PyObject *this_module);
53 /* bus.c */
54 extern dbus_bool_t dbus_py_init_bus_types(void);
55 extern dbus_bool_t dbus_py_insert_bus_types(PyObject *this_module);
57 /* exceptions.c */
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);
63 /* types */
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)
91 /* generic */
92 extern void dbus_py_take_gil_and_xdecref(PyObject *);
93 extern PyObject *dbus_py_empty_tuple;
95 /* message.c */
96 extern DBusMessage *DBusPyMessage_BorrowDBusMessage(PyObject *msg);
97 extern PyObject *DBusPyMessage_ConsumeDBusMessage(DBusMessage *);
98 extern dbus_bool_t dbus_py_init_message_types(void);
99 extern dbus_bool_t dbus_py_insert_message_types(PyObject *this_module);
101 /* pending-call.c */
102 extern PyObject *DBusPyPendingCall_ConsumeDBusPendingCall(DBusPendingCall *,
103 PyObject *);
104 extern dbus_bool_t dbus_py_init_pending_call(void);
105 extern dbus_bool_t dbus_py_insert_pending_call(PyObject *this_module);
107 /* mainloop.c */
108 extern dbus_bool_t dbus_py_set_up_connection(PyObject *conn,
109 PyObject *mainloop);
110 extern PyObject *dbus_py_get_default_main_loop(void);
112 /* validation.c */
113 dbus_bool_t dbus_py_validate_bus_name(const char *name,
114 dbus_bool_t may_be_unique,
115 dbus_bool_t may_be_not_unique);
116 dbus_bool_t dbus_py_validate_member_name(const char *name);
117 dbus_bool_t dbus_py_validate_interface_name(const char *name);
118 dbus_bool_t dbus_py_validate_object_path(const char *path);
119 #define dbus_py_validate_error_name dbus_py_validate_interface_name
121 /* debugging support */
122 #ifdef USING_DBG
124 # include <sys/types.h>
125 # include <unistd.h>
127 void _dbus_py_dbg_exc(void);
128 void _dbus_py_dbg_dump_message(DBusMessage *);
130 # define DBG(format, ...) fprintf(stderr, "DEBUG: " format "\n",\
131 __VA_ARGS__)
132 # define DBG_EXC(format, ...) do {DBG(format, __VA_ARGS__); \
133 _dbus_py_dbg_exc();} while (0)
134 # define DBG_DUMP_MESSAGE(x) _dbg_dump_message(x)
136 #else /* !defined(USING_DBG) */
138 # define DBG(format, ...) do {} while (0)
139 # define DBG_EXC(format, ...) do {} while (0)
140 # define DBG_DUMP_MESSAGE(x) do {} while(0)
142 #endif /* !defined(USING_DBG) */
144 /* General-purpose Python glue */
146 #define DEFERRED_ADDRESS(ADDR) 0
148 #if defined(__GNUC__)
149 # if __GNUC__ >= 3
150 # define UNUSED __attribute__((__unused__))
151 # else
152 # define UNUSED /*nothing*/
153 # endif
154 #else
155 # define UNUSED /*nothing*/
156 #endif
158 #endif