ExternalCallback in StructureField

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

ExternalCallback in StructureField

Martin Rubi
Hello.
I have an ExternalStructure containing a function pointer:

MyStruct class>>defineFields

self
    defineField: #field1 type: (PointerField type: String);
    defineField: #field2 type: LPVOIDField new

now I want to fill the second field with an ExternalCallback, how should I
do it ?

Thanks in advance


Reply | Threaded
Open this post in threaded view
|

Re: ExternalCallback in StructureField

Blair McGlashan-3
"Martin Rubi" <[hidden email]> wrote in message
news:[hidden email]...

> Hello.
> I have an ExternalStructure containing a function pointer:
>
> MyStruct class>>defineFields
>
> self
>    defineField: #field1 type: (PointerField type: String);
>    defineField: #field2 type: LPVOIDField new
>
> now I want to fill the second field with an ExternalCallback, how should I
> do it ?
>
> Thanks in advance
>
>

Add an instance variable to the structure - the iv is necessary to prevent
the callback object from being garbage collected while it is still
referenced from the structure. Then define an accessor such as:

callback: anExternalCallback
    callback := anExternalCallback.
    self field2: anExternalCallback asParameter yourAddress

Regards

Blair


Reply | Threaded
Open this post in threaded view
|

Re: ExternalCallback in StructureField

Martin Rubi
thanks !

> > Hello.
> > I have an ExternalStructure containing a function pointer:
> >
> > MyStruct class>>defineFields
> >
> > self
> >    defineField: #field1 type: (PointerField type: String);
> >    defineField: #field2 type: LPVOIDField new
> >
> > now I want to fill the second field with an ExternalCallback, how should
I

> > do it ?
> >
> > Thanks in advance
> >
> >
>
> Add an instance variable to the structure - the iv is necessary to prevent
> the callback object from being garbage collected while it is still
> referenced from the structure. Then define an accessor such as:
>
> callback: anExternalCallback
>     callback := anExternalCallback.
>     self field2: anExternalCallback asParameter yourAddress
>
> Regards
>
> Blair
>
>
>