Revision f7e6b192

b/Makefile
137 137
obj-y += qemu-char.o aio.o savevm.o
138 138
obj-y += msmouse.o ps2.o
139 139
obj-y += qdev.o qdev-properties.o
140
obj-y += qint.o qstring.o qdict.o qlist.o qfloat.o
140
obj-y += qint.o qstring.o qdict.o qlist.o qfloat.o qbool.o
141 141
obj-y += qemu-config.o block-migration.o
142 142

  
143 143
obj-$(CONFIG_BRLAPI) += baum.o
b/qbool.c
1
/*
2
 * QBool Module
3
 *
4
 * Copyright (C) 2009 Red Hat Inc.
5
 *
6
 * Authors:
7
 *  Luiz Capitulino <lcapitulino@redhat.com>
8
 *
9
 * This work is licensed under the terms of the GNU GPL, version 2.  See
10
 * the COPYING file in the top-level directory.
11
 *
12
 * Copyright IBM, Corp. 2009
13
 *
14
 * Authors:
15
 *  Anthony Liguori   <aliguori@us.ibm.com>
16
 *
17
 * This work is licensed under the terms of the GNU LGPL, version 2.1 or later.
18
 * See the COPYING.LIB file in the top-level directory.
19
 *
20
 */
21

  
22
#include "qbool.h"
23
#include "qobject.h"
24
#include "qemu-common.h"
25

  
26
static void qbool_destroy_obj(QObject *obj);
27

  
28
static const QType qbool_type = {
29
    .code = QTYPE_QBOOL,
30
    .destroy = qbool_destroy_obj,
31
};
32

  
33
/**
34
 * qbool_from_int(): Create a new QBool from an int
35
 *
36
 * Return strong reference.
37
 */
38
QBool *qbool_from_int(int value)
39
{
40
    QBool *qb;
41

  
42
    qb = qemu_malloc(sizeof(*qb));
43
    qb->value = value;
44
    QOBJECT_INIT(qb, &qbool_type);
45

  
46
    return qb;
47
}
48

  
49
/**
50
 * qbool_get_int(): Get the stored int
51
 */
52
int qbool_get_int(const QBool *qb)
53
{
54
    return qb->value;
55
}
56

  
57
/**
58
 * qobject_to_qbool(): Convert a QObject into a QBool
59
 */
60
QBool *qobject_to_qbool(const QObject *obj)
61
{
62
    if (qobject_type(obj) != QTYPE_QBOOL)
63
        return NULL;
64

  
65
    return container_of(obj, QBool, base);
66
}
67

  
68
/**
69
 * qbool_destroy_obj(): Free all memory allocated by a
70
 * QBool object
71
 */
72
static void qbool_destroy_obj(QObject *obj)
73
{
74
    assert(obj != NULL);
75
    qemu_free(qobject_to_qbool(obj));
76
}
b/qbool.h
1
/*
2
 * QBool Module
3
 *
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

  
14
#ifndef QBOOL_H
15
#define QBOOL_H
16

  
17
#include <stdint.h>
18
#include "qobject.h"
19

  
20
typedef struct QBool {
21
    QObject_HEAD;
22
    int value;
23
} QBool;
24

  
25
QBool *qbool_from_int(int value);
26
int qbool_get_int(const QBool *qb);
27
QBool *qobject_to_qbool(const QObject *obj);
28

  
29
#endif /* QBOOL_H */
b/qobject.h
42 42
    QTYPE_QDICT,
43 43
    QTYPE_QLIST,
44 44
    QTYPE_QFLOAT,
45
    QTYPE_QBOOL,
45 46
} qtype_code;
46 47

  
47 48
struct QObject;

Also available in: Unified diff