From patchwork Thu Oct 4 17:33:27 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 189304 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 634242C039E for ; Fri, 5 Oct 2012 06:29:43 +1000 (EST) Received: from localhost ([::1]:54909 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TJpK4-00087D-Ps for incoming@patchwork.ozlabs.org; Thu, 04 Oct 2012 13:34:56 -0400 Received: from eggs.gnu.org ([208.118.235.92]:49074) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TJpJF-0006gS-Nw for qemu-devel@nongnu.org; Thu, 04 Oct 2012 13:34:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TJpJE-0000mu-H5 for qemu-devel@nongnu.org; Thu, 04 Oct 2012 13:34:05 -0400 Received: from mail-ob0-f173.google.com ([209.85.214.173]:43670) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TJpJE-0000gj-8o for qemu-devel@nongnu.org; Thu, 04 Oct 2012 13:34:04 -0400 Received: by mail-ob0-f173.google.com with SMTP id wc18so694637obb.4 for ; Thu, 04 Oct 2012 10:34:03 -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=VTP+4S8+2LcPQQ+3C4rAptdC+neVbG5gbQWiV0lcBaE=; b=Tw67022jTpMgIlsVu7Q8sOdav74Z/JcmRo/qHflDH8OdUjgKOAJw3EGNnJhGx6fJtQ 4Pa8ZmMjpkx/wSu+L9jeC1k8jD5QBCQZTd7U8HKmDVZYEcyg/kb2JdZ7ZVSzJFHZT2VJ Fbv9HjIqGZqfDE/3moCmHf4iPjwToeRO3hl3rkPWApmAM0HiukXzESGdssbfQZarH1CA kiBe86pfsu0gUiXI415D50IE8ImZYAxEiGKPv9MotkxPJ2wPiDXPwRgOrtUCEjgNYVPt dJSuQvKTNQD8vWI5p72cANnxWlEz+ZCi602ackQZRu8hDkZ+zno8ANAu8uGrhfhLPDsV ahmg== Received: by 10.182.75.33 with SMTP id z1mr5054679obv.9.1349372043660; Thu, 04 Oct 2012 10:34:03 -0700 (PDT) Received: from loki.austin.ibm.com ([32.97.110.59]) by mx.google.com with ESMTPS id h2sm7131923obn.11.2012.10.04.10.34.02 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 04 Oct 2012 10:34:03 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Thu, 4 Oct 2012 12:33:27 -0500 Message-Id: <1349372021-31212-9-git-send-email-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1349372021-31212-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1349372021-31212-1-git-send-email-mdroth@linux.vnet.ibm.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.85.214.173 Cc: kwolf@redhat.com, peter.maydell@linaro.org, aliguori@us.ibm.com, blauwirbel@gmail.com, pbonzini@redhat.com, eblake@redhat.com Subject: [Qemu-devel] [PATCH v3 08/22] 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. 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