]>
Commit | Line | Data |
---|---|---|
f7e6b192 AL |
1 | /* |
2 | * QBool Module | |
3 | * | |
f7e6b192 AL |
4 | * Copyright IBM, Corp. 2009 |
5 | * | |
6 | * Authors: | |
7 | * Anthony Liguori <aliguori@us.ibm.com> | |
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" |
80d71121 | 16 | #include "qobject-internal.h" |
f7e6b192 | 17 | |
f7e6b192 | 18 | /** |
fc48ffc3 | 19 | * qbool_from_bool(): Create a new QBool from a bool |
f7e6b192 AL |
20 | * |
21 | * Return strong reference. | |
22 | */ | |
fc48ffc3 | 23 | QBool *qbool_from_bool(bool value) |
f7e6b192 AL |
24 | { |
25 | QBool *qb; | |
26 | ||
7267c094 | 27 | qb = g_malloc(sizeof(*qb)); |
55e1819c | 28 | qobject_init(QOBJECT(qb), QTYPE_QBOOL); |
f7e6b192 | 29 | qb->value = value; |
f7e6b192 AL |
30 | |
31 | return qb; | |
32 | } | |
33 | ||
34 | /** | |
fc48ffc3 | 35 | * qbool_get_bool(): Get the stored bool |
f7e6b192 | 36 | */ |
fc48ffc3 | 37 | bool qbool_get_bool(const QBool *qb) |
f7e6b192 AL |
38 | { |
39 | return qb->value; | |
40 | } | |
41 | ||
b38dd678 HR |
42 | /** |
43 | * qbool_is_equal(): Test whether the two QBools are equal | |
44 | */ | |
45 | bool qbool_is_equal(const QObject *x, const QObject *y) | |
46 | { | |
7dc847eb | 47 | return qobject_to(QBool, x)->value == qobject_to(QBool, y)->value; |
b38dd678 HR |
48 | } |
49 | ||
f7e6b192 AL |
50 | /** |
51 | * qbool_destroy_obj(): Free all memory allocated by a | |
52 | * QBool object | |
53 | */ | |
55e1819c | 54 | void qbool_destroy_obj(QObject *obj) |
f7e6b192 AL |
55 | { |
56 | assert(obj != NULL); | |
7dc847eb | 57 | g_free(qobject_to(QBool, obj)); |
f7e6b192 | 58 | } |
d709bbf3 MAL |
59 | |
60 | void qbool_unref(QBool *q) | |
61 | { | |
62 | qobject_unref(q); | |
63 | } |