mirror of
https://github.com/yuzu-emu/unicorn.git
synced 2025-01-11 03:45:45 +00:00
3e8b0c66a3
Commit 240f64b made all qobject input visitors created outside tests strict, except for the one in object_property_set_qobject(). That one was left behind only because Eric couldn't spare the time to figure out whether making it strict would break anything, with a TODO comment. Time to resolve it. Strict makes a difference only for otherwise successful visits of QAPI structs or unions. Let's examine what the callers of object_property_set_qobject() visit: * object_property_set_str(), object_property_set_bool(), object_property_set_int() visit a QString, QBool, QInt, respectively. Strictness can't matter. * qmp_qom_set visits its @value argument. Comes straight from QMP and can be anything ('any' in the QAPI schema). Strictness matters when the property's set() method visits a struct or union QAPI type. No such methods exist, thus switching to strict can't break anything. If we acquire such methods in the future, we'll *want* the visitor to be strict, so that unexpected members get rejected as they should be. Switch to strict. Backports commit 05601ed2de60df0e344d6b783a6bc0c1ff2b5d1f from qemu
46 lines
1.2 KiB
C
46 lines
1.2 KiB
C
/*
|
|
* QEMU Object Model - QObject wrappers
|
|
*
|
|
* Copyright (C) 2012 Red Hat, Inc.
|
|
*
|
|
* Author: Paolo Bonzini <pbonzini@redhat.com>
|
|
*
|
|
* This work is licensed under the terms of the GNU GPL, version 2 or later.
|
|
* See the COPYING file in the top-level directory.
|
|
*/
|
|
|
|
#include "qemu/osdep.h"
|
|
#include "qapi/error.h"
|
|
#include "qemu-common.h"
|
|
#include "qom/object.h"
|
|
#include "qom/qom-qobject.h"
|
|
#include "qapi/visitor.h"
|
|
#include "qapi/qobject-input-visitor.h"
|
|
#include "qapi/qobject-output-visitor.h"
|
|
|
|
void object_property_set_qobject(struct uc_struct *uc, Object *obj, QObject *value,
|
|
const char *name, Error **errp)
|
|
{
|
|
Visitor *v;
|
|
v = qobject_input_visitor_new(value, true);
|
|
object_property_set(uc, obj, v, name, errp);
|
|
visit_free(v);
|
|
}
|
|
|
|
QObject *object_property_get_qobject(struct uc_struct *uc, Object *obj, const char *name,
|
|
Error **errp)
|
|
{
|
|
QObject *ret = NULL;
|
|
Error *local_err = NULL;
|
|
Visitor *v;
|
|
|
|
v = qobject_output_visitor_new(&ret);
|
|
object_property_get(uc, obj, v, name, &local_err);
|
|
if (!local_err) {
|
|
visit_complete(v, &ret);
|
|
}
|
|
error_propagate(errp, local_err);
|
|
visit_free(v);
|
|
return ret;
|
|
}
|