<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">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_1282091192950816692__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">- 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"><div id="gmail-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>
                                        
                                        <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: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>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 <u></u> a
<br>écrit :
<br>
<br>>
<br>> Hi all, again. :-)
<br>>
<br>> I am aware that such a mechanism would have to be implemented in 2-times-7
<br>> different places:
<br>>
<br>>
<br>> Best,
<br>> Marcel
<br>>
<br>> Am 19.06.2020 13:15:40 schrieb Marcel Taeumel <u></u>:
<br>> Hi all!
<br>>
<br>> We have #doesNotUnderstand:, which is sent to the receiver when a 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 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  ... <u></u><u></u></div></blockquote></div></blockquote></div></div>