qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 01/27] qom: add the base Object class


From: Anthony Liguori
Subject: Re: [Qemu-devel] [PATCH 01/27] qom: add the base Object class
Date: Mon, 02 Jan 2012 18:56:33 -0600
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.23) Gecko/20110922 Lightning/1.0b2 Thunderbird/3.1.15

On 01/02/2012 05:01 PM, Andreas Färber wrote:
Am 22.12.2011 20:57, schrieb Anthony Liguori:
On 12/22/2011 12:00 PM, Kevin O'Connor wrote:
On Thu, Dec 22, 2011 at 11:41:08AM -0600, Anthony Liguori wrote:
On 12/22/2011 11:25 AM, Kevin O'Connor wrote:
Why not declare types with something like the following:

TypeInfo my_device_info = {
      .name = "my-device",
      .parentinfo =&device_info,
      .instance_size = sizeof(MyDevice),
};

That is, instead of looking up the TypeImpl via a string, lookup the
TypeImpl via the address of the TypeInfo.  (Or possibly store a
pointer to TypeImpl in TypeInfo during registration.)
[...]
Yes, thinking about it, I think you're correct that .parent could refer
to some sort of type handle.

But I think it's a bit nicer to have a string identify the parent type
than an extern struct.  I guess it's more a matter of taste than
anything else :-)

The advantage of using some kind of symbolic name is that the compiler
helps us avoid typos. If we use strings, we defer the checking to the
actual instantiation at runtime.

That's why I use #define's to make a symbol for the types. The only reason that's not done universally is it would be a bit challenging to script the conversion to do that (I though I did attempt it a couple times).

Regards,

Anthony Liguori


Andreas





reply via email to

[Prev in Thread] Current Thread [Next in Thread]