Windows FFI

Lee Salzman lsalzman1 at cox.net
Thu Nov 4 03:28:49 PST 2004


Honestly, right now I don't think it's appropriate to dig to deep into
Windows specific features given that VC can't even properly compile
Slate at all. I'd rather wait till I can generate actual stubs rather
than having to go through C before this is messed with.

Lee

On Wed, Nov 03, 2004 at 02:03:59AM -0500, Todd Fleming wrote:
> Hello. I started toying with Slate yesterday and decided to try adding 
> FFI support for Windows. I can now do the following:
> 
> [| l f |
>  l: (ExternalLibrary newNamed: 'User32').
>  f: (l lookup: 'MessageBoxA').
>  f argumentsFormat:
>  {
>    ExternalMethod ArgumentFormat Int.
>    ExternalMethod ArgumentFormat Bytes.
>    ExternalMethod ArgumentFormat Bytes.
>    ExternalMethod ArgumentFormat Int.
>  }.
>  f callFormat: ExternalMethod CallFormat Std.
>  (f applyTo: {0 'Hello from Slate!\0' 'My Dialog\0' 0}).
> ] do.
> 
> Woohoo!
> 
> As is, the FFI works with __cdecl functions. I added the ability to call 
> __stdcall ones. Here is how you set the calling convention:
> 
>   "For the Win32 API"
>   f callFormat: ExternalMethod CallFormat Std.
> 
>   "For normal C functions; the default"
>   f callFormat: ExternalMethod CallFormat C.
> 
> I attached the patch to this message. It also includes some (!untested!) 
> fixes to windows/directory.c needed to compile. Warning: I added an 
> empty readDirectory() because I was too lazy to write a real one.
> 
> The patch requires regenerating both the vm and the image.
> 
> Todd
> 




More information about the Slate mailing list