1*2345c77cSMichael Roth /* 2*2345c77cSMichael Roth * Core Definitions for QAPI Visitor Classes 3*2345c77cSMichael Roth * 4*2345c77cSMichael Roth * Copyright IBM, Corp. 2011 5*2345c77cSMichael Roth * 6*2345c77cSMichael Roth * Authors: 7*2345c77cSMichael Roth * Anthony Liguori <aliguori@us.ibm.com> 8*2345c77cSMichael Roth * 9*2345c77cSMichael Roth * This work is licensed under the terms of the GNU LGPL, version 2.1 or later. 10*2345c77cSMichael Roth * See the COPYING.LIB file in the top-level directory. 11*2345c77cSMichael Roth * 12*2345c77cSMichael Roth */ 13*2345c77cSMichael Roth 14*2345c77cSMichael Roth #include "qapi/qapi-visit-core.h" 15*2345c77cSMichael Roth 16*2345c77cSMichael Roth void visit_start_handle(Visitor *v, void **obj, const char *kind, 17*2345c77cSMichael Roth const char *name, Error **errp) 18*2345c77cSMichael Roth { 19*2345c77cSMichael Roth if (!error_is_set(errp) && v->start_handle) { 20*2345c77cSMichael Roth v->start_handle(v, obj, kind, name, errp); 21*2345c77cSMichael Roth } 22*2345c77cSMichael Roth } 23*2345c77cSMichael Roth 24*2345c77cSMichael Roth void visit_end_handle(Visitor *v, Error **errp) 25*2345c77cSMichael Roth { 26*2345c77cSMichael Roth if (!error_is_set(errp) && v->end_handle) { 27*2345c77cSMichael Roth v->end_handle(v, errp); 28*2345c77cSMichael Roth } 29*2345c77cSMichael Roth } 30*2345c77cSMichael Roth 31*2345c77cSMichael Roth void visit_start_struct(Visitor *v, void **obj, const char *kind, 32*2345c77cSMichael Roth const char *name, size_t size, Error **errp) 33*2345c77cSMichael Roth { 34*2345c77cSMichael Roth if (!error_is_set(errp)) { 35*2345c77cSMichael Roth v->start_struct(v, obj, kind, name, size, errp); 36*2345c77cSMichael Roth } 37*2345c77cSMichael Roth } 38*2345c77cSMichael Roth 39*2345c77cSMichael Roth void visit_end_struct(Visitor *v, Error **errp) 40*2345c77cSMichael Roth { 41*2345c77cSMichael Roth if (!error_is_set(errp)) { 42*2345c77cSMichael Roth v->end_struct(v, errp); 43*2345c77cSMichael Roth } 44*2345c77cSMichael Roth } 45*2345c77cSMichael Roth 46*2345c77cSMichael Roth void visit_start_list(Visitor *v, const char *name, Error **errp) 47*2345c77cSMichael Roth { 48*2345c77cSMichael Roth if (!error_is_set(errp)) { 49*2345c77cSMichael Roth v->start_list(v, name, errp); 50*2345c77cSMichael Roth } 51*2345c77cSMichael Roth } 52*2345c77cSMichael Roth 53*2345c77cSMichael Roth GenericList *visit_next_list(Visitor *v, GenericList **list, Error **errp) 54*2345c77cSMichael Roth { 55*2345c77cSMichael Roth if (!error_is_set(errp)) { 56*2345c77cSMichael Roth return v->next_list(v, list, errp); 57*2345c77cSMichael Roth } 58*2345c77cSMichael Roth 59*2345c77cSMichael Roth return 0; 60*2345c77cSMichael Roth } 61*2345c77cSMichael Roth 62*2345c77cSMichael Roth void visit_end_list(Visitor *v, Error **errp) 63*2345c77cSMichael Roth { 64*2345c77cSMichael Roth if (!error_is_set(errp)) { 65*2345c77cSMichael Roth v->end_list(v, errp); 66*2345c77cSMichael Roth } 67*2345c77cSMichael Roth } 68*2345c77cSMichael Roth 69*2345c77cSMichael Roth void visit_start_optional(Visitor *v, bool *present, const char *name, 70*2345c77cSMichael Roth Error **errp) 71*2345c77cSMichael Roth { 72*2345c77cSMichael Roth if (!error_is_set(errp) && v->start_optional) { 73*2345c77cSMichael Roth v->start_optional(v, present, name, errp); 74*2345c77cSMichael Roth } 75*2345c77cSMichael Roth } 76*2345c77cSMichael Roth 77*2345c77cSMichael Roth void visit_end_optional(Visitor *v, Error **errp) 78*2345c77cSMichael Roth { 79*2345c77cSMichael Roth if (!error_is_set(errp) && v->end_optional) { 80*2345c77cSMichael Roth v->end_optional(v, errp); 81*2345c77cSMichael Roth } 82*2345c77cSMichael Roth } 83*2345c77cSMichael Roth 84*2345c77cSMichael Roth void visit_type_enum(Visitor *v, int *obj, const char *strings[], 85*2345c77cSMichael Roth const char *kind, const char *name, Error **errp) 86*2345c77cSMichael Roth { 87*2345c77cSMichael Roth if (!error_is_set(errp)) { 88*2345c77cSMichael Roth v->type_enum(v, obj, strings, kind, name, errp); 89*2345c77cSMichael Roth } 90*2345c77cSMichael Roth } 91*2345c77cSMichael Roth 92*2345c77cSMichael Roth void visit_type_int(Visitor *v, int64_t *obj, const char *name, Error **errp) 93*2345c77cSMichael Roth { 94*2345c77cSMichael Roth if (!error_is_set(errp)) { 95*2345c77cSMichael Roth v->type_int(v, obj, name, errp); 96*2345c77cSMichael Roth } 97*2345c77cSMichael Roth } 98*2345c77cSMichael Roth 99*2345c77cSMichael Roth void visit_type_bool(Visitor *v, bool *obj, const char *name, Error **errp) 100*2345c77cSMichael Roth { 101*2345c77cSMichael Roth if (!error_is_set(errp)) { 102*2345c77cSMichael Roth v->type_bool(v, obj, name, errp); 103*2345c77cSMichael Roth } 104*2345c77cSMichael Roth } 105*2345c77cSMichael Roth 106*2345c77cSMichael Roth void visit_type_str(Visitor *v, char **obj, const char *name, Error **errp) 107*2345c77cSMichael Roth { 108*2345c77cSMichael Roth if (!error_is_set(errp)) { 109*2345c77cSMichael Roth v->type_str(v, obj, name, errp); 110*2345c77cSMichael Roth } 111*2345c77cSMichael Roth } 112*2345c77cSMichael Roth 113*2345c77cSMichael Roth void visit_type_number(Visitor *v, double *obj, const char *name, Error **errp) 114*2345c77cSMichael Roth { 115*2345c77cSMichael Roth if (!error_is_set(errp)) { 116*2345c77cSMichael Roth v->type_number(v, obj, name, errp); 117*2345c77cSMichael Roth } 118*2345c77cSMichael Roth } 119