Revision 2345c77c

b/Makefile.objs
372 372

  
373 373
libcacard-y = cac.o event.o vcard.o vreader.o vcard_emul_nss.o vcard_emul_type.o card_7816.o
374 374

  
375
######################################################################
376
# qapi
377

  
378
qapi-nested-y = qapi-visit-core.o
379
qapi-obj-y = $(addprefix qapi/, $(qapi-nested-y))
380

  
375 381
vl.o: QEMU_CFLAGS+=$(GPROF_CFLAGS)
376 382

  
377 383
vl.o: QEMU_CFLAGS+=$(SDL_CFLAGS)
b/configure
3486 3486
DIRS="$DIRS pc-bios/spapr-rtas"
3487 3487
DIRS="$DIRS roms/seabios roms/vgabios"
3488 3488
DIRS="$DIRS fsdev ui"
3489
DIRS="$DIRS qapi"
3489 3490
FILES="Makefile tests/Makefile"
3490 3491
FILES="$FILES tests/cris/Makefile tests/cris/.gdbinit"
3491 3492
FILES="$FILES pc-bios/optionrom/Makefile pc-bios/keymaps"
b/qapi/qapi-types-core.h
1
/*
2
 * Core Definitions for QAPI-generated Types
3
 *
4
 * Copyright IBM, Corp. 2011
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 QAPI_TYPES_CORE_H
15
#define QAPI_TYPES_CORE_H
16

  
17
#include "qemu-common.h"
18
#include "error.h"
19

  
20
#endif
b/qapi/qapi-visit-core.c
1
/*
2
 * Core Definitions for QAPI Visitor Classes
3
 *
4
 * Copyright IBM, Corp. 2011
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
#include "qapi/qapi-visit-core.h"
15

  
16
void visit_start_handle(Visitor *v, void **obj, const char *kind,
17
                        const char *name, Error **errp)
18
{
19
    if (!error_is_set(errp) && v->start_handle) {
20
        v->start_handle(v, obj, kind, name, errp);
21
    }
22
}
23

  
24
void visit_end_handle(Visitor *v, Error **errp)
25
{
26
    if (!error_is_set(errp) && v->end_handle) {
27
        v->end_handle(v, errp);
28
    }
29
}
30

  
31
void visit_start_struct(Visitor *v, void **obj, const char *kind,
32
                        const char *name, size_t size, Error **errp)
33
{
34
    if (!error_is_set(errp)) {
35
        v->start_struct(v, obj, kind, name, size, errp);
36
    }
37
}
38

  
39
void visit_end_struct(Visitor *v, Error **errp)
40
{
41
    if (!error_is_set(errp)) {
42
        v->end_struct(v, errp);
43
    }
44
}
45

  
46
void visit_start_list(Visitor *v, const char *name, Error **errp)
47
{
48
    if (!error_is_set(errp)) {
49
        v->start_list(v, name, errp);
50
    }
51
}
52

  
53
GenericList *visit_next_list(Visitor *v, GenericList **list, Error **errp)
54
{
55
    if (!error_is_set(errp)) {
56
        return v->next_list(v, list, errp);
57
    }
58

  
59
    return 0;
60
}
61

  
62
void visit_end_list(Visitor *v, Error **errp)
63
{
64
    if (!error_is_set(errp)) {
65
        v->end_list(v, errp);
66
    }
67
}
68

  
69
void visit_start_optional(Visitor *v, bool *present, const char *name,
70
                          Error **errp)
71
{
72
    if (!error_is_set(errp) && v->start_optional) {
73
        v->start_optional(v, present, name, errp);
74
    }
75
}
76

  
77
void visit_end_optional(Visitor *v, Error **errp)
78
{
79
    if (!error_is_set(errp) && v->end_optional) {
80
        v->end_optional(v, errp);
81
    }
82
}
83

  
84
void visit_type_enum(Visitor *v, int *obj, const char *strings[],
85
                     const char *kind, const char *name, Error **errp)
86
{
87
    if (!error_is_set(errp)) {
88
        v->type_enum(v, obj, strings, kind, name, errp);
89
    }
90
}
91

  
92
void visit_type_int(Visitor *v, int64_t *obj, const char *name, Error **errp)
93
{
94
    if (!error_is_set(errp)) {
95
        v->type_int(v, obj, name, errp);
96
    }
97
}
98

  
99
void visit_type_bool(Visitor *v, bool *obj, const char *name, Error **errp)
100
{
101
    if (!error_is_set(errp)) {
102
        v->type_bool(v, obj, name, errp);
103
    }
104
}
105

  
106
void visit_type_str(Visitor *v, char **obj, const char *name, Error **errp)
107
{
108
    if (!error_is_set(errp)) {
109
        v->type_str(v, obj, name, errp);
110
    }
111
}
112

  
113
void visit_type_number(Visitor *v, double *obj, const char *name, Error **errp)
114
{
115
    if (!error_is_set(errp)) {
116
        v->type_number(v, obj, name, errp);
117
    }
118
}
b/qapi/qapi-visit-core.h
1
/*
2
 * Core Definitions for QAPI Visitor Classes
3
 *
4
 * Copyright IBM, Corp. 2011
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
#ifndef QAPI_VISITOR_CORE_H
14
#define QAPI_VISITOR_CORE_H
15

  
16
#include "qapi/qapi-types-core.h"
17
#include <stdlib.h>
18

  
19
typedef struct GenericList
20
{
21
    void *value;
22
    struct GenericList *next;
23
} GenericList;
24

  
25
typedef struct Visitor Visitor;
26

  
27
struct Visitor
28
{
29
    /* Must be set */
30
    void (*start_struct)(Visitor *v, void **obj, const char *kind,
31
                         const char *name, size_t size, Error **errp);
32
    void (*end_struct)(Visitor *v, Error **errp);
33

  
34
    void (*start_list)(Visitor *v, const char *name, Error **errp);
35
    GenericList *(*next_list)(Visitor *v, GenericList **list, Error **errp);
36
    void (*end_list)(Visitor *v, Error **errp);
37

  
38
    void (*type_enum)(Visitor *v, int *obj, const char *strings[],
39
                      const char *kind, const char *name, Error **errp);
40

  
41
    void (*type_int)(Visitor *v, int64_t *obj, const char *name, Error **errp);
42
    void (*type_bool)(Visitor *v, bool *obj, const char *name, Error **errp);
43
    void (*type_str)(Visitor *v, char **obj, const char *name, Error **errp);
44
    void (*type_number)(Visitor *v, double *obj, const char *name,
45
                        Error **errp);
46

  
47
    /* May be NULL */
48
    void (*start_optional)(Visitor *v, bool *present, const char *name,
49
                           Error **errp);
50
    void (*end_optional)(Visitor *v, Error **errp);
51

  
52
    void (*start_handle)(Visitor *v, void **obj, const char *kind,
53
                         const char *name, Error **errp);
54
    void (*end_handle)(Visitor *v, Error **errp);
55
};
56

  
57
void visit_start_handle(Visitor *v, void **obj, const char *kind,
58
                        const char *name, Error **errp);
59
void visit_end_handle(Visitor *v, Error **errp);
60
void visit_start_struct(Visitor *v, void **obj, const char *kind,
61
                        const char *name, size_t size, Error **errp);
62
void visit_end_struct(Visitor *v, Error **errp);
63
void visit_start_list(Visitor *v, const char *name, Error **errp);
64
GenericList *visit_next_list(Visitor *v, GenericList **list, Error **errp);
65
void visit_end_list(Visitor *v, Error **errp);
66
void visit_start_optional(Visitor *v, bool *present, const char *name,
67
                          Error **errp);
68
void visit_end_optional(Visitor *v, Error **errp);
69
void visit_type_enum(Visitor *v, int *obj, const char *strings[],
70
                     const char *kind, const char *name, Error **errp);
71
void visit_type_int(Visitor *v, int64_t *obj, const char *name, Error **errp);
72
void visit_type_bool(Visitor *v, bool *obj, const char *name, Error **errp);
73
void visit_type_str(Visitor *v, char **obj, const char *name, Error **errp);
74
void visit_type_number(Visitor *v, double *obj, const char *name, Error **errp);
75

  
76
#endif

Also available in: Unified diff