From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:58049) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sc0Xe-0004tD-W2 for qemu-devel@nongnu.org; Tue, 05 Jun 2012 16:39:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Sc0Xc-0006ZX-E1 for qemu-devel@nongnu.org; Tue, 05 Jun 2012 16:39:50 -0400 Received: from mail-pb0-f45.google.com ([209.85.160.45]:42539) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sc0Xc-0006ZK-56 for qemu-devel@nongnu.org; Tue, 05 Jun 2012 16:39:48 -0400 Received: by pbbro12 with SMTP id ro12so8625122pbb.4 for ; Tue, 05 Jun 2012 13:39:46 -0700 (PDT) Sender: Paolo Bonzini Message-ID: <4FCE6E8C.8080708@redhat.com> Date: Tue, 05 Jun 2012 22:39:40 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: <1337683555-13301-1-git-send-email-lersek@redhat.com> <1337683555-13301-3-git-send-email-lersek@redhat.com> In-Reply-To: <1337683555-13301-3-git-send-email-lersek@redhat.com> Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 02/16] qapi: introduce "size" type List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Laszlo Ersek Cc: qemu-devel@nongnu.org Il 22/05/2012 12:45, Laszlo Ersek ha scritto: > Signed-off-by: Laszlo Ersek > --- > qapi/qapi-visit-core.h | 4 ++++ > qapi/qapi-visit-core.c | 7 +++++++ > scripts/qapi.py | 2 +- > 3 files changed, 12 insertions(+), 1 deletions(-) > > diff --git a/qapi/qapi-visit-core.h b/qapi/qapi-visit-core.h > index e850746..bab2fec 100644 > --- a/qapi/qapi-visit-core.h > +++ b/qapi/qapi-visit-core.h > @@ -39,6 +39,9 @@ struct Visitor > const char *kind, const char *name, Error **errp); > > void (*type_int)(Visitor *v, int64_t *obj, const char *name, Error **errp); > + /* visit_type_size() falls back to (*type_int)() if type_size is unset */ > + void (*type_size)(Visitor *v, int64_t *obj, const char *name, > + Error **errp); > void (*type_bool)(Visitor *v, bool *obj, const char *name, Error **errp); > void (*type_str)(Visitor *v, char **obj, const char *name, Error **errp); > void (*type_number)(Visitor *v, double *obj, const char *name, > @@ -69,6 +72,7 @@ void visit_end_optional(Visitor *v, Error **errp); > void visit_type_enum(Visitor *v, int *obj, const char *strings[], > const char *kind, const char *name, Error **errp); > void visit_type_int(Visitor *v, int64_t *obj, const char *name, Error **errp); > +void visit_type_size(Visitor *v, int64_t *obj, const char *name, Error **errp); > void visit_type_bool(Visitor *v, bool *obj, const char *name, Error **errp); > void visit_type_str(Visitor *v, char **obj, const char *name, Error **errp); > void visit_type_number(Visitor *v, double *obj, const char *name, Error **errp); > diff --git a/qapi/qapi-visit-core.c b/qapi/qapi-visit-core.c > index df1ed5c..ea31cf5 100644 > --- a/qapi/qapi-visit-core.c > +++ b/qapi/qapi-visit-core.c > @@ -95,6 +95,13 @@ void visit_type_int(Visitor *v, int64_t *obj, const char *name, Error **errp) > } > } > > +void visit_type_size(Visitor *v, int64_t *obj, const char *name, Error **errp) > +{ > + if (!error_is_set(errp)) { > + (v->type_size ? v->type_size : v->type_int)(v, obj, name, errp); > + } > +} > + > void visit_type_bool(Visitor *v, bool *obj, const char *name, Error **errp) > { > if (!error_is_set(errp)) { > diff --git a/scripts/qapi.py b/scripts/qapi.py > index e062336..6aebb0f 100644 > --- a/scripts/qapi.py > +++ b/scripts/qapi.py > @@ -157,7 +157,7 @@ def is_enum(name): > def c_type(name): > if name == 'str': > return 'char *' > - elif name == 'int': > + elif name == 'int' or name == 'size': > return 'int64_t' > elif name == 'bool': > return 'bool' Reviewed-by: Paolo Bonzini Paolo