All of lore.kernel.org
 help / color / mirror / Atom feed
From: Cao jin <caoj.fnst@cn.fujitsu.com>
To: Markus Armbruster <armbru@redhat.com>
Cc: <qemu-devel@nongnu.org>, <qemu-trivial@nongnu.org>,
	<pbonzini@redhat.com>,  <peter.maydell@linaro.org>
Subject: Re: [Qemu-trivial] [Qemu-devel] [PATCH] qdev property: cleanup
Date: Sat, 9 Apr 2016 22:25:25 +0800	[thread overview]
Message-ID: <570910D5.4030705@cn.fujitsu.com> (raw)
In-Reply-To: <87mvp4xsbk.fsf@dusky.pond.sub.org>



On 04/08/2016 07:17 PM, Markus Armbruster wrote:

>> - * Static properties access data in a struct.  The actual type of the
>> - * property and the field depends on the property type.
>> + * Static properties access data in a struct. The actual type of ObjectProperty
>> + * and the struct field depends on the @qtype type.
>>    */
>
> Not sure this part is an improvement.  What's wrong with the current text?
>

In a word: little hard for newbies like me to understand. (I think 
comments are for newbies). see my feeling about the comment:

As per my understanding, property has 2 kinds, former qdev property and 
the latest QOM property. For me, the original description is too 
ambiguous about 'property'.

original: *The actual type of the property and the field depends on the 
property type*

Using two same word 'property' is ambiguous and hard for newbie to 
distinguish. The 1st 'property' should mean a QOM property. and the 2nd 
'property', I think the original author`s meaning is: qdev property. 
But, what is the qdev property *type*? cannot find 'type' field in the 
definition except a *qtype*

struct Property {
     const char   *name;
     PropertyInfo *info;
     ptrdiff_t    offset;
     uint8_t      bitnr;
     QType        qtype;
     int64_t      defval;
     int          arrayoffset;
     PropertyInfo *arrayinfo;
     int          arrayfieldsize;
};

And *the actual type of the field* depends on the qtype, take bitmap 
field for example, bitmap field in a structure is always a *int*, but 
when convert to QOM property, it is treated as a *bool*, see 
DEFINE_PROP_BIT, DEFINE_PROP_BIT64, its qtype are QTYPE_QBOOL.

But I am little confused also now, I think my modification isn`t perfect
1. see how qdev_property_add_static invoke object_property_add, it pass 
prop->info->name as its QOM property type

2. when structure field is enum, QOM property will treat it as 
string(not depends on qtype now), see code:

else if (prop->info->enum_table) {
     object_property_set_str(obj, prop->info->enum_table[prop->defval],
                             prop->name, &error_abort);

I will do more analyse before v2.

-- 
Yours Sincerely,

Cao jin




WARNING: multiple messages have this Message-ID (diff)
From: Cao jin <caoj.fnst@cn.fujitsu.com>
To: Markus Armbruster <armbru@redhat.com>
Cc: qemu-devel@nongnu.org, qemu-trivial@nongnu.org,
	pbonzini@redhat.com, peter.maydell@linaro.org
Subject: Re: [Qemu-devel] [PATCH] qdev property: cleanup
Date: Sat, 9 Apr 2016 22:25:25 +0800	[thread overview]
Message-ID: <570910D5.4030705@cn.fujitsu.com> (raw)
In-Reply-To: <87mvp4xsbk.fsf@dusky.pond.sub.org>



On 04/08/2016 07:17 PM, Markus Armbruster wrote:

>> - * Static properties access data in a struct.  The actual type of the
>> - * property and the field depends on the property type.
>> + * Static properties access data in a struct. The actual type of ObjectProperty
>> + * and the struct field depends on the @qtype type.
>>    */
>
> Not sure this part is an improvement.  What's wrong with the current text?
>

In a word: little hard for newbies like me to understand. (I think 
comments are for newbies). see my feeling about the comment:

As per my understanding, property has 2 kinds, former qdev property and 
the latest QOM property. For me, the original description is too 
ambiguous about 'property'.

original: *The actual type of the property and the field depends on the 
property type*

Using two same word 'property' is ambiguous and hard for newbie to 
distinguish. The 1st 'property' should mean a QOM property. and the 2nd 
'property', I think the original author`s meaning is: qdev property. 
But, what is the qdev property *type*? cannot find 'type' field in the 
definition except a *qtype*

struct Property {
     const char   *name;
     PropertyInfo *info;
     ptrdiff_t    offset;
     uint8_t      bitnr;
     QType        qtype;
     int64_t      defval;
     int          arrayoffset;
     PropertyInfo *arrayinfo;
     int          arrayfieldsize;
};

And *the actual type of the field* depends on the qtype, take bitmap 
field for example, bitmap field in a structure is always a *int*, but 
when convert to QOM property, it is treated as a *bool*, see 
DEFINE_PROP_BIT, DEFINE_PROP_BIT64, its qtype are QTYPE_QBOOL.

But I am little confused also now, I think my modification isn`t perfect
1. see how qdev_property_add_static invoke object_property_add, it pass 
prop->info->name as its QOM property type

2. when structure field is enum, QOM property will treat it as 
string(not depends on qtype now), see code:

else if (prop->info->enum_table) {
     object_property_set_str(obj, prop->info->enum_table[prop->defval],
                             prop->name, &error_abort);

I will do more analyse before v2.

-- 
Yours Sincerely,

Cao jin

  reply	other threads:[~2016-04-09 14:23 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-24 10:14 [Qemu-trivial] [PATCH] qdev property: cleanup Cao jin
2016-03-24 10:14 ` [Qemu-devel] " Cao jin
2016-03-24 11:25 ` [Qemu-trivial] " Paolo Bonzini
2016-03-24 11:25   ` [Qemu-devel] " Paolo Bonzini
2016-03-25  6:06   ` [Qemu-trivial] " Cao jin
2016-03-25  6:06     ` [Qemu-devel] " Cao jin
2016-04-08 11:17 ` [Qemu-trivial] " Markus Armbruster
2016-04-08 11:17   ` Markus Armbruster
2016-04-09 14:25   ` Cao jin [this message]
2016-04-09 14:25     ` Cao jin
2016-04-12  8:20     ` [Qemu-trivial] " Markus Armbruster
2016-04-12  8:20       ` Markus Armbruster
2016-04-12 12:49       ` [Qemu-trivial] " Cao jin
2016-04-12 12:49         ` Cao jin
2016-04-15 10:06       ` [Qemu-trivial] " Paolo Bonzini
2016-04-15 10:06         ` Paolo Bonzini
2016-04-15 11:15         ` [Qemu-trivial] " Cao jin
2016-04-15 11:15           ` Cao jin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=570910D5.4030705@cn.fujitsu.com \
    --to=caoj.fnst@cn.fujitsu.com \
    --cc=armbru@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-trivial@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.