From patchwork Wed Oct 31 22:35:53 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 196053 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 52D672C0193 for ; Thu, 1 Nov 2012 10:23:58 +1100 (EST) Received: from localhost ([::1]:48901 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TTgv4-0002gr-Ir for incoming@patchwork.ozlabs.org; Wed, 31 Oct 2012 18:37:54 -0400 Received: from eggs.gnu.org ([208.118.235.92]:34738) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TTgu3-00011r-BR for qemu-devel@nongnu.org; Wed, 31 Oct 2012 18:36:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TTgtw-0005nR-55 for qemu-devel@nongnu.org; Wed, 31 Oct 2012 18:36:51 -0400 Received: from mail-ie0-f173.google.com ([209.85.223.173]:33189) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TTgtv-0005k6-Vz for qemu-devel@nongnu.org; Wed, 31 Oct 2012 18:36:44 -0400 Received: by mail-ie0-f173.google.com with SMTP id 17so2893446iea.4 for ; Wed, 31 Oct 2012 15:36:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=zI4/tMTXiGw5tSrAhnqFQcQI6BIxB5s99tiTKiPT3/M=; b=KuNm7bB39FVK0boXfeMzVfFkjf25CUH8FCfBLGpWfkKiBbCin9OgdnRILQkzC9LKJF eCjES58davtQXZ/HoOKwROv+9WgyqQ9V23PcfLHBIAvK0pICsSszxYYccJmN91CCKhfF t2FOj5Qd/xHJNBPLw9NXyz08Mf8yT8G5fyQUKx/mkjHb75qWpAGQQCFap4gO6mQBvO8Z T7GT4hCVSSAPY/Y3t2I+Ge3gxf3c2/zy0MAtOH2aWStV1MybcQEruc1/fwWCL8IUFrmx CQ7VXUV3936a/Z+2WO8qJnp3InFV2Ht341Y5UZiJYu1v/RObSi8y+Nt8JaXZ9ZPL4ZMH fmow== Received: by 10.50.156.232 with SMTP id wh8mr3199527igb.56.1351723003733; Wed, 31 Oct 2012 15:36:43 -0700 (PDT) Received: from loki.morrigu.org (cpe-72-179-62-111.austin.res.rr.com. [72.179.62.111]) by mx.google.com with ESMTPS id hg2sm11556858igc.3.2012.10.31.15.36.42 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 31 Oct 2012 15:36:43 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Wed, 31 Oct 2012 17:35:53 -0500 Message-Id: <1351722972-17801-10-git-send-email-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1351722972-17801-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1351722972-17801-1-git-send-email-mdroth@linux.vnet.ibm.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 209.85.223.173 Cc: kwolf@redhat.com, peter.maydell@linaro.org, aliguori@us.ibm.com, blauwirbel@gmail.com, pbonzini@redhat.com Subject: [Qemu-devel] [PATCH 09/28] qapi: add visitor interfaces for C arrays X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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. Reviewed-by: Paolo Bonzini Signed-off-by: Michael Roth --- qapi/qapi-visit-core.c | 25 +++++++++++++++++++++++++ qapi/qapi-visit-core.h | 8 ++++++++ 2 files changed, 33 insertions(+) diff --git a/qapi/qapi-visit-core.c b/qapi/qapi-visit-core.c index 7a82b63..9a74ed0 100644 --- a/qapi/qapi-visit-core.c +++ b/qapi/qapi-visit-core.c @@ -311,3 +311,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); + } +} diff --git a/qapi/qapi-visit-core.h b/qapi/qapi-visit-core.h index 60aceda..5eb1616 100644 --- a/qapi/qapi-visit-core.h +++ b/qapi/qapi-visit-core.h @@ -43,6 +43,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, @@ -91,5 +95,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