~dannf/qemu-linaro/qemu-highbank-ppa

« back to all changes in this revision

Viewing changes to qapi/qmp-input-visitor.c

  • Committer: Steve Langasek
  • Date: 2012-03-15 21:13:19 UTC
  • mfrom: (0.1.15)
  • Revision ID: steve.langasek@canonical.com-20120315211319-f1j3ot1ihx30b2s9
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
 */
13
13
 
14
14
#include "qmp-input-visitor.h"
 
15
#include "qapi/qapi-visit-impl.h"
15
16
#include "qemu-queue.h"
16
17
#include "qemu-common.h"
17
18
#include "qemu-objects.h"
217
218
    *obj = qfloat_get_double(qobject_to_qfloat(qobj));
218
219
}
219
220
 
220
 
static void qmp_input_type_enum(Visitor *v, int *obj, const char *strings[],
221
 
                                const char *kind, const char *name,
222
 
                                Error **errp)
223
 
{
224
 
    int64_t value = 0;
225
 
    char *enum_str;
226
 
 
227
 
    assert(strings);
228
 
 
229
 
    qmp_input_type_str(v, &enum_str, name, errp);
230
 
    if (error_is_set(errp)) {
231
 
        return;
232
 
    }
233
 
 
234
 
    while (strings[value] != NULL) {
235
 
        if (strcmp(strings[value], enum_str) == 0) {
236
 
            break;
237
 
        }
238
 
        value++;
239
 
    }
240
 
 
241
 
    if (strings[value] == NULL) {
242
 
        error_set(errp, QERR_INVALID_PARAMETER, name ? name : "null");
243
 
        g_free(enum_str);
244
 
        return;
245
 
    }
246
 
 
247
 
    g_free(enum_str);
248
 
    *obj = value;
249
 
}
250
 
 
251
221
static void qmp_input_start_optional(Visitor *v, bool *present,
252
222
                                     const char *name, Error **errp)
253
223
{
262
232
    *present = true;
263
233
}
264
234
 
265
 
static void qmp_input_end_optional(Visitor *v, Error **errp)
266
 
{
267
 
}
268
 
 
269
235
Visitor *qmp_input_get_visitor(QmpInputVisitor *v)
270
236
{
271
237
    return &v->visitor;
288
254
    v->visitor.start_list = qmp_input_start_list;
289
255
    v->visitor.next_list = qmp_input_next_list;
290
256
    v->visitor.end_list = qmp_input_end_list;
291
 
    v->visitor.type_enum = qmp_input_type_enum;
 
257
    v->visitor.type_enum = input_type_enum;
292
258
    v->visitor.type_int = qmp_input_type_int;
293
259
    v->visitor.type_bool = qmp_input_type_bool;
294
260
    v->visitor.type_str = qmp_input_type_str;
295
261
    v->visitor.type_number = qmp_input_type_number;
296
262
    v->visitor.start_optional = qmp_input_start_optional;
297
 
    v->visitor.end_optional = qmp_input_end_optional;
298
263
 
299
264
    v->obj = obj;
300
265
    qobject_incref(v->obj);