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 library is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU Lesser General Public License as published by
9 * the Free Software Foundation; either version 2.1 of the License, or
10 * (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public License
18 * along with this library; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 #include <structmember.h>
28 #include "dbus_bindings-internal.h"
29 #include "types-internal.h"
31 PyDoc_STRVAR(Double_tp_doc
,
32 "A double-precision floating point number (a subtype of float).");
34 #ifdef WITH_DBUS_FLOAT32
35 PyDoc_STRVAR(Float_tp_doc
,
36 "A single-precision floating point number (a subtype of float).");
39 PyTypeObject DBusPyDouble_Type
= {
40 PyObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type
))
52 0, /* tp_as_sequence */
53 0, /* tp_as_mapping */
60 Py_TPFLAGS_DEFAULT
| Py_TPFLAGS_BASETYPE
, /* tp_flags */
61 Double_tp_doc
, /* tp_doc */
64 0, /* tp_richcompare */
65 0, /* tp_weaklistoffset */
71 DEFERRED_ADDRESS(&DBusPythonFloatType
), /* tp_base */
75 0, /* tp_dictoffset */
81 #ifdef WITH_DBUS_FLOAT32
83 PyTypeObject DBusPyFloat_Type
= {
84 PyObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type
))
96 0, /* tp_as_sequence */
97 0, /* tp_as_mapping */
103 0, /* tp_as_buffer */
104 Py_TPFLAGS_DEFAULT
| Py_TPFLAGS_BASETYPE
, /* tp_flags */
105 Float_tp_doc
, /* tp_doc */
108 0, /* tp_richcompare */
109 0, /* tp_weaklistoffset */
115 DEFERRED_ADDRESS(&DBusPythonFloatType
), /* tp_base */
117 0, /* tp_descr_get */
118 0, /* tp_descr_set */
119 0, /* tp_dictoffset */
124 #endif /* defined(WITH_DBUS_FLOAT32) */
127 dbus_py_init_float_types(void)
129 DBusPyDouble_Type
.tp_base
= &DBusPyFloatBase_Type
;
130 if (PyType_Ready(&DBusPyDouble_Type
) < 0) return 0;
131 DBusPyDouble_Type
.tp_print
= NULL
;
133 #ifdef WITH_DBUS_FLOAT32
134 DBusPyFloat_Type
.tp_base
= &DBusPyFloatBase_Type
;
135 if (PyType_Ready(&DBusPyFloat_Type
) < 0) return 0;
136 DBusPyFloat_Type
.tp_print
= NULL
;
143 dbus_py_insert_float_types(PyObject
*this_module
)
145 Py_INCREF(&DBusPyDouble_Type
);
146 if (PyModule_AddObject(this_module
, "Double",
147 (PyObject
*)&DBusPyDouble_Type
) < 0) return 0;
148 #ifdef WITH_DBUS_FLOAT32
149 Py_INCREF(&DBusPyFloat_Type
);
150 if (PyModule_AddObject(this_module
, "Float",
151 (PyObject
*)&DBusPyFloat_Type
) < 0) return 0;