]>
Commit | Line | Data |
---|---|---|
f7e6b192 AL |
1 | /* |
2 | * QBool Module | |
3 | * | |
f7e6b192 AL |
4 | * Copyright IBM, Corp. 2009 |
5 | * | |
6 | * Authors: | |
7 | * Anthony Liguori <[email protected]> | |
8 | * | |
9 | * This work is licensed under the terms of the GNU LGPL, version 2.1 or later. | |
10 | * See the COPYING.LIB file in the top-level directory. | |
11 | * | |
12 | */ | |
13 | ||
f2ad72b3 | 14 | #include "qemu/osdep.h" |
7b1b5d19 | 15 | #include "qapi/qmp/qbool.h" |
f7e6b192 | 16 | |
f7e6b192 | 17 | /** |
fc48ffc3 | 18 | * qbool_from_bool(): Create a new QBool from a bool |
f7e6b192 AL |
19 | * |
20 | * Return strong reference. | |
21 | */ | |
fc48ffc3 | 22 | QBool *qbool_from_bool(bool value) |
f7e6b192 AL |
23 | { |
24 | QBool *qb; | |
25 | ||
7267c094 | 26 | qb = g_malloc(sizeof(*qb)); |
55e1819c | 27 | qobject_init(QOBJECT(qb), QTYPE_QBOOL); |
f7e6b192 | 28 | qb->value = value; |
f7e6b192 AL |
29 | |
30 | return qb; | |
31 | } | |
32 | ||
33 | /** | |
fc48ffc3 | 34 | * qbool_get_bool(): Get the stored bool |
f7e6b192 | 35 | */ |
fc48ffc3 | 36 | bool qbool_get_bool(const QBool *qb) |
f7e6b192 AL |
37 | { |
38 | return qb->value; | |
39 | } | |
40 | ||
b38dd678 HR |
41 | /** |
42 | * qbool_is_equal(): Test whether the two QBools are equal | |
43 | */ | |
44 | bool qbool_is_equal(const QObject *x, const QObject *y) | |
45 | { | |
7dc847eb | 46 | return qobject_to(QBool, x)->value == qobject_to(QBool, y)->value; |
b38dd678 HR |
47 | } |
48 | ||
f7e6b192 AL |
49 | /** |
50 | * qbool_destroy_obj(): Free all memory allocated by a | |
51 | * QBool object | |
52 | */ | |
55e1819c | 53 | void qbool_destroy_obj(QObject *obj) |
f7e6b192 AL |
54 | { |
55 | assert(obj != NULL); | |
7dc847eb | 56 | g_free(qobject_to(QBool, obj)); |
f7e6b192 | 57 | } |