Cast to PyCFunction to avoid compiler warning for function with kwargs
[dbus-python-phuang.git] / _dbus_bindings / module.c
blob4c47cec6ec67b0cba640a0a2d3d787ab697c60e5
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 #define ENTRY(name,flags) {#name, (PyCFunction)name, flags, name##__doc__}
49 ENTRY(validate_interface_name, METH_VARARGS),
50 ENTRY(validate_member_name, METH_VARARGS),
51 ENTRY(validate_bus_name, METH_VARARGS|METH_KEYWORDS),
52 ENTRY(validate_object_path, METH_VARARGS),
53 /* validate_error_name is just implemented as validate_interface_name */
54 {"validate_error_name", validate_interface_name,
55 METH_VARARGS, validate_error_name__doc__},
56 #undef ENTRY
57 {NULL, NULL, 0, NULL}
60 PyMODINIT_FUNC
61 init_dbus_bindings(void)
63 PyObject *this_module;
65 if (!init_generic()) return;
66 if (!init_exception_types()) return;
67 if (!init_signature()) return;
68 if (!init_types()) return;
69 if (!init_container_types()) return;
70 if (!init_byte_types()) return;
71 if (!init_message_types()) return;
72 if (!init_pending_call()) return;
73 if (!init_conn_types()) return;
74 if (!init_bus_types()) return;
76 this_module = Py_InitModule3("_dbus_bindings", module_functions, module_doc);
77 if (!this_module) return;
79 if (!insert_exception_types(this_module)) return;
80 if (!insert_signature(this_module)) return;
81 if (!insert_types(this_module)) return;
82 if (!insert_container_types(this_module)) return;
83 if (!insert_byte_types(this_module)) return;
84 if (!insert_message_types(this_module)) return;
85 if (!insert_pending_call(this_module)) return;
86 if (!insert_conn_types(this_module)) return;
87 if (!insert_bus_types(this_module)) return;
89 #define ADD_CONST_VAL(x, v) \
90 if (PyModule_AddIntConstant(this_module, x, v) < 0) return;
91 #define ADD_CONST_PREFIXED(x) ADD_CONST_VAL(#x, DBUS_##x)
92 #define ADD_CONST(x) ADD_CONST_VAL(#x, x)
94 ADD_CONST(DBUS_START_REPLY_SUCCESS)
95 ADD_CONST(DBUS_START_REPLY_ALREADY_RUNNING)
97 ADD_CONST_PREFIXED(RELEASE_NAME_REPLY_RELEASED)
98 ADD_CONST_PREFIXED(RELEASE_NAME_REPLY_NON_EXISTENT)
99 ADD_CONST_PREFIXED(RELEASE_NAME_REPLY_NOT_OWNER)
101 ADD_CONST_PREFIXED(REQUEST_NAME_REPLY_PRIMARY_OWNER)
102 ADD_CONST_PREFIXED(REQUEST_NAME_REPLY_IN_QUEUE)
103 ADD_CONST_PREFIXED(REQUEST_NAME_REPLY_EXISTS)
104 ADD_CONST_PREFIXED(REQUEST_NAME_REPLY_ALREADY_OWNER)
106 ADD_CONST_PREFIXED(NAME_FLAG_ALLOW_REPLACEMENT)
107 ADD_CONST_PREFIXED(NAME_FLAG_REPLACE_EXISTING)
108 ADD_CONST_PREFIXED(NAME_FLAG_DO_NOT_QUEUE)
110 ADD_CONST_PREFIXED(BUS_SESSION)
111 ADD_CONST_PREFIXED(BUS_SYSTEM)
112 ADD_CONST_PREFIXED(BUS_STARTER)
114 ADD_CONST_PREFIXED(MESSAGE_TYPE_INVALID)
115 ADD_CONST_PREFIXED(MESSAGE_TYPE_METHOD_CALL)
116 ADD_CONST_PREFIXED(MESSAGE_TYPE_METHOD_RETURN)
117 ADD_CONST_PREFIXED(MESSAGE_TYPE_ERROR)
118 ADD_CONST_PREFIXED(MESSAGE_TYPE_SIGNAL)
120 ADD_CONST_PREFIXED(MESSAGE_TYPE_SIGNAL)
122 ADD_CONST_PREFIXED(TYPE_INVALID)
123 ADD_CONST_PREFIXED(TYPE_BYTE)
124 ADD_CONST_PREFIXED(TYPE_BOOLEAN)
125 ADD_CONST_PREFIXED(TYPE_INT16)
126 ADD_CONST_PREFIXED(TYPE_UINT16)
127 ADD_CONST_PREFIXED(TYPE_INT32)
128 ADD_CONST_PREFIXED(TYPE_UINT32)
129 ADD_CONST_PREFIXED(TYPE_INT64)
130 ADD_CONST_PREFIXED(TYPE_UINT64)
131 ADD_CONST_PREFIXED(TYPE_DOUBLE)
132 ADD_CONST_PREFIXED(TYPE_STRING)
133 ADD_CONST_PREFIXED(TYPE_OBJECT_PATH)
134 ADD_CONST_PREFIXED(TYPE_SIGNATURE)
135 ADD_CONST_PREFIXED(TYPE_ARRAY)
136 ADD_CONST_PREFIXED(TYPE_STRUCT)
137 ADD_CONST_VAL("STRUCT_BEGIN", DBUS_STRUCT_BEGIN_CHAR)
138 ADD_CONST_VAL("STRUCT_END", DBUS_STRUCT_END_CHAR)
139 ADD_CONST_PREFIXED(TYPE_VARIANT)
140 ADD_CONST_PREFIXED(TYPE_DICT_ENTRY)
141 ADD_CONST_VAL("DICT_ENTRY_BEGIN", DBUS_DICT_ENTRY_BEGIN_CHAR)
142 ADD_CONST_VAL("DICT_ENTRY_END", DBUS_DICT_ENTRY_END_CHAR)
144 ADD_CONST_PREFIXED(HANDLER_RESULT_HANDLED)
145 ADD_CONST_PREFIXED(HANDLER_RESULT_NOT_YET_HANDLED)
146 ADD_CONST_PREFIXED(HANDLER_RESULT_NEED_MEMORY)
148 if (PyModule_AddStringConstant(this_module, "__docformat__",
149 "restructuredtext") < 0) return;
152 /* vim:set ft=c cino< sw=4 sts=4 et: */