Received: from eggs.gnu.org ([208.118.235.92]:36499) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UFc52-0007MT-Cr for qemu-devel@nongnu.org; Tue, 12 Mar 2013 23:10:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UFc4q-0002RF-7K for qemu-devel@nongnu.org; Tue, 12 Mar 2013 23:10:16 -0400 Received: from e7.ny.us.ibm.com ([32.97.182.137]:33861) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UFc4q-0002PJ-4P for qemu-devel@nongnu.org; Tue, 12 Mar 2013 23:10:04 -0400 Received: from /spool/local by e7.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 12 Mar 2013 23:10:03 -0400 Received: from d01relay01.pok.ibm.com (d01relay01.pok.ibm.com [9.56.227.233]) by d01dlp02.pok.ibm.com (Postfix) with ESMTP id D7C916E8044 for ; Tue, 12 Mar 2013 23:09:58 -0400 (EDT) Received: from d01av05.pok.ibm.com (d01av05.pok.ibm.com [9.56.224.195]) by d01relay01.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r2D3A0pZ182416 for ; Tue, 12 Mar 2013 23:10:00 -0400 Received: from d01av05.pok.ibm.com (loopback [127.0.0.1]) by d01av05.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r2D3A0Lw009516 for ; Tue, 12 Mar 2013 23:10:00 -0400 From: Joel Schopp Date: Tue, 12 Mar 2013 22:09:35 -0500 Message-Id: <1363144182-1016-3-git-send-email-jschopp@linux.vnet.ibm.com> In-Reply-To: <1363144182-1016-1-git-send-email-jschopp@linux.vnet.ibm.com> References: <1363144182-1016-1-git-send-email-jschopp@linux.vnet.ibm.com> Subject: [Qemu-devel] [PATCH 2/9] qapi_c_arrays.diff List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Joel Schopp , Paolo Bonzini , Michael Roth , Michael Tsirkin Forward ported Mike's previously sent patch (see http://lists.gnu.org/archive/html/qemu-devel/2012-10/msg05782.html ) in my series since it impelments a qapi array interface the ASN.1 BER visitor needs. Generally these will be serialized into lists, but the representation can be of any form so long as it can be deserialized into a single-dimension C array. Cc: Michael Tsirkin Cc: Paolo Bonzini Signed-off-by: Michael Roth Signed-off-by: Joel Schopp --- include/qapi/visitor-impl.h | 4 ++++ include/qapi/visitor.h | 4 ++++ qapi/qapi-visit-core.c | 25 +++++++++++++++++++++++++ 3 files changed, 33 insertions(+) diff --git a/include/qapi/visitor-impl.h b/include/qapi/visitor-impl.h index 5159964..79fe039 100644 --- a/include/qapi/visitor-impl.h +++ b/include/qapi/visitor-impl.h @@ -34,6 +34,10 @@ struct Visitor void (*type_str)(Visitor *v, char **obj, const char *name, Error **errp); void (*type_number)(Visitor *v, double *obj, const char *name, Error **errp); + void (*start_carray)(Visitor *v, void **obj, const char *name, + size_t elem_count, size_t elem_size, Error **errp); + void (*next_carray)(Visitor *v, Error **errp); + void (*end_carray)(Visitor *v, Error **errp); /* May be NULL */ void (*start_optional)(Visitor *v, bool *present, const char *name, diff --git a/include/qapi/visitor.h b/include/qapi/visitor.h index 1fef18c..49f411f 100644 --- a/include/qapi/visitor.h +++ b/include/qapi/visitor.h @@ -51,5 +51,9 @@ void visit_type_size(Visitor *v, uint64_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); +void visit_start_carray(Visitor *v, void **obj, const char *name, + size_t elem_count, size_t elem_size, Error **errp); +void visit_next_carray(Visitor *v, Error **errp); +void visit_end_carray(Visitor *v, Error **errp); #endif diff --git a/qapi/qapi-visit-core.c b/qapi/qapi-visit-core.c index 401ee6e..d9982f8 100644 --- a/qapi/qapi-visit-core.c +++ b/qapi/qapi-visit-core.c @@ -313,3 +313,28 @@ void input_type_enum(Visitor *v, int *obj, const char *strings[], g_free(enum_str); *obj = value; } + +void visit_start_carray(Visitor *v, void **obj, const char *name, + size_t elem_count, size_t elem_size, Error **errp) +{ + g_assert(v->start_carray); + if (!error_is_set(errp)) { + v->start_carray(v, obj, name, elem_count, elem_size, errp); + } +} + +void visit_next_carray(Visitor *v, Error **errp) +{ + g_assert(v->next_carray); + if (!error_is_set(errp)) { + v->next_carray(v, errp); + } +} + +void visit_end_carray(Visitor *v, Error **errp) +{ + g_assert(v->end_carray); + if (!error_is_set(errp)) { + v->end_carray(v, errp); + } +} -- 1.7.10.4