Hi,

That’s not really possible :)
In your case, Method is already a pointer (with arity 1).
Which means 

Method *

Is in fact a pointer to a pointer (arity 2), something like "void**"

This is a typical case, but you are not “having the two cases”, you still have 
one :)

UFFI will try to box/unbox that for you, btw… but sometimes this is not what 
you want (because pointers to pointers is a typical way to answer lists, for 
example). And UFFI does not know what you want there… in this cases (when you 
want the list), the recommended way is to get the pointer and create the list 
yourself. Instead: 

Method *methodList()

You call 

void *methodList()

To avoid the unbox attempt, and then you process your answer “in raw” (for 
example using the #readArrayOf:until: method).

If it happens that you use both SomeStructure, and SomeStructure*, then is not 
an opaque type, and you need to map it by subclasses FFIExternalStructure and 
implementing fieldsDesc, etc.

Esteban

> On 23 May 2020, at 20:00, Sean P. DeNigris <s...@clipperadams.com> wrote:
> 
> Esteban Lorenzano wrote
>> The easiest way I have to explain is: 
>> 
>> You use an OpaqueObject when you will refer to the opaque type in calls
>> as:  someFunction(opaqueobject *someArg).
>> You use an ExternalObject when you will refer to the opaque type in calls
>> as: someFunction(externalobject someArg).
> 
> Very clear! We're getting somewhere :) But...
> 
> What if a type is used both ways? 
> 
> For example:
>   ^ self ffiCall: #(Method * class_copyMethodList(Class self, uint
> *outCount))
> and
>   ^ self ffiCall: #(struct objc_method_description *
> method_getDescription(Method self))
> 
> 
> 
> -----
> Cheers,
> Sean
> --
> Sent from: http://forum.world.st/Pharo-Smalltalk-Developers-f1294837.html
> 




Reply via email to