mirror of
https://github.com/yuzu-emu/unicorn.git
synced 2025-06-24 20:21:21 +00:00
qapi: Use QNull for a more regular visit_type_null()
Make visit_type_null() take an @obj argument like its buddies. This helps keep the next commit simple. Backports commit d2f95f4d482374485234790a6fc3cca29ebb7355 from qemu
This commit is contained in:
parent
3fd0ff8aa7
commit
4a7abec7c9
|
@ -104,7 +104,8 @@ struct Visitor
|
||||||
Error **errp);
|
Error **errp);
|
||||||
|
|
||||||
/* Must be set to visit explicit null values. */
|
/* Must be set to visit explicit null values. */
|
||||||
void (*type_null)(Visitor *v, const char *name, Error **errp);
|
void (*type_null)(Visitor *v, const char *name, QNull **obj,
|
||||||
|
Error **errp);
|
||||||
|
|
||||||
/* Must be set for input visitors to visit structs, optional otherwise.
|
/* Must be set for input visitors to visit structs, optional otherwise.
|
||||||
The core takes care of the return type in the public interface. */
|
The core takes care of the return type in the public interface. */
|
||||||
|
|
|
@ -618,10 +618,10 @@ void visit_type_any(Visitor *v, const char *name, QObject **obj, Error **errp);
|
||||||
* @name expresses the relationship of the null value to its parent
|
* @name expresses the relationship of the null value to its parent
|
||||||
* container; see the general description of @name above.
|
* container; see the general description of @name above.
|
||||||
*
|
*
|
||||||
* Unlike all other visit_type_* functions, no obj parameter is
|
* @obj must be non-NULL. Input visitors set *@obj to the value;
|
||||||
* needed; rather, this is a witness that an explicit null value is
|
* other visitors ignore *@obj.
|
||||||
* expected rather than any other type.
|
|
||||||
*/
|
*/
|
||||||
void visit_type_null(Visitor *v, const char *name, Error **errp);
|
void visit_type_null(Visitor *v, const char *name, QNull **obj,
|
||||||
|
Error **errp);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -127,12 +127,13 @@ static void qapi_clone_type_number(Visitor *v, const char *name, double *obj,
|
||||||
/* Value was already cloned by g_memdup() */
|
/* Value was already cloned by g_memdup() */
|
||||||
}
|
}
|
||||||
|
|
||||||
static void qapi_clone_type_null(Visitor *v, const char *name, Error **errp)
|
static void qapi_clone_type_null(Visitor *v, const char *name, QNull **obj,
|
||||||
|
Error **errp)
|
||||||
{
|
{
|
||||||
QapiCloneVisitor *qcv = to_qcv(v);
|
QapiCloneVisitor *qcv = to_qcv(v);
|
||||||
|
|
||||||
assert(qcv->depth);
|
assert(qcv->depth);
|
||||||
/* Nothing to do */
|
*obj = qnull();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void qapi_clone_free(Visitor *v)
|
static void qapi_clone_free(Visitor *v)
|
||||||
|
|
|
@ -103,8 +103,12 @@ static void qapi_dealloc_type_anything(Visitor *v, const char *name,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void qapi_dealloc_type_null(Visitor *v, const char *name, Error **errp)
|
static void qapi_dealloc_type_null(Visitor *v, const char *name,
|
||||||
|
QNull **obj, Error **errp)
|
||||||
{
|
{
|
||||||
|
if (obj) {
|
||||||
|
QDECREF(*obj);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void qapi_dealloc_free(Visitor *v)
|
static void qapi_dealloc_free(Visitor *v)
|
||||||
|
|
|
@ -280,9 +280,10 @@ void visit_type_any(Visitor *v, const char *name, QObject **obj, Error **errp)
|
||||||
error_propagate(errp, err);
|
error_propagate(errp, err);
|
||||||
}
|
}
|
||||||
|
|
||||||
void visit_type_null(Visitor *v, const char *name, Error **errp)
|
void visit_type_null(Visitor *v, const char *name, QNull **obj,
|
||||||
|
Error **errp)
|
||||||
{
|
{
|
||||||
v->type_null(v, name, errp);
|
v->type_null(v, name, obj, errp);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void output_type_enum(Visitor *v, const char *name, int *obj,
|
static void output_type_enum(Visitor *v, const char *name, int *obj,
|
||||||
|
|
|
@ -465,11 +465,13 @@ static void qobject_input_type_any(Visitor *v, const char *name, QObject **obj,
|
||||||
*obj = qobj;
|
*obj = qobj;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void qobject_input_type_null(Visitor *v, const char *name, Error **errp)
|
static void qobject_input_type_null(Visitor *v, const char *name,
|
||||||
|
QNull **obj, Error **errp)
|
||||||
{
|
{
|
||||||
QObjectInputVisitor *qiv = to_qiv(v);
|
QObjectInputVisitor *qiv = to_qiv(v);
|
||||||
QObject *qobj = qobject_input_get_object(qiv, name, true, errp);
|
QObject *qobj = qobject_input_get_object(qiv, name, true, errp);
|
||||||
|
|
||||||
|
*obj = NULL;
|
||||||
if (!qobj) {
|
if (!qobj) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -477,7 +479,10 @@ static void qobject_input_type_null(Visitor *v, const char *name, Error **errp)
|
||||||
if (qobject_type(qobj) != QTYPE_QNULL) {
|
if (qobject_type(qobj) != QTYPE_QNULL) {
|
||||||
error_setg(errp, QERR_INVALID_PARAMETER_TYPE,
|
error_setg(errp, QERR_INVALID_PARAMETER_TYPE,
|
||||||
full_name(qiv, name), "null");
|
full_name(qiv, name), "null");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
*obj = qnull();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void qobject_input_optional(Visitor *v, const char *name, bool *present)
|
static void qobject_input_optional(Visitor *v, const char *name, bool *present)
|
||||||
|
|
|
@ -193,7 +193,8 @@ static void qobject_output_type_any(Visitor *v, const char *name, QObject **obj,
|
||||||
qobject_output_add_obj(qov, name, *obj);
|
qobject_output_add_obj(qov, name, *obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void qobject_output_type_null(Visitor *v, const char *name, Error **errp)
|
static void qobject_output_type_null(Visitor *v, const char *name,
|
||||||
|
QNull **obj, Error **errp)
|
||||||
{
|
{
|
||||||
QObjectOutputVisitor *qov = to_qov(v);
|
QObjectOutputVisitor *qov = to_qov(v);
|
||||||
qobject_output_add(qov, name, qnull());
|
qobject_output_add(qov, name, qnull());
|
||||||
|
|
|
@ -310,14 +310,20 @@ static void parse_type_number(Visitor *v, const char *name, double *obj,
|
||||||
*obj = val;
|
*obj = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void parse_type_null(Visitor *v, const char *name, Error **errp)
|
static void parse_type_null(Visitor *v, const char *name, QNull **obj,
|
||||||
|
Error **errp)
|
||||||
{
|
{
|
||||||
StringInputVisitor *siv = to_siv(v);
|
StringInputVisitor *siv = to_siv(v);
|
||||||
|
|
||||||
|
*obj = NULL;
|
||||||
|
|
||||||
if (!siv->string || siv->string[0]) {
|
if (!siv->string || siv->string[0]) {
|
||||||
error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : "null",
|
error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : "null",
|
||||||
"null");
|
"null");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
*obj = qnull();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void string_input_free(Visitor *v)
|
static void string_input_free(Visitor *v)
|
||||||
|
|
Loading…
Reference in a new issue