Add a test case for the various options to get_args_list.
[dbus-python-phuang.git] / _dbus_bindings / module.c
blobb872a874fa8815ddf74082b71fb1fc6102a60a8b
1 /* Main module source for the _dbus_bindings extension.
3 * Copyright (C) 2006 Collabora Ltd.
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 #include <Python.h>
26 #include <structmember.h>
28 #define INSIDE_DBUS_BINDINGS
29 #include "dbus_bindings.h"
31 PyDoc_STRVAR(module_doc,
32 "Low-level Python bindings for libdbus.\n");
34 #include "debug-impl.h" /* DBG, USING_DBG, DBG_EXC */
35 #include "generic-impl.h" /* Non D-Bus support code */
36 #include "validation-impl.h" /* Interface name, etc., validation */
37 #include "exceptions-impl.h" /* Exception base classes */
38 #include "signature-impl.h" /* Signature and its custom iterator */
39 #include "types-impl.h" /* IntNN, UIntNN, ObjectPath */
40 #include "containers-impl.h" /* Array, Dict, Variant */
41 #include "bytes-impl.h" /* Byte, ByteArray */
42 #include "message-impl.h" /* Message and subclasses */
43 #include "pending-call-impl.h" /* PendingCall */
44 #include "conn-impl.h" /* Connection */
45 #include "bus-impl.h" /* Bus */
47 static PyMethodDef module_functions[] = {
48 {NULL, NULL, 0, NULL}
51 PyMODINIT_FUNC
52 init_dbus_bindings(void)
54 PyObject *this_module;
56 if (!init_generic()) return;
57 if (!init_exception_types()) return;
58 if (!init_signature()) return;
59 if (!init_types()) return;
60 if (!init_container_types()) return;
61 if (!init_byte_types()) return;
62 if (!init_message_types()) return;
63 if (!init_pending_call()) return;
64 if (!init_conn_types()) return;
65 if (!init_bus_types()) return;
67 this_module = Py_InitModule3("_dbus_bindings", module_functions, module_doc);
68 if (!this_module) return;
70 if (!insert_exception_types(this_module)) return;
71 if (!insert_signature(this_module)) return;
72 if (!insert_types(this_module)) return;
73 if (!insert_container_types(this_module)) return;
74 if (!insert_byte_types(this_module)) return;
75 if (!insert_message_types(this_module)) return;
76 if (!insert_pending_call(this_module)) return;
77 if (!insert_conn_types(this_module)) return;
78 if (!insert_bus_types(this_module)) return;
80 #define ADD_CONST_VAL(x, v) \
81 if (PyModule_AddIntConstant(this_module, x, v) < 0) return;
82 #define ADD_CONST_PREFIXED(x) ADD_CONST_VAL(#x, DBUS_##x)
83 #define ADD_CONST(x) ADD_CONST_VAL(#x, x)
85 ADD_CONST(DBUS_START_REPLY_SUCCESS)
86 ADD_CONST(DBUS_START_REPLY_ALREADY_RUNNING)
88 ADD_CONST_PREFIXED(RELEASE_NAME_REPLY_RELEASED)
89 ADD_CONST_PREFIXED(RELEASE_NAME_REPLY_NON_EXISTENT)
90 ADD_CONST_PREFIXED(RELEASE_NAME_REPLY_NOT_OWNER)
92 ADD_CONST_PREFIXED(REQUEST_NAME_REPLY_PRIMARY_OWNER)
93 ADD_CONST_PREFIXED(REQUEST_NAME_REPLY_IN_QUEUE)
94 ADD_CONST_PREFIXED(REQUEST_NAME_REPLY_EXISTS)
95 ADD_CONST_PREFIXED(REQUEST_NAME_REPLY_ALREADY_OWNER)
97 ADD_CONST_PREFIXED(NAME_FLAG_ALLOW_REPLACEMENT)
98 ADD_CONST_PREFIXED(NAME_FLAG_REPLACE_EXISTING)
99 ADD_CONST_PREFIXED(NAME_FLAG_DO_NOT_QUEUE)
101 ADD_CONST_PREFIXED(BUS_SESSION)
102 ADD_CONST_PREFIXED(BUS_SYSTEM)
103 ADD_CONST_PREFIXED(BUS_STARTER)
105 ADD_CONST_PREFIXED(MESSAGE_TYPE_INVALID)
106 ADD_CONST_PREFIXED(MESSAGE_TYPE_METHOD_CALL)
107 ADD_CONST_PREFIXED(MESSAGE_TYPE_METHOD_RETURN)
108 ADD_CONST_PREFIXED(MESSAGE_TYPE_ERROR)
109 ADD_CONST_PREFIXED(MESSAGE_TYPE_SIGNAL)
111 ADD_CONST_PREFIXED(MESSAGE_TYPE_SIGNAL)
113 ADD_CONST_PREFIXED(TYPE_INVALID)
114 ADD_CONST_PREFIXED(TYPE_BYTE)
115 ADD_CONST_PREFIXED(TYPE_BOOLEAN)
116 ADD_CONST_PREFIXED(TYPE_INT16)
117 ADD_CONST_PREFIXED(TYPE_UINT16)
118 ADD_CONST_PREFIXED(TYPE_INT32)
119 ADD_CONST_PREFIXED(TYPE_UINT32)
120 ADD_CONST_PREFIXED(TYPE_INT64)
121 ADD_CONST_PREFIXED(TYPE_UINT64)
122 ADD_CONST_PREFIXED(TYPE_DOUBLE)
123 ADD_CONST_PREFIXED(TYPE_STRING)
124 ADD_CONST_PREFIXED(TYPE_OBJECT_PATH)
125 ADD_CONST_PREFIXED(TYPE_SIGNATURE)
126 ADD_CONST_PREFIXED(TYPE_ARRAY)
127 ADD_CONST_PREFIXED(TYPE_STRUCT)
128 ADD_CONST_VAL("STRUCT_BEGIN", DBUS_STRUCT_BEGIN_CHAR)
129 ADD_CONST_VAL("STRUCT_END", DBUS_STRUCT_END_CHAR)
130 ADD_CONST_PREFIXED(TYPE_VARIANT)
131 ADD_CONST_PREFIXED(TYPE_DICT_ENTRY)
132 ADD_CONST_VAL("DICT_ENTRY_BEGIN", DBUS_DICT_ENTRY_BEGIN_CHAR)
133 ADD_CONST_VAL("DICT_ENTRY_END", DBUS_DICT_ENTRY_END_CHAR)
135 ADD_CONST_PREFIXED(HANDLER_RESULT_HANDLED)
136 ADD_CONST_PREFIXED(HANDLER_RESULT_NOT_YET_HANDLED)
137 ADD_CONST_PREFIXED(HANDLER_RESULT_NEED_MEMORY)
139 if (PyModule_AddStringConstant(this_module, "__docformat__",
140 "restructuredtext") < 0) return;
143 /* vim:set ft=c cino< sw=4 sts=4 et: */