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