Remove from EXTRA_DIST files we'd already be distributing
[dbus-python-phuang.git] / _dbus_bindings / float.c
blob72afec1e773cfec50a2b5f4c13cee7f810b74a49
1 /* Simple D-Bus types: Double and (with appropriate #defines) Float
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 #include <stdint.h>
30 #include "dbus_bindings-internal.h"
31 #include "types-internal.h"
33 PyDoc_STRVAR(Double_tp_doc,
34 "A double-precision floating point number (a subtype of float).");
36 #ifdef WITH_DBUS_FLOAT32
37 PyDoc_STRVAR(Float_tp_doc,
38 "A single-precision floating point number (a subtype of float).");
39 #endif
41 PyTypeObject DBusPyDouble_Type = {
42 PyObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type))
44 "dbus.Double",
47 0, /* tp_dealloc */
48 0, /* tp_print */
49 0, /* tp_getattr */
50 0, /* tp_setattr */
51 0, /* tp_compare */
52 0, /* tp_repr */
53 0, /* tp_as_number */
54 0, /* tp_as_sequence */
55 0, /* tp_as_mapping */
56 0, /* tp_hash */
57 0, /* tp_call */
58 0, /* tp_str */
59 0, /* tp_getattro */
60 0, /* tp_setattro */
61 0, /* tp_as_buffer */
62 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
63 Double_tp_doc, /* tp_doc */
64 0, /* tp_traverse */
65 0, /* tp_clear */
66 0, /* tp_richcompare */
67 0, /* tp_weaklistoffset */
68 0, /* tp_iter */
69 0, /* tp_iternext */
70 0, /* tp_methods */
71 0, /* tp_members */
72 0, /* tp_getset */
73 DEFERRED_ADDRESS(&DBusPythonFloatType), /* tp_base */
74 0, /* tp_dict */
75 0, /* tp_descr_get */
76 0, /* tp_descr_set */
77 0, /* tp_dictoffset */
78 0, /* tp_init */
79 0, /* tp_alloc */
80 0, /* tp_new */
83 #ifdef WITH_DBUS_FLOAT32
85 PyTypeObject DBusPyFloat_Type = {
86 PyObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type))
88 "dbus.Float",
91 0, /* tp_dealloc */
92 0, /* tp_print */
93 0, /* tp_getattr */
94 0, /* tp_setattr */
95 0, /* tp_compare */
96 0, /* tp_repr */
97 0, /* tp_as_number */
98 0, /* tp_as_sequence */
99 0, /* tp_as_mapping */
100 0, /* tp_hash */
101 0, /* tp_call */
102 0, /* tp_str */
103 0, /* tp_getattro */
104 0, /* tp_setattro */
105 0, /* tp_as_buffer */
106 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
107 Float_tp_doc, /* tp_doc */
108 0, /* tp_traverse */
109 0, /* tp_clear */
110 0, /* tp_richcompare */
111 0, /* tp_weaklistoffset */
112 0, /* tp_iter */
113 0, /* tp_iternext */
114 0, /* tp_methods */
115 0, /* tp_members */
116 0, /* tp_getset */
117 DEFERRED_ADDRESS(&DBusPythonFloatType), /* tp_base */
118 0, /* tp_dict */
119 0, /* tp_descr_get */
120 0, /* tp_descr_set */
121 0, /* tp_dictoffset */
122 0, /* tp_init */
123 0, /* tp_alloc */
124 0, /* tp_new */
126 #endif /* defined(WITH_DBUS_FLOAT32) */
128 dbus_bool_t
129 dbus_py_init_float_types(void)
131 DBusPyDouble_Type.tp_base = &DBusPyFloatBase_Type;
132 if (PyType_Ready(&DBusPyDouble_Type) < 0) return 0;
133 DBusPyDouble_Type.tp_print = NULL;
135 #ifdef WITH_DBUS_FLOAT32
136 DBusPyFloat_Type.tp_base = &DBusPyFloatBase_Type;
137 if (PyType_Ready(&DBusPyFloat_Type) < 0) return 0;
138 DBusPyFloat_Type.tp_print = NULL;
139 #endif
141 return 1;
144 dbus_bool_t
145 dbus_py_insert_float_types(PyObject *this_module)
147 Py_INCREF(&DBusPyDouble_Type);
148 if (PyModule_AddObject(this_module, "Double",
149 (PyObject *)&DBusPyDouble_Type) < 0) return 0;
150 #ifdef WITH_DBUS_FLOAT32
151 Py_INCREF(&DBusPyFloat_Type);
152 if (PyModule_AddObject(this_module, "Float",
153 (PyObject *)&DBusPyFloat_Type) < 0) return 0;
154 #endif
156 return 1;