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
26 #include <structmember.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).");
41 PyTypeObject DBusPyDouble_Type
= {
42 PyObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type
))
54 0, /* tp_as_sequence */
55 0, /* tp_as_mapping */
62 Py_TPFLAGS_DEFAULT
| Py_TPFLAGS_BASETYPE
, /* tp_flags */
63 Double_tp_doc
, /* tp_doc */
66 0, /* tp_richcompare */
67 0, /* tp_weaklistoffset */
73 DEFERRED_ADDRESS(&DBusPythonFloatType
), /* tp_base */
77 0, /* tp_dictoffset */
83 #ifdef WITH_DBUS_FLOAT32
85 PyTypeObject DBusPyFloat_Type
= {
86 PyObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type
))
98 0, /* tp_as_sequence */
99 0, /* tp_as_mapping */
105 0, /* tp_as_buffer */
106 Py_TPFLAGS_DEFAULT
| Py_TPFLAGS_BASETYPE
, /* tp_flags */
107 Float_tp_doc
, /* tp_doc */
110 0, /* tp_richcompare */
111 0, /* tp_weaklistoffset */
117 DEFERRED_ADDRESS(&DBusPythonFloatType
), /* tp_base */
119 0, /* tp_descr_get */
120 0, /* tp_descr_set */
121 0, /* tp_dictoffset */
126 #endif /* defined(WITH_DBUS_FLOAT32) */
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
;
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;