qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [Question] About object oriented programming in qemu


From: Paolo Bonzini
Subject: Re: [Qemu-devel] [Question] About object oriented programming in qemu
Date: Tue, 30 Oct 2018 19:10:18 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.0

On 30/10/2018 17:08, Li Qiang wrote:
> Hello all,
> 
>  
> 
> Today I read the BusClass’ definition.
> 
>  
> 
> The comment
> 
> /* FIXME first arg should be BusState */
> 
> remind me that OOP in qemu is not very OOP.

It is not "not very OOP", it is not language-supported and so it can
take a few more liberties.

Perhaps these functions should be moved to DeviceClass instead.  That
would make sense, I think.

Paolo

> Maybe we should take the first arg as the Object pointer, just as the
> cpp’s this pointer.
> 
> For example, we can define the BusClass function as this
> 
> void (*print_dev)(BusState*, Monitor *mon, DeviceState *dev, int indent);
> char *(*get_dev_path)(BusState*,  DeviceState *dev);
> char *(*get_fw_dev_path)(BusState*, DeviceState *dev);
> 
> So we don’t need get the BusState in the callback function, such as
> ‘usb_bus_dev_print’.
> 
>  
> 
> I want to know do do you think it make senses?
> 
> If not I will not spend time to write the patch.
> 
>  
> 
> Thanks,
> 
> Li Qiang
> 




reply via email to

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