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: Andreas Färber
Subject: Re: [Qemu-devel] [PATCH 01/27] qom: add the base Object class
Date: Tue, 03 Jan 2012 00:01:07 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:9.0) Gecko/20111220 Thunderbird/9.0

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.

Andreas

-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg



reply via email to

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