With UFFI, what youâll do for âbeing OOâ is to: 1) extend FFIExternalStructure 2) then use your class adding methods that use the structure into it (using âselfâ as argument). For example: FFIExternalStructure subclass: #MyStruct. MyStruct>>#method1: arg ^ self ffiCall: #(int function1(self, arg1)) (and example of this can be found on AthensCairoMatrix in image). cheers, Esteban ps: in Pharo5, you may want to update to latest UFFI (not *needed* but better⦠I need to make a new Pharo5 build with updated versions)
On 10 Sep 2016, at 04:41, Ben Coman <btc@openinworld.com> wrote:
On Sat, Sep 10, 2016 at 8:47 AM, Pierce Ng <pierce@samadhiweb.com> wrote:
On Sat, Sep 10, 2016 at 01:11:18AM +0800, Ben Coman wrote:
Are arrays within structs handled? I have a C type declaration...
Ben,
Is it possible to write C functions to manipulate these structures, build these functions into a shared library, and call the functions from Pharo?
Maybe. Particularly since my next challenge is to use a callback. My usage is parsing the VM platform C files as a one-shot import to analyse from Pharo, so doing most of the legwork in C and returning just the final result to Pharo may be fine. However at the moment my goal is as much about learning to use FFI, so I'll push in that direction as long as I can.
More "object oriented", heh.
Actually "clang" is OO being written in C++. But I understand the C++ name mangling makes life difficult for our FFI. "libclang" is the plain-C wrapper interface of "clang", which also is advertised as more stable, with clang advertised as often changing. Apparently libclang can't access all of clang's features, but I think it will be a while before I reach the point of discovering the impact of that, and it may well be outside my requirements.
cheers -ben
Of course I've only just had a cursory glance at libclang while typing this reply and don't know what your usage is.
Pierce