FFI Callbacks

Alejandro F. Reimondo aleReimondo at smalltalking.net
Fri Sep 1 16:40:10 UTC 2006


Hi Diego,
The <...> syntax is a short syntax notation to make a method
 as a primitive method, calling a function (object) like
 you instantiate for platformFunction (the object will be
 instantiated by the compiler and bounded to the method
 as a primitive) and returning the result (following normal
 primitive failure policy).
Dynamic function calls (instantiate functions on demand)
 can be used, but are more long expressions.
With dynamic functions you can call more than
 one function in a method, but invalidate
 senders/implementors as a powerful tool for browsing
 (#call:with:... will return all API calls in the universe).
Using <...> syntax let you choose better (smalltalk) selectors
 for calls and let you bind the calls without reducing
 browsing effectiveness.
Ale.


----- Original Message ----- 
From: "Diego Fernandez" <diegof79 at gmail.com>
To: "The general-purpose Squeak developers list"
<squeak-dev at lists.squeakfoundation.org>
Sent: Friday, September 01, 2006 12:45 PM
Subject: Re: FFI Callbacks


> I don't know anything about the internals but I like how callbacks are
> declared in VAST:
>
> windowProc := EsEntryPoint
>        receiver: [:hwnd :lParam | "call back object to be executed" ]
>        selector: #value:value:
>        callingConvention: 'c'
>        arrayBased: false
>        parameterTypes: #(uint32 pointer)
>        returnType: #boolean.
>
> platformFunction := PlatformFunction
>        callingConvention: 'c'
>        function: 'EnumWindows'
>        library: 'user32'
>        parameterTypes: #(pointer uint32)
>        returnType: #boolean.
>
> platformFunction callWith: address with: 0
>
> An off topic question:
> I never used FFI, It's possible to make function calls like in the
> example shown above, or I must to use the special syntax: <...> ?
>
> Regards,
> Diego
>




More information about the Squeak-dev mailing list