From nobody Tue Feb 10 05:09:49 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1579796445; cv=none; d=zohomail.com; s=zohoarc; b=VmdQKt4ioa/d2mG/y0dpYrEwwl5MgiyLbW6Vzgi1Xfd1RvWc4U9tDCM0GOi+fKnfXEQDWtvZOTrqmyvg4QfqGBCbdMpr7VSXB+7cFemac+x3XVFIUMyn+YhBExMZHa5VcoN0CQ2Ex4mKIrkcfkeW/ENTpVId8jFtf6GJxa04FSs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1579796445; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=cNSBVvuhqWAGJYrIfEMAuXBTzy9mOBWpnwL0MQDgTyk=; b=UlWW57x0joAoyR70+3cktcFwotbNiIQUf0gN9OsDjFDTEAlBP5CEC2DCqo592HB6yGs0hbPQ6h7/qLhO3gbLKW+Lk5RQJjRWonlxcj5XuCYPt9RnzqPtDdVHIX6/WWY+qaRemYTtA8ewTZxeCP1E2B2dKKNySRyXHJCZ5uyXJks= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1579796445901275.84507050900993; Thu, 23 Jan 2020 08:20:45 -0800 (PST) Received: from localhost ([::1]:60242 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iufDo-0002LE-HB for importer@patchew.org; Thu, 23 Jan 2020 11:20:44 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51684) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iucrd-0005M9-71 for qemu-devel@nongnu.org; Thu, 23 Jan 2020 08:49:42 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iucrc-00048G-0d for qemu-devel@nongnu.org; Thu, 23 Jan 2020 08:49:41 -0500 Received: from mail-wr1-x433.google.com ([2a00:1450:4864:20::433]:45385) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iucrb-00044r-PP for qemu-devel@nongnu.org; Thu, 23 Jan 2020 08:49:39 -0500 Received: by mail-wr1-x433.google.com with SMTP id j42so3107241wrj.12 for ; Thu, 23 Jan 2020 05:49:39 -0800 (PST) Received: from 640k.localdomain.com ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id s15sm3073171wrp.4.2020.01.23.05.49.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 23 Jan 2020 05:49:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=cNSBVvuhqWAGJYrIfEMAuXBTzy9mOBWpnwL0MQDgTyk=; b=pe9UA2H8guk5hFdS7uASs9SAtsFshkRhPgYBdUqodol4xMqnXLDdm5cHK3UOGsAEDI tt/ZuL3OKbHBXN83Aw2sRlyusy1rIxboBMEbnYw3trMQQoxhgW2P5LBwqKhJ09Db96N9 N8OgUYsX0hmekidvZHAG7IZ9izFuxwD/Ze2lHNchJtgMJzHl+x/0Uu3mPfCTmjswLqa3 Gd6yNIA8u7/9Hus1NCjdUb7xw8QxsBDoNqzyrPHX8g2MwX0BMPK2TYslDdvKAnBTgUeE MDCCMxSml5W7C9JO25sMj9zbZ9kCAUB2pcDkoQTae3HqEVS24BxI5RC5+SKnd+qKSqgm Rd/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=cNSBVvuhqWAGJYrIfEMAuXBTzy9mOBWpnwL0MQDgTyk=; b=PnGsN5HZNm7hIZc3lL9LfwKIGoNboo0/yOdlOGEH2aTgpBt6sBxrPEJH8holA5gsi6 faxPAG/YaAWbPeTuqmWeN3Xk4TRuw2YBdfLUBFnptmFtOjRqV68v8WeZcu9AeC5zVuce iKjRcQPZohUwZIsRNWPwSzVn3SIFNAgmHrYCFr44c9xszWUroYC1mbIWoc311j31l0iE mvdjqnC/7K9TcnVzBhDzzZdevihONeQdd/a2ZLcwdhjtFNupvopTgEfYWwUnyiYfY5m2 EkT1vw/atnE4PdZfpSgtqV2ccIkJ6f/PDjxvWjIrIJ8tSuO7+kqFJEU9XLq6/sZ3F+Ju Jycw== X-Gm-Message-State: APjAAAUgBg7H/0iYkuLgq2PeYY4FcaAjzGb4a9BHKWevCDKwtjR7xHB4 eqqxuaJBV8Jmzg9zg6mos9R7Ut8P X-Google-Smtp-Source: APXvYqyY2gEVx8pbFh5NxrSXkJ8gziTBMt2gxDgJbujJdwbhTimwcXK0Nf+bsEnrAk+D7lT1Vo4fmA== X-Received: by 2002:adf:e984:: with SMTP id h4mr18017722wrm.275.1579787378522; Thu, 23 Jan 2020 05:49:38 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 36/59] object: add class property initializer Date: Thu, 23 Jan 2020 14:48:39 +0100 Message-Id: <1579787342-27146-37-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1579787342-27146-1-git-send-email-pbonzini@redhat.com> References: <1579787342-27146-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::433 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Marc-Andr=C3=A9 Lureau This callback is used to set default value in following patch "object: add object_property_set_defaut_{bool,str,int,uint}()". Signed-off-by: Marc-Andr=C3=A9 Lureau Message-Id: <20200110153039.1379601-7-marcandre.lureau@redhat.com> Signed-off-by: Paolo Bonzini --- include/qom/object.h | 16 ++++++++++++++-- qom/object.c | 14 ++++++++++++++ 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/include/qom/object.h b/include/qom/object.h index 54a5488..29f47d3 100644 --- a/include/qom/object.h +++ b/include/qom/object.h @@ -309,6 +309,8 @@ typedef struct InterfaceInfo InterfaceInfo; */ =20 =20 +typedef struct ObjectProperty ObjectProperty; + /** * ObjectPropertyAccessor: * @obj: the object that owns the property @@ -356,7 +358,16 @@ typedef void (ObjectPropertyRelease)(Object *obj, const char *name, void *opaque); =20 -typedef struct ObjectProperty +/** + * ObjectPropertyInit: + * @obj: the object that owns the property + * @prop: the property to set + * + * Called when a property is initialized. + */ +typedef void (ObjectPropertyInit)(Object *obj, ObjectProperty *prop); + +struct ObjectProperty { gchar *name; gchar *type; @@ -365,8 +376,9 @@ typedef struct ObjectProperty ObjectPropertyAccessor *set; ObjectPropertyResolve *resolve; ObjectPropertyRelease *release; + ObjectPropertyInit *init; void *opaque; -} ObjectProperty; +}; =20 /** * ObjectUnparent: diff --git a/qom/object.c b/qom/object.c index e921363..cd7ce81 100644 --- a/qom/object.c +++ b/qom/object.c @@ -478,6 +478,19 @@ void object_apply_compat_props(Object *obj) } } =20 +static void object_class_property_init_all(Object *obj) +{ + ObjectPropertyIterator iter; + ObjectProperty *prop; + + object_class_property_iter_init(&iter, object_get_class(obj)); + while ((prop =3D object_property_iter_next(&iter))) { + if (prop->init) { + prop->init(obj, prop); + } + } +} + static void object_initialize_with_type(void *data, size_t size, TypeImpl = *type) { Object *obj =3D data; @@ -491,6 +504,7 @@ static void object_initialize_with_type(void *data, siz= e_t size, TypeImpl *type) memset(obj, 0, type->instance_size); obj->class =3D type->class; object_ref(obj); + object_class_property_init_all(obj); obj->properties =3D g_hash_table_new_full(g_str_hash, g_str_equal, NULL, object_property_free); object_init_with_type(obj, type); --=20 1.8.3.1