[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 11/21] qdev: move bus properties to abstract sup
From: |
Paolo Bonzini |
Subject: |
Re: [Qemu-devel] [PATCH 11/21] qdev: move bus properties to abstract superclasses |
Date: |
Wed, 02 May 2012 09:21:54 -0400 (EDT) |
> This little bit of magic is a bit too magical for my taste.
>
> Polymorphism relies on the idea that a subclass overloads base class
> members/methods. From the base classes perspective, it's unaware if
> a subclass has overloaded something (that's allowed to be overloaded).
>
> This code doesn't get the current class *as* the base class but rather gets
> the
> non-overloaded form of the base class. This isn't really something
> that most OO systems allow and I think it could lead to major ugliness in the
> future.
Not really, in fact this kind of class-side data is really bread and butter
of all dynamic languages, and it's how most of them implement polymorphism.
They have an associative array (method names -> method bytecode for example)
in each class on the hierarchy, and walk the hierarchy for each function call.
Doing method lookups like that is not something we can do in C of course, but
for data it's perfectly fine IMHO.
> I much prefer moving property installation to a function call that is
> invoked during base class init.
That leaves you without the possibility to inspect static property info,
unless you do the gross-ish hack of calling object_new and immediately
freeing the object.
Paolo
- [Qemu-devel] [PATCH 17/21] qdev: move sysbus initialization to sysbus.c, (continued)
- [Qemu-devel] [PATCH 17/21] qdev: move sysbus initialization to sysbus.c, Paolo Bonzini, 2012/05/02
- [Qemu-devel] [PATCH 19/21] qdev: connect busses with their parent devices, Paolo Bonzini, 2012/05/02
- [Qemu-devel] [PATCH 18/21] qdev: convert busses to QEMU Object Model, Paolo Bonzini, 2012/05/02
- [Qemu-devel] [PATCH 21/21] qbus: initialize in standard way, Paolo Bonzini, 2012/05/02
- [Qemu-devel] [PATCH 11/21] qdev: move bus properties to abstract superclasses, Paolo Bonzini, 2012/05/02
- [Qemu-devel] [PATCH 16/21] qdev: use wrapper for qdev_get_path, Paolo Bonzini, 2012/05/02
- [Qemu-devel] [PATCH 20/21] qbus: make child devices links, Paolo Bonzini, 2012/05/02
- [Qemu-devel] [PATCH 12/21] pc: add back PCI.rombar compat property, Paolo Bonzini, 2012/05/02