Re: [Qemu-devel] [RFC] QOM design - add instance data to Object (-> add constructors)

2015-06-15 Thread Liviu Ionescu
> On 14 Jun 2015, at 15:43, Liviu Ionescu wrote: > > in practical terms this means that realize() should be called right after > creation, immediately after setting the properties: > > DeviceState *mcu = qdev_create(NULL, TYPE_STM32F103RB); > { > qdev_prop_set_uint32(mcu, "hse-freq-h

Re: [Qemu-devel] [RFC] QOM design - add instance data to Object

2015-06-14 Thread Peter Crosthwaite
On Sun, Jun 14, 2015 at 11:47 AM, Liviu Ionescu wrote: > >> On 13 Jun 2015, at 12:29, Peter Crosthwaite >> wrote: >> >> There is a way :). Check object_class_get_parent. qdev.c uses it to >> implement device properties on multiple levels without overriding. You >> still need to explicit call to

Re: [Qemu-devel] [RFC] QOM design - add instance data to Object

2015-06-14 Thread Liviu Ionescu
> On 13 Jun 2015, at 12:29, Peter Crosthwaite > wrote: > > There is a way :). Check object_class_get_parent. qdev.c uses it to > implement device properties on multiple levels without overriding. You > still need to explicit call to superclass in each child class but that > is normal of OO synt

Re: [Qemu-devel] [RFC] QOM design - add instance data to Object (-> add constructors)

2015-06-14 Thread Liviu Ionescu
> On 14 Jun 2015, at 04:49, Peter Crosthwaite > wrote: > > ... > The number of machine init args blew out of control at one stage so > they were structified. It was natural to roll this struct into the > machine-state struct. can we have multiple machine instances simultaneously, each with its

Re: [Qemu-devel] [RFC] QOM design - add instance data to Object (-> add constructors)

2015-06-14 Thread Liviu Ionescu
> On 14 Jun 2015, at 15:43, Liviu Ionescu wrote: > > >> I never said you cant ref one object from another. QOM links exist for >> this exact purpose. > > Q: any example of QOM links? ok, I found them, they are not part of qdev but only in qom. they look like this: object_property_set_l

Re: [Qemu-devel] [RFC] QOM design - add instance data to Object (-> add constructors)

2015-06-14 Thread Liviu Ionescu
> On 14 Jun 2015, at 04:49, Peter Crosthwaite > wrote: > > > ... > Infact, I have an application of constructor arugments myself. This is > for the ARM A9 MPCore container where the number of CPUs is variable > per-instance. Same problem as you are facing, realize is too late, > init is too ea

Re: [Qemu-devel] [RFC] QOM design - add instance data to Object (-> add constructors)

2015-06-13 Thread Peter Crosthwaite
On Sat, Jun 13, 2015 at 5:56 PM, Liviu Ionescu wrote: > >> On 14 Jun 2015, at 01:46, Peter Crosthwaite >> wrote: >> >>> not to mention that in real life situations, constructors are used to pass >>> non-static data, for example the 'machine' structure (for various command >>> line params) when

Re: [Qemu-devel] [RFC] QOM design - add instance data to Object (-> add constructors)

2015-06-13 Thread Liviu Ionescu
> On 14 Jun 2015, at 01:46, Peter Crosthwaite > wrote: > >> not to mention that in real life situations, constructors are used to pass >> non-static data, for example the 'machine' structure (for various command >> line params) when constructing MCUs, or the 'mcu' when constructing LEDs. >>

Re: [Qemu-devel] [RFC] QOM design - add instance data to Object

2015-06-13 Thread Peter Crosthwaite
On Sat, Jun 13, 2015 at 11:57 AM, Liviu Ionescu wrote: > >> On 13 Jun 2015, at 21:29, Peter Crosthwaite >> wrote: >> >> >> ... As all the information >> you need to construct the object is constant per-concrete class, the >> information can be added to the class to resolve. > > the one-instance-

Re: [Qemu-devel] [RFC] QOM design - add instance data to Object (-> add constructors)

2015-06-13 Thread Peter Crosthwaite
On Sat, Jun 13, 2015 at 12:52 PM, Liviu Ionescu wrote: > >> On 13 Jun 2015, at 21:57, Liviu Ionescu wrote: >> >> ... so, no, the class structure is not suitable for multi-instances objects, >> and even for singletons I think that using it for passing such configuration >> data is generally abus

Re: [Qemu-devel] [RFC] QOM design - add instance data to Object (-> add constructors)

2015-06-13 Thread Liviu Ionescu
> On 13 Jun 2015, at 21:57, Liviu Ionescu wrote: > > ... so, no, the class structure is not suitable for multi-instances objects, > and even for singletons I think that using it for passing such configuration > data is generally abusive. not to mention that in real life situations, constructo

Re: [Qemu-devel] [RFC] QOM design - add instance data to Object

2015-06-13 Thread Liviu Ionescu
> On 13 Jun 2015, at 21:29, Peter Crosthwaite > wrote: > > > ... As all the information > you need to construct the object is constant per-concrete class, the > information can be added to the class to resolve. the one-instance-per-class might be true for MCUs, but generally it isn't, for ex

Re: [Qemu-devel] [RFC] QOM design - add instance data to Object

2015-06-13 Thread Peter Crosthwaite
On Sat, Jun 13, 2015 at 4:41 AM, Liviu Ionescu wrote: > >> On 13 Jun 2015, at 12:29, Peter Crosthwaite >> wrote: >> >>> >>> STM32F103RB* mcu = new STM32F103RB(&stm32f103rb_capabilities); >>> >> >> Is the capabilities genuinely variable from instance to instance? > > good point. > > my example wa

Re: [Qemu-devel] [RFC] QOM design - add instance data to Object (-> add constructors)

2015-06-13 Thread Liviu Ionescu
> On 13 Jun 2015, at 14:41, Liviu Ionescu wrote: > > ... so I invented another solution: > > - do not define any of the instance_init() and instance_post_init() > - add custom construct(...) callbacks to all my classes > - make each instance call parent construct(...) at the beginning, as for

Re: [Qemu-devel] [RFC] QOM design - add instance data to Object

2015-06-13 Thread Liviu Ionescu
> On 13 Jun 2015, at 12:29, Peter Crosthwaite > wrote: > >> >> STM32F103RB* mcu = new STM32F103RB(&stm32f103rb_capabilities); >> > > Is the capabilities genuinely variable from instance to instance? good point. my example was not very accurate, the capabilities are indeed specific to a c

Re: [Qemu-devel] [RFC] QOM design - add instance data to Object

2015-06-13 Thread Peter Crosthwaite
On Fri, Jun 12, 2015 at 4:33 AM, Liviu Ionescu wrote: > while implementing the cortex-m hierarchical objects I faced several problems > that required some hack, and I wanted to know your comments on them. > > for convenience I'll explain the problem in C++ and then return to the issues > of the

Re: [Qemu-devel] [RFC] QOM design - add instance data to Object

2015-06-13 Thread Liviu Ionescu
any object oriented gurus around? regards, Liviu > On 12 Jun 2015, at 14:33, Liviu Ionescu wrote: > > while implementing the cortex-m hierarchical objects I faced several problems > that required some hack, and I wanted to know your comments on them. > > for convenience I'll explain the pro

[Qemu-devel] [RFC] QOM design - add instance data to Object

2015-06-12 Thread Liviu Ionescu
while implementing the cortex-m hierarchical objects I faced several problems that required some hack, and I wanted to know your comments on them. for convenience I'll explain the problem in C++ and then return to the issues of the C implementation. (the C++ syntax may not be very strict). one