Hi
I'm not a FFI expert, and you code may not be the latest FFI version. However, If I look at it from Pharo side:
When you want to use Athens with Cairo backend, you have to initialize its surface using a call like:
surface := AthensCairoSurface extent: self extent
Note that I'm calling a class method of AthensCairoSurface.
In this example, 'self extent' will give you the size of the rectangle used by Morph for its bounds size.
This, in turn, will call
AthensCairoSurface class >> extent: anExtent
^self extent: anExtent format: CAIRO_FORMAT_ARGB32
and you reach:
AthensCairoSurface class >> extent: anExtent format: aFormat
^ ( self primImage: aFormat width: anExtent x height: anExtent y + 1) initialize
Which lead you to:
primImage: aFormat width: aWidth height: aHeight
^ self ffiCall: #(AthensCairoSurface cairo_image_surface_create (int aFormat,
int aWidth,
int aHeight) )
From there, you have linked your pharo code done to initialize a Cairo surface.
This will do a C call like:
cairo_image_surface_create(CAIRO_FORMAT_ARGB32, aWidth, aHeight)
Through the magic of FFI, It'll return an instance of AthensCairoSurface you''ll be able to use directly in your Pharo code.
You can have a look to AthensFlakeDemo in Athens-Demo for a full working example.
Renaud
actually i am just exploring UFFI from the pdf "Calling Foreign Functions
with Pharo" there one section is for external objects so i cant understand
that code what i attach as screenshot above. can u able to explain what
actually happen here ??
--
Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html