<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Le ven. 19 juin 2020 à 16:02, Marcel Taeumel <<a href="mailto:marcel.taeumel@hpi.de">marcel.taeumel@hpi.de</a>> a écrit :<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"> <div id="gmail-m_-135701879938359316__MailbirdStyleContent" style="font-size:10pt;font-family:Arial;color:rgb(0,0,0)">
                                        
                                        
                                            
                                        
                                        
                                        Hi Nicolas.<div><br></div><div>><span style="font-family:Arial,Helvetica,sans-serif;font-size:13px">ExternalStructureFoo (the class, not an instance) acts as an ExternalType</span></div><span style="font-family:Arial,Helvetica,sans-serif;font-size:13px">> surrogate.</span><div><br></div><div>Well, only by name. Not by object identity.</div><div><br></div><div>> <span style="font-family:Arial,Helvetica,sans-serif;font-size:13px">ExternalType structTypeNamed: #FFISmallStruct1.</span></div><span style="font-family:Arial,Helvetica,sans-serif;font-size:13px">> It will answer FFISmallStruct1, so FFISmallStruct1 is a type somehow, a</span><br style="font-family:Arial,Helvetica,sans-serif;font-size:13px"><span style="font-family:Arial,Helvetica,sans-serif;font-size:13px">> structType more exactly (or a type alias).</span><div><span style="font-family:Arial,Helvetica,sans-serif;font-size:13px"><br></span></div><div><span style="font-family:Arial,Helvetica,sans-serif;font-size:13px">Well, #structTypeNamed: answers an instance of ExternalType whose referentClass points to the structure class, which is FFISmallStruct in this example.</span></div><div><span style="font-family:Arial,Helvetica,sans-serif;font-size:13px"><br></span></div></div></blockquote><div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div id="gmail-m_-135701879938359316__MailbirdStyleContent" style="font-size:10pt;font-family:Arial;color:rgb(0,0,0)"><div><span style="font-family:Arial,Helvetica,sans-serif;font-size:13px"><br></span></div></div></blockquote><div>Ah sorry, my mistake.</div><div>I indeed need to go thru referentClass to achieve what I was thinking of.</div><div>Thanks!</div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div id="gmail-m_-135701879938359316__MailbirdStyleContent" style="font-size:10pt;font-family:Arial;color:rgb(0,0,0)"><div><span style="font-family:Arial,Helvetica,sans-serif;font-size:13px"></span></div><div><span style="font-family:Arial,Helvetica,sans-serif;font-size:13px">Yet, the VM / plugin does not care about the name here. It only cares about instances of ExternalType and to which referentClass those types point.</span></div><div><span style="font-family:Arial,Helvetica,sans-serif;font-size:13px"></span></div></div></blockquote><div>Since we pass argClass, we can simply check against ExternalData type referentClass.<br></div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div id="gmail-m_-135701879938359316__MailbirdStyleContent" style="font-size:10pt;font-family:Arial;color:rgb(0,0,0)"><div><span style="font-family:Arial,Helvetica,sans-serif;font-size:13px"></span></div><div><span style="font-family:Arial,Helvetica,sans-serif;font-size:13px">Best,</span></div><div><span style="font-family:Arial,Helvetica,sans-serif;font-size:13px">Marcel</span></div><div></div>
                                        
                                        <blockquote type="cite" style="border-left-style:solid;border-width:1px;margin-top:20px;margin-left:0px;padding-left:10px;min-width:500px">
                        <p style="color:rgb(170,170,170);margin-top:10px">Am 19.06.2020 15:58:59 schrieb Nicolas Cellier <<a href="mailto:nicolas.cellier.aka.nice@gmail.com" target="_blank">nicolas.cellier.aka.nice@gmail.com</a>>:</p><div style="font-family:Arial,Helvetica,sans-serif"> Le ven. 19 juin 2020 à 15:46, Marcel Taeumel <u></u> a
<br>écrit :
<br>
<br>>
<br>> Hi Nicolas.
<br>>
<br>> > - enable ExternalData to have an ExternalStructure or ExternalTypeAlias
<br>> as type inst. var.
<br>>
<br>> This does not sound right. But I think you mean that "type" in
<br>> ExternalData could be a struct type and the plugin would automatically
<br>> coerce it correctly.
<br>>
<br>> That's good. :-)
<br>>
<br>> "type" in ExternalData must always be an instance of ExternalType.
<br>>
<br>> I see what you mean.
<br>But, that's not exactly how it works.
<br>ExternalStructureFoo (the class, not an instance) acts as an ExternalType
<br>surrogate.
<br>See:
<br>    ExternalType structTypeNamed: #FFISmallStruct1.
<br>It will answer FFISmallStruct1, so FFISmallStruct1 is a type somehow, a
<br>structType more exactly (or a type alias).
<br>
<br>I suggest to use that as ExternalData type whenever we have a pointer to a
<br>FFISmallStruct1 or an array of FFISmallStruct1.
<br>It also make FFI type checking super easy, because we already pass the
<br>FFISmallStruct1 as argClass (only when passing struct by value by now, but
<br>I suggest extending it when passing FFISmallStruct1 *, which currently is
<br>not even possible - we have to declare void *)
<br>
<br>
<br>> This way, we can make FFI a bit safer than using those void *
<br>>
<br>> Sounds good.
<br>>
<br>> Best,
<br>> Marcel
<br>>
<br>> P.S.: I think I messed up with the name "ExternalTypeAlias". Hmpf. Because
<br>> is a subclass of ExternalStructure, not ExternalType. Well. :-)
<br>>
<br>> Am 19.06.2020 15:09:01 schrieb Nicolas Cellier <><br>> <a href="mailto:nicolas.cellier.aka.nice@gmail.com" target="_blank">nicolas.cellier.aka.nice@gmail.com</a>>:
<br>> Hi Marcel,
<br>> Forget about FFIPlugin it's legacy
<br>>
<br>> I'm currently changing ThreadedFFIPlugin to:
<br>> - enable passing ExternalData as atomicType by value
<br>> The use case is the one of ExternalVariable
<br>> - enable ExternalData to have an ExternalStructure or ExternalTypeAlias as
<br>> type inst. var.
<br>> and enable passing that to a corresponding
<br>> ExternalStructure/ExternalStructure pointer/ExternalTypeAlias/
<br>> ExternalTypeAlias pointer
<br>> - returning a new ExternalTypeAlias when returning such type by value
<br>>
<br>> This way, we can make FFI a bit safer than using those void *
<br>>
<br>>
<br>> Le ven. 19 juin 2020 à 13:45, Marcel Taeumel a
<br>> écrit :
<br>>
<br>> >
<br>> > Hi all, again. :-)
<br>> >
<br>> > I am aware that such a mechanism would have to be implemented in
<br>> 2-times-7
<br>> > different places:
<br>> >
<br>> >
<br>> > Best,
<br>> > Marcel
<br>> >
<br>> > Am 19.06.2020 13:15:40 schrieb Marcel Taeumel :
<br>> > Hi all!
<br>> >
<br>> > We have #doesNotUnderstand:, which is sent to the receiver when a
<br>> message
<br>> > cannot be understood. Default reaction in Object is to raise
<br>> > MessageNotUnderstood exception.
<br>> >
<br>> > What if we could have a similar mechanism for FFI calls:
<br>> > #doesNotCoerce:for:. The receiver would be the one that made that call,
<br>> > should be an instance of ExternalLibrary, but could be any object. The
<br>> > arguments would be a pair of (argObject, argType) and the message (like
<br>> the
<br>> > argument for doesNotUnderstand:) that represents the FFI call.
<br>> >
<br>> > The pair of (argObject, argType) could be expressed as FFICallArgument:
<br>> >
<br>> > FFICallArgument
<br>> > argObject ...
<br>>
<br>>
<br><div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Le ven. 19 juin 2020 à 15:46, Marcel Taeumel <<a href="mailto:marcel.taeumel@hpi.de" target="_blank">marcel.taeumel@hpi.de</a>> a écrit :<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex;min-width:500px"> <div id="gmail-m_-135701879938359316gmail-m_1282091192950816692__MailbirdStyleContent" style="font-size:10pt;font-family:Arial;color:rgb(0,0,0)">
<br>                                        
<br>                                        
<br>                                            
<br>                                        
<br>                                        
<br>                                        Hi Nicolas.<div><br></div><div>> <span style="font-family:Arial,Helvetica,sans-serif;font-size:13px">- enable ExternalData to have an ExternalStructure or ExternalTypeAlias as </span><span style="font-family:Arial,Helvetica,sans-serif;font-size:13px">type inst. var.</span></div><div><span style="font-family:Arial,Helvetica,sans-serif;font-size:13px"><br></span></div><div><span style="font-family:Arial,Helvetica,sans-serif"><span style="font-size:13px">This does not sound right. But I think you mean that "type" in ExternalData could be a struct type and the plugin would automatically coerce it correctly.</span></span></div><div><span style="font-family:Arial,Helvetica,sans-serif"><span style="font-size:13px"><br></span></span></div><div><span style="font-family:Arial,Helvetica,sans-serif"><span style="font-size:13px">That's good. :-)</span></span></div><div><span style="font-family:Arial,Helvetica,sans-serif"><span style="font-size:13px"><br></span></span></div><div><span style="font-family:Arial,Helvetica,sans-serif"><span style="font-size:13px">"type" in ExternalData must always be an instance of ExternalType.</span></span></div><div><span style="font-family:Arial,Helvetica,sans-serif"><span style="font-size:13px"><br></span></span></div></div></blockquote><div>I see what you mean.</div><div>But, that's not exactly how it works.</div><div>ExternalStructureFoo (the class, not an instance) acts as an ExternalType surrogate.</div><div>See:</div><div>    ExternalType structTypeNamed: #FFISmallStruct1.</div><div>It will answer FFISmallStruct1, so FFISmallStruct1 is a type somehow, a structType more exactly (or a type alias).<br></div><div><br></div><div>I suggest to use that as ExternalData type whenever we have a pointer to a FFISmallStruct1 or an array of FFISmallStruct1.</div><div>It also make FFI type checking super easy, because we already pass the FFISmallStruct1 as argClass (only when passing struct by value by now, but I suggest extending it when passing FFISmallStruct1 *, which currently is not even possible - we have to declare void *)<br></div><div><br></div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex;min-width:500px"><div id="gmail-m_-135701879938359316gmail-m_1282091192950816692__MailbirdStyleContent" style="font-size:10pt;font-family:Arial;color:rgb(0,0,0)"><div><span style="font-family:Arial,Helvetica,sans-serif"><span style="font-size:13px"></span></span></div><div><span style="font-family:Arial,Helvetica,sans-serif"><span style="font-size:13px">> </span></span><span style="font-family:Arial,Helvetica,sans-serif;font-size:13px">This way, we can make FFI a bit safer than using those void *</span></div><div><span style="font-family:Arial,Helvetica,sans-serif;font-size:13px"><br></span></div><div><span style="font-family:Arial,Helvetica,sans-serif;font-size:13px">Sounds good.</span></div><div><span style="font-family:Arial,Helvetica,sans-serif"><span style="font-size:13px"><br></span></span></div><div><span style="font-family:Arial,Helvetica,sans-serif"><span style="font-size:13px">Best,</span></span></div><div><span style="font-family:Arial,Helvetica,sans-serif"><span style="font-size:13px">Marcel</span></span></div><div><span style="font-family:Arial,Helvetica,sans-serif"><span style="font-size:13px"><br></span></span></div><div><span style="font-family:Arial,Helvetica,sans-serif"><span style="font-size:13px">P.S.: I think I messed up with the name "ExternalTypeAlias". Hmpf. Because is a subclass of ExternalStructure, not ExternalType. Well. :-)</span></span></div><div></div>
<br>                                        
<br>                                        <blockquote type="cite" style="border-left-style:solid;border-width:1px;margin-top:20px;margin-left:0px;padding-left:10px;min-width:500px">
<br>                        <p style="color:rgb(170,170,170);margin-top:10px">Am 19.06.2020 15:09:01 schrieb Nicolas Cellier <<a href="mailto:nicolas.cellier.aka.nice@gmail.com" target="_blank">nicolas.cellier.aka.nice@gmail.com</a>>:</p><div style="font-family:Arial,Helvetica,sans-serif"> Hi Marcel,
<br><br>Forget about FFIPlugin it's legacy
<br><br>
<br><br>I'm currently changing ThreadedFFIPlugin to:
<br><br>- enable passing ExternalData as atomicType by value
<br><br> The use case is the one of ExternalVariable
<br><br>- enable ExternalData to have an ExternalStructure or ExternalTypeAlias as
<br><br>type inst. var.
<br><br> and enable passing that to a corresponding
<br><br>ExternalStructure/ExternalStructure pointer/ExternalTypeAlias/
<br><br>ExternalTypeAlias pointer
<br><br>- returning a new ExternalTypeAlias when returning such type by value
<br><br>
<br><br>This way, we can make FFI a bit safer than using those void *
<br><br>
<br><br>
<br><br>Le ven. 19 juin 2020 à 13:45, Marcel Taeumel <u></u> a
<br><br>écrit :
<br><br>
<br><br>>
<br><br>> Hi all, again. :-)
<br><br>>
<br><br>> I am aware that such a mechanism would have to be implemented in 2-times-7
<br><br>> different places:
<br><br>>
<br><br>>
<br><br>> Best,
<br><br>> Marcel
<br><br>>
<br><br>> Am 19.06.2020 13:15:40 schrieb Marcel Taeumel <u></u>:
<br><br>> Hi all!
<br><br>>
<br><br>> We have #doesNotUnderstand:, which is sent to the receiver when a message
<br><br>> cannot be understood. Default reaction in Object is to raise
<br><br>> MessageNotUnderstood exception.
<br><br>>
<br><br>> What if we could have a similar mechanism for FFI calls:
<br><br>> #doesNotCoerce:for:. The receiver would be the one that made that call,
<br><br>> should be an instance of ExternalLibrary, but could be any object. The
<br><br>> arguments would be a pair of (argObject, argType) and the message (like the
<br><br>> argument for doesNotUnderstand:) that represents the FFI call.
<br><br>>
<br><br>> The pair of (argObject, argType) could be expressed as FFICallArgument:
<br><br>>
<br><br>> FFICallArgument
<br><br>>    argObject  ... <u></u><u></u></div></blockquote></div></blockquote></div></div>
<br><u></u></div></blockquote></div></blockquote></div></div>