I am a newbie to Pharo and therefore UFFI usage. My goal is to use Pharo as a bridge to some functionality in a shared dynamic library. I am working in 64Bit Linux with Pharo 6 and trying to use UFFI. Documentation seems to be sparse on the usage of UFFI. I have reviewed the
UFFI Booklet, which only has a place holder for an Array example and I have reviewed a
presentation on UFFI usage. In addition a search of the mailing list has not given me enough information to move forward.
What I am looking for is an example/template to use for passing arrays, but to make a concrete example. I am trying to send 2 arrays of unsigned machine sized integers to the shared library, the code for my last failed attempt...
jaccard_similarity: aVector1 anotherVector: aVector2
| ffiVec1 ffiVec2 |
ffiVec1 := FFIExternalArray externalNewType: 'FFISizeT' size: aVector1 size.
1 to: aVector1 size do: [ :i | ffiVec1 at: i put: (aVector1 at: i) ].
ffiVec2 := FFIExternalArray externalNewType: 'FFISizeT' size: aVector2 size.
1 to: aVector2 size do: [ :i | ffiVec2 at: i put: (aVector2 at: i) ].
^ self
ffiCall: #(double jaccard_similarity #(FFISizeT * ffiVec1 , FFISizeT * ffiVec2)) module: '/pathto/libextern_dynlib.so'
In this particular incarnation, the error I get is "Could not find accessor for variable name "ffVec1" So okay, I "Proceed" anyway and, not suprisingly, get the same error for "ffVec2".
It may seem obvious in the error message what the issue is; however, I am a newbie so it is not so obvious to me.
I have seen references to running a command to autogenerate the accessor methods, but I don't know what command to run or where to run it. Additionally, I don't understand why accessor methods would be needed here and finally, will this code work if accessor methods are created?
This has had me stumped for days so thanks for any help!